aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/jogamp/graph/ui
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/jogamp/graph/ui
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/jogamp/graph/ui')
-rw-r--r--src/graphui/classes/jogamp/graph/ui/TreeTool.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/graphui/classes/jogamp/graph/ui/TreeTool.java b/src/graphui/classes/jogamp/graph/ui/TreeTool.java
index dcb847932..979c6a3b1 100644
--- a/src/graphui/classes/jogamp/graph/ui/TreeTool.java
+++ b/src/graphui/classes/jogamp/graph/ui/TreeTool.java
@@ -27,6 +27,7 @@
*/
package jogamp.graph.ui;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
@@ -36,6 +37,7 @@ import com.jogamp.graph.ui.Scene;
import com.jogamp.graph.ui.Shape;
import com.jogamp.graph.ui.Shape.Visitor1;
import com.jogamp.graph.ui.Shape.Visitor2;
+import com.jogamp.math.geom.AABBox;
import com.jogamp.math.util.PMVMatrix4f;
/** Generic static {@link Shape} tree traversal tools, utilized by {@link Scene} and {@link Container} implementations. */
@@ -245,4 +247,32 @@ public class TreeTool {
});
return res[0];
}
+
+ public static boolean isCovered(final List<AABBox> coverage, final AABBox box) {
+ for(final AABBox b : coverage) {
+ if( b.contains(box) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static void cullShapes(final Shape[] shapesZAsc, final int shapeCount) {
+ final List<AABBox> coverage = new ArrayList<AABBox>();
+ for(int i=shapeCount-1; i>=0; --i) {
+ final Shape s = shapesZAsc[i];
+ if( coverage.size() == 0 ) {
+ coverage.add(s.getBounds());
+ s.setDiscarded(false);
+ } else {
+ final AABBox b = s.getBounds();
+ if( isCovered(coverage, b) ) {
+ s.setDiscarded(true);
+ } else {
+ coverage.add(b);
+ s.setDiscarded(false);
+ }
+ }
+ }
+ }
}