diff --git a/changes.txt b/changes.txt index be5e83d..32deb6f 100644 --- a/changes.txt +++ b/changes.txt @@ -1,6 +1,7 @@ -------------------------- Changes in 1.9 (not yet released) +- Add ISceneNode::UpdateAbsolutePosBehavior variable to allow nodes to ignore the scale/rotation parts of their parents transformation. - Add IGUISpinBox functions getValueFor and getOldValue - Bugfix: IGUIElement::getNextElement now passing includeInvisible and includeDisabled flags recursively instead of disabling those for children. This fixes problems that elements sometimes didn't get a tab order because some parent was invisible and so tab'ing for them failed completely. diff --git a/include/ESceneNodeUpdateAbs.h b/include/ESceneNodeUpdateAbs.h new file mode 100644 index 0000000..6b4a115 --- /dev/null +++ b/include/ESceneNodeUpdateAbs.h @@ -0,0 +1,34 @@ +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef IRR_E_SCENE_NODE_UPDATE_ABS_H_INCLUDED +#define IRR_E_SCENE_NODE_UPDATE_ABS_H_INCLUDED + +namespace irr +{ +namespace scene +{ + //! Options how ISceneNode::updateAbsolutePosition calculates the AbsoluteTransformation + enum ESCENE_NODE_UPDATE_ABS + { + //! Node and parent transformation matrices are multiplied (default) + ESNUA_TRANSFORM_MATRIX, + + //! 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 + }; + + //! Names for culling type + const c8* const SceneNodeUpdateAbsNames[] = + { + "matrix", + "pos", + 0 + }; + +} // end namespace scene +} // end namespace irr + +#endif diff --git a/include/ISceneNode.h b/include/ISceneNode.h index e53d3c6..d6cdc70 100644 --- a/include/ISceneNode.h +++ b/include/ISceneNode.h @@ -7,6 +7,7 @@ #include "IAttributeExchangingObject.h" #include "ESceneNodeTypes.h" +#include "ESceneNodeUpdateAbs.h" #include "ECullingTypes.h" #include "EDebugSceneTypes.h" #include "ISceneNodeAnimator.h" @@ -29,6 +30,7 @@ namespace scene //! Typedef for list of scene node animators typedef core::list ISceneNodeAnimatorList; + //! Scene node interface. /** A scene node is a node in the hierarchical scene graph. Every scene node may have children, which are also scene nodes. Children move @@ -48,7 +50,8 @@ namespace scene const core::vector3df& scale = core::vector3df(1.0f, 1.0f, 1.0f)) : RelativeTranslation(position), RelativeRotation(rotation), RelativeScale(scale), Parent(0), SceneManager(mgr), TriangleSelector(0), ID(id), - AutomaticCullingState(EAC_BOX), DebugDataVisible(EDS_OFF), + AutomaticCullingState(EAC_BOX), UpdateAbsolutePosBehavior(ESNUA_TRANSFORM_MATRIX), + DebugDataVisible(EDS_OFF), IsVisible(true), IsDebugObject(false) { if (parent) @@ -558,6 +561,18 @@ namespace scene return AutomaticCullingState; } + //! Set how updateAbsolutePosition calculates the absolute transformation matrix + void setUpdateAbsolutePosBehavior(ESCENE_NODE_UPDATE_ABS behavior) + { + UpdateAbsolutePosBehavior = behavior; + } + + //! Get how updateAbsolutePosition calculates the absolute transformation matrix + ESCENE_NODE_UPDATE_ABS getUpdateAbsolutePosBehavior() const + { + return UpdateAbsolutePosBehavior; + } + //! Sets if debug data like bounding boxes should be drawn. /** A bitwise OR of the types from @ref irr::scene::E_DEBUG_SCENE_TYPE. @@ -659,15 +674,24 @@ namespace scene } - //! Updates the absolute position based on the relative and the parents position - /** Note: This does not recursively update the parents absolute positions, so if you have a deeper + //! Updates the absolute tranformation or position based on the relative and the parents transformation + /** It's exact behavior can be controlled by setUpdateAbsolutePosBehavior. + Note: This does not recursively update the parents absolute positions, so if you have a deeper hierarchy you might want to update the parents first.*/ virtual void updateAbsolutePosition() { if (Parent) { - AbsoluteTransformation = - Parent->getAbsoluteTransformation() * getRelativeTransformation(); + if ( UpdateAbsolutePosBehavior == ESNUA_TRANSFORM_MATRIX ) + { + AbsoluteTransformation = + Parent->getAbsoluteTransformation() * getRelativeTransformation(); + } + else if ( UpdateAbsolutePosBehavior == ESNUA_TRANSFORM_POSITION ) + { + AbsoluteTransformation = getRelativeTransformation(); + Parent->getAbsoluteTransformation().transformVect(reinterpret_cast(AbsoluteTransformation[12])); + } } else AbsoluteTransformation = getRelativeTransformation(); @@ -709,6 +733,7 @@ namespace scene out->addVector3d("Scale", getScale() ); out->addBool("Visible", IsVisible ); + out->addEnum("AbsPosUpdate", (s32)UpdateAbsolutePosBehavior, SceneNodeUpdateAbsNames); out->addInt("AutomaticCulling", AutomaticCullingState); out->addInt("DebugDataVisible", DebugDataVisible ); out->addBool("IsDebugObject", IsDebugObject ); @@ -734,13 +759,17 @@ namespace scene setScale(in->getAttributeAsVector3d("Scale", RelativeScale)); IsVisible = in->getAttributeAsBool("Visible", IsVisible); + + UpdateAbsolutePosBehavior = (ESCENE_NODE_UPDATE_ABS)in->getAttributeAsEnumeration("AbsPosUpdate", SceneNodeUpdateAbsNames, (s32)UpdateAbsolutePosBehavior); + if (in->existsAttribute("AutomaticCulling")) { + // compatibility for older version, new one uses int's const s32 tmpState = in->getAttributeAsEnumeration("AutomaticCulling", scene::AutomaticCullingNames); if (tmpState != -1) AutomaticCullingState = (u32)tmpState; - else + else AutomaticCullingState = in->getAttributeAsInt("AutomaticCulling"); } @@ -779,6 +808,7 @@ namespace scene RelativeScale = toCopyFrom->RelativeScale; ID = toCopyFrom->ID; setTriangleSelector(toCopyFrom->TriangleSelector); + UpdateAbsolutePosBehavior = toCopyFrom->UpdateAbsolutePosBehavior; AutomaticCullingState = toCopyFrom->AutomaticCullingState; DebugDataVisible = toCopyFrom->DebugDataVisible; IsVisible = toCopyFrom->IsVisible; @@ -853,6 +883,9 @@ namespace scene //! ID of the node. s32 ID; + //! How updateAbsolutePosition calculates AbsoluteTransformation + ESCENE_NODE_UPDATE_ABS UpdateAbsolutePosBehavior; + //! Automatic culling state u32 AutomaticCullingState; diff --git a/source/Irrlicht/Irrlicht10.0.vcxproj b/source/Irrlicht/Irrlicht10.0.vcxproj index 6dc6718..db45692 100644 --- a/source/Irrlicht/Irrlicht10.0.vcxproj +++ b/source/Irrlicht/Irrlicht10.0.vcxproj @@ -846,6 +846,7 @@ + diff --git a/source/Irrlicht/Irrlicht10.0.vcxproj.filters b/source/Irrlicht/Irrlicht10.0.vcxproj.filters index d3af122..1ee7983 100644 --- a/source/Irrlicht/Irrlicht10.0.vcxproj.filters +++ b/source/Irrlicht/Irrlicht10.0.vcxproj.filters @@ -1441,6 +1441,9 @@ include\scene + + include\scene + diff --git a/tests/media/scene.irr b/tests/media/scene.irr index 244913b..dd44064 100644 Binary files a/tests/media/scene.irr and b/tests/media/scene.irr differ diff --git a/tests/media/scene2.irr b/tests/media/scene2.irr index 49ff185..d55ac9c 100644 Binary files a/tests/media/scene2.irr and b/tests/media/scene2.irr differ diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index f3aceff..c1bc1c5 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 Sat Sep 24 13:51:42 2022 - +Tests finished. 72 tests of 72 passed. +Compiled as DEBUG +Test suite pass at GMT Thu Sep 29 16:32:30 2022 +