summaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp/graph
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-04-14 17:51:50 +0200
committerSven Gothel <[email protected]>2023-04-14 17:51:50 +0200
commitdfae4e3d9a171d2bba62d828ef4b5ce3980f90a7 (patch)
treed26f26435aa99996a598d8071d7d6ed74260d823 /src/graphui/classes/com/jogamp/graph
parent64c95ce8d90d3b488fa5909603321b377cae7f9f (diff)
GraphUI Group.drawImpl0(): Copy List<Shape> to array and sort using Shape.ZAscendingComparator
- fixes z-order issue, as we shall do same approach as in Scene.display() - fixes mutated container issue if a Shape gets removed or added to original List
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Group.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java
index e748969cf..d89d91c8c 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Group.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java
@@ -28,6 +28,7 @@
package com.jogamp.graph.ui;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
@@ -191,12 +192,16 @@ public class Group extends Shape implements Container {
@Override
public final boolean isFrustumCullingEnabled() { return doFrustumCulling; }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected final void drawImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount, final float[] rgba) {
final PMVMatrix pmv = renderer.getMatrix();
- final int shapeCount = shapes.size();
+ final Object[] shapesS = shapes.toArray();
+ Arrays.sort(shapesS, (Comparator)Shape.ZAscendingComparator);
+
+ final int shapeCount = shapesS.length;
for(int i=0; i<shapeCount; i++) {
- final Shape shape = shapes.get(i);
+ final Shape shape = (Shape) shapesS[i];
if( shape.isEnabled() ) {
pmv.glPushMatrix();
shape.setTransform(pmv);