move joints to end of list on output

This commit is contained in:
David Rose 2003-06-05 23:47:53 +00:00
parent 63db1b1d1c
commit 3c1914b19a
5 changed files with 50 additions and 1 deletions

View File

@ -294,6 +294,20 @@ write(ostream &out, int indent_level) const {
indent(out, indent_level) << "}\n";
}
////////////////////////////////////////////////////////////////////
// Function: EggGroup::is_joint
// Access: Public, Virtual
// Description: Returns true if this particular node represents a
// <Joint> entry or not. This is a handy thing to know
// since Joints are sorted to the end of their sibling
// list when writing an egg file. See
// EggGroupNode::write().
////////////////////////////////////////////////////////////////////
bool EggGroup::
is_joint() const {
return (get_group_type() == GT_joint);
}
////////////////////////////////////////////////////////////////////
// Function: EggGroup::determine_alpha_mode
// Access: Public, Virtual

View File

@ -99,6 +99,8 @@ public:
virtual void write(ostream &out, int indent_level) const;
virtual bool is_joint() const;
virtual EggRenderMode *determine_alpha_mode();
virtual EggRenderMode *determine_depth_write_mode();
virtual EggRenderMode *determine_depth_test_mode();

View File

@ -86,8 +86,25 @@ EggGroupNode::
void EggGroupNode::
write(ostream &out, int indent_level) const {
iterator i;
// Since joints tend to reference vertex pools, which sometimes
// appear later in the file, and since generally non-joints don't
// reference joints, we try to maximize our chance of writing out a
// one-pass readable egg file by writing joints at the end of the
// list of children of a particular node.
for (i = begin(); i != end(); ++i) {
(*i)->write(out, indent_level);
PT(EggNode) child = (*i);
if (!child->is_joint()) {
child->write(out, indent_level);
}
}
for (i = begin(); i != end(); ++i) {
PT(EggNode) child = (*i);
if (child->is_joint()) {
child->write(out, indent_level);
}
}
}

View File

@ -44,6 +44,20 @@ apply_texmats() {
r_apply_texmats(textures);
}
////////////////////////////////////////////////////////////////////
// Function: EggNode::is_joint
// Access: Public, Virtual
// Description: Returns true if this particular node represents a
// <Joint> entry or not. This is a handy thing to know
// since Joints are sorted to the end of their sibling
// list when writing an egg file. See
// EggGroupNode::write().
////////////////////////////////////////////////////////////////////
bool EggNode::
is_joint() const {
return false;
}
////////////////////////////////////////////////////////////////////
// Function: EggNode::determine_alpha_mode
// Access: Public, Virtual

View File

@ -63,6 +63,8 @@ public:
INLINE void flatten_transforms();
void apply_texmats();
virtual bool is_joint() const;
virtual EggRenderMode *determine_alpha_mode();
virtual EggRenderMode *determine_depth_write_mode();
virtual EggRenderMode *determine_depth_test_mode();