aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-01-16 08:05:27 +0100
committerSven Göthel <[email protected]>2024-01-16 08:05:27 +0100
commit3336d930e991679eadaa1ff4068cb8d23562b42c (patch)
treecaacf6ab6283c6057094d582fc8ce7a530f2853b /src/graphui/classes
parenta8cf4cd506297cd05175e43eeefa4e6d7eabb960 (diff)
GraphUI Enhance Clipping: Drop 'cullingScale' param, a simple intersection-test against 'clipBox' to discard whole shapes if completely outside is enough.
Commit f06fe57b0ae738870a61700ff2c65680102d9e73 turns out addition of using `clipbBox*cullingScale` for the AABBox contains test was not required to render the new Glyphs in the FontView01 demo 'in time'. A simple intersection-test against 'clipBox' to discard shapes if completely outside is enough, hence dropping the 'cullingScale' parameter - simplifying.
Diffstat (limited to 'src/graphui/classes')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Group.java26
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java13
2 files changed, 11 insertions, 28 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java
index a4451501a..be34ecf3b 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Group.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java
@@ -85,7 +85,6 @@ public class Group extends Shape implements Container {
private boolean widgetMode = false;
private boolean clipOnBounds = false;
private AABBox clipBBox = null;
- private final Vec3f clipCullingScale = new Vec3f();
/**
* Create a group of {@link Shape}s w/o {@link Group.Layout}.
@@ -126,40 +125,34 @@ public class Group extends Shape implements Container {
/**
* Enable {@link AABBox} clipping on {@link #getBounds()} for this group and its shapes as follows
* <ul>
- * <li>Discard {@link Shape} {@link #draw(GL2ES2, RegionRenderer) rendering} if completely outside of {@code clip-box*cullingScale}.</li>
- * <li>Otherwise perform pixel-accurate clipping inside the shader within [{@code clip-box} .. {@code clip-box*cullingScale}].</li>
- * <li>If {@code clip-box} >= {@code clip-box*cullingScale} for all axis, no pixel-accurate clipping is performed as shapes are culled before.</li>
+ * <li>Discard {@link Shape} {@link #draw(GL2ES2, RegionRenderer) rendering} if not intersecting {@code clip-box}.</li>
+ * <li>Otherwise perform pixel-accurate clipping inside the shader to {@code clip-box}.</li>
* </ul>
* <p>
* {@link #setClipBBox(AABBox)} takes precedence over {@link #setClipOnBounds(boolean)}.
* </p>
* @param v boolean to toggle clipping
- * @param cullingScale culling scale factor per axis for the {@code clip-box} to discard {@link #draw(GL2ES2, RegionRenderer) rendering} completely,
- * should be {@code >= 1} for each axis.
* @return this instance for chaining
* @see #setClipBBox(AABBox)
*/
- public Group setClipOnBounds(final boolean v, final Vec3f cullingScale) { clipOnBounds = v; clipCullingScale.set(cullingScale); return this; }
+ public Group setClipOnBounds(final boolean v) { clipOnBounds = v; return this; }
/** Returns {@link #setClipOnBounds(boolean)} value */
public boolean getClipOnBounds() { return clipOnBounds; }
/**
* Enable {@link AABBox} clipping on explicit given pre-multiplied Mv-matrix {@code clip-box} as follows
* <ul>
- * <li>Discard {@link Shape} {@link #draw(GL2ES2, RegionRenderer) rendering} if completely outside of {@code clip-box*cullingScale}.</li>
- * <li>Otherwise perform pixel-accurate clipping inside the shader within [{@code clip-box} .. {@code clip-box*cullingScale}].</li>
- * <li>If {@code clip-box} >= {@code clip-box*cullingScale} for all axis, no pixel-accurate clipping is performed as shapes are culled before.</li>
+ * <li>Discard {@link Shape} {@link #draw(GL2ES2, RegionRenderer) rendering} if not intersecting {@code clip-box}.</li>
+ * <li>Otherwise perform pixel-accurate clipping inside the shader to {@code clip-box}.</li>
* </ul>
* <p>
* {@link #setClipBBox(AABBox)} takes precedence over {@link #setClipOnBounds(boolean)}.
* </p>
* @param v {@link AABBox} pre-multiplied Mv-matrix
- * @param cullingScale culling scale factor per axis for the {@code clip-box} to discard {@link #draw(GL2ES2, RegionRenderer) rendering} completely,
- * should be {@code >= 1} for each axis.
* @return this instance for chaining
* @see #setClipOnBounds(boolean)
*/
- public Group setClipBBox(final AABBox v, final Vec3f cullingScale) { clipBBox = v; clipCullingScale.set(cullingScale); return this; }
+ public Group setClipBBox(final AABBox v) { clipBBox = v; return this; }
/** Returns {@link #setClipBBox(AABBox)} value */
public AABBox getClipBBox() { return clipBBox; }
@@ -293,10 +286,7 @@ public class Group extends Shape implements Container {
final AABBox origClipBox = renderer.getClipBBox();
final AABBox clipBox = useClipBBox ? clipBBox : box.transform(pmv.getMv(), tempBB0);
- if( clipCullingScale.x() > 1f || clipCullingScale.y() > 1f || clipCullingScale.z() > 1f) {
- renderer.setClipBBox( tempBB1.set(clipBox) ); // Mv pre-multiplied AABBox
- } // else clip-box >= 'clip-box*cullingScale' for all axis, no pixel-accurate clipping is performed as shapes are culled before
- clipBox.scale(clipCullingScale.x(), clipCullingScale.y(), clipCullingScale.z());
+ renderer.setClipBBox( tempBB1.set(clipBox) ); // Mv pre-multiplied AABBox
final int shapeCount = shapesS.length;
for(int i=0; i<shapeCount; i++) {
@@ -306,7 +296,7 @@ public class Group extends Shape implements Container {
shape.setTransformMv(pmv);
final AABBox childBox = shape.getBounds();
- if( clipBox.contains( childBox.transform(pmv.getMv(), tempBB0) ) &&
+ if( clipBox.intersects( childBox.transform(pmv.getMv(), tempBB0) ) &&
( !doFrustumCulling || !pmv.getFrustum().isAABBoxOutside( childBox ) ) )
{
shape.draw(gl, renderer);
diff --git a/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java b/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java
index 8336a7631..f84c3cf5a 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/widgets/RangedGroup.java
@@ -50,7 +50,6 @@ import com.jogamp.opengl.util.texture.TextureSequence;
public class RangedGroup extends Widget {
private final Group content;
private final Group clippedContent;
- private final Vec3f clipCullingScale;
private final RangeSlider horizSlider, vertSlider;
private final Vec2f contentPosZero = new Vec2f();
@@ -85,14 +84,10 @@ public class RangedGroup extends Widget {
* @param renderModes Graph's {@link Region} render modes, see {@link GLRegion#create(GLProfile, int, TextureSequence) create(..)}.
* @param content the {@link Group} with content to view
* @param contentSize the fixed size of the clipped content to view, i.e. page-size
- * @param cullingScale culling scale factor per axis for the {@code clip-box} to discard
- * {@link #draw(GL2ES2, RegionRenderer) rendering} completely outside of {@code clip-box*cullingScale}.
- * Pixel-accurate clipping is applied within [{@code clip-box} .. {@code clip-box*cullingScale}] if any scale-axis of {@code cullingScale} > 1.
- * See {@link Group#setClipBBox(AABBox, Vec3f)}.
* @param horizSliderParam optional horizontal slider parameters, null for none
* @param vertSliderParam optional vertical slider parameters, null for none
*/
- public RangedGroup(final int renderModes, final Group content, final Vec2f contentSize, final Vec3f cullingScale,
+ public RangedGroup(final int renderModes, final Group content, final Vec2f contentSize,
final SliderParam horizSliderParam, final SliderParam vertSliderParam)
{
super( new GridLayout(1 + (null != vertSliderParam ? 1 : 0), 0f, 0f, Alignment.None)); // vertical slider adds to the right column
@@ -101,7 +96,6 @@ public class RangedGroup extends Widget {
this.clippedContent.setFixedSize(contentSize);
this.clippedContent.addShape(content);
addShape(clippedContent);
- clipCullingScale = cullingScale;
if( null != horizSliderParam ) {
horizSlider = new RangeSlider(renderModes, horizSliderParam.size,
@@ -141,7 +135,6 @@ public class RangedGroup extends Widget {
public Group getContent() { return content; }
public Vec2f getContentSize() { return clippedContent.getFixedSize(); }
- public Vec3f getClipCullingScale() { return clipCullingScale; }
public Group getClippedContent() { return clippedContent; }
public RangeSlider getHorizSlider() { return horizSlider; }
public RangeSlider getVertSlider() { return vertSlider; }
@@ -173,9 +166,9 @@ public class RangedGroup extends Widget {
if( content.isVisible() ) {
// Mv pre-multiplied AABBox, clippedContent is on same PMV
final AABBox clipBBox = clippedContent.getBounds().transform(renderer.getMatrix().getMv(), tempBB);
- content.setClipBBox(clipBBox, clipCullingScale);
+ content.setClipBBox(clipBBox);
super.drawImpl0(gl, renderer, rgba);
- content.setClipBBox(null, clipCullingScale);
+ content.setClipBBox(null);
}
}
private final AABBox tempBB = new AABBox(); // OK, synchronized