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
3.0
mul..va 14 years ago
parent fbc980152e
commit e280c27adf
  1. 20
      engine/src/core/com/jme3/renderer/Camera.java
  2. 15
      engine/src/core/com/jme3/scene/Spatial.java

@ -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
@ -962,6 +964,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.
@ -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();
frustrumIntersects = cam.contains(getWorldBound());
cam.setPlaneState(state);
if (getQueueBucket() == Bucket.Gui) {
return cam.containsGui(getWorldBound());
} else {
int state = cam.getPlaneState();
frustrumIntersects = cam.contains(getWorldBound());
cam.setPlaneState(state);
}
}
return frustrumIntersects != Camera.FrustumIntersect.Outside;

Loading…
Cancel
Save