ecere/gfx/3D/Mesh; Object: Fixed radius and bounding box calculations
authorJerome St-Louis <jerome@ecere.com>
Tue, 8 Apr 2014 19:28:38 +0000 (15:28 -0400)
committerJerome St-Louis <jerome@ecere.com>
Tue, 8 Apr 2014 19:28:38 +0000 (15:28 -0400)
ecere/src/gfx/3D/Mesh.ec
ecere/src/gfx/3D/Object.ec

index 84b0f88..d3d2257 100644 (file)
@@ -601,7 +601,7 @@ private:
       float xRadius, yRadius, zRadius;
 
       min = { MAXFLOAT, MAXFLOAT, MAXFLOAT };
-      max = { MINFLOAT, MINFLOAT, MINFLOAT };
+      max = {-MAXFLOAT,-MAXFLOAT,-MAXFLOAT };
 
       for(c = 0; c<nVertices; c++)
       {
index 461c803..89f9e23 100644 (file)
@@ -500,7 +500,7 @@ public:
             mesh.SetMinMaxRadius();
          min = mesh.min;
          max = mesh.max;
-         volume = true;
+         volume = (max.x >= min.x && max.y >= min.y && max.z >= min.z);
       }
       else
       {
@@ -532,13 +532,13 @@ public:
                Vector3Df point;
                point.MultMatrix(points[c], child.localMatrix);
 
-               if(point.x < this.min.x) this.min.x = point.x;
-               if(point.y < this.min.y) this.min.y = point.y;
-               if(point.z < this.min.z) this.min.z = point.z;
+               if(point.x < min.x) min.x = point.x;
+               if(point.y < min.y) min.y = point.y;
+               if(point.z < min.z) min.z = point.z;
 
-               if(point.x > this.max.x) this.max.x = point.x;
-               if(point.y > this.max.y) this.max.y = point.y;
-               if(point.z > this.max.z) this.max.z = point.z;
+               if(point.x > max.x) max.x = point.x;
+               if(point.y > max.y) max.y = point.y;
+               if(point.z > max.z) max.z = point.z;
             }
             volume = true;
          }