Skip to content

Commit 3313517

Browse files
committed
2 parents d8ad174 + 821cb94 commit 3313517

File tree

7 files changed

+34
-19
lines changed

7 files changed

+34
-19
lines changed

CollisionGrid/CollisionGrid.csproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>CollisionGrid</RootNamespace>
1111
<AssemblyName>CollisionGrid</AssemblyName>
12-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
1415
</PropertyGroup>
1516
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1617
<DebugSymbols>true</DebugSymbols>
@@ -20,6 +21,7 @@
2021
<DefineConstants>DEBUG;TRACE</DefineConstants>
2122
<ErrorReport>prompt</ErrorReport>
2223
<WarningLevel>4</WarningLevel>
24+
<Prefer32Bit>false</Prefer32Bit>
2325
</PropertyGroup>
2426
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2527
<DebugType>pdbonly</DebugType>
@@ -28,6 +30,7 @@
2830
<DefineConstants>TRACE</DefineConstants>
2931
<ErrorReport>prompt</ErrorReport>
3032
<WarningLevel>4</WarningLevel>
33+
<Prefer32Bit>false</Prefer32Bit>
3134
</PropertyGroup>
3235
<ItemGroup>
3336
<Reference Include="JetBrains.Annotations, Version=10.1.4.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
@@ -38,8 +41,9 @@
3841
<HintPath>..\packages\MonoGame.Extended.0.5.149\lib\MonoGame.Extended.dll</HintPath>
3942
<Private>True</Private>
4043
</Reference>
41-
<Reference Include="MonoGame.Framework">
42-
<HintPath>..\Test\_EXTERNAL_LIBRARIES\MonoGame\MonoGame.Framework.dll</HintPath>
44+
<Reference Include="MonoGame.Framework, Version=3.5.1.1679, Culture=neutral, processorArchitecture=MSIL">
45+
<HintPath>..\packages\MonoGame.Framework.WindowsDX.3.5.1.1679\lib\net40\MonoGame.Framework.dll</HintPath>
46+
<Private>True</Private>
4347
</Reference>
4448
<Reference Include="System" />
4549
<Reference Include="System.Core" />

CollisionGrid/packages.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
<packages>
33
<package id="JetBrains.Annotations" version="10.1.4" targetFramework="net45" />
44
<package id="MonoGame.Extended" version="0.5.149" targetFramework="net45" />
5-
<package id="System.Runtime" version="4.0.0" targetFramework="net45" />
5+
<package id="MonoGame.Framework.WindowsDX" version="3.5.1.1679" targetFramework="net461" />
6+
<package id="System.Runtime" version="4.0.20" targetFramework="net461" />
67
</packages>

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ If you want to contribute to our repository (push, open pull requests), please u
1414
# CollisionGrid
1515

1616
This class implements a collision-grid.
17-
When doing game development you've all come across a point when you'd like to do some collision-checks and that's usually the time when you realize that just checking all sprites against each other just doesn't cut it.
18-
The problem is that the number of checks grow very fast (N² for N sprites) when the number of your sprites grow.
17+
When doing game development you've probably come across a point when you'd liked to do some collision-checks and that's usually the time when you've realize that just checking all sprites against each other doesn't cut it.
18+
The problem with that brute-force-approach is, that the number of checks grow very fast (N² for N sprites) when the number of your sprites increase.
1919

20-
So you somehow have to narrow down your collision-candidates.
21-
This piece of software does that for you. It does not do collision checking itself. It just tells you if a sprite is near enough to a second one to maybe collide which allows you to do a collision test for those two, or three, or five...
20+
So you somehow have to narrow down your collision-candidates.
21+
This piece of software does that for you. It does not do the collision checks themself. It just tells you if a sprite may be near enough to a second one to maybe collide with it, which allows you to do a collision test for those two, or three, or five sprites instead of the whole bunch.
2222
## What It Really Does...
2323
...is a simple trade-off.
2424
You may query it about the sprites around your coordinate or rectangle, but your sprites have to register with it and update their position/AABB on every update.
@@ -105,14 +105,15 @@ protected override void UnloadContent()
105105
## So What's A QuadTree Then?
106106
Maybe you've heard of such a data-structure that does essentially exactly the same things as this grid with one major difference:
107107

