- fix use of tempVars

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7148 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 14 years ago
parent d80616ef89
commit 3c10d7c16b
  1. 19
      engine/src/desktop-fx/com/jme3/water/SimpleWaterProcessor.java

@ -94,6 +94,9 @@ public class SimpleWaterProcessor implements SceneProcessor {
private Plane refractionClipPlane; private Plane refractionClipPlane;
private float refractionClippingOffset = 0.3f; private float refractionClippingOffset = 0.3f;
private float reflectionClippingOffset = -5f; private float reflectionClippingOffset = -5f;
private Vector3f vect1 = new Vector3f();
private Vector3f vect2 = new Vector3f();
private Vector3f vect3 = new Vector3f();
public SimpleWaterProcessor(AssetManager manager) { public SimpleWaterProcessor(AssetManager manager) {
this.manager = manager; this.manager = manager;
@ -180,16 +183,13 @@ public class SimpleWaterProcessor implements SceneProcessor {
sceneCam.getFrustumRight(), sceneCam.getFrustumRight(),
sceneCam.getFrustumTop(), sceneCam.getFrustumTop(),
sceneCam.getFrustumBottom()); sceneCam.getFrustumBottom());
TempVars vars=TempVars.get();
vars.lock();
// tempVec and calcVect are just temporary vector3f objects // tempVec and calcVect are just temporary vector3f objects
vars.vect1.set( sceneCam.getLocation() ).addLocal( sceneCam.getUp() ); vect1.set(sceneCam.getLocation()).addLocal(sceneCam.getUp());
float planeDistance = plane.pseudoDistance( vars.vect1 ); float planeDistance = plane.pseudoDistance(vect1);
vars.vect2.set(plane.getNormal()).multLocal( planeDistance * 2.0f ); vect2.set(plane.getNormal()).multLocal(planeDistance * 2.0f);
vars.vect3.set( vars.vect1.subtractLocal( vars.vect2 ) ).subtractLocal( loc ).normalizeLocal().negateLocal(); vect3.set(vect1.subtractLocal(vect2)).subtractLocal(loc).normalizeLocal().negateLocal();
// now set the up vector // now set the up vector
reflectionCam.lookAt(targetLocation, vars.vect3); reflectionCam.lookAt(targetLocation, vect3);
vars.unlock();
if (inv) { if (inv) {
reflectionCam.setAxes(reflectionCam.getLeft().negateLocal(), reflectionCam.getUp(), reflectionCam.getDirection().negateLocal()); reflectionCam.setAxes(reflectionCam.getLeft().negateLocal(), reflectionCam.getUp(), reflectionCam.getDirection().negateLocal());
} }
@ -481,9 +481,6 @@ public class SimpleWaterProcessor implements SceneProcessor {
updateClipPlanes(); updateClipPlanes();
} }
/** /**
* Refraction Processor * Refraction Processor
*/ */

Loading…
Cancel
Save