From 04d814ee315a2880bb75d7f9046b1d11fb32cda8 Mon Sep 17 00:00:00 2001 From: cutealien Date: Tue, 2 May 2023 16:05:22 +0000 Subject: [PATCH] Allow nodes ignoring parent transformations with ESNUA_RELATIVE New AbsPosUpdateBehavior which makes updateAbsolutePosition calls behave as if a node had no parent. Allows for micro optimizations in cases where we have non-moving root node (all scenenodes are always added to the SceneManager which is generally not moved but it's transformation is still multiplied each frame for each node) As a side-effect this also allows abusing the SceneManager to group objects without affecting transformations. No real extra cost since I added ESNUA_TRANSFORM_POSITION already. Thought turns out those matrix transformations are so fast that I also didn't noticed any difference in tests with > 20.000 nodes. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6481 dfc29bdd-3216-0410-991c-e03cc46cb475 --- include/ESceneNodeUpdateAbs.h | 7 ++++++- include/ISceneNode.h | 16 ++++++++++++---- tests/tests-last-passed-at.txt | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/ESceneNodeUpdateAbs.h b/include/ESceneNodeUpdateAbs.h index 6b4a115..4a75163 100644 --- a/include/ESceneNodeUpdateAbs.h +++ b/include/ESceneNodeUpdateAbs.h @@ -17,7 +17,11 @@ namespace scene //! Only transform the position of the node transformation matrix //! by the parent transformation matrix. //! Parent will not affect the rotation/scale of the node transformation. - ESNUA_TRANSFORM_POSITION + ESNUA_TRANSFORM_POSITION, + + //! Use the relative matrix as absolute transformation matrix + //! Parent node transformation is ignored just like when the parent is set to 0 + ESNUA_RELATIVE }; //! Names for culling type @@ -25,6 +29,7 @@ namespace scene { "matrix", "pos", + "relative", 0 }; diff --git a/include/ISceneNode.h b/include/ISceneNode.h index a20daab..4f18cc9 100644 --- a/include/ISceneNode.h +++ b/include/ISceneNode.h @@ -79,7 +79,7 @@ namespace scene //! This method is called just before the rendering process of the whole scene. /** Nodes may register themselves in the render pipeline during this call, - precalculate the geometry which should be rendered, and prevent their + pre-calculate the geometry which should be rendered, and prevent their children from being able to register themselves if they are clipped by simply not calling their OnRegisterSceneNode method. If you are implementing your own scene node, you should overwrite this method @@ -543,7 +543,7 @@ namespace scene //! Set a culling style or disable culling completely. - /** Box cullling (EAC_BOX) is set by default. Note that not + /** Box culling (EAC_BOX) is set by default. Note that not all SceneNodes support culling and that some nodes always cull their geometry because it is their only reason for existence, for example the OctreeSceneNode. @@ -682,16 +682,24 @@ namespace scene { if (Parent) { - if ( AbsPosUpdateBehavior == ESNUA_TRANSFORM_MATRIX ) + switch ( AbsPosUpdateBehavior ) + { + case ESNUA_TRANSFORM_MATRIX: { AbsoluteTransformation = Parent->getAbsoluteTransformation() * getRelativeTransformation(); } - else if ( AbsPosUpdateBehavior == ESNUA_TRANSFORM_POSITION ) + break; + case ESNUA_TRANSFORM_POSITION: { AbsoluteTransformation = getRelativeTransformation(); Parent->getAbsoluteTransformation().transformVect(reinterpret_cast(AbsoluteTransformation[12])); } + break; + case ESNUA_RELATIVE: + AbsoluteTransformation = getRelativeTransformation(); + break; + } } else AbsoluteTransformation = getRelativeTransformation(); diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index a8373c2..a9358f5 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 72 tests of 72 passed. Compiled as DEBUG -Test suite pass at GMT Fri Apr 28 17:44:32 2023 +Test suite pass at GMT Tue May 02 15:59:37 2023