aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-01-22 05:53:34 +0100
committerSven Göthel <[email protected]>2024-01-22 05:53:34 +0100
commita883f3e2e1563736df32573141fd5119f0678c92 (patch)
tree647dd5b5ec8fcd236406a27ed38d68eda0de5c7a /src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java
parentffe4e670c9d35121934c6f3c95067d9c18aee386 (diff)
Bug 1490 - GraphUI Group: Resolve Performance Issues with Shape Mv Transform -> PMVMatrix4f
Shape.setTransformMv() is called for each renderer frame and for each shape, involving 6 Matrix4f.mul() and set*() operations. Since mutation of shape's position, rotation or scale is less frequent than rendering one frame (for all shapes), it is more efficient to maintain a local Matrix4f and update it on such single mutations. Rendering then only needs to perform one Matrix4f.mul() operation using this internal matrix. +++ Also changes name from setTransformMv(PMVMatrix4f) to applyMatToMv(PMVMatrix4f), as its name might be misleading.
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java b/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java
index 01e9f0611..450b2cda5 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java
@@ -306,7 +306,7 @@ public class AnimGroup extends Group {
* <p>
* The given {@link PMVMatrix4f} has to be setup properly for this object,
* i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene
- * only, without a shape's {@link #setTransformMv(PMVMatrix4f)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}.
+ * only, without a shape's {@link #applyMatToMv(PMVMatrix4f)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}.
* </p>
* @param pixPerMM monitor pixel per millimeter for accurate animation
* @param glp used {@link GLProfile}
@@ -331,7 +331,7 @@ public class AnimGroup extends Group {
refShape.validate(glp);
pmv.pushMv();
{
- refShape.setTransformMv(pmv);
+ refShape.applyMatToMv(pmv);
as = new Set(pixPerMM, refShape.getPixelPerShapeUnit(pmv, viewport, new float[2]), refShape,
accel, velocity, ang_accel, ang_velo,
new ArrayList<ShapeData>(), new AABBox(), lerp);
@@ -347,7 +347,7 @@ public class AnimGroup extends Group {
* <p>
* The given {@link PMVMatrix4f} has to be setup properly for this object,
* i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene
- * only, without a shape's {@link #setTransformMv(PMVMatrix4f)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}.
+ * only, without a shape's {@link #applyMatToMv(PMVMatrix4f)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}.
* </p>
* @param pixPerMM monitor pixel per millimeter for accurate animation
* @param glp used {@link GLProfile}
@@ -381,7 +381,7 @@ public class AnimGroup extends Group {
refShape.validate(glp);
pmv.pushMv();
{
- refShape.setTransformMv(pmv);
+ refShape.applyMatToMv(pmv);
as = new Set(pixPerMM, refShape.getPixelPerShapeUnit(pmv, viewport, new float[2]), refShape,
accel, velocity, ang_accel, ang_velo, allShapes, sourceBounds, lerp);
}
@@ -426,7 +426,7 @@ public class AnimGroup extends Group {
* <p>
* The given {@link PMVMatrix4f} has to be setup properly for this object,
* i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene
- * only, without a shape's {@link #setTransformMv(PMVMatrix4f)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}.
+ * only, without a shape's {@link #applyMatToMv(PMVMatrix4f)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}.
* </p>
* @param pixPerMM monitor pixel per millimeter for accurate animation
* @param glp used {@link GLProfile}
@@ -475,7 +475,7 @@ public class AnimGroup extends Group {
* <p>
* The given {@link PMVMatrix4f} has to be setup properly for this object,
* i.e. its {@link GLMatrixFunc#GL_PROJECTION} and {@link GLMatrixFunc#GL_MODELVIEW} for the surrounding scene
- * only, without a shape's {@link #setTransformMv(PMVMatrix4f)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}.
+ * only, without a shape's {@link #applyMatToMv(PMVMatrix4f)}. See {@link Scene.PMVMatrixSetup#set(PMVMatrix4f, Recti)}.
* </p>
* @param pixPerMM monitor pixel per millimeter for accurate animation
* @param glp used {@link GLProfile}
@@ -633,9 +633,8 @@ public class AnimGroup extends Group {
final Vec3f pos = sd.shape.getPosition().copy();
final Vec3f p_t = sd.targetPos.minus(pos);
final float p_t_diff = p_t.length();
- final Quaternion q = sd.shape.getRotation();
- final Vec3f euler = q.toEuler(new Vec3f());
- final float rotAng = euler.length();
+ final Quaternion q = sd.shape.getRotation().copy();
+ final float rotAng = q.toEuler(new Vec3f()).length();
final float rotAngDiff = Math.min(Math.abs(rotAng), FloatUtil.TWO_PI - Math.abs(rotAng));
final boolean pos_ok = p_t_diff <= AnimGroup.POS_EPS;
final boolean pos_near = pos_ok || p_t_diff <= sd.shape.getBounds().getSize() * shapeScale * 2f;
@@ -649,6 +648,7 @@ public class AnimGroup extends Group {
}
sd.shape.moveTo(sd.targetPos);
q.setIdentity();
+ sd.shape.setRotation(q);
sd.shape.setInteractive(false);
return false;
}
@@ -670,6 +670,7 @@ public class AnimGroup extends Group {
} else {
q.rotateByAngleNormalAxis( rot_step, rotAxis );
}
+ sd.shape.setRotation(q);
}
} else {
if( DEBUG ) {
@@ -682,6 +683,7 @@ public class AnimGroup extends Group {
} else {
q.rotateByAngleNormalAxis( rot_step * 3f, rotAxis );
}
+ sd.shape.setRotation(q);
}
return true;
}