]> git.mxchange.org Git - flightgear.git/commitdiff
Mathias Fröhlich:
authorehofman <ehofman>
Sat, 18 Dec 2004 10:33:36 +0000 (10:33 +0000)
committerehofman <ehofman>
Sat, 18 Dec 2004 10:33:36 +0000 (10:33 +0000)
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.

src/AIModel/AICarrier.cxx
src/AIModel/AICarrier.hxx

index 84775fa58e3cb463c3025e137b88eeb22d7de0ca..6c33639e30b92f3c650555d052660d78f43faaa1 100644 (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;
index 15f2bdf452711027028644d85db11075037e986b..a9ae9e962d9f9e1b70d540e6d4d04fe608e4bdcd 100644 (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