diff options
author | Harvey Harrison <[email protected]> | 2012-01-15 16:48:51 -0800 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2012-01-15 16:48:51 -0800 |
commit | 979ab971d7fdea92fd1908f0cce64c28117e19cf (patch) | |
tree | 25b8b0def9646ac6d7b4081e4960aa62c5d0a908 /src/classes | |
parent | dd8b091b2f0a809985cb2dd8c144521c32567f88 (diff) |
j3dcore: reduce memory footprint of BoundSphere
The temp array of Point3d's are only used in one constructor, which is not called
anywhere in the Java3d package. Allocate a temp inside the constructor as-required
and reduce the memory use for everyone else.
Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src/classes')
-rw-r--r-- | src/classes/share/javax/media/j3d/BoundingSphere.java | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/classes/share/javax/media/j3d/BoundingSphere.java b/src/classes/share/javax/media/j3d/BoundingSphere.java index db14526..2f10b9e 100644 --- a/src/classes/share/javax/media/j3d/BoundingSphere.java +++ b/src/classes/share/javax/media/j3d/BoundingSphere.java @@ -55,9 +55,6 @@ final Point3d center; */ double radius; - Point3d boxVerts[]; - boolean allocBoxVerts = false; - // reusable temp objects private BoundingBox tmpBox = null; private BoundingPolytope tmpPolytope = null; @@ -193,6 +190,7 @@ double radius; if(boundsIsInfinite) return; + Point3d[] boxVerts = null; for(;i<boundsObjects.length;i++) { if( boundsObjects[i] == null ); // do nothing else if( boundsObjects[i].boundsIsEmpty); // do nothing @@ -202,11 +200,12 @@ double radius; } else if( boundsObjects[i].boundId == BOUNDING_BOX){ BoundingBox b = (BoundingBox)boundsObjects[i]; - if( !allocBoxVerts){ - boxVerts = new Point3d[8]; - for(int j=0;j<8;j++)boxVerts[j] = new Point3d(); - allocBoxVerts = true; - } + if (boxVerts == null) { + boxVerts = new Point3d[8]; + for (int j = 0; j < 8; j++) + boxVerts[j] = new Point3d(); + + } boxVerts[0].set(b.lower.x, b.lower.y, b.lower.z ); boxVerts[1].set(b.lower.x, b.upper.y, b.lower.z ); boxVerts[2].set(b.upper.x, b.lower.y, b.lower.z ); |