Adding SDF format to kernel.#324
Open
meet-brad-ch wants to merge 1 commit intoProjectPhysX:masterfrom
Open
Conversation
Author
|
This is the example code. The SDF file can be generated from cow.stl. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add SDF (Signed Distance Field) Voxelization Support
Summary
This PR adds support for voxelizing pre-computed Signed Distance Fields (SDF) as an alternative to runtime STL mesh voxelization. SDF voxelization uses GPU-accelerated trilinear interpolation for smoother boundaries and can be faster for complex geometries that are reused across simulations.
Motivation
voxelize_stl()methodsModified Files
src/utilities.hpp (+148 lines)
SDFstruct for storing 3D signed distance field dataread_sdf()function to load binary SDF filestranspose()function forfloat3x3matrices (needed for inverse rotation)src/lbm.hpp (+5 lines)
LBM_Domain::voxelize_sdf_on_device()declarationLBM::voxelize_sdf()overloads matchingvoxelize_stl()APIsrc/lbm.cpp (+73 lines)
LBM_Domain::voxelize_sdf_on_device()- uploads SDF to GPU and runs kernelLBM::voxelize_sdf()overloads with/without center and rotation parameterssrc/kernel.cpp (+88 lines)
voxelize_sdfOpenCL kernel with:API
Parameters:
path: Path to binary SDF filecenter: Position in LBM coordinates where SDF center should be placedrotation: 3x3 rotation matrix (same asvoxelize_stl)scale: Target size of the largest SDF dimension in LBM unitsflag: Voxel flag type (default:TYPE_Sfor solid)SDF File Format
Binary format (little-endian, 36-byte header + float array):
Data layout:
data[x + Nx*(y + Ny*z)]Example Usage
Generating SDF Files
SDF files can be generated from STL meshes using SDFGenFast:
Testing
Backward Compatibility