aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2012-01-24 22:58:28 -0800
committerHarvey Harrison <[email protected]>2012-01-24 22:58:28 -0800
commit3b050374919eb89d0b1a153659a1edb0d7d320d4 (patch)
tree0e3b62ea340853440607ea9e2b895d279e71a93b /src/classes
parent681ba61a9971570d1a00448432961ea6dad6fad9 (diff)
j3dcore: remove the unneeded centroid from BoundingBox
Return a temp Point3d as it's not that much more expensive than the math we're already doing. Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src/classes')
-rw-r--r--src/classes/share/javax/media/j3d/BoundingBox.java23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/classes/share/javax/media/j3d/BoundingBox.java b/src/classes/share/javax/media/j3d/BoundingBox.java
index b1baee4..0c1afa8 100644
--- a/src/classes/share/javax/media/j3d/BoundingBox.java
+++ b/src/classes/share/javax/media/j3d/BoundingBox.java
@@ -55,8 +55,6 @@ final Point3d lower;
* The corner of the bounding box with the numerically largest values.
*/
final Point3d upper;
-
- private Point3d centroid = null;
private static final double EPS = 1.0E-8;
/**
@@ -1563,7 +1561,7 @@ public void setUpper(Point3d p1) {
return null;
}
- getCenter();
+ Point3d centroid = getCenter();
double dis;
double cenX = 0.0, cenY = 0.0, cenZ = 0.0;
@@ -1825,18 +1823,13 @@ private void setInfiniteBounds() {
}
}
- // For a infinite bounds. What is the centroid ?
- Point3d getCenter() {
- if(centroid == null) {
- centroid = new Point3d();
- }
-
- centroid.x = (upper.x+lower.x)*0.5;
- centroid.y = (upper.y+lower.y)*0.5;
- centroid.z = (upper.z+lower.z)*0.5;
-
- return centroid;
- }
+// For a infinite bounds. What is the centroid ?
+Point3d getCenter() {
+ Point3d cent = new Point3d();
+ cent.add(upper, lower);
+ cent.scale(0.5d);
+ return cent;
+}
public void getCenter(Point3d center) {
center.add(lower, upper);