|
52 | 52 | #include "modelNode.h"
|
53 | 53 | #include "animBundleNode.h"
|
54 | 54 | #include "animChannelMatrixXfmTable.h"
|
| 55 | +#include "characterJointEffect.h" |
55 | 56 | #include "characterJoint.h"
|
56 | 57 | #include "character.h"
|
57 | 58 | #include "string_utils.h"
|
@@ -155,6 +156,16 @@ convert_node(const WorkingNodePath &node_path, EggGroupNode *egg_parent,
|
155 | 156 | convert_character_node(DCAST(Character, node), node_path, egg_parent, has_decal);
|
156 | 157 |
|
157 | 158 | } else {
|
| 159 | + // Is this a ModelNode that represents an exposed joint? If so, skip it, |
| 160 | + // as we'll take care of it when building the joint hierarchy. |
| 161 | + if (node->get_type() == ModelNode::get_class_type()) { |
| 162 | + ModelNode *model_node = (ModelNode *)node; |
| 163 | + if (model_node->get_preserve_transform() == ModelNode::PT_net && |
| 164 | + model_node->has_effect(CharacterJointEffect::get_class_type())) { |
| 165 | + return; |
| 166 | + } |
| 167 | + } |
| 168 | + |
158 | 169 | // Just a generic node.
|
159 | 170 | EggGroup *egg_group = new EggGroup(node->get_name());
|
160 | 171 | egg_parent->add_child(egg_group);
|
@@ -354,6 +365,17 @@ convert_character_bundle(PartGroup *bundleNode, EggGroupNode *egg_parent, Charac
|
354 | 365 | EggGroup *joint = new EggGroup(bundleNode->get_name());
|
355 | 366 | joint->add_matrix4(transformd);
|
356 | 367 | joint->set_group_type(EggGroup::GT_joint);
|
| 368 | + |
| 369 | + // Is this joint exposed? |
| 370 | + NodePathCollection coll = character_joint->get_net_transforms(); |
| 371 | + for (size_t i = 0; i < coll.size(); ++i) { |
| 372 | + const NodePath &np = coll[i]; |
| 373 | + if (np.get_name() == bundleNode->get_name() && np.node()->is_of_type(ModelNode::get_class_type())) { |
| 374 | + joint->set_dcs_type(EggGroup::DC_net); |
| 375 | + break; |
| 376 | + } |
| 377 | + } |
| 378 | + |
357 | 379 | joint_group = joint;
|
358 | 380 | egg_parent->add_child(joint_group);
|
359 | 381 | if (joint_map != NULL) {
|
@@ -384,16 +406,33 @@ convert_character_node(Character *node, const WorkingNodePath &node_path,
|
384 | 406 |
|
385 | 407 | // A sequence node gets converted to an ordinary EggGroup, we only apply the
|
386 | 408 | // appropriate switch attributes to turn it into a sequence.
|
387 |
| - // We have to use DT_structured since it is the only mode that preserves the |
388 |
| - // node hierarchy, including LODNodes and CollisionNodes that may be under |
389 |
| - // this Character node. |
390 | 409 | EggGroup *egg_group = new EggGroup(node->get_name());
|
391 |
| - egg_group->set_dart_type(EggGroup::DT_structured); |
392 | 410 | egg_parent->add_child(egg_group);
|
393 | 411 | apply_node_properties(egg_group, node);
|
394 | 412 |
|
395 | 413 | CharacterJointMap joint_map;
|
396 |
| - recurse_nodes(node_path, egg_group, has_decal, &joint_map); |
| 414 | + bool is_structured = false; |
| 415 | + |
| 416 | + int num_children = node->get_num_children(); |
| 417 | + for (int i = 0; i < num_children; i++) { |
| 418 | + PandaNode *child = node->get_child(i); |
| 419 | + convert_node(WorkingNodePath(node_path, child), egg_parent, has_decal, &joint_map); |
| 420 | + |
| 421 | + TypeHandle type = child->get_type(); |
| 422 | + if (child->get_num_children() > 0 || |
| 423 | + (type != GeomNode::get_class_type() && type != ModelNode::get_class_type())) { |
| 424 | + is_structured = true; |
| 425 | + } |
| 426 | + } |
| 427 | + |
| 428 | + // We have to use DT_structured if it is necessary to preserve any node |
| 429 | + // hierarchy, such as LODNodes and CollisionNodes that may be under this |
| 430 | + // Character node. |
| 431 | + if (is_structured) { |
| 432 | + egg_group->set_dart_type(EggGroup::DT_structured); |
| 433 | + } else { |
| 434 | + egg_group->set_dart_type(EggGroup::DT_default); |
| 435 | + } |
397 | 436 |
|
398 | 437 | // turn it into a switch.. egg_group->set_switch_flag(true);
|
399 | 438 |
|
|
0 commit comments