Browse Source

force_update, etc.

David Rose 23 years ago
parent
commit
1e334b3a03

+ 6 - 6
panda/src/char/character.I

@@ -20,7 +20,7 @@
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Character::get_bundle
 //     Function: Character::get_bundle
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE CharacterJointBundle *Character::
 INLINE CharacterJointBundle *Character::
@@ -31,7 +31,7 @@ get_bundle() const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Character::get_computed_vertices
 //     Function: Character::get_computed_vertices
-//       Access: Public
+//       Access: Published
 //  Description:
 //  Description:
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE ComputedVertices *Character::
 INLINE ComputedVertices *Character::
@@ -41,7 +41,7 @@ get_computed_vertices() const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Character::get_num_parts
 //     Function: Character::get_num_parts
-//       Access: Public
+//       Access: Published
 //  Description: Returns the total number of moving parts (e.g. joints
 //  Description: Returns the total number of moving parts (e.g. joints
 //               and sliders) associated with the Character.
 //               and sliders) associated with the Character.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -52,7 +52,7 @@ get_num_parts() const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Character::get_part
 //     Function: Character::get_part
-//       Access: Public
+//       Access: Published
 //  Description: Returns the nth moving part associated with the
 //  Description: Returns the nth moving part associated with the
 //               Character.
 //               Character.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -64,7 +64,7 @@ get_part(int n) const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Character::write_parts
 //     Function: Character::write_parts
-//       Access: Public
+//       Access: Published
 //  Description: Writes a list of the Character's joints and sliders,
 //  Description: Writes a list of the Character's joints and sliders,
 //               in their hierchical structure, to the indicated
 //               in their hierchical structure, to the indicated
 //               output stream.
 //               output stream.
@@ -76,7 +76,7 @@ write_parts(ostream &out) const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Character::write_part_values
 //     Function: Character::write_part_values
-//       Access: Public
+//       Access: Published
 //  Description: Writes a list of the Character's joints and sliders,
 //  Description: Writes a list of the Character's joints and sliders,
 //               along with each current position, in their hierchical
 //               along with each current position, in their hierchical
 //               structure, to the indicated output stream.
 //               structure, to the indicated output stream.

+ 22 - 2
panda/src/char/character.cxx

@@ -154,7 +154,7 @@ cull_callback(CullTraverser *, CullTraverserData &) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Character::update_to_now
 //     Function: Character::update_to_now
-//       Access: Public
+//       Access: Published
 //  Description: Advances the character's frame to the current time,
 //  Description: Advances the character's frame to the current time,
 //               and then calls update().  This can be used by show
 //               and then calls update().  This can be used by show
 //               code to force an update of the character's position
 //               code to force an update of the character's position
