bryanedds / Nu

Repository hosting the open-source Nu Game Engine and related projects.
MIT License
1.05k stars 151 forks source link

Attempt to make spatial tree nodes be constructed lazily, #773

Closed bryanedds closed 3 months ago

bryanedds commented 3 months ago

Nu having to create half a million objects the moment a single 3D entity is placed in the scene is wasteful in terms of memory as well as potentially what the GC may have to scan.

Let's try our best to make this structure lazily constructed. For hashed node access, we can just check for null nodes before peeking into them in the fast path.

Lazy construction does have a down-side: unlike preconstructing all the octnodes, they won't be placed so closely in memory. This may or may not have measurable performance implications for access time. But either way, it's worth a try if we can make it work.

bryanedds commented 3 months ago

Done.