From 37e93d30c7c8973a7ae07cd09c5603317cd0e242 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 9 Oct 2006 18:53:41 +0000 Subject: [PATCH] Rather than trying to invert the model transform, just recompute the bounds after temporarily setting the transform to identity. I think there are still issues with JME's bounding volume transformations, but they seem to err on the side of larger bounding volumes. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@45 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/java/com/threerings/jme/model/Model.java | 31 ++++++++++---------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/java/com/threerings/jme/model/Model.java b/src/java/com/threerings/jme/model/Model.java index b9fe4793..49a8e9bc 100644 --- a/src/java/com/threerings/jme/model/Model.java +++ b/src/java/com/threerings/jme/model/Model.java @@ -44,7 +44,6 @@ import java.util.Properties; import com.jme.bounding.BoundingVolume; import com.jme.math.FastMath; -import com.jme.math.Matrix4f; import com.jme.math.Quaternion; import com.jme.math.Vector3f; import com.jme.renderer.Camera; @@ -830,15 +829,22 @@ public class Model extends ModelNode */ protected void storeWorldBound () { - if (worldBound == null) { - return; - } - _rot.set(getWorldRotation()).inverseLocal(); - _scale.set(Vector3f.UNIT_XYZ).divideLocal(getWorldScale()); - _rot.mult(getWorldTranslation(), _trans).multLocal( - _scale).negateLocal(); - _storedBound = worldBound.transform( - _rot, _trans, _scale, _storedBound); + Quaternion orot = new Quaternion(getLocalRotation()); + Vector3f otrans = new Vector3f(getLocalTranslation()), + oscale = new Vector3f(getLocalScale()); + + getLocalRotation().set(Quaternion.IDENTITY); + getLocalTranslation().set(Vector3f.ZERO); + getLocalScale().set(Vector3f.UNIT_XYZ); + + updateWorldData(0f); + updateWorldBound(); + + _storedBound = worldBound.clone(_storedBound); + + getLocalRotation().set(orot); + getLocalTranslation().set(otrans); + getLocalScale().set(oscale); } /** @@ -1016,11 +1022,6 @@ public class Model extends ModelNode /** Whether or not we were outside the frustum at the last update. */ protected boolean _outside; - /** Temporary transform variables. */ - protected Matrix4f _xform = new Matrix4f(); - protected Vector3f _trans = new Vector3f(), _scale = new Vector3f(); - protected Quaternion _rot = new Quaternion(); - /** Animation completion listeners. */ protected ObserverList _animObservers = new ObserverList(ObserverList.FAST_UNSAFE_NOTIFY);