|
Post by disembleergon on Oct 2, 2021 18:26:19 GMT
Hi,
so I implemented groups in my C++ ray tracer, but because of C++'s pointer "magic" I have some problems adding the same group to the scene multiple times.
Because I couldn't fix it, I decided to temporarely skip this feature. Are groups just a small extra feature or are they important later on?
|
|
|
Post by inventordave on Oct 4, 2021 13:47:28 GMT
They are essential if you add the optimisation "Bounding Box Volume Hierarchy". It's not in the book itself, but it is an essential mod after integrating triangle support, because meshes are defined as 000s of triangles, so you need the renderer to optimise how many shapes a ray needs to manually check against for a hit. BVH is a bonus chapter online. Search this forum for a link by way of a Jamis post. Necessary then.
Can't you copy a pointer as a 32/64bit int, approx:
Group *pointer1 = groupRef(id); // ....
long int* pointer2; // ... pointer2 = pointer1; // no * or & on either lvalue or rvalue
(Group*)pointer2 // statement fragment
|
|
|
Post by Jamis on Oct 4, 2021 15:54:17 GMT
As @inventordave mentioned, groups are pretty important for some optimizations. However, they also come into play in the CSG chapter at the end of the book; it's worth figuring out.
Instead of adding the same group multiple times (which may cause problem for telling the object which parent should be considered when evaluating things like world-space and pattern-space), consider duplicating the group. This is what I've done in my own renderer. In practice, the duplication won't be significant for most scenes (and for those where it is, you could consider other optimizations to store the bulk of the data in one place, and reference it from the duplicates).
|
|