Mugen87/yuka

BVHNode intersectRay Method extension

xjindf opened this issue · 1 comments

Hello!

How can I use the intersectray method of bvhnode to return the triangle index of the original meshgeometry, because I added some custom attribute attributes to the meshgeometry, and I need to judge the custom data of the corresponding location according to the current intersection index. What can I do if I can?

thank you!

Unfortunately, it's not possible to retrieve the mentioned index when using BVHNode.intersectRay(). The method just returns the intersection point in 3D space (if there is an intersection) which is its primary purpose.

BVH always converts indexed geometries to non-indexed ones. So if you're original geometry is has an index, the internal geometry of BVH will have a different structure anway.

Besides, instance of BVHNode manage their primitive subset independently of parent nodes. Meaning their triangle indices have no relation to upper nodes.

I don't think it's realistic to change the implementation of BVH so that your use case is supported. For now, it seems you have to use a different BVH code or modify the code according to your needs.