Skip to content

Commit

Permalink
Merge pull request #67 from Forceflow/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Forceflow authored Jul 7, 2022
2 parents b952136 + 5fa241a commit 8ad0804
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build Status](https://travis-ci.org/Forceflow/cuda_voxelizer.svg?branch=master)](https://travis-ci.org/Forceflow/cuda_voxelizer) ![](https://img.shields.io/github/license/Forceflow/cuda_voxelizer.svg) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/Forceflow)

# cuda_voxelizer v0.4.12
# cuda_voxelizer v0.4.13
A command-line tool to convert polygon meshes to (annotated) voxel grids.
* Supported input formats: .ply, .off, .obj, .3DS, .SM and RAY
* Supported output formats: .binvox, .obj, morton ordered grid
Expand Down
8 changes: 4 additions & 4 deletions msvc/vs2019/cuda_voxelizer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 11.6.props" />
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 11.7.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
Expand Down Expand Up @@ -133,6 +133,6 @@ copy /y "$(SolutionDir)$(Platform)\$(Configuration)\$(TargetName).exe" "$(BINARY
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 11.6.targets" />
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 11.7.targets" />
</ImportGroup>
</Project>
27 changes: 27 additions & 0 deletions msvc/vs2022/cuda_voxelizer.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.271
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cuda_voxelizer", "cuda_voxelizer.vcxproj", "{D4330816-735D-4CC7-AE2A-04A0E998099E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C52A2702-E60C-4590-9C55-C8C66CCA5BAB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D4330816-735D-4CC7-AE2A-04A0E998099E}.Debug|x64.ActiveCfg = Debug|x64
{D4330816-735D-4CC7-AE2A-04A0E998099E}.Debug|x64.Build.0 = Debug|x64
{D4330816-735D-4CC7-AE2A-04A0E998099E}.Release|x64.ActiveCfg = Release|x64
{D4330816-735D-4CC7-AE2A-04A0E998099E}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D7628502-09E5-4B15-AB62-365471E954D4}
EndGlobalSection
EndGlobal
138 changes: 138 additions & 0 deletions msvc/vs2022/cuda_voxelizer.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D4330816-735D-4CC7-AE2A-04A0E998099E}</ProjectGuid>
<RootNamespace>cuda_voxelizer</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 11.7.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="custom_includes.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="custom_includes.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>C:\libs\trimesh2\include;C:\libs\glm;$(IncludePath)</IncludePath>
<LibraryPath>C:\libs\trimesh2\lib.Win64;$(LibraryPath)</LibraryPath>
<CustomBuildAfterTargets>xcopy /y "$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName).exe" "$(BINARY_OUTPUT_DIR)$(ProjectName).exe"</CustomBuildAfterTargets>
<TargetName>$(ProjectName)_debug</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>C:\libs\trimesh2\include;C:\libs\glm;$(IncludePath)</IncludePath>
<LibraryPath>C:\libs\trimesh2\lib.Win64;$(LibraryPath)</LibraryPath>
<CustomBuildAfterTargets>xcopy /y "$(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName).exe" "$(BINARY_OUTPUT_DIR)$(ProjectName).exe"</CustomBuildAfterTargets>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<OpenMPSupport>true</OpenMPSupport>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>trimeshd.lib;cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)"
copy "$(CudaToolkitBinDir)\cudart*.dll" "$(BINARY_OUTPUT_DIR)"
copy /y "$(SolutionDir)$(Platform)\$(Configuration)\$(TargetName).exe" "$(BINARY_OUTPUT_DIR)$(TargetName).exe"</Command>
</PostBuildEvent>
<CudaCompile>
<PtxAsOptionV>true</PtxAsOptionV>
<AdditionalOptions>--source-in-ptx %(AdditionalOptions)</AdditionalOptions>
</CudaCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<OpenMPSupport>true</OpenMPSupport>
<WholeProgramOptimization>false</WholeProgramOptimization>
<FloatingPointModel>Strict</FloatingPointModel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>trimesh.lib;cudart.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>copy "$(CudaToolkitBinDir)\cudart*.dll" "$(OutDir)"
copy "$(CudaToolkitBinDir)\cudart*.dll" "$(BINARY_OUTPUT_DIR)"
copy /y "$(SolutionDir)$(Platform)\$(Configuration)\$(TargetName).exe" "$(BINARY_OUTPUT_DIR)$(TargetName).exe"</Command>
</PostBuildEvent>
<CudaCompile>
<FastMath>true</FastMath>
</CudaCompile>
</ItemDefinitionGroup>
<ItemGroup>
<CudaCompile Include="..\..\src/voxelize.cu" />
<CudaCompile Include="..\..\src\thrust_operations.cu" />
<CudaCompile Include="..\..\src\voxelize_solid.cu" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\cpu_voxelizer.cpp" />
<ClCompile Include="..\..\src\util_io.cpp" />
<ClCompile Include="..\..\src\util_cuda.cpp" />
<ClCompile Include="..\..\src\main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\cpu_voxelizer.h" />
<ClInclude Include="..\..\src\util_io.h" />
<ClInclude Include="..\..\src\util.h" />
<ClInclude Include="..\..\src\util_cuda.h" />
<ClInclude Include="..\..\src\libs\helper_cuda.h" />
<ClInclude Include="..\..\src\libs\helper_string.h" />
<ClInclude Include="..\..\src\morton_LUTs.h" />
<ClInclude Include="..\..\src\thrust_operations.cuh" />
<ClInclude Include="..\..\src\timer.h" />
<ClInclude Include="..\..\src\voxelize.cuh" />
</ItemGroup>
<ItemGroup>
<Text Include="..\..\src\todo.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 11.7.targets" />
</ImportGroup>
</Project>
55 changes: 55 additions & 0 deletions msvc/vs2022/cuda_voxelizer.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<CudaCompile Include="..\..\src\thrust_operations.cu" />
<CudaCompile Include="..\..\src/voxelize.cu" />
<CudaCompile Include="..\..\src\voxelize_solid.cu" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\main.cpp" />
<ClCompile Include="..\..\src\util_cuda.cpp">
<Filter>util</Filter>
</ClCompile>
<ClCompile Include="..\..\src\util_io.cpp">
<Filter>util</Filter>
</ClCompile>
<ClCompile Include="..\..\src\cpu_voxelizer.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\libs\helper_cuda.h">
<Filter>cuda</Filter>
</ClInclude>
<ClInclude Include="..\..\src\libs\helper_string.h">
<Filter>cuda</Filter>
</ClInclude>
<ClInclude Include="..\..\src\voxelize.cuh" />
<ClInclude Include="..\..\src\thrust_operations.cuh" />
<ClInclude Include="..\..\src\morton_LUTs.h">
<Filter>util</Filter>
</ClInclude>
<ClInclude Include="..\..\src\timer.h" />
<ClInclude Include="..\..\src\util_cuda.h">
<Filter>util</Filter>
</ClInclude>
<ClInclude Include="..\..\src\util_io.h">
<Filter>util</Filter>
</ClInclude>
<ClInclude Include="..\..\src\util.h">
<Filter>util</Filter>
</ClInclude>
<ClInclude Include="..\..\src\cpu_voxelizer.h">
<Filter>util</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="..\..\src\todo.txt" />
</ItemGroup>
<ItemGroup>
<Filter Include="util">
<UniqueIdentifier>{a0232da8-2097-49f4-9412-0e4223c7ba4d}</UniqueIdentifier>
</Filter>
<Filter Include="cuda">
<UniqueIdentifier>{ea2a8fd1-3d76-496e-9ad4-123e8f208140}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
30 changes: 30 additions & 0 deletions msvc/vs2022/custom_includes.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros">
<TRIMESH_DIR>D:\dev\libs\trimesh2\</TRIMESH_DIR>
<GLM_DIR>D:\dev\libs\glm\</GLM_DIR>
<BINARY_OUTPUT_DIR>D:\dev\Binaries\</BINARY_OUTPUT_DIR>
</PropertyGroup>
<PropertyGroup>
<IncludePath>$(GLM_DIR);$(TRIMESH_DIR)\include\;$(IncludePath)</IncludePath>
<_PropertySheetDisplayName>custom_includes</_PropertySheetDisplayName>
<LibraryPath>$(TRIMESH_DIR)\lib.Win$(PlatformArchitecture).vs$(PlatformToolsetVersion);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup />
<ItemDefinitionGroup />
<ItemGroup>
<BuildMacro Include="BINARY_OUTPUT_DIR">
<Value>$(BINARY_OUTPUT_DIR)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
</BuildMacro>
<BuildMacro Include="TRIMESH_DIR">
<Value>$(TRIMESH_DIR)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
</BuildMacro>
<BuildMacro Include="GLM_DIR">
<Value>$(GLM_DIR)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
</BuildMacro>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "cpu_voxelizer.h"

