Thanks for this nice library!
I want to use Embree to create my own BVH2 (for GPU traversal, so I don't want the BVH4/8).
I got the tutorial bvh builder running, but have some questions about it:
a) How is the memory of the nodes managed/who owns it? They are allocated with the RTCThreadLocalAllocator. Does the Embree BVH own it and destroy it when the BVH is deleted via Embree API?
b) Internally I saw that the primitives are kept in range<size_t>, but in RTCCreateLeafFunc, one only gets
const RTCBuildPrimitive* prims, size_t numPrims
Is it safe to calculate the start offset by using the prims pointer (and the original primitive pointer that was passed into the function?), because I want to store the range in my LeafNode? Is it safe to assume that the range will not change afterwards (that the primitives in the range will not change/be sorted) or do I need to copy the primitive ids at that time?
c) I guess the input primitives are modified when calling the rtcBuildBVH, right? Can I free the memory after building the BVH, or does it still reference the primitives somehow? (except for the ranges that I would store in my leafs).
d) Would it be a better alternative to create a BVH4 with normal Embree Mesh API and then convert it to a BVH2 by adding additional inner nodes, or is that a bad alternative?