16 #include "auto_bind.h" 17 #include "animBundleNode.h" 18 #include "partBundleNode.h" 19 #include "config_chan.h" 20 #include "string_utils.h" 21 #include "partGroup.h" 38 bind_anims(
const PartBundles &parts,
const AnimBundles &anims,
40 int hierarchy_match_flags) {
41 PartBundles::const_iterator pbi;
43 for (pbi = parts.begin(); pbi != parts.end(); ++pbi) {
45 AnimBundles::const_iterator abi;
46 for (abi = anims.begin(); abi != anims.end(); ++abi) {
48 if (chan_cat.is_info()) {
50 <<
"Attempting to bind " << *part <<
" to " << *anim <<
"\n";
54 part->bind_anim(anim, hierarchy_match_flags);
55 string name = (*abi)->get_name();
57 name = anim->get_name();
66 new_name = name +
'.' + format_string(index);
74 if (chan_cat.is_info()) {
80 <<
"Bind succeeded, index " 81 << control->get_channel_index() <<
"; accessible as " 96 r_find_bundles(
PandaNode *node, Anims &anims, Parts &parts) {
97 if (node->
is_of_type(AnimBundleNode::get_class_type())) {
100 anims[bundle->get_name()].insert(bundle);
102 }
else if (node->
is_of_type(PartBundleNode::get_class_type())) {
104 int num_bundles = bn->get_num_bundles();
105 for (
int i = 0; i < num_bundles; ++i) {
107 parts[bundle->get_name()].insert(bundle);
113 for (
int i = 0; i < num_children; i++) {
114 r_find_bundles(cr.
get_child(i), anims, parts);
130 int hierarchy_match_flags) {
133 AnimBundles extra_anims;
135 PartBundles extra_parts;
136 r_find_bundles(root_node, anims, parts);
138 if (chan_cat.is_debug()) {
140 Anims::const_iterator ai;
141 for (ai = anims.begin(); ai != anims.end(); ++ai) {
142 anim_count += (int)(*ai).second.size();
145 <<
"Found " << anim_count <<
" anims:\n";
146 for (ai = anims.begin(); ai != anims.end(); ++ai) {
147 chan_cat.debug(
false)
148 <<
" " << (*ai).first;
149 if ((*ai).second.size() != 1) {
150 chan_cat.debug(
false)
151 <<
"*" << ((*ai).second.size());
154 chan_cat.debug(
false)
158 Parts::const_iterator pi;
159 for (pi = parts.begin(); pi != parts.end(); ++pi) {
160 part_count += (int)(*pi).second.size();
163 <<
"Found " << part_count <<
" parts:\n";
164 for (pi = parts.begin(); pi != parts.end(); ++pi) {
165 chan_cat.debug(
false)
166 <<
" " << (*pi).first;
167 if ((*pi).second.size() != 1) {
168 chan_cat.debug(
false)
169 <<
"*" << ((*pi).second.size());
172 chan_cat.debug(
false)
178 Anims::const_iterator ai = anims.begin();
179 Parts::const_iterator pi = parts.begin();
181 while (ai != anims.end() && pi != parts.end()) {
182 if ((*ai).first < (*pi).first) {
184 if (hierarchy_match_flags & PartGroup::HMF_ok_wrong_root_name) {
185 AnimBundles::const_iterator abi;
186 for (abi = (*ai).second.begin(); abi != (*ai).second.end(); ++abi) {
187 extra_anims.insert(*abi);
192 }
else if ((*pi).first < (*ai).first) {
194 if (hierarchy_match_flags & PartGroup::HMF_ok_wrong_root_name) {
195 PartBundles::const_iterator pbi;
196 for (pbi = (*pi).second.begin(); pbi != (*pi).second.end(); ++pbi) {
197 extra_parts.insert(*pbi);
204 bind_anims((*pi).second, (*ai).second, controls,
205 hierarchy_match_flags);
214 if (hierarchy_match_flags & PartGroup::HMF_ok_wrong_root_name) {
217 while (ai != anims.end()) {
219 if (hierarchy_match_flags & PartGroup::HMF_ok_wrong_root_name) {
220 AnimBundles::const_iterator abi;
221 for (abi = (*ai).second.begin(); abi != (*ai).second.end(); ++abi) {
222 extra_anims.insert(*abi);
228 while (pi != parts.end()) {
230 if (hierarchy_match_flags & PartGroup::HMF_ok_wrong_root_name) {
231 PartBundles::const_iterator pbi;
232 for (pbi = (*pi).second.begin(); pbi != (*pi).second.end(); ++pbi) {
233 extra_parts.insert(*pbi);
239 bind_anims(extra_parts, extra_anims, controls,
240 hierarchy_match_flags);
int get_num_children() const
Returns the number of children of the node.
A basic node of the scene graph or data graph.
This is our own Panda specialization on the default STL map.
This is the root of an AnimChannel hierarchy.
void store_anim(AnimControl *control, const string &name)
Associates the given AnimControl with this collection under the given name.
This is a node that contains a pointer to an PartBundle.
This is a named collection of AnimControl pointers.
Children get_children(Thread *current_thread=Thread::get_current_thread()) const
Returns an object that can be used to walk through the list of children of the node.
This is the root of a MovingPart hierarchy.
Controls the timing of a character animation.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
This is our own Panda specialization on the default STL set.
PandaNode * get_child(int n) const
Returns the nth child of the node.
AnimControl * find_anim(const string &name) const
Returns the AnimControl associated with the given name, or NULL if no such control has been associate...
This is a node that contains a pointer to an AnimBundle.