108-
The QuadTree divides the space itself.
109-
It doesn't need a fixed grid, but divides it unevenly and only when another partition is needed.
110-
And that's good and bad at the same time.
111-
Unfortunately that costs a lot of time (the updating of this data-structure); At least when compared to the grid.
112-
[Here's a very good implementation on GitHub with an excellent explanation what it does.][quadtree]
108+
The QuadTree divides the space all by itself, dynamically whenever you add new items.
109+
It doesn't need a fixed uniform grid, but divides space unevenly and only when another partition is needed.
110+
And that's good and bad at the same time.
111+
The good thing is that it can cope with unevenly distributed items very well.
112+
The bad thing is that it costs a lot more time (the updating of this data-structure); At least when compared to this grid here.
113+
[Here's a very good implementation of a QuadTree on GitHub with an excellent explanation what it exactly does.][quadtree]
113114

114-
The good news about the QuadTree is that it's exactly what you're looking for if you thought...
115-
> Oh! Nice thing this grid. But the space I have to check is REALLY BIG and my sprites are very unevenly distributed. Most of the time they are clustered with much space in between those clusters. So my cells become way too big for those clusters to help in any way.
115+
The good news about the QuadTree is that it's exactly what you're looking for if you are thinking...
116+
> Oh! Nice thing this grid. But the space I have to check is REALLY BIG and my sprites are very unevenly distributed. Most of the time they are clustered with much space in between those clusters. So my cells become way too big to segment those clusters in a helpful way.
116117
117118
...when reading the explanation of the CollisionGrid.
118119

Test/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[assembly: AssemblyTitle("Test")]
99
[assembly: AssemblyDescription("")]
1010
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyCompany("Unterrainer Informatik OG")]
1212
[assembly: AssemblyProduct("Test")]
1313
[assembly: AssemblyCopyright("Copyright © 2016")]
1414
[assembly: AssemblyTrademark("")]

Test/Test.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>Test</RootNamespace>
1111
<AssemblyName>Test</AssemblyName>
12-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
1415
</PropertyGroup>
1516
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1617
<DebugSymbols>true</DebugSymbols>
@@ -20,6 +21,7 @@
2021
<DefineConstants>DEBUG;TRACE</DefineConstants>
2122
<ErrorReport>prompt</ErrorReport>
2223
<WarningLevel>4</WarningLevel>
24+
<Prefer32Bit>false</Prefer32Bit>
2325
</PropertyGroup>
2426
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2527
<DebugType>pdbonly</DebugType>
@@ -28,6 +30,7 @@
2830
<DefineConstants>TRACE</DefineConstants>
2931
<ErrorReport>prompt</ErrorReport>
3032
<WarningLevel>4</WarningLevel>
33+
<Prefer32Bit>false</Prefer32Bit>
3134
</PropertyGroup>
3235
<PropertyGroup>
3336
<StartupObject>Test.Program</StartupObject>
@@ -37,8 +40,9 @@
3740
<HintPath>..\packages\MonoGame.Extended.0.5.149\lib\MonoGame.Extended.dll</HintPath>
3841
<Private>True</Private>
3942
</Reference>
40-
<Reference Include="MonoGame.Framework">
41-
<HintPath>_EXTERNAL_LIBRARIES\MonoGame\MonoGame.Framework.dll</HintPath>
43+
<Reference Include="MonoGame.Framework, Version=3.5.1.1679, Culture=neutral, processorArchitecture=MSIL">
44+
<HintPath>..\packages\MonoGame.Framework.WindowsDX.3.5.1.1679\lib\net40\MonoGame.Framework.dll</HintPath>
45+
<Private>True</Private>
4246
</Reference>
4347
<Reference Include="System" />
4448
<Reference Include="System.Core" />
@@ -62,6 +66,7 @@
6266
</ProjectReference>
6367
</ItemGroup>
6468
<ItemGroup>
69+
<None Include="app.config" />
6570
<None Include="packages.config" />
6671
</ItemGroup>
6772
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Test/app.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>

Test/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="MonoGame.Extended" version="0.5.149" targetFramework="net45" />
4+
<package id="MonoGame.Framework.WindowsDX" version="3.5.1.1679" targetFramework="net461" />
45
</packages>

0 commit comments

Comments
 (0)