Skip to content

Commit 904081d

Browse files
Part 14d in the "box pruning revisited" project
See Reports\Part14d.pdf for details
1 parent 0cfdcee commit 904081d

11 files changed

Lines changed: 999 additions & 0 deletions

BoxPruning14d/BoxPruning.cpp

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#include "stdafx.h"
2+
3+
#ifdef REMOVED
4+
5+
void RunTest();
6+
7+
// Play with the settings!
8+
static const udword NbBoxes = 5000;
9+
static const float BoxSize = 20.0f;
10+
static const float Spread = 2000.0f;
11+
12+
int main(int argc, char* argv[])
13+
{
14+
if(1)
15+
{
16+
RunTest();
17+
return 0;
18+
}
19+
20+
// 1) Create random boxes
21+
AABB* Boxes = new AABB[NbBoxes];
22+
const AABB** List = new const AABB*[NbBoxes];
23+
for(udword i=0;i<NbBoxes;i++)
24+
{
25+
// Get a random center in a cube
26+
Point Center;
27+
Center.x = (UnitRandomFloat()-0.5f)*Spread;
28+
Center.y = (UnitRandomFloat()-0.5f)*Spread;
29+
Center.z = (UnitRandomFloat()-0.5f)*Spread;
30+
31+
// Get random extents
32+
Point Extents;
33+
Extents.x = UnitRandomFloat()*BoxSize;
34+
Extents.y = UnitRandomFloat()*BoxSize;
35+
Extents.z = UnitRandomFloat()*BoxSize;
36+
37+
// Setup random box
38+
Boxes[i].mMin.x = Center.x - Extents.x;
39+
Boxes[i].mMin.y = Center.y - Extents.y;
40+
Boxes[i].mMin.z = Center.z - Extents.z;
41+
Boxes[i].mMax.x = Center.x + Extents.x;
42+
Boxes[i].mMax.y = Center.y + Extents.y;
43+
Boxes[i].mMax.z = Center.z + Extents.z;
44+
List[i] = &Boxes[i];
45+
}
46+
47+
const udword NB = 16;
48+
49+
// 2) Do queries
50+
udword Time;
51+
Axes axes;
52+
axes.Axis0 = 0;
53+
axes.Axis1 = 2;
54+
axes.Axis2 = 1;
55+
// 2-1) Brute-force
56+
Container Pairs;
57+
udword MinTime = 0xffffffff;
58+
59+
// StartProfile(Time);
60+
for(udword i=0;i<NB;i++)
61+
{
62+
Pairs.Reset();
63+
StartProfile(Time);
64+
BruteForceCompleteBoxTest(NbBoxes, List, Pairs);
65+
EndProfile(Time);
66+
if(Time<MinTime)
67+
MinTime = Time;
68+
}
69+
// EndProfile(Time);
70+
// printf("Brute force: found %d intersections in %d K-cycles.\n", Pairs.GetNbEntries()>>1, Time/(1024*NB));
71+
printf("Brute force: found %d intersections in %d K-cycles.\n", Pairs.GetNbEntries()>>1, MinTime/1024);
72+
73+
// 2-1) Sweep&prune
74+
// Pairs.Reset();
75+
MinTime = 0xffffffff;
76+
// StartProfile(Time);
77+
for(udword i=0;i<NB;i++)
78+
{
79+
Pairs.Reset();
80+
StartProfile(Time);
81+
CompleteBoxPruning(NbBoxes, Boxes/*List*/, Pairs/*, axes*/);
82+
EndProfile(Time);
83+
if(Time<MinTime)
84+
MinTime = Time;
85+
}
86+
// EndProfile(Time);
87+
printf("Sweep&Prune: found %d intersections in %d K-cycles.\n", Pairs.GetNbEntries()>>1, MinTime/1024);
88+
// printf("Sweep&Prune: found %d intersections in %d K-cycles.\n", Pairs.GetNbEntries()>>1, Time/(1024*NB));
89+
90+
// 3) Free & exit
91+
DELETEARRAY(Boxes);
92+
93+
return 0;
94+
}
95+
96+
#endif

