From 124cd55e47761ec18be4131752132a2e20d5108b Mon Sep 17 00:00:00 2001 From: Chien Yang Date: Tue, 4 Dec 2007 05:33:54 +0000 Subject: Fix to Issue 514 : NPE in Wonderland : triggered in cached bounds computation git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@876 ba19aa83-45c5-6ac9-afd3-db810772062c --- src/classes/share/javax/media/j3d/GroupRetained.java | 6 ++++-- src/classes/share/javax/media/j3d/NodeRetained.java | 5 +++-- src/classes/share/javax/media/j3d/Shape3DRetained.java | 7 +++++-- src/classes/share/javax/media/j3d/SharedGroupRetained.java | 3 ++- src/classes/share/javax/media/j3d/SwitchRetained.java | 7 +++++-- src/classes/share/javax/media/j3d/TransformGroupRetained.java | 4 ++-- 6 files changed, 21 insertions(+), 11 deletions(-) (limited to 'src/classes/share/javax/media') diff --git a/src/classes/share/javax/media/j3d/GroupRetained.java b/src/classes/share/javax/media/j3d/GroupRetained.java index f69a14b..c6451a1 100644 --- a/src/classes/share/javax/media/j3d/GroupRetained.java +++ b/src/classes/share/javax/media/j3d/GroupRetained.java @@ -2451,7 +2451,8 @@ class GroupRetained extends NodeRetained implements BHLeafInterface { } } } else { - if (cachedBounds!=null && boundsAutoCompute) { + // Issue 514 : NPE in Wonderland : triggered in cached bounds computation + if (validCachedBounds && boundsAutoCompute) { bounds.combine(cachedBounds); return; } @@ -2483,7 +2484,8 @@ class GroupRetained extends NodeRetained implements BHLeafInterface { Bounds getBounds() { if ( boundsAutoCompute) { - if (cachedBounds!=null) { + // Issue 514 : NPE in Wonderland : triggered in cached bounds computation + if (validCachedBounds) { return (Bounds) cachedBounds.clone(); } diff --git a/src/classes/share/javax/media/j3d/NodeRetained.java b/src/classes/share/javax/media/j3d/NodeRetained.java index 6978854..e287c9b 100644 --- a/src/classes/share/javax/media/j3d/NodeRetained.java +++ b/src/classes/share/javax/media/j3d/NodeRetained.java @@ -141,7 +141,7 @@ abstract class NodeRetained extends SceneGraphObjectRetained implements NnuId { Bounds apiBounds; protected Bounds cachedBounds=null; // Cached auto compute bounds, could we use localBounds ? - + protected boolean validCachedBounds = false; // Fix to Issue 514 /** * Each element, p, of branchGroupPaths is a list of BranchGroup from * root of the tree to this. @@ -957,7 +957,8 @@ abstract class NodeRetained extends SceneGraphObjectRetained implements NnuId { // if the cachedBounds==null. However this is not the case // if the node is the child of a SharedGroup if (VirtualUniverse.mc.cacheAutoComputedBounds) { - cachedBounds = null; + // Issue 514 : NPE in Wonderland : triggered in cached bounds computation + validCachedBounds = false; if (parent!=null) { parent.dirtyBoundsCache(); } diff --git a/src/classes/share/javax/media/j3d/Shape3DRetained.java b/src/classes/share/javax/media/j3d/Shape3DRetained.java index b4ec88c..92a4a49 100644 --- a/src/classes/share/javax/media/j3d/Shape3DRetained.java +++ b/src/classes/share/javax/media/j3d/Shape3DRetained.java @@ -840,7 +840,8 @@ class Shape3DRetained extends LeafRetained { if(boundsAutoCompute) { // System.err.println("getBounds ---- localBounds is " + localBounds); - if (cachedBounds!=null) { + // Issue 514 : NPE in Wonderland : triggered in cached bounds computation + if (validCachedBounds) { return (Bounds) cachedBounds.clone(); } @@ -912,7 +913,9 @@ class Shape3DRetained extends LeafRetained { } } } else { - if (cachedBounds==null) { + // Issue 514 : NPE in Wonderland : triggered in cached bounds computation + if (!validCachedBounds) { + validCachedBounds = true; cachedBounds = new BoundingBox((BoundingBox) null); for(int i=0; i