From df4fa2a5a8725e9a99930049354ba4c759099f97 Mon Sep 17 00:00:00 2001 From: Death Date: Sun, 1 Jun 2025 17:37:07 +1000 Subject: [PATCH 1/2] fix: correct logical operator in distance comparison and clean up code formatting --- third_party/voxelize/src/udf_kernel.cu | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/third_party/voxelize/src/udf_kernel.cu b/third_party/voxelize/src/udf_kernel.cu index 2488606..93e8128 100644 --- a/third_party/voxelize/src/udf_kernel.cu +++ b/third_party/voxelize/src/udf_kernel.cu @@ -20,7 +20,7 @@ __device__ Point3D cross(const Point3D& v1, const Point3D& v2) { // Compute the dot product of two vectors __device__ float dot(const Point3D& v1, const Point3D& v2) { - return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; + return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; } // Subtract two 3D points (vector subtraction) @@ -179,7 +179,7 @@ __device__ void updateUDF(Triangle t, int* udf, const int DIM, const float thres Point3D queryPoint = {(float)i/(DIM-1) - 0.5, (float)j/(DIM-1) - 0.5, (float)k/(DIM-1) -0.5}; float distance = pointToTriangleDistance(queryPoint, t.v0, t.v1, t.v2); float distance2 = pointToTriangleDistance(queryPoint, t.v0, t.v1, t.v2, true); - if (distance < threshold / DIM or distance2 < threshold / DIM){ + if (distance < threshold / DIM || distance2 < threshold / DIM){ //distance = distance2; int int_dist = (int)(distance * 10000000); atomicMin(&udf[idx], int_dist); @@ -211,4 +211,3 @@ void compute_valid_udf_cuda(float* vertices, int* faces, int* udf, int numTriang // Launch the kernel compute_udf_kernel<<>>(vertices, faces, udf, numTriangles, DIM, threshold); } - From 2bd8efc218f94b61ce5806994d3e19edde36999a Mon Sep 17 00:00:00 2001 From: Death Date: Sun, 1 Jun 2025 18:12:59 +1000 Subject: [PATCH 2/2] style: adjust indentation for consistency in dot product and updateUDF functions --- third_party/voxelize/src/udf_kernel.cu | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/third_party/voxelize/src/udf_kernel.cu b/third_party/voxelize/src/udf_kernel.cu index 93e8128..46571d8 100644 --- a/third_party/voxelize/src/udf_kernel.cu +++ b/third_party/voxelize/src/udf_kernel.cu @@ -20,7 +20,7 @@ __device__ Point3D cross(const Point3D& v1, const Point3D& v2) { // Compute the dot product of two vectors __device__ float dot(const Point3D& v1, const Point3D& v2) { - return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; + return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; } // Subtract two 3D points (vector subtraction) @@ -179,12 +179,12 @@ __device__ void updateUDF(Triangle t, int* udf, const int DIM, const float thres Point3D queryPoint = {(float)i/(DIM-1) - 0.5, (float)j/(DIM-1) - 0.5, (float)k/(DIM-1) -0.5}; float distance = pointToTriangleDistance(queryPoint, t.v0, t.v1, t.v2); float distance2 = pointToTriangleDistance(queryPoint, t.v0, t.v1, t.v2, true); - if (distance < threshold / DIM || distance2 < threshold / DIM){ - //distance = distance2; - int int_dist = (int)(distance * 10000000); - atomicMin(&udf[idx], int_dist); - } - } + if (distance < threshold / DIM || distance2 < threshold / DIM){ + //distance = distance2; + int int_dist = (int)(distance * 10000000); + atomicMin(&udf[idx], int_dist); + } + } } }