From a34cb75f8244964cc65b9a8a8ef1acb1fa0174bf Mon Sep 17 00:00:00 2001 From: Zhao Huang Date: Thu, 15 Dec 2011 01:51:59 +0000 Subject: [PATCH] Added to characterJoint INLINE const LMatrix4 &get_transform() const; CPT(TransformState) get_transform_state() const; This is to reduce the code bloat for freezing a joint using actor. Previously, freezing a joint (using its current transform required two temporary initailizations, a Mat4() and a TransformState in python. tmat = tmat4(); joint.getTransform( tmat); tstate = TransformState( tmat); freeze(..., transform = tstate ) now this can be collapsed down to freeze( ..., transform = joint.getTransformState() ) --- panda/src/char/characterJoint.I | 9 +++++++++ panda/src/char/characterJoint.cxx | 5 +++++ panda/src/char/characterJoint.h | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/panda/src/char/characterJoint.I b/panda/src/char/characterJoint.I index 1ebba2f209..b087eeaf58 100644 --- a/panda/src/char/characterJoint.I +++ b/panda/src/char/characterJoint.I @@ -12,3 +12,12 @@ // //////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////// +// Function: CharacterJoint::get_transform +// Access: Published +// Description: Returns the transform matrix of the joint +//////////////////////////////////////////////////////////////////// +INLINE const LMatrix4 &CharacterJoint:: +get_transform() const { + return _value; +} \ No newline at end of file diff --git a/panda/src/char/characterJoint.cxx b/panda/src/char/characterJoint.cxx index bb2ead57bd..32b042d479 100644 --- a/panda/src/char/characterJoint.cxx +++ b/panda/src/char/characterJoint.cxx @@ -425,6 +425,11 @@ get_transform(LMatrix4 &transform) const { transform = _value; } +CPT(TransformState) CharacterJoint:: +get_transform_state() const { + return TransformState::make_mat( _value ); +} + //////////////////////////////////////////////////////////////////// // Function: CharacterJoint::get_net_transform // Access: Published diff --git a/panda/src/char/characterJoint.h b/panda/src/char/characterJoint.h index dc57b09d08..00aa74437b 100644 --- a/panda/src/char/characterJoint.h +++ b/panda/src/char/characterJoint.h @@ -16,6 +16,7 @@ #define CHARACTERJOINT_H #include "pandabase.h" +#include "transformState.h" #include "movingPartMatrix.h" #include "pandaNode.h" @@ -64,6 +65,9 @@ PUBLISHED: NodePathCollection get_local_transforms(); void get_transform(LMatrix4 &transform) const; + INLINE const LMatrix4 &get_transform() const; + CPT(TransformState) get_transform_state() const; + void get_net_transform(LMatrix4 &transform) const; Character *get_character() const;