DCS-flagged nodes shouldn't get their transforms modified by flatten

This commit is contained in:
David Rose 2002-06-27 18:32:10 +00:00
parent 7d5d680b57
commit 78fc774942
5 changed files with 58 additions and 2 deletions

View File

@ -65,6 +65,23 @@ safe_to_transform() const {
return !_preserve_transform;
}
////////////////////////////////////////////////////////////////////
// Function: ModelNode::safe_to_modify_transform
// Access: Public, Virtual
// Description: Returns true if it is safe to automatically adjust
// the transform on this kind of node. Usually, this is
// only a bad idea if the user expects to find a
// particular transform on the node.
//
// ModelNodes with the preserve_transform flag set are
// presently the only kinds of nodes that should not
// have their transform even adjusted.
////////////////////////////////////////////////////////////////////
bool ModelNode::
safe_to_modify_transform() const {
return !_preserve_transform;
}
////////////////////////////////////////////////////////////////////
// Function: ModelNode::safe_to_combine
// Access: Public, Virtual

View File

@ -47,6 +47,7 @@ public:
virtual bool safe_to_flatten() const;
virtual bool safe_to_transform() const;
virtual bool safe_to_modify_transform() const;
virtual bool safe_to_combine() const;
virtual bool preserve_name() const;

View File

@ -470,6 +470,23 @@ safe_to_transform() const {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: PandaNode::safe_to_modify_transform
// Access: Public, Virtual
// Description: Returns true if it is safe to automatically adjust
// the transform on this kind of node. Usually, this is
// only a bad idea if the user expects to find a
// particular transform on the node.
//
// ModelNodes with the preserve_transform flag set are
// presently the only kinds of nodes that should not
// have their transform even adjusted.
////////////////////////////////////////////////////////////////////
bool PandaNode::
safe_to_modify_transform() const {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: PandaNode::safe_to_combine
// Access: Public, Virtual

View File

@ -69,6 +69,7 @@ public:
virtual bool safe_to_flatten() const;
virtual bool safe_to_transform() const;
virtual bool safe_to_modify_transform() const;
virtual bool safe_to_combine() const;
virtual bool preserve_name() const;
virtual void xform(const LMatrix4f &mat);

View File

@ -406,6 +406,28 @@ r_apply_attribs(PandaNode *node, int attrib_types,
apply_types |= TT_transform;
}
// Also, check the children of this node. If any of them indicates
// it is not safe to modify its transform, we must drop our
// transform here.
int num_children = node->get_num_children();
int i;
if ((apply_types & TT_transform) == 0) {
bool children_transform_friendly = true;
for (i = 0; i < num_children && children_transform_friendly; i++) {
PandaNode *child_node = node->get_child(i);
children_transform_friendly = child_node->safe_to_modify_transform();
}
if (!children_transform_friendly) {
if (pgraph_cat.is_debug()) {
pgraph_cat.debug()
<< "Node " << *node
<< " has a child that cannot modify its transform; leaving transform here.\n";
}
apply_types |= TT_transform;
}
}
// Directly store whatever attributes we must,
trans.apply_to_node(node, attrib_types & apply_types);
@ -414,8 +436,6 @@ r_apply_attribs(PandaNode *node, int attrib_types,
// Do we need to copy any children to flatten instances?
bool resist_copy = false;
int num_children = node->get_num_children();
int i;
for (i = 0; i < num_children; i++) {
PandaNode *child_node = node->get_child(i);