37 PartGroup(
PartGroup *parent,
const std::string &name) :
39 _children(get_class_type())
41 nassertv(parent !=
nullptr);
43 parent->_children.push_back(
this);
78 if (root->get_type() != get_type()) {
80 <<
"Don't know how to copy " << get_type() <<
"\n";
83 Children::const_iterator ci;
84 for (ci = _children.begin(); ci != _children.end(); ++ci) {
86 root->_children.push_back(child);
97 get_num_children()
const {
98 return _children.size();
107 nassertr(n >= 0 && n < (
int)_children.size(),
nullptr);
119 Children::const_iterator ci;
120 for (ci = _children.begin(); ci != _children.end(); ++ci) {
122 if (child->get_name() == name) {
137 Children::const_iterator ci;
138 for (ci = _children.begin(); ci != _children.end(); ++ci) {
140 if (child->get_name() == name) {
144 if (result !=
nullptr) {
153 class PartGroupAlphabeticalOrder {
156 return a->get_name() < b->get_name();
168 std::stable_sort(_children.begin(), _children.end(), PartGroupAlphabeticalOrder());
170 Children::iterator ci;
171 for (ci = _children.begin(); ci != _children.end(); ++ci) {
172 (*ci)->sort_descendants();
256 write(ostream &out,
int indent_level)
const {
258 << get_type() <<
" " << get_name() <<
" {\n";
259 write_descendants(out, indent_level + 2);
260 indent(out, indent_level) <<
"}\n";
270 << get_type() <<
" " << get_name() <<
" {\n";
271 write_descendants_with_value(out, indent_level + 2);
272 indent(out, indent_level) <<
"}\n";
282 return TypeHandle::none();
295 int hierarchy_match_flags)
const {
298 if (chan_cat.is_error()) {
301 <<
" while matching anim node has type " << anim->
get_value_type()
307 if (chan_cat.is_info()) {
333 <<
" children, while matching anim node has " 343 match = (pc->get_name() == ac->get_name());
347 <<
"Part " << get_name() <<
" has a different set of children " 348 <<
" than matching anim node:\n";
358 if (pc->get_name() < ac->get_name()) {
360 <<
" part has " << pc->get_name()
361 <<
", not in anim.\n";
363 }
else if (ac->get_name() < pc->get_name()) {
365 <<
" anim has " << ac->get_name()
366 <<
", not in part.\n";
379 <<
" part has " << pc->get_name()
380 <<
", not in anim.\n";
387 <<
" anim has " << ac->get_name()
388 <<
", not in part.\n";
403 if (pc->get_name() < ac->get_name()) {
404 if (pc->get_name() ==
"morph") {
407 if ((hierarchy_match_flags & HMF_ok_part_extra) == 0) {
412 }
else if (ac->get_name() < pc->get_name()) {
413 if (ac->get_name() ==
"morph") {
416 if ((hierarchy_match_flags & HMF_ok_anim_extra) == 0) {
434 if (pc->get_name() ==
"morph") {
437 if ((hierarchy_match_flags & HMF_ok_part_extra) == 0) {
448 if (ac->get_name() ==
"morph") {
451 if ((hierarchy_match_flags & HMF_ok_anim_extra) == 0) {
471 bool parent_changed,
bool anim_changed,
Thread *current_thread) {
472 bool any_changed =
false;
474 Children::iterator ci;
475 for (ci = _children.begin(); ci != _children.end(); ++ci) {
476 if ((*ci)->do_update(root, root_cdata,
this, parent_changed,
477 anim_changed, current_thread)) {
490 do_xform(
const LMatrix4 &mat,
const LMatrix4 &inv_mat) {
491 Children::const_iterator ci;
493 for (ci = _children.begin(); ci != _children.end(); ++ci) {
494 (*ci)->do_xform(mat, inv_mat);
504 Children::iterator ci;
505 for (ci = _children.begin(); ci != _children.end(); ++ci) {
506 (*ci)->determine_effective_channels(root_cdata);
515 write_descendants(ostream &out,
int indent_level)
const {
516 Children::const_iterator ci;
518 for (ci = _children.begin(); ci != _children.end(); ++ci) {
519 (*ci)->write(out, indent_level);
528 write_descendants_with_value(ostream &out,
int indent_level)
const {
529 Children::const_iterator ci;
531 for (ci = _children.begin(); ci != _children.end(); ++ci) {
532 (*ci)->write_with_value(out, indent_level);
542 pick_channel_index(
plist<int> &holes,
int &next)
const {
543 Children::const_iterator ci;
544 for (ci = _children.begin(); ci != _children.end(); ++ci) {
545 (*ci)->pick_channel_index(holes, next);
555 bind_hierarchy(
AnimGroup *anim,
int channel_index,
int &joint_index,
556 bool is_included,
BitArray &bound_joints,
569 while (i < part_num_children && j < anim_num_children) {
573 if (pc->get_name() < ac->get_name()) {
575 pc->bind_hierarchy(
nullptr, channel_index, joint_index, is_included,
576 bound_joints, subset);
579 }
else if (ac->get_name() < pc->get_name()) {
585 pc->bind_hierarchy(ac, channel_index, joint_index, is_included,
586 bound_joints, subset);
593 while (i < part_num_children) {
595 pc->bind_hierarchy(
nullptr, channel_index, joint_index, is_included,
596 bound_joints, subset);
609 find_bound_joints(
int &joint_index,
bool is_included,
BitArray &bound_joints,
618 for (
int i = 0; i < part_num_children; ++i) {
620 pc->find_bound_joints(joint_index, is_included, bound_joints, subset);
632 for (
size_t i = 0; i < _children.size(); i++) {
650 mat.read_datagram(scan);
654 _children.reserve(num_children);
655 for (
int i = 0; i < num_children; i++) {
657 _children.push_back(
nullptr);
669 Children::iterator ci;
670 for (ci = _children.begin(); ci != _children.end(); ++ci) {
687 me->fillin(scan, manager);
A basic node of the scene graph or data graph.
bool matches_exclude(const std::string &joint_name) const
Returns true if the indicated name matches a name on the exclude list, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual AnimChannelBase * get_forced_channel() const
Returns the AnimChannelBase that has been forced to this joint by a previous call to apply_freeze() o...
bool get_bool()
Extracts a boolean value.
void sort_descendants()
Sorts the children nodes at each level of the hierarchy into alphabetical order.
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.
A single page of data maintained by a PipelineCycler.
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
get_num_children
Returns the number of child nodes of the group.
virtual void do_xform(const LMatrix4 &mat, const LMatrix4 &inv_mat)
Called by PartBundle::xform(), this indicates the indicated transform is being applied to the root jo...
static void consider_yield()
Possibly suspends the current thread for the rest of the current epoch, if it has run for enough this...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_num_children
Returns the number of child nodes of the group.
std::string get_string()
Extracts a variable-length string.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
PartGroup * get_child_named(const std::string &name) const
Returns the first child found with the indicated name, or NULL if no such child exists.
A dynamic array with an unlimited number of bits.
Parent class for all animation channels.
PartGroup * find_child(const std::string &name) const
Returns the first descendant found with the indicated name, or NULL if no such descendant exists.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
A base class for all things which can have a name.
virtual TypeHandle get_value_type() const
Returns the TypeHandle associated with the ValueType we are concerned with.
virtual void write(std::ostream &out, int indent_level) const
Writes a brief description of the group and all of its descendants.
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...
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
virtual void write_with_value(std::ostream &out, int indent_level) const
Writes a brief description of the group, showing its current value, and that of all of its descendant...
get_child
Returns the nth child of the group.
virtual bool apply_freeze_matrix(const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale)
Freezes this particular joint so that it will always hold the specified transform.
void add_string(const std::string &str)
Adds a variable-length string to the datagram.
bool apply_freeze(const TransformState *transform)
Freezes this particular joint so that it will always hold the specified transform.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
virtual TypeHandle get_value_type() const
Returns the TypeHandle associated with the ValueType we are concerned with.
virtual bool apply_control(PandaNode *node)
Specifies a node to influence this particular joint so that it will always hold the node's transform.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool is_character_joint() const
Returns true if this part is a CharacterJoint, false otherwise.
This class is used to define a subset of part names to apply to the PartBundle::bind_anim() operation...
static void register_with_read_factory()
Factory method to generate a PartGroup object.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
A thread; that is, a lightweight process.
This is the root of a MovingPart hierarchy.
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
virtual bool clear_forced_channel()
Undoes the effect of a previous call to apply_freeze() or apply_control().
bool check_hierarchy(const AnimGroup *anim, const PartGroup *parent, int hierarchy_match_flags=0) const
Walks the part hierarchy in tandem with the indicated anim hierarchy, and returns true if the hierarc...
PartGroup * copy_subgraph() const
Allocates and returns a new copy of this node and of all of its children.
A class to retrieve the individual data elements previously stored in a Datagram.
get_child
Returns the nth child of the group.
static TypedWritable * make_PartGroup(const FactoryParams ¶ms)
Factory method to generate a PartGroup object.
TypeHandle is the identifier used to differentiate C++ class types.
virtual PartGroup * make_copy() const
Allocates and returns a new copy of the node.
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...
virtual bool apply_freeze_scalar(PN_stdfloat value)
Freezes this particular joint so that it will always hold the specified transform.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
AnimGroup * get_child_named(const std::string &name) const
Returns the first child found with the indicated name, or NULL if no such child exists.
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.