diff options
author | Sven Gothel <[email protected]> | 2023-04-10 06:05:41 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-04-10 06:05:41 +0200 |
commit | 05de3b0797ea2e41462a3a419bccc998c77a30dd (patch) | |
tree | cf50e65df7594fd158dadeca588ca4f380502cd8 /src/graphui/classes/com/jogamp/graph | |
parent | df60909c70b5dba10c9734e0c26d31e0649f4309 (diff) |
GraphUI: Container (Group, Scene): Add removeAllShapes() and expose frustum-culling get/set
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph')
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/Container.java | 9 | ||||
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/Group.java | 21 | ||||
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/Scene.java | 16 |
3 files changed, 43 insertions, 3 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Container.java b/src/graphui/classes/com/jogamp/graph/ui/Container.java index e48476fcf..3cc8e2ce4 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Container.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Container.java @@ -56,10 +56,19 @@ public interface Container { /** Removes all given shapes, w/o {@link Shape#destroy(com.jogamp.opengl.GL2ES2, com.jogamp.graph.curve.opengl.RegionRenderer) destroying} them. */ void removeShapes(Collection<? extends Shape> shapes); + /** Removes all contained shapes, w/o {@link Shape#destroy(com.jogamp.opengl.GL2ES2, com.jogamp.graph.curve.opengl.RegionRenderer) destroying} them. */ + void removeAllShapes(); + boolean contains(Shape s); AABBox getBounds(final PMVMatrix pmv, Shape shape); + /** Enable or disable {@link PMVMatrix#getFrustum()} culling per {@link Shape}. Default is disabled. */ + void setFrustumCullingEnabled(final boolean v); + + /** Return whether {@link #setFrustumCullingEnabled(boolean) frustum culling} is enabled. */ + boolean isFrustumCullingEnabled(); + /** * Traverses through the graph up until {@code shape} and apply {@code action} on it. * @param pmv diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java index aa6952031..ea4a15e67 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Group.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java @@ -121,6 +121,19 @@ public class Group extends Shape implements Container { } @Override + public void removeAllShapes() { + shapes.clear(); + } + + /** Removes all given shapes and destroys them. */ + public void removeAllShapes(final GL2ES2 gl, final RegionRenderer renderer) { + final int count = shapes.size(); + for(int i=count-1; i>=0; --i) { + removeShape(gl, renderer, shapes.get(i)); + } + } + + @Override public boolean hasColorChannel() { return false; // FIXME } @@ -147,7 +160,13 @@ public class Group extends Shape implements Container { } } - private final boolean doFrustumCulling = false; // FIXME + private boolean doFrustumCulling = false; + + @Override + public final void setFrustumCullingEnabled(final boolean v) { doFrustumCulling = v; } + + @Override + public final boolean isFrustumCullingEnabled() { return doFrustumCulling; } @Override protected final void drawImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount, final float[] rgba) { diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java index e1ee538ab..d4c981e62 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java @@ -180,10 +180,10 @@ public final class Scene implements Container, GLEventListener { /** Returns the {@link GL#glClear(int) glClear(..)} mask, see {@link #setClearParams(float[], int)}. */ public final int getClearMask() { return clearMask; } - /** Enable or disable {@link PMVMatrix#getFrustum()} culling per {@link Shape}. Default is disabled. */ + @Override public final void setFrustumCullingEnabled(final boolean v) { doFrustumCulling = v; } - /** Return whether {@link #setFrustumCullingEnabled(boolean) frustum culling} is enabled. */ + @Override public final boolean isFrustumCullingEnabled() { return doFrustumCulling; } public void attachInputListenerTo(final GLWindow window) { @@ -247,6 +247,18 @@ public final class Scene implements Container, GLEventListener { } } @Override + public void removeAllShapes() { + shapes.clear(); + } + /** Removes all given shapes and destroys them. */ + public void removeAllShapes(final GL2ES2 gl) { + final int count = shapes.size(); + for(int i=count-1; i>=0; --i) { + removeShape(gl, shapes.get(i)); + } + } + + @Override public boolean contains(final Shape s) { return false; } |