From 943e4c805dc48b08db36cf318399bc0b2fd3e0dc Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Wed, 24 Aug 2011 21:25:01 +0000 Subject: [PATCH] Prevent boundingBox to create new vectors in distanceToEdge thanks to maximusgrey http://jmonkeyengine.org/groups/graphics/forum/topic/boudingbox-and-vector3fs/#post-140072 git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8077 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core/com/jme3/bounding/BoundingBox.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/engine/src/core/com/jme3/bounding/BoundingBox.java b/engine/src/core/com/jme3/bounding/BoundingBox.java index 878ba37c2..4ce9df6d3 100644 --- a/engine/src/core/com/jme3/bounding/BoundingBox.java +++ b/engine/src/core/com/jme3/bounding/BoundingBox.java @@ -805,7 +805,10 @@ public class BoundingBox extends BoundingVolume { public float distanceToEdge(Vector3f point) { // compute coordinates of point in box coordinate system - Vector3f closest = point.subtract(center); + TempVars vars= TempVars.get(); + Vector3f closest = vars.vect1; + + point.subtract(center,closest); // project test point onto box float sqrDistance = 0.0f; @@ -840,7 +843,8 @@ public class BoundingBox extends BoundingVolume { sqrDistance += delta * delta; closest.z = zExtent; } - + + vars.release(); return FastMath.sqrt(sqrDistance); }