ashawkey / cubvh

CUDA Mesh BVH tools.
MIT License
156 stars 11 forks source link

how can i get ray mesh intersection index? #3

Closed HaoZhang990127 closed 5 months ago

HaoZhang990127 commented 1 year ago

Hi,

thank you for your nice work again. I have another question, i can use this API to get the depth(distance) between the camera and mesh,

### query ray-mesh intersection
rays_o, rays_d = get_ray(pose, intrinsics, H, W) # [N, 3], [N, 3], query with torch.Tensor (cuda)
intersections, face_id, depth = BVH.ray_trace(rays_o, rays_d) # [N, 3], [N,], [N,]

but the face_id is mesh face index and intersections is ray mesh intersection coordinate. how can i get the information that which ray are interaction with mesh?

Thank you.

ashawkey commented 1 year ago

@HaoZhang990127 Hi, I think you can get that mask by face_id >= 0?

HaoZhang990127 commented 1 year ago

Thank you for you reply.

this method works for me, but i find sometimes the face_id>=0 will give me larger region out of the mesh, i am not sure why this will happen. now i render the depth map as the mask of rays mesh intersection works better for me.

Thanks again.