Check Culling of Gui Node on Screen Space Now Gui node can have Bucket.Dynamic git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7145 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
fbc980152e
commit
e280c27adf
@ -31,6 +31,7 @@
|
||||
*/
|
||||
package com.jme3.renderer;
|
||||
|
||||
import com.jme3.bounding.BoundingBox;
|
||||
import com.jme3.bounding.BoundingVolume;
|
||||
import com.jme3.export.JmeExporter;
|
||||
import com.jme3.export.JmeImporter;
|
||||
@ -205,6 +206,7 @@ public class Camera implements Savable, Cloneable {
|
||||
protected Matrix4f viewMatrix = new Matrix4f();
|
||||
protected Matrix4f projectionMatrix = new Matrix4f();
|
||||
protected Matrix4f viewProjectionMatrix = new Matrix4f();
|
||||
private BoundingBox guiBounding = new BoundingBox();
|
||||
|
||||
/**
|
||||
* Constructor instantiates a new <code>Camera</code> object. All
|
||||
@ -963,6 +965,10 @@ public class Camera implements Savable, Cloneable {
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public boolean containsGui(BoundingVolume bound) {
|
||||
return guiBounding.intersects(bound);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the view matrix of the camera.
|
||||
* The view matrix transforms world space into eye space.
|
||||
@ -1042,6 +1048,20 @@ public class Camera implements Savable, Cloneable {
|
||||
*/
|
||||
public void onViewPortChange() {
|
||||
viewportChanged = true;
|
||||
setGuiBounding();
|
||||
}
|
||||
|
||||
private void setGuiBounding() {
|
||||
float sx = width*viewPortLeft;
|
||||
float ex = width*viewPortRight;
|
||||
float sy = height*viewPortBottom;
|
||||
float ey = height*viewPortTop;
|
||||
float xExtent = (ex-sx)/2;
|
||||
float yExtent = (ey-sy)/2;
|
||||
guiBounding.setCenter(new Vector3f(sx+xExtent, sy+yExtent, 0));
|
||||
guiBounding.setXExtent(xExtent);
|
||||
guiBounding.setYExtent(yExtent);
|
||||
guiBounding.setZExtent(Float.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,6 +51,7 @@ import com.jme3.renderer.Camera;
|
||||
import com.jme3.renderer.RenderManager;
|
||||
import com.jme3.renderer.ViewPort;
|
||||
import com.jme3.renderer.queue.RenderQueue;
|
||||
import com.jme3.renderer.queue.RenderQueue.Bucket;
|
||||
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
|
||||
import com.jme3.scene.control.Control;
|
||||
import com.jme3.util.TempVars;
|
||||
@ -247,11 +248,15 @@ public abstract class Spatial implements Savable, Cloneable, Collidable {
|
||||
: Camera.FrustumIntersect.Intersects);
|
||||
|
||||
if (frustrumIntersects == Camera.FrustumIntersect.Intersects) {
|
||||
int state = cam.getPlaneState();
|
||||
if (getQueueBucket() == Bucket.Gui) {
|
||||
return cam.containsGui(getWorldBound());
|
||||
} else {
|
||||
int state = cam.getPlaneState();
|
||||
|
||||
frustrumIntersects = cam.contains(getWorldBound());
|
||||
frustrumIntersects = cam.contains(getWorldBound());
|
||||
|
||||
cam.setPlaneState(state);
|
||||
cam.setPlaneState(state);
|
||||
}
|
||||
}
|
||||
|
||||
return frustrumIntersects != Camera.FrustumIntersect.Outside;
|
||||
|
Loading…
x
Reference in New Issue
Block a user