diff options
author | Kevin Rushforth <[email protected]> | 2008-02-12 19:35:59 +0000 |
---|---|---|
committer | Kevin Rushforth <[email protected]> | 2008-02-12 19:35:59 +0000 |
commit | 99239b2c6b7e8887da30668a88253e1161a89244 (patch) | |
tree | 9acb47cc1d68f1f25ba1a2bc4d18feed2d58f92e | |
parent | 022c0bd9b799caa8793a61860dc407fcb3eea0ba (diff) |
Issue number: 561
Obtained from: paasiala
Submitted by: kcr
Reviewed by: kcr
Fixed issue 561: Decrease memory footprint of BoundingBox
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@888 ba19aa83-45c5-6ac9-afd3-db810772062c
-rw-r--r-- | src/classes/share/javax/media/j3d/BoundingBox.java | 20 | ||||
-rw-r--r-- | src/classes/share/javax/media/j3d/MasterControl.java | 15 |
2 files changed, 31 insertions, 4 deletions
diff --git a/src/classes/share/javax/media/j3d/BoundingBox.java b/src/classes/share/javax/media/j3d/BoundingBox.java index bb73c8b..5133550 100644 --- a/src/classes/share/javax/media/j3d/BoundingBox.java +++ b/src/classes/share/javax/media/j3d/BoundingBox.java @@ -42,7 +42,7 @@ public class BoundingBox extends Bounds { private BoundingSphere tmpSphere = null; private BoundingBox tmpBox = null; private BoundingPolytope tmpPolytope = null; - private Point3d tmpP3d = new Point3d(); + private Point3d tmpP3d = null; /** @@ -683,6 +683,13 @@ public class BoundingBox extends Bounds { else { throw new IllegalArgumentException(J3dI18N.getString("BoundingBox5")); } + + // Release the temporary fields: + if (VirtualUniverse.mc.releaseBoundingBoxMemory) { + tmpSphere = null; + tmpBox = null; + tmpPolytope = null; + } } /** @@ -693,7 +700,11 @@ public class BoundingBox extends Bounds { if(boundsIsInfinite) return; - + + if (tmpP3d == null) { + tmpP3d = new Point3d(); + } + double ux, uy, uz, lx, ly, lz; ux = upper.x; uy = upper.y; uz = upper.z; lx = lower.x; ly = lower.y; lz = lower.z; @@ -770,6 +781,11 @@ public class BoundingBox extends Bounds { if ( tmpP3d.y < lower.y ) lower.y = tmpP3d.y; if ( tmpP3d.z < lower.z ) lower.z = tmpP3d.z; + if (VirtualUniverse.mc.releaseBoundingBoxMemory) { + // Free memory + tmpP3d = null; + } + } /** diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java index fee00ce..0dd364e 100644 --- a/src/classes/share/javax/media/j3d/MasterControl.java +++ b/src/classes/share/javax/media/j3d/MasterControl.java @@ -476,7 +476,15 @@ class MasterControl { //Set as true if you have memory leaks after disposing Canvas3D. //Default false value does affect Java3D View dispose behavior. boolean forceReleaseView = false; - + + // 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. + boolean releaseBoundingBoxMemory = false; + // Issue 480: Cache the bounds of nodes so that getBounds does not // recompute the boounds of the entire graph per call boolean cacheAutoComputedBounds = false; @@ -535,6 +543,9 @@ class MasterControl { "forceReleaseView after Canvas3D dispose enabled", "forceReleaseView after Canvas3D dispose disabled"); + releaseBoundingBoxMemory = getBooleanProperty("j3d.releaseBoundingBoxMemory", + releaseBoundingBoxMemory, "releasing memory after bounding box transform"); + useCombiners = getBooleanProperty("j3d.usecombiners", useCombiners, "Using NV_register_combiners if available", "NV_register_combiners disabled"); @@ -1417,7 +1428,7 @@ class MasterControl { } } } - } + } if ((targetThreads & J3dThread.UPDATE_RENDER) != 0) { // Note that we don't check for active view |