fix flatten some more

This commit is contained in:
David Rose 2001-06-08 22:12:38 +00:00
parent 0bf2b83727
commit 4cb4ba7598
5 changed files with 37 additions and 0 deletions

View File

@ -377,6 +377,12 @@ collapse_siblings(Node *parent, NodeRelation *arc1, NodeRelation *arc2) {
////////////////////////////////////////////////////////////////////
Node *GraphReducer::
collapse_nodes(Node *node1, Node *node2, bool) {
if (!node1->safe_to_combine() || !node2->safe_to_combine()) {
// One or both nodes cannot be safely combined with another node;
// do nothing.
return NULL;
}
// We get to choose whether to remove node1 or node2.
if (node2->is_exact_type(Node::get_class_type()) ||
node2->is_exact_type(NamedNode::get_class_type())) {

View File

@ -159,6 +159,20 @@ safe_to_transform() const {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: Node::safe_to_combine
// Access: Public, Virtual
// Description: Returns true if it is generally safe to combine
// this particular kind of Node with other kinds of
// Nodes, adding children or whatever. For instance, an
// LODNode should not be combined with any other node,
// because its set of children is meaningful.
////////////////////////////////////////////////////////////////////
bool Node::
safe_to_combine() const {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: Node::xform
// Access: Public, Virtual

View File

@ -68,6 +68,7 @@ public:
virtual bool safe_to_flatten() const;
virtual bool safe_to_transform() const;
virtual bool safe_to_combine() const;
virtual void xform(const LMatrix4f &mat);
virtual void transform_changed(NodeRelation *arc);

View File

@ -19,3 +19,18 @@
#include "switchNode.h"
TypeHandle SwitchNode::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: SwitchNode::safe_to_combine
// Access: Public, Virtual
// Description: Returns true if it is generally safe to combine
// this particular kind of Node with other kinds of
// Nodes, adding children or whatever. For instance, an
// LODNode should not be combined with any other node,
// because its set of children is meaningful.
////////////////////////////////////////////////////////////////////
bool SwitchNode::
safe_to_combine() const {
return false;
}

View File

@ -44,6 +44,7 @@ PUBLISHED:
INLINE void operator = (const SwitchNode &copy);
public:
virtual bool safe_to_combine() const;
virtual void compute_switch(RenderTraverser *trav)=0;
virtual bool is_child_visible(TypeHandle type, int index)=0;