Changed Camera.setViewPort(float,float,float,float) to not call onViewPortChage 4 times.

thanks to Lutherion http://jmonkeyengine.org/groups/development-discussion-jme3/forum/topic/possible-bug-with-viewport-on-camera/#post-124630

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7235 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent 7d09cafa71
commit 14e4b79170
  1. 28
      engine/src/core/com/jme3/renderer/Camera.java

@ -207,7 +207,6 @@ public class Camera implements Savable, Cloneable {
protected Matrix4f projectionMatrix = new Matrix4f(); protected Matrix4f projectionMatrix = new Matrix4f();
protected Matrix4f viewProjectionMatrix = new Matrix4f(); protected Matrix4f viewProjectionMatrix = new Matrix4f();
private BoundingBox guiBounding = new BoundingBox(); private BoundingBox guiBounding = new BoundingBox();
/** The camera's name. */ /** The camera's name. */
protected String name; protected String name;
@ -913,10 +912,11 @@ public class Camera implements Savable, Cloneable {
* @param top the top boundary of the viewport (default: 1) * @param top the top boundary of the viewport (default: 1)
*/ */
public void setViewPort(float left, float right, float bottom, float top) { public void setViewPort(float left, float right, float bottom, float top) {
setViewPortLeft(left); this.viewPortLeft = left;
setViewPortRight(right); this.viewPortRight = right;
setViewPortBottom(bottom); this.viewPortBottom = bottom;
setViewPortTop(top); this.viewPortTop = top;
onViewPortChange();
} }
/** /**
@ -983,7 +983,7 @@ public class Camera implements Savable, Cloneable {
return rVal; return rVal;
} }
public boolean containsGui(BoundingVolume bound) { public boolean containsGui(BoundingVolume bound) {
return guiBounding.intersects(bound); return guiBounding.intersects(bound);
} }
@ -1069,15 +1069,15 @@ public class Camera implements Savable, Cloneable {
viewportChanged = true; viewportChanged = true;
setGuiBounding(); setGuiBounding();
} }
private void setGuiBounding() { private void setGuiBounding() {
float sx = width*viewPortLeft; float sx = width * viewPortLeft;
float ex = width*viewPortRight; float ex = width * viewPortRight;
float sy = height*viewPortBottom; float sy = height * viewPortBottom;
float ey = height*viewPortTop; float ey = height * viewPortTop;
float xExtent = (ex-sx)/2; float xExtent = (ex - sx) / 2;
float yExtent = (ey-sy)/2; float yExtent = (ey - sy) / 2;
guiBounding.setCenter(new Vector3f(sx+xExtent, sy+yExtent, 0)); guiBounding.setCenter(new Vector3f(sx + xExtent, sy + yExtent, 0));
guiBounding.setXExtent(xExtent); guiBounding.setXExtent(xExtent);
guiBounding.setYExtent(yExtent); guiBounding.setYExtent(yExtent);
guiBounding.setZExtent(Float.MAX_VALUE); guiBounding.setZExtent(Float.MAX_VALUE);

Loading…
Cancel
Save