Commits

Karsten Schmidt committed 6812640

adding Vec2D/3D.NEG_MAX_VALUE and bug fixing bounding box computations in AABB, PointCloud3D, TriangleMesh & DLA

Comments (0)

Files changed (6)

src.core/toxi/geom/AABB.java

         if (points == null || points.size() == 0) {
             return null;
         }
-        Vec3D min = Vec3D.MAX_VALUE.copy();
-        Vec3D max = Vec3D.MIN_VALUE.copy();
+        Vec3D first = points.get(0);
+        Vec3D min = first.copy();
+        Vec3D max = first.copy();
         for (Vec3D p : points) {
             min.minSelf(p);
             max.maxSelf(p);

src.core/toxi/geom/PointCloud3D.java

     public PointCloud3D clear() {
         points.clear();
         min = Vec3D.MAX_VALUE.copy();
-        max = Vec3D.MIN_VALUE.copy();
+        max = Vec3D.NEG_MAX_VALUE.copy();
         centroid = new Vec3D();
         return this;
     }
      */
     public PointCloud3D updateBounds() {
         min = Vec3D.MAX_VALUE.copy();
-        max = Vec3D.MIN_VALUE.copy();
+        max = Vec3D.NEG_MAX_VALUE.copy();
         for (Vec3D p : points) {
             min.minSelf(p);
             max.maxSelf(p);

src.core/toxi/geom/Vec2D.java

     public static final ReadonlyVec2D MAX_VALUE = new Vec2D(Float.MAX_VALUE,
             Float.MAX_VALUE);
 
+    public static final ReadonlyVec2D NEG_MAX_VALUE = new Vec2D(
+            -Float.MAX_VALUE, -Float.MAX_VALUE);
+
     /**
      * Creates a new vector from the given angle in the XY plane.
      * 

src.core/toxi/geom/Vec3D.java

     public static final ReadonlyVec3D MAX_VALUE = new Vec3D(Float.MAX_VALUE,
             Float.MAX_VALUE, Float.MAX_VALUE);
 
+    public static final ReadonlyVec3D NEG_MAX_VALUE = new Vec3D(
+            -Float.MAX_VALUE, -Float.MAX_VALUE, -Float.MAX_VALUE);
+
     /**
      * Creates a new vector from the given angle in the XY plane. The Z
      * component of the vector will be zero.

src.core/toxi/geom/mesh/TriangleMesh.java

 
     public AABB getBoundingBox() {
         final Vec3D minBounds = Vec3D.MAX_VALUE.copy();
-        final Vec3D maxBounds = Vec3D.MIN_VALUE.copy();
+        final Vec3D maxBounds = Vec3D.NEG_MAX_VALUE.copy();
         for (Vertex v : vertices.values()) {
             minBounds.minSelf(v);
             maxBounds.maxSelf(v);

src.sim/toxi/sim/dla/DLA.java

         octreeGuides = createOctree(new Vec3D(-0.5f, -0.5f, -0.5f).scale(size),
                 size);
         minBounds = Vec3D.MAX_VALUE.copy();
-        maxBounds = Vec3D.MIN_VALUE.copy();
+        maxBounds = Vec3D.NEG_MAX_VALUE.copy();
     }
 
     public DLA(float size, DLAConfiguration config, DLAGuideLines guides) {