Skip to content

add one test model and fix the problem metioned in issue 7 #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cpu_voxelizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ namespace cpu_voxelizer {
n_zx_e1 = -n_zx_e1;
n_zx_e2 = -n_zx_e2;
}
float d_xz_e0 = (-1.0f * glm::dot(n_zx_e0, glm::vec2(v0.z, v0.x))) + glm::max(0.0f, info.unit.x * n_zx_e0[0]) + glm::max(0.0f, info.unit.z * n_zx_e0[1]);
float d_xz_e1 = (-1.0f * glm::dot(n_zx_e1, glm::vec2(v1.z, v1.x))) + glm::max(0.0f, info.unit.x * n_zx_e1[0]) + glm::max(0.0f, info.unit.z * n_zx_e1[1]);
float d_xz_e2 = (-1.0f * glm::dot(n_zx_e2, glm::vec2(v2.z, v2.x))) + glm::max(0.0f, info.unit.x * n_zx_e2[0]) + glm::max(0.0f, info.unit.z * n_zx_e2[1]);
float d_xz_e0 = (-1.0f * glm::dot(n_zx_e0, glm::vec2(v0.z, v0.x))) + glm::max(0.0f, info.unit.z * n_zx_e0[0]) + glm::max(0.0f, info.unit.x * n_zx_e0[1]);
float d_xz_e1 = (-1.0f * glm::dot(n_zx_e1, glm::vec2(v1.z, v1.x))) + glm::max(0.0f, info.unit.z * n_zx_e1[0]) + glm::max(0.0f, info.unit.x * n_zx_e1[1]);
float d_xz_e2 = (-1.0f * glm::dot(n_zx_e2, glm::vec2(v2.z, v2.x))) + glm::max(0.0f, info.unit.z * n_zx_e2[0]) + glm::max(0.0f, info.unit.x * n_zx_e2[1]);

// test possible grid boxes for overlap
for (int z = t_bbox_grid.min.z; z <= t_bbox_grid.max.z; z++) {
Expand Down
6 changes: 3 additions & 3 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ inline AABox<T> createMeshBBCube(AABox<T> box) {
// Suspected cause: If a triangle is axis-aligned and lies perfectly on a voxel edge, it sometimes gets counted / not counted
// Probably due to a numerical instability (division by zero?)
// Ugly fix: we pad the bounding box on all sides by 1/10001th of its total length, bringing all triangles ever so slightly off-grid
glm::vec3 epsilon = (answer.max - answer.min) / 10001.0f;
answer.min -= epsilon;
answer.max += epsilon;
// glm::vec3 epsilon = (answer.max - answer.min) / 10001.0f;
// answer.min -= epsilon;
// answer.max += epsilon;
return answer;
}

Expand Down
6 changes: 3 additions & 3 deletions src/voxelize.cu
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ __global__ void voxelize_triangle(voxinfo info, float* triangle_data, unsigned i
n_zx_e1 = -n_zx_e1;
n_zx_e2 = -n_zx_e2;
}
float d_xz_e0 = (-1.0f * glm::dot(n_zx_e0, glm::vec2(v0.z, v0.x))) + glm::max(0.0f, info.unit.x*n_zx_e0[0]) + glm::max(0.0f, info.unit.z*n_zx_e0[1]);
float d_xz_e1 = (-1.0f * glm::dot(n_zx_e1, glm::vec2(v1.z, v1.x))) + glm::max(0.0f, info.unit.x*n_zx_e1[0]) + glm::max(0.0f, info.unit.z*n_zx_e1[1]);
float d_xz_e2 = (-1.0f * glm::dot(n_zx_e2, glm::vec2(v2.z, v2.x))) + glm::max(0.0f, info.unit.x*n_zx_e2[0]) + glm::max(0.0f, info.unit.z*n_zx_e2[1]);
float d_xz_e0 = (-1.0f * glm::dot(n_zx_e0, glm::vec2(v0.z, v0.x))) + glm::max(0.0f, info.unit.z*n_zx_e0[0]) + glm::max(0.0f, info.unit.x*n_zx_e0[1]);
float d_xz_e1 = (-1.0f * glm::dot(n_zx_e1, glm::vec2(v1.z, v1.x))) + glm::max(0.0f, info.unit.z*n_zx_e1[0]) + glm::max(0.0f, info.unit.x*n_zx_e1[1]);
float d_xz_e2 = (-1.0f * glm::dot(n_zx_e2, glm::vec2(v2.z, v2.x))) + glm::max(0.0f, info.unit.z*n_zx_e2[0]) + glm::max(0.0f, info.unit.x*n_zx_e2[1]);

// test possible grid boxes for overlap
for (int z = t_bbox_grid.min.z; z <= t_bbox_grid.max.z; z++){
Expand Down
Binary file added test_models/mechanical.STL
Binary file not shown.