remove backstage object before palettizing

This commit is contained in:
David Rose 2003-04-11 21:19:25 +00:00
parent 3be7a57292
commit 7125ac9121
3 changed files with 49 additions and 22 deletions

View File

@ -25,14 +25,15 @@
#include "palettizer.h" #include "palettizer.h"
#include "filenameUnifier.h" #include "filenameUnifier.h"
#include <eggData.h> #include "eggData.h"
#include <eggTextureCollection.h> #include "eggGroup.h"
#include <datagram.h> #include "eggTextureCollection.h"
#include <datagramIterator.h> #include "datagram.h"
#include <bamReader.h> #include "datagramIterator.h"
#include <bamWriter.h> #include "bamReader.h"
#include <executionEnvironment.h> #include "bamWriter.h"
#include <dSearchPath.h> #include "executionEnvironment.h"
#include "dSearchPath.h"
TypeHandle EggFile::_type_handle; TypeHandle EggFile::_type_handle;
@ -449,6 +450,8 @@ read_egg() {
} }
_data = data; _data = data;
remove_backstage(_data);
return true; return true;
} }
@ -515,6 +518,41 @@ write_texture_refs(ostream &out, int indent_level) const {
} }
} }
////////////////////////////////////////////////////////////////////
// Function: EggFile::remove_backstage
// Access: Private
// Description: Recursively walks the egg hierarchy and removes any
// "backstage" nodes found from the scene graph
// completely. These aren't part of the egg scene
// anyway, and removing them early helps reduce
// confusion.
////////////////////////////////////////////////////////////////////
void EggFile::
remove_backstage(EggGroupNode *node) {
EggGroupNode::iterator ci;
ci = node->begin();
while (ci != node->end()) {
EggNode *child = (*ci);
bool remove_child = false;
if (child->is_of_type(EggGroup::get_class_type())) {
EggGroup *egg_group;
DCAST_INTO_V(egg_group, child);
remove_child = egg_group->has_object_type("backstage");
}
if (remove_child) {
ci = node->erase(ci);
} else {
if (child->is_of_type(EggGroupNode::get_class_type())) {
// Recurse on children.
remove_backstage(DCAST(EggGroupNode, child));
}
++ci;
}
}
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: EggFile::register_with_read_factory // Function: EggFile::register_with_read_factory
// Access: Public, Static // Access: Public, Static

View File

@ -79,6 +79,9 @@ public:
void write_description(ostream &out, int indent_level = 0) const; void write_description(ostream &out, int indent_level = 0) const;
void write_texture_refs(ostream &out, int indent_level = 0) const; void write_texture_refs(ostream &out, int indent_level = 0) const;
private:
void remove_backstage(EggGroupNode *node);
private: private:
EggData *_data; EggData *_data;
Filename _current_directory; Filename _current_directory;

View File

@ -445,13 +445,6 @@ get_uv_range(EggGroupNode *group, Palettizer::RemapUV remap) {
if (group->is_of_type(EggGroup::get_class_type())) { if (group->is_of_type(EggGroup::get_class_type())) {
EggGroup *egg_group; EggGroup *egg_group;
DCAST_INTO_V(egg_group, group); DCAST_INTO_V(egg_group, group);
for (int i = 0; i < egg_group->get_num_object_types(); i++) {
if (cmp_nocase_uh(egg_group->get_object_type(i), "backstage") == 0) {
// If we reach a <Group> node with the "backstage" flag set,
// ignore it and everything under it.
return;
}
}
if (egg_group->get_dart_type() != EggGroup::DT_none) { if (egg_group->get_dart_type() != EggGroup::DT_none) {
// If it's a character, we might change the kind of remapping we // If it's a character, we might change the kind of remapping we
@ -541,13 +534,6 @@ update_uv_range(EggGroupNode *group, Palettizer::RemapUV remap) {
if (group->is_of_type(EggGroup::get_class_type())) { if (group->is_of_type(EggGroup::get_class_type())) {
EggGroup *egg_group; EggGroup *egg_group;
DCAST_INTO_V(egg_group, group); DCAST_INTO_V(egg_group, group);
for (int i = 0; i < egg_group->get_num_object_types(); i++) {
if (cmp_nocase_uh(egg_group->get_object_type(i), "backstage") == 0) {
// If we reach a <Group> node with the "backstage" flag set,
// ignore it and everything under it.
return;
}
}
if (egg_group->get_dart_type() != EggGroup::DT_none) { if (egg_group->get_dart_type() != EggGroup::DT_none) {
// If it's a character, we might change the kind of remapping we // If it's a character, we might change the kind of remapping we