I have a generically written geometry tree class, which can be instantiated for 1 or more dimensions (2 yields a quadtree, 3 a octtree, …).
The number of dimensions is specified in the constructor, and assigned to a final instance variable.
Obviously, most geometry manipulations need to loop over the number of dimensions. These loops are mostly tight and straight-forward, and also straight-forward for me to override and optimize in an octtree subclass later on.
I’m curious though regarding the intelligence of today’s dynamically optimizing VMs… Are they able to unwind loops over small, final variables? Especially when the loops contain straight-forward, easily inlineable code?
/ Chris