Forceflow / cuda_voxelizer

CUDA Voxelizer to convert polygon meshes into annotated voxel grids
MIT License
595 stars 98 forks source link

Axis-aligned surfaces problem mentioned in util.h #48

Open conceptclear opened 3 years ago

conceptclear commented 3 years ago

Hi,@Forceflow I have found the reason which caused the problem that you mentioned in util.h. In cpu_voxelizer.cpp Line 133 to Line 135 and voxelize.cu Line 131 to Line 133 The positions of z and x in these lines of code are wrong. The modified code could be

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]);

After modifying these codes, the problems mentioned in https://github.com/Forceflow/cuda_voxelizer/issues/7 should not happen again :)

Forceflow commented 3 years ago

Interesting, looking into this. If I can get rid of the hacky little epsilon perturbation, would be nice.

Forceflow commented 3 years ago

@conceptclear this doesn't fix the problem unfortunately. I added this, and removed the ugly fix in util.h - the problem returns.

Tried it on the problematic model from issue #7 and it still has holes along the edges.

conceptclear commented 3 years ago

I have tried this on my own computer and it could solve the problem as shown below: Screenshot from 2020-12-03 16-35-57 Screenshot from 2020-12-03 16-36-46 The origin model in https://github.com/Forceflow/cuda_voxelizer/issues/7 has been deleted from the server so that I am not sure whether it could solve it.

Forceflow commented 3 years ago

Could you make a PR with the exact changes?

conceptclear commented 3 years ago

OK, I have made a PR to dev

Forceflow commented 3 years ago

Here's the problem model. problem.zip