]> git.mxchange.org Git - flightgear.git/commitdiff
Give up on the idea of using a singleton dummy bounding sphere;
authordavid <david>
Fri, 26 Jul 2002 19:06:29 +0000 (19:06 +0000)
committerdavid <david>
Fri, 26 Jul 2002 19:06:29 +0000 (19:06 +0000)
instead, use a separate dummy bounding sphere for each triangle and
each tile, with the actual bounds, to make sure that objects are
always added when they should be in sight.

src/Objects/obj.cxx

index 905fdf2048950de28f16e1b2e1e9078e356f24ce..747f933082b19a473dad1c2a96b53f5ddaf79c11 100644 (file)
@@ -525,7 +525,7 @@ tri_out_of_range_callback (ssgEntity * entity, int mask)
 
 
 /**
- * Singleton ssgEntity with a dummy bounding sphere, to fool culling.
+ * ssgEntity with a dummy bounding sphere, to fool culling.
  *
  * This forces the in-range and out-of-range branches to be visited
  * when appropriate, even if they have no children.  It's ugly, but
@@ -535,42 +535,22 @@ tri_out_of_range_callback (ssgEntity * entity, int mask)
 class DummyBSphereEntity : public ssgEntity
 {
 public:
+  DummyBSphereEntity (float radius)
+  {
+    bsphere.setCenter(0, 0, 0);
+    bsphere.setRadius(radius);
+  }
   virtual ~DummyBSphereEntity () {}
   virtual void recalcBSphere () { bsphere_is_invalid = false; }
   virtual void cull (sgFrustum *f, sgMat4 m, int test_needed) {}
   virtual void isect (sgSphere *s, sgMat4 m, int test_needed) {}
   virtual void hot (sgVec3 s, sgMat4 m, int test_needed) {}
   virtual void los (sgVec3 s, sgMat4 m, int test_needed) {}
-  static ssgEntity * get_entity ();
-private:
-  DummyBSphereEntity ()
-  {
-    bsphere.setCenter(0, 0, 0);
-    bsphere.setRadius(1000);
-  }
-  static DummyBSphereEntity * entity;
+  static ssgEntity * get_tri_entity ();
+  static ssgEntity * get_tile_entity ();
 };
 
 
-DummyBSphereEntity * DummyBSphereEntity::entity = 0;
-
-
-/**
- * Ensure that only one copy of the dummy entity exists.
- *
- * @return The singleton copy of the DummyBSphereEntity.
- */
-ssgEntity *
-DummyBSphereEntity::get_entity ()
-{
-  if (entity == 0) {
-    entity = new DummyBSphereEntity;
-    entity->ref();
-  }
-  return entity;
-}
-
-
 /**
  * Calculate the bounding radius of a triangle from its center.
  *
@@ -672,7 +652,7 @@ setup_triangle (float * p1, float * p2, float * p3,
        out_of_range->setUserData(data);
        out_of_range->setTravCallback(SSG_CALLBACK_PRETRAV,
                                      tri_out_of_range_callback);
-       out_of_range->addKid(DummyBSphereEntity::get_entity());
+       out_of_range->addKid(new DummyBSphereEntity(bounding_radius));
        lod->addKid(out_of_range);
     }
 }
@@ -831,7 +811,8 @@ gen_random_surface_objects (ssgLeaf *leaf,
     out_of_range->setUserData(data);
     out_of_range->setTravCallback(SSG_CALLBACK_PRETRAV,
                                   tile_out_of_range_callback);
-    out_of_range->addKid(DummyBSphereEntity::get_entity());
+    out_of_range
+      ->addKid(new DummyBSphereEntity(leaf->getBSphere()->getRadius()));
 }