From eff91a9e29fc97d7e5051d9900e79ba9d044fb3a Mon Sep 17 00:00:00 2001 From: Sven Göthel Date: Mon, 5 Feb 2024 17:23:41 +0100 Subject: 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 .. --- src/graphui/classes/com/jogamp/graph/ui/Group.java | 11 ++++++-- src/graphui/classes/com/jogamp/graph/ui/Scene.java | 6 ++++- src/graphui/classes/com/jogamp/graph/ui/Shape.java | 15 +++++++++-- src/graphui/classes/jogamp/graph/ui/TreeTool.java | 30 ++++++++++++++++++++++ 4 files changed, 57 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 iShapes = renderedShapes == renderedShapesB0 ? renderedShapesB1 : renderedShapesB0; iShapes.clear(); @@ -412,7 +413,7 @@ public class Group extends Shape implements Container { for(int i=0; i iShapes = renderedShapes == renderedShapesB0 ? renderedShapesB1 : renderedShapesB0; iShapes.clear(); @@ -504,13 +505,16 @@ public final class Scene implements Container, GLEventListener { for(int i=0; i 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 coverage = new ArrayList(); + 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); + } + } + } + } } -- cgit v1.2.3