Panda3D
|
This is the base class for a single animatable piece that may be bound to one channel (or more, if blending is in effect). More...
#include "movingPartBase.h"
Public Member Functions | |
MovingPartBase (PartGroup *parent, const string &name) | |
virtual bool | clear_forced_channel () |
Undoes the effect of a previous call to apply_freeze() or apply_control(). | |
virtual int | complete_pointers (TypedWritable **plist, BamReader *manager) |
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin(). | |
virtual bool | do_update (PartBundle *root, const CycleData *root_cdata, PartGroup *parent, bool parent_changed, bool anim_changed, Thread *current_thread) |
Recursively update this particular part and all of its descendents for the current frame. | |
virtual TypeHandle | force_init_type () |
virtual void | get_blend_value (const PartBundle *root)=0 |
AnimChannelBase * | get_bound (int n) const |
Returns the nth bound channel on this PartGroup. | |
virtual AnimChannelBase * | get_forced_channel () const |
Returns the AnimChannelBase that has been forced to this joint by a previous call to apply_freeze() or apply_control(), or NULL if no such channel has been applied. | |
int | get_max_bound () const |
Returns the number of channels that might be bound to this PartGroup. | |
virtual TypeHandle | get_type () const |
virtual TypeHandle | get_value_type () const =0 |
Returns the TypeHandle associated with the ValueType we are concerned with. | |
virtual AnimChannelBase * | make_default_channel () const =0 |
virtual void | output_value (ostream &out) const =0 |
virtual bool | update_internals (PartBundle *root, PartGroup *parent, bool self_changed, bool parent_changed, Thread *current_thread) |
This is called by do_update() whenever the part or some ancestor has changed values. | |
virtual void | write (ostream &out, int indent_level) const |
Writes a brief description of the channel and all of its descendants. | |
virtual void | write_datagram (BamWriter *manager, Datagram &dg) |
Writes the contents of this object to the datagram for shipping out to a Bam file. | |
virtual void | write_with_value (ostream &out, int indent_level) const |
Writes a brief description of the channel and all of its descendants, along with their values. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Protected Types | |
typedef pvector< PT(AnimChannelBase) > | Channels |
Protected Member Functions | |
MovingPartBase (const MovingPartBase ©) | |
Normally, you'd use make_copy() or copy_subgraph() to make a copy of this. | |
virtual void | bind_hierarchy (AnimGroup *anim, int channel_index, int &joint_index, bool is_included, BitArray &bound_joints, const PartSubset &subset) |
Binds the indicated anim hierarchy to the part hierarchy, at the given channel index number. | |
virtual void | determine_effective_channels (const CycleData *root_cdata) |
Should be called whenever the ChannelBlend values have changed, this recursively updates the _effective_channel member in each part. | |
void | fillin (DatagramIterator &scan, BamReader *manager) |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new MovingPartBase. | |
virtual void | find_bound_joints (int &joint_index, bool is_included, BitArray &bound_joints, const PartSubset &subset) |
Similar to bind_hierarchy, but does not actually perform any binding. | |
virtual void | pick_channel_index (plist< int > &holes, int &next) const |
Walks the part hierarchy, looking for a suitable channel index number to use. | |
PT (AnimChannelBase) _effective_channel | |
PT (AnimChannelBase) _forced_channel | |
Protected Attributes | |
Channels | _channels |
AnimControl * | _effective_control |
int | _num_effective_channels |
This is the base class for a single animatable piece that may be bound to one channel (or more, if blending is in effect).
It corresponds to, for instance, a single joint or slider of a character.
MovingPartBase does not have a particular value type. See the derived template class, MovingPart, for this.
Definition at line 34 of file movingPartBase.h.
MovingPartBase::MovingPartBase | ( | const MovingPartBase & | copy | ) | [inline, protected] |
Normally, you'd use make_copy() or copy_subgraph() to make a copy of this.
Definition at line 23 of file movingPartBase.I.
void MovingPartBase::bind_hierarchy | ( | AnimGroup * | anim, |
int | channel_index, | ||
int & | joint_index, | ||
bool | is_included, | ||
BitArray & | bound_joints, | ||
const PartSubset & | subset | ||
) | [protected, virtual] |
Binds the indicated anim hierarchy to the part hierarchy, at the given channel index number.
Reimplemented from PartGroup.
Definition at line 260 of file movingPartBase.cxx.
References BitArray::clear_bit(), PartSubset::matches_exclude(), PartSubset::matches_include(), and BitArray::set_bit().
bool MovingPartBase::clear_forced_channel | ( | ) | [virtual] |
Undoes the effect of a previous call to apply_freeze() or apply_control().
Returns true if the joint was modified, false otherwise.
Reimplemented from PartGroup.
Definition at line 59 of file movingPartBase.cxx.
int MovingPartBase::complete_pointers | ( | TypedWritable ** | p_list, |
BamReader * | manager | ||
) | [virtual] |
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Returns the number of pointers processed.
This is the callback function that is made by the BamReader at some later point, after all of the required pointers have been filled in. It is necessary because there might be forward references in a bam file; when we call read_pointer() in fillin(), the object may not have been read from the file yet, so we do not have a pointer available at that time. Thus, instead of returning a pointer, read_pointer() simply reserves a later callback. This function provides that callback. The calling object is responsible for keeping track of the number of times it called read_pointer() and extracting the same number of pointers out of the supplied vector, and storing them appropriately within the object.
Reimplemented from PartGroup.
Reimplemented in CharacterJoint.
Definition at line 413 of file movingPartBase.cxx.
References BamReader::get_file_minor_ver().
void MovingPartBase::determine_effective_channels | ( | const CycleData * | root_cdata | ) | [protected, virtual] |
Should be called whenever the ChannelBlend values have changed, this recursively updates the _effective_channel member in each part.
Reimplemented from PartGroup.
Definition at line 343 of file movingPartBase.cxx.
References AnimControl::get_channel_index().
bool MovingPartBase::do_update | ( | PartBundle * | root, |
const CycleData * | root_cdata, | ||
PartGroup * | parent, | ||
bool | parent_changed, | ||
bool | anim_changed, | ||
Thread * | current_thread | ||
) | [virtual] |
Recursively update this particular part and all of its descendents for the current frame.
This is not really public and is not intended to be called directly; it is called from the top of the tree by PartBundle::update().
The return value is true if any part has changed, false otherwise.
Reimplemented from PartGroup.
Definition at line 132 of file movingPartBase.cxx.
References AnimControl::channel_has_changed(), AnimControl::get_channel_index(), and update_internals().
void MovingPartBase::fillin | ( | DatagramIterator & | scan, |
BamReader * | manager | ||
) | [protected, virtual] |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new MovingPartBase.
Reimplemented from PartGroup.
Reimplemented in CharacterJoint, MovingPart< SwitchType >, MovingPart< ACScalarSwitchType >, and MovingPart< ACMatrixSwitchType >.
Definition at line 431 of file movingPartBase.cxx.
References BamReader::get_file_minor_ver(), and BamReader::read_pointer().
Referenced by MovingPart< SwitchType >::fillin().
void MovingPartBase::find_bound_joints | ( | int & | joint_index, |
bool | is_included, | ||
BitArray & | bound_joints, | ||
const PartSubset & | subset | ||
) | [protected, virtual] |
Similar to bind_hierarchy, but does not actually perform any binding.
All it does is compute the BitArray bount_joints according to the specified subset. This is useful in preparation for asynchronous binding--in this case, we may need to know bound_joints immediately, without having to wait for the animation itself to load and bind.
Reimplemented from PartGroup.
Definition at line 321 of file movingPartBase.cxx.
References PartSubset::matches_exclude(), PartSubset::matches_include(), and BitArray::set_bit_to().
AnimChannelBase * MovingPartBase::get_bound | ( | int | n | ) | const [inline] |
Returns the nth bound channel on this PartGroup.
n can be determined by iterating from 0 to one less than get_max_bound(); or n might be AnimControl::get_channel_index().
This will return NULL if there is no channel bound on the indicated index. It is an error to call this if n is less than zero or greater than or equal to get_max_bound().
Definition at line 62 of file movingPartBase.I.
AnimChannelBase * MovingPartBase::get_forced_channel | ( | ) | const [virtual] |
Returns the AnimChannelBase that has been forced to this joint by a previous call to apply_freeze() or apply_control(), or NULL if no such channel has been applied.
Reimplemented from PartGroup.
Definition at line 76 of file movingPartBase.cxx.
int MovingPartBase::get_max_bound | ( | ) | const [inline] |
Returns the number of channels that might be bound to this PartGroup.
This might not be the actual number of channels, since there might be holes in the list; it is one more than the index number of the highest bound channel. Thus, it is called get_max_bound() instead of get_num_bound().
Definition at line 44 of file movingPartBase.I.
virtual TypeHandle MovingPartBase::get_value_type | ( | ) | const [pure virtual] |
Returns the TypeHandle associated with the ValueType we are concerned with.
This is provided to allow a bit of run-time checking that joints and channels are matching properly in type.
Reimplemented from PartGroup.
Implemented in MovingPart< SwitchType >, MovingPart< ACScalarSwitchType >, and MovingPart< ACMatrixSwitchType >.
Referenced by write(), and write_with_value().
void MovingPartBase::pick_channel_index | ( | plist< int > & | holes, |
int & | next | ||
) | const [protected, virtual] |
Walks the part hierarchy, looking for a suitable channel index number to use.
Available index numbers are the elements of the holes set, as well as next to infinity.
Reimplemented from PartGroup.
Definition at line 217 of file movingPartBase.cxx.
bool MovingPartBase::update_internals | ( | PartBundle * | root, |
PartGroup * | parent, | ||
bool | self_changed, | ||
bool | parent_changed, | ||
Thread * | current_thread | ||
) | [virtual] |
This is called by do_update() whenever the part or some ancestor has changed values.
It is a hook for derived classes to update whatever cache they may have that depends on these.
The return value is true if the part has changed as a result of the update, or false otherwise.
Reimplemented in CharacterJoint, and CharacterSlider.
Definition at line 204 of file movingPartBase.cxx.
Referenced by do_update().
void MovingPartBase::write | ( | ostream & | out, |
int | indent_level | ||
) | const [virtual] |
Writes a brief description of the channel and all of its descendants.
Reimplemented from PartGroup.
Definition at line 87 of file movingPartBase.cxx.
References get_value_type(), and PartGroup::write_descendants().
void MovingPartBase::write_datagram | ( | BamWriter * | manager, |
Datagram & | dg | ||
) | [virtual] |
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from PartGroup.
Reimplemented in CharacterJoint, MovingPart< SwitchType >, MovingPart< ACScalarSwitchType >, and MovingPart< ACMatrixSwitchType >.
Definition at line 384 of file movingPartBase.cxx.
References BamWriter::write_pointer().
Referenced by MovingPart< SwitchType >::write_datagram().
void MovingPartBase::write_with_value | ( | ostream & | out, |
int | indent_level | ||
) | const [virtual] |
Writes a brief description of the channel and all of its descendants, along with their values.
Reimplemented from PartGroup.
Definition at line 105 of file movingPartBase.cxx.
References get_value_type(), and PartGroup::write_descendants_with_value().