29 MovingPartBase(
PartGroup *parent,
const std::string &name) :
31 _num_effective_channels(0),
32 _effective_control(nullptr)
41 _num_effective_channels(0),
42 _effective_control(nullptr)
52 if (_forced_channel !=
nullptr) {
53 _forced_channel.clear();
66 return _forced_channel;
73 write(std::ostream &out,
int indent_level)
const {
75 if (_children.empty()) {
79 write_descendants(out, indent_level + 2);
80 indent(out, indent_level) <<
"}\n";
94 if (_children.empty()) {
98 write_descendants_with_value(out, indent_level + 2);
99 indent(out, indent_level) <<
"}\n";
112 bool parent_changed,
bool anim_changed,
114 bool any_changed =
false;
115 bool needs_update = anim_changed;
120 if (_forced_channel !=
nullptr) {
121 needs_update = _forced_channel->has_changed(0, 0.0, 0, 0.0);
123 }
else if (_effective_control !=
nullptr) {
124 const PartBundle::CData *cdata = (
const PartBundle::CData *)root_cdata;
125 needs_update = _effective_control->
channel_has_changed(_effective_channel, cdata->_frame_blend_flag);
128 const PartBundle::CData *cdata = (
const PartBundle::CData *)root_cdata;
129 PartBundle::ChannelBlend::const_iterator bci;
130 for (bci = cdata->_blend.begin();
131 !needs_update && bci != cdata->_blend.end();
137 if (channel_index >= 0 && channel_index < (
int)_channels.size()) {
138 channel = _channels[channel_index];
140 if (channel !=
nullptr) {
149 get_blend_value(root);
152 if (parent_changed || needs_update) {
158 Children::iterator ci;
159 for (ci = _children.begin(); ci != _children.end(); ++ci) {
160 if ((*ci)->do_update(root, root_cdata,
this,
161 parent_changed || needs_update,
162 anim_changed, current_thread)) {
189 void MovingPartBase::
190 pick_channel_index(
plist<int> &holes,
int &next)
const {
195 while (ii != holes.end()) {
200 nassertv(hole >= 0 && hole < next);
201 if (hole < (
int)_channels.size() ||
202 _channels[hole] !=
nullptr) {
210 if (next < (
int)_channels.size()) {
212 for (i = next; i < (int)_channels.size(); i++) {
213 if (_channels[i] ==
nullptr) {
218 next = _channels.size();
221 PartGroup::pick_channel_index(holes, next);
230 void MovingPartBase::
231 bind_hierarchy(
AnimGroup *anim,
int channel_index,
int &joint_index,
232 bool is_included,
BitArray &bound_joints,
240 if (chan_cat.is_debug()) {
241 if (anim ==
nullptr) {
243 <<
"binding " << *
this <<
" to NULL, is_included = " 244 << is_included <<
"\n";
247 <<
"binding " << *
this <<
" to " << *anim <<
", is_included = " 248 << is_included <<
"\n";
251 while ((
int)_channels.size() <= channel_index) {
252 _channels.push_back(
nullptr);
255 nassertv(_channels[channel_index] ==
nullptr);
258 if (anim ==
nullptr) {
261 _channels[channel_index] = make_default_channel();
267 bound_joints.
set_bit(joint_index);
274 PartGroup::bind_hierarchy(anim, channel_index, joint_index,
275 is_included, bound_joints, subset);
285 void MovingPartBase::
286 find_bound_joints(
int &joint_index,
bool is_included,
BitArray &bound_joints,
294 bound_joints.
set_bit_to(joint_index, is_included);
297 PartGroup::find_bound_joints(joint_index, is_included, bound_joints, subset);
304 void MovingPartBase::
305 determine_effective_channels(
const CycleData *root_cdata) {
306 _effective_control =
nullptr;
307 _effective_channel =
nullptr;
308 _num_effective_channels = 0;
312 int num_effective_channels = 0;
314 const PartBundle::CData *cdata = (
const PartBundle::CData *)root_cdata;
315 PartBundle::ChannelBlend::const_iterator cbi;
316 for (cbi = cdata->_blend.begin();
317 cbi != cdata->_blend.end();
321 if (channel_index >= 0 && channel_index < (
int)_channels.size()) {
322 if (_channels[channel_index] !=
nullptr) {
323 effective_control = control;
324 effective_channel = _channels[channel_index];
325 ++num_effective_channels;
330 _num_effective_channels = num_effective_channels;
331 if (num_effective_channels == 1) {
332 _effective_control = effective_control;
333 _effective_channel = effective_channel;
380 void MovingPartBase::
382 PartGroup::fillin(scan, manager);
void set_bit_to(int index, bool value)
Sets the nth bit either on or off, according to the indicated bool value.
bool matches_exclude(const std::string &joint_name) const
Returns true if the indicated name matches a name on the exclude list, false otherwise.
virtual void write(std::ostream &out, int indent_level) const
Writes a brief description of the channel and all of its descendants.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool matches_include(const std::string &joint_name) const
Returns true if the indicated name matches a name on the include list, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A single page of data maintained by a PipelineCycler.
Base class for objects that can be written to and read from Bam files.
virtual AnimChannelBase * get_forced_channel() const
Returns the AnimChannelBase that has been forced to this joint by a previous call to apply_freeze() o...
virtual void write_with_value(std::ostream &out, int indent_level) const
Writes a brief description of the channel and all of its descendants, along with their values.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
bool channel_has_changed(AnimChannelBase *channel, bool frame_blend_flag) const
Returns true if the indicated channel value has changed since the last call to mark_channels().
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
void clear_bit(int index)
Sets the nth bit off.
A dynamic array with an unlimited number of bits.
Parent class for all animation channels.
This is the base class for AnimChannel and AnimBundle.
virtual void determine_effective_channels(const CycleData *root_cdata)
Should be called whenever the ChannelBlend values have changed, this recursively updates the _effecti...
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class is used to define a subset of part names to apply to the PartBundle::bind_anim() operation...
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.
void set_bit(int index)
Sets the nth bit on.
A thread; that is, a lightweight process.
This is the root of a MovingPart hierarchy.
virtual bool clear_forced_channel()
Undoes the effect of a previous call to apply_freeze() or apply_control().
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
int get_channel_index() const
Returns the particular channel index associated with this AnimControl.
virtual int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
Controls the timing of a character animation.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
virtual TypeHandle get_value_type() const =0
Returns the TypeHandle associated with the ValueType we are concerned with.
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Takes in a vector of pointers to TypedWritable objects that correspond to all the requests for pointe...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the base class for PartRoot and MovingPart.