From 1e334b3a034f752fc589166baa5fcabff36a845f Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 24 Jan 2003 00:52:05 +0000 Subject: [PATCH] force_update, etc. --- panda/src/char/character.I | 12 ++++++------ panda/src/char/character.cxx | 24 ++++++++++++++++++++++-- panda/src/char/character.h | 1 + panda/src/char/characterJoint.cxx | 27 +++++++++++++++++++-------- panda/src/char/characterJoint.h | 2 ++ 5 files changed, 50 insertions(+), 16 deletions(-) diff --git a/panda/src/char/character.I b/panda/src/char/character.I index cc0b95b4dd..b5da46414d 100644 --- a/panda/src/char/character.I +++ b/panda/src/char/character.I @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////// // Function: Character::get_bundle -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE CharacterJointBundle *Character:: @@ -31,7 +31,7 @@ get_bundle() const { //////////////////////////////////////////////////////////////////// // Function: Character::get_computed_vertices -// Access: Public +// Access: Published // Description: //////////////////////////////////////////////////////////////////// INLINE ComputedVertices *Character:: @@ -41,7 +41,7 @@ get_computed_vertices() const { //////////////////////////////////////////////////////////////////// // Function: Character::get_num_parts -// Access: Public +// Access: Published // Description: Returns the total number of moving parts (e.g. joints // and sliders) associated with the Character. //////////////////////////////////////////////////////////////////// @@ -52,7 +52,7 @@ get_num_parts() const { //////////////////////////////////////////////////////////////////// // Function: Character::get_part -// Access: Public +// Access: Published // Description: Returns the nth moving part associated with the // Character. //////////////////////////////////////////////////////////////////// @@ -64,7 +64,7 @@ get_part(int n) const { //////////////////////////////////////////////////////////////////// // Function: Character::write_parts -// Access: Public +// Access: Published // Description: Writes a list of the Character's joints and sliders, // in their hierchical structure, to the indicated // output stream. @@ -76,7 +76,7 @@ write_parts(ostream &out) const { //////////////////////////////////////////////////////////////////// // Function: Character::write_part_values -// Access: Public +// Access: Published // Description: Writes a list of the Character's joints and sliders, // along with each current position, in their hierchical // structure, to the indicated output stream. diff --git a/panda/src/char/character.cxx b/panda/src/char/character.cxx index 379c8312f2..f01166665f 100644 --- a/panda/src/char/character.cxx +++ b/panda/src/char/character.cxx @@ -154,7 +154,7 @@ cull_callback(CullTraverser *, CullTraverserData &) { //////////////////////////////////////////////////////////////////// // Function: Character::update_to_now -// Access: Public +// Access: Published // Description: Advances the character's frame to the current time, // and then calls update(). This can be used by show // code to force an update of the character's position @@ -175,7 +175,7 @@ update_to_now() { //////////////////////////////////////////////////////////////////// // Function: Character::update -// Access: Public +// Access: Published // Description: Recalculates the Character's joints and vertices for // the current frame. Normally this is performed // 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 // Access: Private diff --git a/panda/src/char/character.h b/panda/src/char/character.h index 2489354a2b..fcf9770f8f 100644 --- a/panda/src/char/character.h +++ b/panda/src/char/character.h @@ -63,6 +63,7 @@ PUBLISHED: void update_to_now(); void update(); + void force_update(); private: void copy_joints(PartGroup *copy, PartGroup *orig); diff --git a/panda/src/char/characterJoint.cxx b/panda/src/char/characterJoint.cxx index 2a9e9e988f..eb88b47489 100644 --- a/panda/src/char/characterJoint.cxx +++ b/panda/src/char/characterJoint.cxx @@ -149,7 +149,7 @@ update_internals(PartGroup *parent, bool self_changed, bool parent_changed) { //////////////////////////////////////////////////////////////////// // Function: CharacterJoint::add_net_transform -// Access: Public +// Access: Published // Description: Adds the indicated node to the list of nodes that will // be updated each frame with the joint's net transform // from the root. Returns true if the node is @@ -163,7 +163,7 @@ add_net_transform(PandaNode *node) { //////////////////////////////////////////////////////////////////// // Function: CharacterJoint::remove_net_transform -// Access: Public +// Access: Published // Description: Removes the indicated node from the list of nodes that // will be updated each frame with the joint's net // transform from the root. Returns true if the node is @@ -177,7 +177,7 @@ remove_net_transform(PandaNode *node) { //////////////////////////////////////////////////////////////////// // Function: CharacterJoint::has_net_transform -// Access: Public +// Access: Published // Description: Returns true if the node is on the list of nodes that // will be updated each frame with the joint's net // transform from the root, false otherwise. @@ -189,7 +189,7 @@ has_net_transform(PandaNode *node) const { //////////////////////////////////////////////////////////////////// // Function: CharacterJoint::clear_net_transforms -// Access: Public +// Access: Published // Description: Removes all nodes from the list of nodes that will be // updated each frame with the joint's net transform // from the root. @@ -201,7 +201,7 @@ clear_net_transforms() { //////////////////////////////////////////////////////////////////// // Function: CharacterJoint::add_local_transform -// Access: Public +// Access: Published // Description: Adds the indicated node to the list of nodes that will // be updated each frame with the joint's local // transform from its parent. Returns true if the node @@ -215,7 +215,7 @@ add_local_transform(PandaNode *node) { //////////////////////////////////////////////////////////////////// // Function: CharacterJoint::remove_local_transform -// Access: Public +// Access: Published // Description: Removes the indicated node from the list of nodes that // will be updated each frame with the joint's local // transform from its parent. Returns true if the node @@ -229,7 +229,7 @@ remove_local_transform(PandaNode *node) { //////////////////////////////////////////////////////////////////// // Function: CharacterJoint::has_local_transform -// Access: Public +// Access: Published // Description: Returns true if the node is on the list of nodes that // will be updated each frame with the joint's local // transform from its parent, false otherwise. @@ -241,7 +241,7 @@ has_local_transform(PandaNode *node) const { //////////////////////////////////////////////////////////////////// // Function: CharacterJoint::clear_local_transforms -// Access: Public +// Access: Published // Description: Removes all nodes from the list of nodes that will be // updated each frame with the joint's local transform // from its parent. @@ -251,6 +251,17 @@ clear_local_transforms() { _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 // Access: Public diff --git a/panda/src/char/characterJoint.h b/panda/src/char/characterJoint.h index f1f9f038dc..e9bcb2b92f 100644 --- a/panda/src/char/characterJoint.h +++ b/panda/src/char/characterJoint.h @@ -54,6 +54,8 @@ PUBLISHED: bool has_local_transform(PandaNode *node) const; void clear_local_transforms(); + void get_transform(LMatrix4f &transform) const; + private: typedef pset< PT(PandaNode) > NodeList; NodeList _net_transform_nodes;