1
0
Fork 0

Mathias Frhlich:

I have a small update which fixes the algorythm used for marking solid
surfaces for some cases where some branch nodes carry the object names I had
expected in the leaf nodes.
That will also introduce the possibility to mark whole subtrees from the
scenegraph solid.
This commit is contained in:
ehofman 2004-12-18 10:33:36 +00:00
parent 9afec17205
commit 127e84cee9
2 changed files with 10 additions and 5 deletions

View file

@ -92,7 +92,7 @@ bool FGAICarrier::init() {
// Attach a pointer to this carrier class to those objects.
mark_wires(sel, wire_objects);
mark_cat(sel, catapult_objects);
mark_solid(sel, solid_objects);
mark_solid(sel, solid_objects, false);
return true;
}
@ -160,13 +160,18 @@ bool FGAICarrier::mark_wires(ssgEntity* e, const list<string>& wire_objects) {
return found;
}
bool FGAICarrier::mark_solid(ssgEntity* e, const list<string>& solid_objects) {
bool FGAICarrier::mark_solid(ssgEntity* e, const list<string>& solid_objects, bool mark) {
bool found = false;
if (e->isAKindOf(ssgTypeBranch())) {
ssgBranch* br = (ssgBranch*)e;
ssgEntity* kid;
list<string>::const_iterator it;
for (it = solid_objects.begin(); it != solid_objects.end(); ++it)
mark = mark || e->getName() && (*it) == e->getName();
for ( kid = br->getKid(0); kid != NULL ; kid = br->getNextKid() )
found = mark_solid(kid, solid_objects) || found;
found = mark_solid(kid, solid_objects, mark) || found;
if (found)
br->setTraversalMaskBits(SSGTRAV_HOT);
@ -174,7 +179,7 @@ bool FGAICarrier::mark_solid(ssgEntity* e, const list<string>& solid_objects) {
} else if (e->isAKindOf(ssgTypeLeaf())) {
list<string>::const_iterator it;
for (it = solid_objects.begin(); it != solid_objects.end(); ++it) {
if (e->getName() && (*it) == e->getName()) {
if (mark || (e->getName() && (*it) == e->getName())) {
e->setTraversalMaskBits(SSGTRAV_HOT);
e->setUserData( FGAICarrierHardware::newSolid( this ) );
found = true;

View file

@ -92,7 +92,7 @@ private:
void mark_nohot(ssgEntity*);
bool mark_wires(ssgEntity*, const list<string>&);
bool mark_cat(ssgEntity*, const list<string>&);
bool mark_solid(ssgEntity*, const list<string>&);
bool mark_solid(ssgEntity*, const list<string>&, bool);
list<string> solid_objects; // List of solid object names
list<string> wire_objects; // List of wire object names