diff options
author | Sven Gothel <[email protected]> | 2023-09-03 08:33:57 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-09-03 08:33:57 +0200 |
commit | 604b7cd0a4062a5aa44d669a51882f7f80efd08f (patch) | |
tree | d3016b291eacf221d8d4f132c02889754c945345 | |
parent | deeb9db8ed288dcfbbb478c01b4508a691d81b80 (diff) |
GraphUI Shape.ZAscendingComparator: Use (faster) FloatUtil.isEqual2(a,b) and consider Z-scaling
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/Shape.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java index b3fc72467..b1e4081db 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java @@ -448,6 +448,13 @@ public abstract class Shape { return box.getHeight() * getScale().y(); } + public final float getScaledDepth() { + return box.getDepth() * getScale().z(); + } + private final float getScaledMinZ() { + return box.getMinZ() * getScale().z(); + } + /** * Returns the unscaled bounding {@link AABBox} for this shape. * @@ -1514,9 +1521,9 @@ public abstract class Shape { public static Comparator<Shape> ZAscendingComparator = new Comparator<Shape>() { @Override public int compare(final Shape s1, final Shape s2) { - final float s1Z = s1.getBounds().getMinZ()+s1.getPosition().z(); - final float s2Z = s2.getBounds().getMinZ()+s2.getPosition().z(); - if( FloatUtil.isEqual(s1Z, s2Z, FloatUtil.EPSILON) ) { + final float s1Z = s1.getScaledMinZ()+s1.getPosition().z(); + final float s2Z = s2.getScaledMinZ()+s2.getPosition().z(); + if( FloatUtil.isEqual2(s1Z, s2Z) ) { return 0; } else if( s1Z < s2Z ){ return -1; |