Browse Source

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() )

Zhao Huang 14 years ago
parent
commit
a34cb75f82

+ 9 - 0
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;
+}

+ 5 - 0
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

+ 4 - 0
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;