It shouldn’t be much faster, really. One is a hashmap lookup which amounts to a buffer access… the other is a method call and a buffer access. So both amount to a method call and an array lookup. I guess the hashmap version will also do an .equals() on the string (fast) so you might save one whole millisecond per hour or so.
JME does this automatically now. Only children with controls (or that indicate that they should if they are subclasses) have their updateLogicalState() called. And updateGeometricState was already only called if needed.
re: the updateLogicalState() thing, if you are (ill-advisedly) subclasses JME spatial classes then you will have to override a method that indicates that you want to participate in the optimization. This was to avoid backwards compatibility issues for anyone (ill-advisedly) subclasses these classes.
It’s even better than just not traversing children because it builds a list in the root node of just the nodes that need updates… doesn’t even do a scene graph traversal at that point.
The problem with early micro-optimization is that you end up down paths that are hard to undo when you either find out that they don’t matter or find out that there was a higher level optimization to do.
I did not found any issues with my current Node’s subclass. Using this solution I can do more: pause animations and particle emitters globally. By enabling/disabling one node I can allow/block the execution of the whole branch’s controls. My pause uses that.
I did not found any decent solution for game time in JME so I wrote my own global game timer, it have the ability to pause/resume and can be serialized. It of course is not affecting the tpf parameter, which is used by all the scene but it does not have to. My game logic is separated from game scene, they are sending small messages to each other, game timer is able to send messages too, which are used as a ‘clock signal’ for game logic object.
Yeah, really JME should probably have a couple different ‘time sources’ for things like animation (and even user defined ones). Because maybe you do want to pause your game animation but not UI animation, etc… Requires lots of changes to this right… your solution is probably the best you can do with today’s code.
More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. –William Wulf
We should forget about small efficiencies, say about 97% of the time: Premature Optimization is the root of all evil. –Donald Knuth
The First Rule of Program Optimization: Don’t do it. The Second Rule of Program Optimization – For experts only : Don’t do it yet. –Michael A. Jackson