BoxPruning14d/BoxPruning.sln

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BoxPruning", "BoxPruning.vcxproj", "{35D7F2C2-E8EA-4B0C-A7CE-57269DD6B171}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Win32 = Debug|Win32
9+
Release|Win32 = Release|Win32
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{35D7F2C2-E8EA-4B0C-A7CE-57269DD6B171}.Debug|Win32.ActiveCfg = Debug|Win32
13+
{35D7F2C2-E8EA-4B0C-A7CE-57269DD6B171}.Debug|Win32.Build.0 = Debug|Win32
14+
{35D7F2C2-E8EA-4B0C-A7CE-57269DD6B171}.Release|Win32.ActiveCfg = Release|Win32
15+
{35D7F2C2-E8EA-4B0C-A7CE-57269DD6B171}.Release|Win32.Build.0 = Release|Win32
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal

BoxPruning14d/BoxPruning.v11.suo

100 KB
Binary file not shown.

BoxPruning14d/BoxPruning.vcxproj

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<SccProjectName />
15+
<SccLocalPath />
16+
<ProjectGuid>{35D7F2C2-E8EA-4B0C-A7CE-57269DD6B171}</ProjectGuid>
17+
</PropertyGroup>
18+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
19+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
20+
<ConfigurationType>Application</ConfigurationType>
21+
<PlatformToolset>v110</PlatformToolset>
22+
<UseOfMfc>false</UseOfMfc>
23+
<CharacterSet>MultiByte</CharacterSet>
24+
</PropertyGroup>
25+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
26+
<ConfigurationType>Application</ConfigurationType>
27+
<PlatformToolset>v110</PlatformToolset>
28+
<UseOfMfc>false</UseOfMfc>
29+
<CharacterSet>MultiByte</CharacterSet>
30+
</PropertyGroup>
31+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
32+
<ImportGroup Label="ExtensionSettings">
33+
</ImportGroup>
34+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
35+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
36+
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
37+
</ImportGroup>
38+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
39+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
40+
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
41+
</ImportGroup>
42+
<PropertyGroup Label="UserMacros" />
43+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
44+
<OutDir>.\Release\</OutDir>
45+
<IntDir>.\Release\</IntDir>
46+
<LinkIncremental>false</LinkIncremental>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
49+
<OutDir>.\Debug\</OutDir>
50+
<IntDir>.\Debug\</IntDir>
51+
<LinkIncremental>false</LinkIncremental>
52+
</PropertyGroup>
53+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
54+
<ClCompile>
55+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
56+
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
57+
<StringPooling>true</StringPooling>
58+
<FunctionLevelLinking>true</FunctionLevelLinking>
59+
<Optimization>MaxSpeed</Optimization>
60+
<SuppressStartupBanner>true</SuppressStartupBanner>
61+
<WarningLevel>Level3</WarningLevel>
62+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
63+
<AssemblerListingLocation>.\Release\</AssemblerListingLocation>
64+
<PrecompiledHeaderOutputFile>.\Release\BoxPruning.pch</PrecompiledHeaderOutputFile>
65+
<PrecompiledHeader>Use</PrecompiledHeader>
66+
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
67+
<ObjectFileName>.\Release\</ObjectFileName>
68+
<ProgramDataBaseFileName>.\Release\</ProgramDataBaseFileName>
69+
<IntrinsicFunctions>true</IntrinsicFunctions>
70+
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
71+
<OmitFramePointers>true</OmitFramePointers>
72+
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
73+
<WholeProgramOptimization>false</WholeProgramOptimization>
74+
<FloatingPointModel>Fast</FloatingPointModel>
75+
<FloatingPointExceptions>false</FloatingPointExceptions>
76+
<RuntimeTypeInfo>false</RuntimeTypeInfo>
77+
<ExceptionHandling>false</ExceptionHandling>
78+
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
79+
<BrowseInformation>true</BrowseInformation>
80+
</ClCompile>
81+
<Midl>
82+
<TypeLibraryName>.\Release\BoxPruning.tlb</TypeLibraryName>
83+
</Midl>
84+
<ResourceCompile>
85+
<Culture>0x040c</Culture>
86+
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
87+
</ResourceCompile>
88+
<Bscmake>
89+
<SuppressStartupBanner>true</SuppressStartupBanner>
90+
<OutputFile>.\Release\BoxPruning.bsc</OutputFile>
91+
</Bscmake>
92+
<Link>
93+
<SuppressStartupBanner>true</SuppressStartupBanner>
94+
<SubSystem>Console</SubSystem>
95+
<OutputFile>.\Release\BoxPruning.exe</OutputFile>
96+
<AdditionalDependencies>odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
97+
<GenerateDebugInformation>true</GenerateDebugInformation>
98+
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
99+
</Link>
100+
</ItemDefinitionGroup>
101+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
102+
<ClCompile>
103+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
104+
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
105+
<FunctionLevelLinking>false</FunctionLevelLinking>
106+
<Optimization>Disabled</Optimization>
107+
<SuppressStartupBanner>true</SuppressStartupBanner>
108+
<WarningLevel>Level3</WarningLevel>
109+
<MinimalRebuild>true</MinimalRebuild>
110+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
111+
<AssemblerListingLocation>.\Debug\</AssemblerListingLocation>
112+
<BrowseInformation>true</BrowseInformation>
113+
<PrecompiledHeaderOutputFile>.\Debug\BoxPruning.pch</PrecompiledHeaderOutputFile>
114+
<PrecompiledHeader>Use</PrecompiledHeader>
115+
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
116+
<ObjectFileName>.\Debug\</ObjectFileName>
117+
<ProgramDataBaseFileName>.\Debug\</ProgramDataBaseFileName>
118+
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
119+
</ClCompile>
120+
<Midl>
121+
<TypeLibraryName>.\Debug\BoxPruning.tlb</TypeLibraryName>
122+
</Midl>
123+
<ResourceCompile>
124+
<Culture>0x040c</Culture>
125+
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
126+
</ResourceCompile>
127+
<Bscmake>
128+
<SuppressStartupBanner>true</SuppressStartupBanner>
129+
<OutputFile>.\Debug\BoxPruning.bsc</OutputFile>
130+
</Bscmake>
131+
<Link>
132+
<SuppressStartupBanner>true</SuppressStartupBanner>
133+
<GenerateDebugInformation>true</GenerateDebugInformation>
134+
<SubSystem>Console</SubSystem>
135+
<OutputFile>.\Debug\BoxPruning.exe</OutputFile>
136+
<AdditionalDependencies>odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
137+
</Link>
138+
</ItemDefinitionGroup>
139+
<ItemGroup>
140+
<ClCompile Include="..\Shared\IceBoxPruning_BruteForce.cpp" />
141+
<ClCompile Include="..\Shared\IceContainer.cpp" />
142+
<ClCompile Include="..\Shared\IceProfiler.cpp" />
143+
<ClCompile Include="..\Shared\IceRevisitedRadix.cpp" />
144+
<ClCompile Include="..\Shared\Main.cpp" />
145+
<ClCompile Include="IceBoxPruning.cpp" />
146+
<ClCompile Include="BoxPruning.cpp" />
147+
<ClCompile Include="StdAfx.cpp">
148+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
149+
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">stdafx.h</PrecompiledHeaderFile>
150+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
151+
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">stdafx.h</PrecompiledHeaderFile>
152+
</ClCompile>
153+
</ItemGroup>
154+
<ItemGroup>
155+
<ClInclude Include="..\Shared\IceBoxPruning_BruteForce.h" />
156+
<ClInclude Include="..\Shared\IceContainer.h" />
157+
<ClInclude Include="..\Shared\IceFPU.h" />
158+
<ClInclude Include="..\Shared\IceMemoryMacros.h" />
159+
<ClInclude Include="..\Shared\IcePoint.h" />
160+
<ClInclude Include="..\Shared\IceProfiler.h" />
161+
<ClInclude Include="..\Shared\IceRevisitedRadix.h" />
162+
<ClInclude Include="..\Shared\IceTypes.h" />
163+
<ClInclude Include="..\Shared\IceUtils.h" />
164+
<ClInclude Include="..\Shared\StdAfx.h" />
165+
<ClInclude Include="IceBoxPruning.h" />
166+
<ClInclude Include="StdAfx.h" />
167+
</ItemGroup>
168+
<ItemGroup>
169+
<Text Include="ReadMe.txt" />
170+
</ItemGroup>
171+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
172+
<ImportGroup Label="ExtensionTargets">
173+
</ImportGroup>
174+
</Project>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Utils">
5+
<UniqueIdentifier>{d50b631d-ab78-48fa-b589-e853d8653590}</UniqueIdentifier>
6+
</Filter>
7+
<Filter Include="App">
8+
<UniqueIdentifier>{8895af4d-fb5a-4218-8f51-1b9bbe3fc754}</UniqueIdentifier>
9+
</Filter>
10+
</ItemGroup>
11+
<ItemGroup>
12+
<ClCompile Include="BoxPruning.cpp">
13+
<Filter>App</Filter>
14+
</ClCompile>
15+
<ClCompile Include="StdAfx.cpp">
16+
<Filter>App</Filter>
17+
</ClCompile>
18+
<ClCompile Include="..\Shared\IceContainer.cpp">
19+
<Filter>Utils</Filter>
20+
</ClCompile>
21+
<ClCompile Include="..\Shared\IceProfiler.cpp">
22+
<Filter>Utils</Filter>
23+
</ClCompile>
24+
<ClCompile Include="..\Shared\IceRevisitedRadix.cpp">
25+
<Filter>Utils</Filter>
26+
</ClCompile>
27+
<ClCompile Include="IceBoxPruning.cpp">
28+
<Filter>App</Filter>
29+
</ClCompile>
30+
<ClCompile Include="..\Shared\Main.cpp">
31+
<Filter>Utils</Filter>
32+
</ClCompile>
33+
<ClCompile Include="..\Shared\IceBoxPruning_BruteForce.cpp">
34+
<Filter>Utils</Filter>
35+
</ClCompile>
36+
</ItemGroup>
37+
<ItemGroup>
38+
<ClInclude Include="StdAfx.h">
39+
<Filter>App</Filter>
40+
</ClInclude>
41+
<ClInclude Include="..\Shared\IceContainer.h">
42+
<Filter>Utils</Filter>
43+
</ClInclude>
44+
<ClInclude Include="..\Shared\IceFPU.h">
45+
<Filter>Utils</Filter>
46+
</ClInclude>
47+
<ClInclude Include="..\Shared\IceMemoryMacros.h">
48+
<Filter>Utils</Filter>
49+
</ClInclude>
50+
<ClInclude Include="..\Shared\IcePoint.h">
51+
<Filter>Utils</Filter>
52+
</ClInclude>
53+
<ClInclude Include="..\Shared\IceProfiler.h">
54+
<Filter>Utils</Filter>
55+
</ClInclude>
56+
<ClInclude Include="..\Shared\IceRevisitedRadix.h">
57+
<Filter>Utils</Filter>
58+
</ClInclude>
59+
<ClInclude Include="..\Shared\IceTypes.h">
60+
<Filter>Utils</Filter>
61+
</ClInclude>
62+
<ClInclude Include="..\Shared\IceUtils.h">
63+
<Filter>Utils</Filter>
64+
</ClInclude>
65+
<ClInclude Include="..\Shared\StdAfx.h">
66+
<Filter>Utils</Filter>
67+
</ClInclude>
68+
<ClInclude Include="IceBoxPruning.h">
69+
<Filter>App</Filter>
70+
</ClInclude>
71+
<ClInclude Include="..\Shared\IceBoxPruning_BruteForce.h">
72+
<Filter>Utils</Filter>
73+
</ClInclude>
74+
</ItemGroup>
75+
<ItemGroup>
76+
<Text Include="ReadMe.txt" />
77+
</ItemGroup>
78+
</Project>

0 commit comments

Comments
 (0)