aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-02-05 17:23:41 +0100
committerSven Göthel <[email protected]>2024-02-05 17:23:41 +0100
commiteff91a9e29fc97d7e5051d9900e79ba9d044fb3a (patch)
treee0c14a3bf3608da6f334e348cacd790061b875b4 /src/graphui/classes/com/jogamp
parent0ac7b2e59d5b41302f8e0ec7596d8f44447cf0a1 (diff)
GraphUI: Add Shape.IO_DISCARDED and update it @ Scene/Group draw(); Prepare for experimental occlusion-culling
TreeTool's cullShapes(), actually a naive dumm occlusion test (*RENAME IT*), would need to realize whether the shape/groups actually cover shapes below, i.e. are not on same Z-Axis and transparent. Hence, this is disabled in code and we rely on the Z buffer still, just an idea ..
Diffstat (limited to 'src/graphui/classes/com/jogamp')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Group.java11
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Scene.java6
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Shape.java15
3 files changed, 27 insertions, 5 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java
index 245400700..f482605ea 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Group.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java
@@ -399,6 +399,7 @@ public class Group extends Shape implements Container {
final Shape[] shapeArray = shapes.toArray(drawShapeArray); // local-backup
drawShapeArray = shapeArray; // keep backup
Arrays.sort(shapeArray, 0, shapeCount, Shape.ZAscendingComparator);
+ // TreeTool.cullShapes(shapeArray, shapeCount);
final List<Shape> iShapes = renderedShapes == renderedShapesB0 ? renderedShapesB1 : renderedShapesB0;
iShapes.clear();
@@ -412,7 +413,7 @@ public class Group extends Shape implements Container {
for(int i=0; i<shapeCount; i++) {
final Shape shape = shapeArray[i];
- if( shape.isVisible() ) {
+ if( shape.isVisible() ) { // && !shape.isDiscarded() ) {
pmv.pushMv();
shape.applyMatToMv(pmv);
@@ -424,6 +425,9 @@ public class Group extends Shape implements Container {
{
shape.draw(gl, renderer);
iShapes.add(shape);
+ shape.setDiscarded(false);
+ } else {
+ shape.setDiscarded(true);
}
pmv.popMv();
}
@@ -432,12 +436,15 @@ public class Group extends Shape implements Container {
} else {
for(int i=0; i<shapeCount; i++) {
final Shape shape = shapeArray[i];
- if( shape.isVisible() ) {
+ if( shape.isVisible() ) { // && !shape.isDiscarded() ) {
pmv.pushMv();
shape.applyMatToMv(pmv);
if( !doFrustumCulling || !pmv.getFrustum().isOutside( shape.getBounds() ) ) {
shape.draw(gl, renderer);
iShapes.add(shape);
+ shape.setDiscarded(false);
+ } else {
+ shape.setDiscarded(true);
}
pmv.popMv();
}
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
index b515a55e6..ff1bebbd5 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
@@ -488,6 +488,7 @@ public final class Scene implements Container, GLEventListener {
final Shape[] shapeArray = shapes.toArray(displayShapeArray); // local-backup
displayShapeArray = shapeArray; // keep backup
Arrays.sort(shapeArray, 0, shapeCount, Shape.ZAscendingComparator);
+ // TreeTool.cullShapes(shapeArray, shapeCount);
final List<Shape> iShapes = renderedShapes == renderedShapesB0 ? renderedShapesB1 : renderedShapesB0;
iShapes.clear();
@@ -504,13 +505,16 @@ public final class Scene implements Container, GLEventListener {
for(int i=0; i<shapeCount; i++) {
final Shape shape = shapeArray[i];
- if( shape.isVisible() ) {
+ if( shape.isVisible() ) { // && !shape.isDiscarded() ) {
pmv.pushMv();
shape.applyMatToMv(pmv);
if( !doFrustumCulling || !pmv.getFrustum().isOutside( shape.getBounds() ) ) {
shape.draw(gl, renderer);
iShapes.add(shape);
+ shape.setDiscarded(false);
+ } else {
+ shape.setDiscarded(true);
}
pmv.popMv();
}
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java
index 183f8901e..6e5a904ee 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java
@@ -270,6 +270,7 @@ public abstract class Shape {
private static final int IO_RESIZABLE = 1 << 5;
private static final int IO_RESIZE_FIXED_RATIO = 1 << 6;
private static final int IO_ACTIVE = 1 << 7;
+ private static final int IO_DISCARDED = 1 << 25;
private static final int IO_DOWN = 1 << 26;
private static final int IO_TOGGLE = 1 << 27;
private static final int IO_DRAG_FIRST = 1 << 28;
@@ -1523,12 +1524,13 @@ public abstract class Shape {
} else {
rotateS = "";
}
- final String activeS = ", active["+(isIO(IO_ACTIVE) ? "SELF," : "")+(isGroup() && isActive()?"GROUP":"")+", adjZ "+getAdjustedZ()+"]";
+ final String discS = isDiscarded()?", DISCARDED":"";
+ final String activeS = isActive()?", ACTIVE[adjZ "+getAdjustedZ()+"]":"";
final String ps = hasPadding() ? padding.toString()+", " : "";
final String bs = hasBorder() ? "border[l "+getBorderThickness()+", c "+getBorderColor()+"], " : "";
final String idS = -1 != id ? ", id "+id : "";
final String nameS = "noname" != name ? ", '"+name+"'" : "";
- return getDirtyString()+idS+nameS+", visible "+isIO(IO_VISIBLE)+activeS+", toggle "+isIO(IO_TOGGLE)+
+ return getDirtyString()+idS+nameS+", visible "+isIO(IO_VISIBLE)+discS+activeS+", toggle "+isIO(IO_TOGGLE)+
", able[toggle "+isIO(IO_TOGGLEABLE)+", iactive "+isInteractive()+", resize "+isResizable()+", drag "+this.isDraggable()+
"], pos["+position+"], "+pivotS+scaleS+rotateS+iMatS+
ps+bs+"box"+box;
@@ -1709,6 +1711,15 @@ public abstract class Shape {
public final boolean isActivable() { return isIO(IO_ACTIVABLE); }
/**
+ * Set whether this shape is discarded in last {@link #draw(GL2ES2, RegionRenderer)},
+ * i.e. culled via frustum or occlusion criteria.
+ */
+ public final Shape setDiscarded(final boolean v) { return setIO(IO_DISCARDED, v); }
+
+ /** Returns whether this shape is discarded in last {@link #draw(GL2ES2, RegionRenderer)}, i.e. culled via frustum or occlusion criteria.*/
+ public final boolean isDiscarded() { return isIO(IO_DISCARDED); }
+
+ /**
* Set whether this shape is draggable,
* i.e. translated by 1-pointer-click and drag.
* <p>