aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2012-01-16 14:31:24 -0800
committerHarvey Harrison <[email protected]>2012-01-16 14:31:24 -0800
commit6d40cd6a55c9b3ddff4de901f2027f6802e256a9 (patch)
tree08600b7f452edeafabc88cb27b322fce3c751b09 /src/classes
parent687ca5f02d22fa489cf0e7dd4dd3c5e9fcfa7b19 (diff)
j3dcore: further reduce sizes of BoundingSphere and BoundingBox
Essentially this undoes all the code added for issue 561. Just rely on escape analysis to allocate on-stack. On 64-bit: Reduces BoundingSphere from 54 -> 38 bytes Reduces BoundingBox from 62 -> 46 bytes Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src/classes')
-rw-r--r--src/classes/share/javax/media/j3d/BoundingBox.java49
-rw-r--r--src/classes/share/javax/media/j3d/BoundingSphere.java32
2 files changed, 17 insertions, 64 deletions
diff --git a/src/classes/share/javax/media/j3d/BoundingBox.java b/src/classes/share/javax/media/j3d/BoundingBox.java
index 6a41dbd..c0a30b2 100644
--- a/src/classes/share/javax/media/j3d/BoundingBox.java
+++ b/src/classes/share/javax/media/j3d/BoundingBox.java
@@ -59,27 +59,6 @@ final Point3d upper;
private Point3d centroid = null;
private static final double EPS = 1.0E-8;
- // reusable temp objects
- private BoundingSphere tmpSphere = null;
- private BoundingPolytope tmpPolytope = null;
-
- // Issue 561: Set by -Dj3d.releaseBoundingBoxMemory property.
- // When set to true, the per-instance fields used in bounding box
- // transformation are released at the end of transform methods. This saves
- // a significant amount of memory in large scenes containing huge amounts
- // of bounding boxes. Setting this false can improve performance when
- // lots of transforms are performed. The default is false.
- // This was initialing in MasterControl, but was moved to here to fix issue 592. This avoids
- // instantiating and intializing VirtualUniverse and MasterControl
- private static boolean releaseBoundingBoxMemory = false;
-
- static {
- releaseBoundingBoxMemory = MasterControl.getBooleanProperty("j3d.releaseBoundingBoxMemory",
- releaseBoundingBoxMemory, "releasing memory after bounding box transform");
-
- }
-
-
/**
* Constructs and initializes a BoundingBox given min,max in x,y,z.
* @param lower the "small" corner
@@ -659,34 +638,18 @@ public void setUpper(Point3d p1) {
this.transform(matrix);
}
else if(boundsObject.boundId == BOUNDING_SPHERE) {
- if (tmpSphere == null) {
- tmpSphere = new BoundingSphere( (BoundingSphere)boundsObject);
- } else {
- tmpSphere.set((BoundingSphere)boundsObject);
- }
- tmpSphere.transform(matrix);
- this.set(tmpSphere);
+ BoundingSphere tmpSphere = new BoundingSphere(boundsObject);
+ tmpSphere.transform(matrix);
+ this.set(tmpSphere);
}
else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- if (tmpPolytope == null) {
- tmpPolytope =
- new BoundingPolytope((BoundingPolytope) boundsObject);
- } else {
- tmpPolytope.set((BoundingPolytope)boundsObject);
- }
- tmpPolytope.transform(matrix);
- this.set(tmpPolytope);
-
+ BoundingPolytope tmpPolytope = new BoundingPolytope(boundsObject);
+ tmpPolytope.transform(matrix);
+ this.set(tmpPolytope);
}
else {
throw new IllegalArgumentException(J3dI18N.getString("BoundingBox5"));
}
-
- // Release the temporary fields:
- if (releaseBoundingBoxMemory) {
- tmpSphere = null;
- tmpPolytope = null;
- }
}
/**
diff --git a/src/classes/share/javax/media/j3d/BoundingSphere.java b/src/classes/share/javax/media/j3d/BoundingSphere.java
index 9e163f2..e7bec53 100644
--- a/src/classes/share/javax/media/j3d/BoundingSphere.java
+++ b/src/classes/share/javax/media/j3d/BoundingSphere.java
@@ -55,10 +55,6 @@ final Point3d center;
*/
double radius;
- // reusable temp objects
- private BoundingBox tmpBox = null;
- private BoundingPolytope tmpPolytope = null;
-
/**
* Constructs and initializes a BoundingSphere from a center and radius.
* @param center the center of the bounding sphere
@@ -767,25 +763,19 @@ public void setCenter(Point3d center) {
return;
}
- if( boundsObject.boundId == BOUNDING_BOX){
- if (tmpBox == null) {
- tmpBox = new BoundingBox( (BoundingBox)boundsObject);
- } else {
- tmpBox.set((BoundingBox)boundsObject);
- }
- tmpBox.transform(matrix);
- this.set(tmpBox);
- }else if( boundsObject.boundId == BOUNDING_SPHERE ) {
+ if (boundsObject.boundId == BOUNDING_BOX) {
+ BoundingBox tmpBox = new BoundingBox(boundsObject);
+ tmpBox.transform(matrix);
+ this.set(tmpBox);
+ }
+ else if (boundsObject.boundId == BOUNDING_SPHERE) {
this.set(boundsObject);
this.transform(matrix);
- } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- if (tmpPolytope == null) {
- tmpPolytope = new BoundingPolytope((BoundingPolytope)boundsObject);
- } else {
- tmpPolytope.set((BoundingPolytope)boundsObject);
- }
- tmpPolytope.transform(matrix);
- this.set(tmpPolytope);
+ }
+ else if (boundsObject.boundId == BOUNDING_POLYTOPE) {
+ BoundingPolytope tmpPolytope = new BoundingPolytope(boundsObject);
+ tmpPolytope.transform(matrix);
+ this.set(tmpPolytope);
} else {
throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere5"));
}