@@ -175,7 +175,7 @@ update_to_now() {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Character::update
 //     Function: Character::update
-//       Access: Public
+//       Access: Published
 //  Description: Recalculates the Character's joints and vertices for
 //  Description: Recalculates the Character's joints and vertices for
 //               the current frame.  Normally this is performed
 //               the current frame.  Normally this is performed
 //               automatically during the render and need not be
 //               automatically during the render and need not be
@@ -198,6 +198,26 @@ update() {
   }
   }
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: Character::force_update
+//       Access: Published
+//  Description: Recalculates the character even if we think it
+//               doesn't need it.
+////////////////////////////////////////////////////////////////////
+void Character::
+force_update() {
+  // Statistics
+  PStatTimer timer(_char_pcollector);
+
+  // First, update all the joints and sliders.
+  get_bundle()->force_update();
+
+  // Now update the vertices.
+  if (_computed_vertices != (ComputedVertices *)NULL) {
+    _computed_vertices->update(this);
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: Character::copy_joints
 //     Function: Character::copy_joints
 //       Access: Private
 //       Access: Private

+ 1 - 0
panda/src/char/character.h

@@ -63,6 +63,7 @@ PUBLISHED:
 
 
   void update_to_now();
   void update_to_now();
   void update();
   void update();
+  void force_update();
 
 
 private:
 private:
   void copy_joints(PartGroup *copy, PartGroup *orig);
   void copy_joints(PartGroup *copy, PartGroup *orig);

+ 19 - 8
panda/src/char/characterJoint.cxx

@@ -149,7 +149,7 @@ update_internals(PartGroup *parent, bool self_changed, bool parent_changed) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CharacterJoint::add_net_transform
 //     Function: CharacterJoint::add_net_transform
-//       Access: Public
+//       Access: Published
 //  Description: Adds the indicated node to the list of nodes that will
 //  Description: Adds the indicated node to the list of nodes that will
 //               be updated each frame with the joint's net transform
 //               be updated each frame with the joint's net transform
 //               from the root.  Returns true if the node is
 //               from the root.  Returns true if the node is
@@ -163,7 +163,7 @@ add_net_transform(PandaNode *node) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CharacterJoint::remove_net_transform
 //     Function: CharacterJoint::remove_net_transform
-//       Access: Public
+//       Access: Published
 //  Description: Removes the indicated node from the list of nodes that
 //  Description: Removes the indicated node from the list of nodes that
 //               will be updated each frame with the joint's net
 //               will be updated each frame with the joint's net
 //               transform from the root.  Returns true if the node is
 //               transform from the root.  Returns true if the node is
@@ -177,7 +177,7 @@ remove_net_transform(PandaNode *node) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CharacterJoint::has_net_transform
 //     Function: CharacterJoint::has_net_transform
-//       Access: Public
+//       Access: Published
 //  Description: Returns true if the node is on the list of nodes that
 //  Description: Returns true if the node is on the list of nodes that
 //               will be updated each frame with the joint's net
 //               will be updated each frame with the joint's net
 //               transform from the root, false otherwise.
 //               transform from the root, false otherwise.
@@ -189,7 +189,7 @@ has_net_transform(PandaNode *node) const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CharacterJoint::clear_net_transforms
 //     Function: CharacterJoint::clear_net_transforms
-//       Access: Public
+//       Access: Published
 //  Description: Removes all nodes from the list of nodes that will be
 //  Description: Removes all nodes from the list of nodes that will be
 //               updated each frame with the joint's net transform
 //               updated each frame with the joint's net transform
 //               from the root.
 //               from the root.
@@ -201,7 +201,7 @@ clear_net_transforms() {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CharacterJoint::add_local_transform
 //     Function: CharacterJoint::add_local_transform
-//       Access: Public
+//       Access: Published
 //  Description: Adds the indicated node to the list of nodes that will
 //  Description: Adds the indicated node to the list of nodes that will
 //               be updated each frame with the joint's local
 //               be updated each frame with the joint's local
 //               transform from its parent.  Returns true if the node
 //               transform from its parent.  Returns true if the node
@@ -215,7 +215,7 @@ add_local_transform(PandaNode *node) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CharacterJoint::remove_local_transform
 //     Function: CharacterJoint::remove_local_transform
-//       Access: Public
+//       Access: Published
 //  Description: Removes the indicated node from the list of nodes that
 //  Description: Removes the indicated node from the list of nodes that
 //               will be updated each frame with the joint's local
 //               will be updated each frame with the joint's local
 //               transform from its parent.  Returns true if the node
 //               transform from its parent.  Returns true if the node
@@ -229,7 +229,7 @@ remove_local_transform(PandaNode *node) {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CharacterJoint::has_local_transform
 //     Function: CharacterJoint::has_local_transform
-//       Access: Public
+//       Access: Published
 //  Description: Returns true if the node is on the list of nodes that
 //  Description: Returns true if the node is on the list of nodes that
 //               will be updated each frame with the joint's local
 //               will be updated each frame with the joint's local
 //               transform from its parent, false otherwise.
 //               transform from its parent, false otherwise.
@@ -241,7 +241,7 @@ has_local_transform(PandaNode *node) const {
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CharacterJoint::clear_local_transforms
 //     Function: CharacterJoint::clear_local_transforms
-//       Access: Public
+//       Access: Published
 //  Description: Removes all nodes from the list of nodes that will be
 //  Description: Removes all nodes from the list of nodes that will be
 //               updated each frame with the joint's local transform
 //               updated each frame with the joint's local transform
 //               from its parent.
 //               from its parent.
@@ -251,6 +251,17 @@ clear_local_transforms() {
   _local_transform_nodes.clear();
   _local_transform_nodes.clear();
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: CharacterJoint::get_transform
+//       Access: Published
+//  Description: Copies the joint's current transform into the
+//               indicated matrix.
+////////////////////////////////////////////////////////////////////
+void CharacterJoint::
+get_transform(LMatrix4f &transform) const {
+  transform = _value;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CharacterJoint::write_datagram
 //     Function: CharacterJoint::write_datagram
 //       Access: Public
 //       Access: Public

+ 2 - 0
panda/src/char/characterJoint.h

@@ -54,6 +54,8 @@ PUBLISHED:
   bool has_local_transform(PandaNode *node) const;
   bool has_local_transform(PandaNode *node) const;
   void clear_local_transforms();
   void clear_local_transforms();
 
 
+  void get_transform(LMatrix4f &transform) const;
+
 private:
 private:
   typedef pset< PT(PandaNode) > NodeList;
   typedef pset< PT(PandaNode) > NodeList;
   NodeList _net_transform_nodes;
   NodeList _net_transform_nodes;