using namespace std;
string version_number = "v0.4.12";
string version_number = "v0.4.13";

// Forward declaration of CUDA functions
float* meshToGPU_thrust(const trimesh::TriMesh *mesh); // METHOD 3 to transfer triangles can be found in thrust_operations.cu(h)
Expand Down
6 changes: 4 additions & 2 deletions src/voxelize.cu
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ __global__ void voxelize_triangle(voxinfo info, float* triangle_data, unsigned i
for (int z = t_bbox_grid.min.z; z <= t_bbox_grid.max.z; z++){
for (int y = t_bbox_grid.min.y; y <= t_bbox_grid.max.y; y++){
for (int x = t_bbox_grid.min.x; x <= t_bbox_grid.max.x; x++){
// size_t location = x + (y*info.gridsize) + (z*info.gridsize*info.gridsize);
// if (checkBit(voxel_table, location)){ continue; }
#ifdef _DEBUG
atomicAdd(&debug_d_n_voxels_tested, 1);
Expand Down Expand Up @@ -173,7 +172,10 @@ __global__ void voxelize_triangle(voxinfo info, float* triangle_data, unsigned i
size_t location = mortonEncode_LUT(x, y, z);
setBit(voxel_table, location);
} else {
size_t location = static_cast<size_t>(x) + (static_cast<size_t>(y)* static_cast<size_t>(info.gridsize.y)) + (static_cast<size_t>(z)* static_cast<size_t>(info.gridsize.y)* static_cast<size_t>(info.gridsize.z));
size_t location =
static_cast<size_t>(x) +
(static_cast<size_t>(y)* static_cast<size_t>(info.gridsize.x)) +
(static_cast<size_t>(z)* (static_cast<size_t>(info.gridsize.y)* static_cast<size_t>(info.gridsize.x)));
setBit(voxel_table, location);
}
continue;
Expand Down
10 changes: 6 additions & 4 deletions src/voxelize_solid.cu
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ __global__ void voxelize_triangle_solid(voxinfo info, float* triangle_data, unsi
if (fabs(n.x) < float_error)
return;

//Calculate the projection of three point into yoz plane
// Calculate the projection of three point into yoz plane
glm::vec2 v0_yz = glm::vec2(v0.y, v0.z);
glm::vec2 v1_yz = glm::vec2(v1.y, v1.z);
glm::vec2 v2_yz = glm::vec2(v2.y, v2.z);

//set the triangle counterclockwise
// Set the triangle counterclockwise
if (!checkCCW(v0_yz, v1_yz, v2_yz))
{
glm::vec2 v3 = v1_yz;
Expand Down Expand Up @@ -128,15 +128,17 @@ __global__ void voxelize_triangle_solid(voxinfo info, float* triangle_data, unsi
size_t location = mortonEncode_LUT(x, y, z);
setBitXor(voxel_table, location);
} else {
size_t location = static_cast<size_t>(x) + (static_cast<size_t>(y)* static_cast<size_t>(info.gridsize.y)) + (static_cast<size_t>(z)* static_cast<size_t>(info.gridsize.y)* static_cast<size_t>(info.gridsize.z));
size_t location =
static_cast<size_t>(x) +
(static_cast<size_t>(y) * static_cast<size_t>(info.gridsize.x)) +
(static_cast<size_t>(z) * (static_cast<size_t>(info.gridsize.y) * static_cast<size_t>(info.gridsize.x)));
setBitXor(voxel_table, location);
}
continue;
}
}
}
}

// sanity check: atomically count triangles
//atomicAdd(&triangles_seen_count, 1);
thread_id += stride;
Expand Down

0 comments on commit 8ad0804

Please sign in to comment.