Browse Source

whoops, incorrect bounding volume

David Rose 18 years ago
parent
commit
4362ebc862
1 changed files with 11 additions and 1 deletions
  1. 11 1
      panda/src/pgui/pgItem.cxx

+ 11 - 1
panda/src/pgui/pgItem.cxx

@@ -32,6 +32,8 @@
 #include "clipPlaneAttrib.h"
 #include "clipPlaneAttrib.h"
 #include "dcast.h"
 #include "dcast.h"
 #include "boundingSphere.h"
 #include "boundingSphere.h"
+#include "boundingBox.h"
+#include "config_mathutil.h"
 
 
 #ifdef HAVE_AUDIO
 #ifdef HAVE_AUDIO
 #include "audioSound.h"
 #include "audioSound.h"
@@ -301,7 +303,13 @@ compute_internal_bounds(PandaNode::BoundsData *bdata, int pipeline_stage,
   int num_vertices = 0;
   int num_vertices = 0;
 
 
   // First, get ourselves a fresh, empty bounding volume.
   // First, get ourselves a fresh, empty bounding volume.
-  PT(BoundingVolume) bound = new BoundingSphere;
+  PT(BoundingVolume) bound;
+
+  if (bounds_type == BoundingVolume::BT_sphere) {
+    bound = new BoundingSphere;
+  } else {
+    bound = new BoundingBox;
+  }
 
 
   // Now actually compute the bounding volume by putting it around all
   // Now actually compute the bounding volume by putting it around all
   // of our states' bounding volumes.
   // of our states' bounding volumes.
@@ -322,6 +330,8 @@ compute_internal_bounds(PandaNode::BoundsData *bdata, int pipeline_stage,
   const BoundingVolume **child_begin = &child_volumes[0];
   const BoundingVolume **child_begin = &child_volumes[0];
   const BoundingVolume **child_end = child_begin + child_volumes.size();
   const BoundingVolume **child_end = child_begin + child_volumes.size();
 
 
+  bound->around(child_begin, child_end);
+
   bdata->_internal_bounds = bound;
   bdata->_internal_bounds = bound;
   bdata->_internal_vertices = num_vertices;
   bdata->_internal_vertices = num_vertices;
   bdata->_internal_bounds_stale = false;
   bdata->_internal_bounds_stale = false;