Bugs in ops.mesh.check_sign() triggered under special circumstances
Bugs in ops.mesh.check_sign() triggered under special circumstances
We found that if a point is in a sepcific axis, the check_sign is invalid for some primitive meshes.
from kaolin.ops.mesh import check_sign, index_vertices_by_faces
import trimesh as tm
import torch
# we test the check_sign function
x_points = torch.Tensor([[[1, 0, 0]]])
y_points = torch.Tensor([[[0, 1, 0]]])
z_points = torch.Tensor([[[0, 0, 1]]])
# e.g. When the test primitive is Sphere, check_sign is incorrect on x/y-axis
sphere_mesh = tm.primitives.Sphere(radius=2.0, subdivision=3)
points = z_points
print(f'trimesh contains() result: {sphere_mesh.contains(points.squeeze(0))}')
print(f'check_sign() result: {check_sign(torch.Tensor(sphere_mesh.vertices).unsqueeze(0), torch.Tensor(sphere_mesh.faces).long(), points)}')
Note that the cast a ray from the point is a really smart idea, and it is valid for most of points in our test, we don't know if this is an imperfection in the implementation.
Hi @Xiaoyao-Li , thank you for your interest, I'm exploring the issue. From what I'm seeing of the case the problem seems to be occuring from when the ray is intersecting a vertice or an edge.
Note: both cuda and cpu are failing, however returning different results.
Thank you for this helpful info in your timely reply. We are benefitted from kaolin a lot and looking forward to a new version.
Hi @Xiaoyao-Li ,
Just merged the fix on GPU version, don't have enough time for the CPU version but I would happily merge an MR if someone wants to adapt the fix to CPU.
Thank you for your hardworking again! Keep opening this issue for someone to fix on the CPU version.