diff options
author | Sven Gothel <[email protected]> | 2023-04-18 05:15:16 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-04-18 05:15:16 +0200 |
commit | c65c750e032118f229050ff8e834961264ed0591 (patch) | |
tree | 8500286ca6086eb21a9b275ccd586185090b1500 /src/jogl/classes/jogamp/graph | |
parent | cd845589eea6c7773007e013bd5f2f37242cbe1a (diff) |
Graph + GraphUI: Consolidate Vertex: Drop SVertex and factory, use Vec[234]f instead of float[] and remove unused VectorUtil methods
After Matrix4f consolidation and proving same or better performance on non array types,
this enhances code readability, simplifies API, reduces bugs and may improve performance.
GraphUI:
- Have RoundButton as a functional class to make a round or rectangular backdrop,
i.e. impl. addShapeToRegion() via reused addRoundShapeToRegion()
Diffstat (limited to 'src/jogl/classes/jogamp/graph')
9 files changed, 118 insertions, 108 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java index d970b7029..c6c7f567c 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java @@ -48,6 +48,8 @@ import com.jogamp.opengl.FBObject; import com.jogamp.opengl.FBObject.Attachment; import com.jogamp.opengl.math.Matrix4f; import com.jogamp.opengl.math.Recti; +import com.jogamp.opengl.math.Vec3f; +import com.jogamp.opengl.math.Vec4f; import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.SyncMatrices4f16; @@ -221,12 +223,12 @@ public final class VBORegion2PMSAAES2 extends GLRegion { } @Override - protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) { - put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords[0], coords[1], coords[2]); - put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams[0], texParams[1], texParams[2]); + protected final void pushVertex(final Vec3f coords, final Vec3f texParams, final Vec4f rgba) { + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams); if( null != gca_ColorsAttr ) { if( null != rgba ) { - put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), rgba[0], rgba[1], rgba[2], rgba[3]); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), rgba); } else { throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode"); } @@ -234,17 +236,17 @@ public final class VBORegion2PMSAAES2 extends GLRegion { } @Override - protected final void pushVertices(final float[] coords1, final float[] coords2, final float[] coords3, - final float[] texParams1, final float[] texParams2, final float[] texParams3, final float[] rgba) { - put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords1[0], coords1[1], coords1[2]); - put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords2[0], coords2[1], coords2[2]); - put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords3[0], coords3[1], coords3[2]); - put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams1[0], texParams1[1], texParams1[2]); - put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams2[0], texParams2[1], texParams2[2]); - put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams3[0], texParams3[1], texParams3[2]); + protected final void pushVertices(final Vec3f coords1, final Vec3f coords2, final Vec3f coords3, + final Vec3f texParams1, final Vec3f texParams2, final Vec3f texParams3, final Vec4f rgba) { + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords1); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords2); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords3); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams1); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams2); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams3); if( null != gca_ColorsAttr ) { if( null != rgba ) { - final float r=rgba[0], g=rgba[1], b=rgba[2], a=rgba[3]; + final float r=rgba.x(), g=rgba.y(), b=rgba.z(), a=rgba.w(); put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java index 889f4448d..1b580437f 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PVBAAES2.java @@ -51,6 +51,8 @@ import com.jogamp.opengl.FBObject.Attachment; import com.jogamp.opengl.FBObject.TextureAttachment; import com.jogamp.opengl.math.Matrix4f; import com.jogamp.opengl.math.Recti; +import com.jogamp.opengl.math.Vec3f; +import com.jogamp.opengl.math.Vec4f; import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.SyncMatrices4f16; @@ -322,19 +324,19 @@ public final class VBORegion2PVBAAES2 extends GLRegion { } @Override - protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) { + protected final void pushVertex(final Vec3f coords, final Vec3f texParams, final Vec4f rgba) { // NIO array[3] is much slows than group/single // gca_VerticesAttr.putf(coords, 0, 3); // gca_CurveParamsAttr.putf(texParams, 0, 3); // gca_VerticesAttr.put3f(coords[0], coords[1], coords[2]); - put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords[0], coords[1], coords[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords); // gca_CurveParamsAttr.put3f(texParams[0], texParams[1], texParams[2]); - put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams[0], texParams[1], texParams[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams); if( null != gca_ColorsAttr ) { if( null != rgba ) { // gca_ColorsAttr.putf(rgba, 0, 4); // gca_ColorsAttr.put4f(rgba[0], rgba[1], rgba[2], rgba[3]); - put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), rgba[0], rgba[1], rgba[2], rgba[3]); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), rgba); } else { throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode"); } @@ -342,23 +344,23 @@ public final class VBORegion2PVBAAES2 extends GLRegion { } @Override - protected final void pushVertices(final float[] coords1, final float[] coords2, final float[] coords3, - final float[] texParams1, final float[] texParams2, final float[] texParams3, final float[] rgba) { + protected final void pushVertices(final Vec3f coords1, final Vec3f coords2, final Vec3f coords3, + final Vec3f texParams1, final Vec3f texParams2, final Vec3f texParams3, final Vec4f rgba) { // gca_VerticesAttr.put3f(coords1[0], coords1[1], coords1[2]); // gca_VerticesAttr.put3f(coords2[0], coords2[1], coords2[2]); // gca_VerticesAttr.put3f(coords3[0], coords3[1], coords3[2]); - put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords1[0], coords1[1], coords1[2]); - put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords2[0], coords2[1], coords2[2]); - put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords3[0], coords3[1], coords3[2]); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords1); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords2); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords3); // gca_CurveParamsAttr.put3f(texParams1[0], texParams1[1], texParams1[2]); // gca_CurveParamsAttr.put3f(texParams2[0], texParams2[1], texParams2[2]); // gca_CurveParamsAttr.put3f(texParams3[0], texParams3[1], texParams3[2]); - put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams1[0], texParams1[1], texParams1[2]); - put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams2[0], texParams2[1], texParams2[2]); - put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams3[0], texParams3[1], texParams3[2]); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams1); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams2); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams3); if( null != gca_ColorsAttr ) { if( null != rgba ) { - final float r=rgba[0], g=rgba[1], b=rgba[2], a=rgba[3]; + final float r=rgba.x(), g=rgba.y(), b=rgba.z(), a=rgba.w(); // gca_ColorsAttr.put4f(r, g, b, a); // gca_ColorsAttr.put4f(r, g, b, a); // gca_ColorsAttr.put4f(r, g, b, a); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java index 9e29821fa..e149203f9 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegionSPES2.java @@ -36,6 +36,8 @@ import com.jogamp.opengl.GL; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.GLUniformData; +import com.jogamp.opengl.math.Vec3f; +import com.jogamp.opengl.math.Vec4f; import jogamp.graph.curve.opengl.shader.AttributeNames; import jogamp.graph.curve.opengl.shader.UniformNames; @@ -172,12 +174,12 @@ public final class VBORegionSPES2 extends GLRegion { } @Override - protected final void pushVertex(final float[] coords, final float[] texParams, final float[] rgba) { - put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords[0], coords[1], coords[2]); - put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams[0], texParams[1], texParams[2]); + protected final void pushVertex(final Vec3f coords, final Vec3f texParams, final Vec4f rgba) { + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams); if( null != gca_ColorsAttr ) { if( null != rgba ) { - put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), rgba[0], rgba[1], rgba[2], rgba[3]); + put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), rgba); } else { throw new IllegalArgumentException("Null color given for COLOR_CHANNEL rendering mode"); } @@ -185,17 +187,17 @@ public final class VBORegionSPES2 extends GLRegion { } @Override - protected final void pushVertices(final float[] coords1, final float[] coords2, final float[] coords3, - final float[] texParams1, final float[] texParams2, final float[] texParams3, final float[] rgba) { - put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords1[0], coords1[1], coords1[2]); - put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords2[0], coords2[1], coords2[2]); - put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords3[0], coords3[1], coords3[2]); - put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams1[0], texParams1[1], texParams1[2]); - put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams2[0], texParams2[1], texParams2[2]); - put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams3[0], texParams3[1], texParams3[2]); + protected final void pushVertices(final Vec3f coords1, final Vec3f coords2, final Vec3f coords3, + final Vec3f texParams1, final Vec3f texParams2, final Vec3f texParams3, final Vec4f rgba) { + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords1); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords2); + put3f((FloatBuffer)gca_VerticesAttr.getBuffer(), coords3); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams1); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams2); + put3f((FloatBuffer)gca_CurveParamsAttr.getBuffer(), texParams3); if( null != gca_ColorsAttr ) { if( null != rgba ) { - final float r=rgba[0], g=rgba[1], b=rgba[2], a=rgba[3]; + final float r=rgba.x(), g=rgba.y(), b=rgba.z(), a=rgba.w(); put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); put4f((FloatBuffer)gca_ColorsAttr.getBuffer(), r, g, b, a); diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java index 715b812c1..9772b860f 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java @@ -36,6 +36,7 @@ import com.jogamp.graph.geom.Outline; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.plane.Winding; +import com.jogamp.opengl.math.Vec2f; import com.jogamp.opengl.math.VectorUtil; import jogamp.opengl.Debug; @@ -145,13 +146,13 @@ public class CDTriangulator2D implements Triangulator { } } if( TEST_ENABLED ) { - final float[] tempV2 = new float[2]; + final Vec2f tempV2 = new Vec2f(); final CDTriangulator2DExpAddOn addOn = new CDTriangulator2DExpAddOn(); final int sinkSize = sink.size(); if( TEST_MARK_LINE ) { for(int i=0; i<sinkSize; i++) { final Triangle t0 = sink.get(i); - addOn.markLineInTriangle(t0, tempV2); + addOn.markLineInTriangle(t0); } } else if ( TEST_LINE_AA ){ for(int i=0; i<sinkSize-1; i+=2) { diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java index a836e2023..86edf7d61 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java @@ -30,7 +30,8 @@ package jogamp.graph.curve.tess; import com.jogamp.graph.geom.Triangle; import com.jogamp.graph.geom.Vertex; -import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.opengl.math.Vec2f; +import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.math.VectorUtil; /** @@ -40,10 +41,10 @@ import com.jogamp.opengl.math.VectorUtil; */ public class CDTriangulator2DExpAddOn { - private final float[] tempV3a = new float[3]; - private final float[] tempV3b = new float[3]; + private final Vec3f tempV3a = new Vec3f(); + private final Vec3f tempV3b = new Vec3f(); - protected final void markLineInTriangle(final Triangle tri1, final float[] tempV2) { + protected final void markLineInTriangle(final Triangle tri1) { if( !tri1.isOnCurve() || !tri1.isLine() ) { return; } @@ -56,19 +57,19 @@ public class CDTriangulator2DExpAddOn { int lineSegCount = 0; final boolean v0IsLS, v1IsLS, v2IsLS; - if( v0.isOnCurve() && VectorUtil.isVec2Zero(v0.getTexCoord(), 0) && !boundVs[0] ) { + if( v0.isOnCurve() && VectorUtil.isVec2Zero(v0.getTexCoord()) && !boundVs[0] ) { v0IsLS = true; lineSegCount++; } else { v0IsLS = false; } - if( v1.isOnCurve() && VectorUtil.isVec2Zero(v1.getTexCoord(), 0) && !boundVs[1] ) { + if( v1.isOnCurve() && VectorUtil.isVec2Zero(v1.getTexCoord()) && !boundVs[1] ) { v1IsLS = true; lineSegCount++; } else { v1IsLS = false; } - if( v2.isOnCurve() && VectorUtil.isVec2Zero(v2.getTexCoord(), 0) && !boundVs[2] ) { + if( v2.isOnCurve() && VectorUtil.isVec2Zero(v2.getTexCoord()) && !boundVs[2] ) { v2IsLS = true; lineSegCount++; } else { @@ -155,17 +156,17 @@ public class CDTriangulator2DExpAddOn { * </p> * @param tri2 * @param checkThisOnCurve - * @param tempV2 temp float[2] storage + * @param temp temp storage */ - protected final float[] processLineAA(final int i, final Triangle tri1, final Triangle tri2, final float[] tempV2) { + protected final Vec2f processLineAA(final int i, final Triangle tri1, final Triangle tri2, final Vec2f temp) { if(CDTriangulator2D.DEBUG){ System.err.println("CDTri.genP2["+i+"].1: ? t1 "+tri1); System.err.println("CDTri.genP2["+i+"].1: ? t2 "+tri2); } - final float[] rect = processLineAAImpl(tri1, tri2, tempV2); + final Vec2f rect = processLineAAImpl(tri1, tri2, temp); if(CDTriangulator2D.DEBUG){ if( null != rect ) { - System.err.println("CDTri.genP2["+i+"].1: RECT ["+rect[0]+", "+rect[1]+"]"); + System.err.println("CDTri.genP2["+i+"].1: RECT ["+rect.x()+", "+rect.y()+"]"); System.err.println("CDTri.genP2["+i+"].1: RECT t1 "+tri1); System.err.println("CDTri.genP2["+i+"].1: RECT t2 "+tri2); } else { @@ -175,40 +176,40 @@ public class CDTriangulator2DExpAddOn { } return rect; } - private final float[] processLineAAImpl(final Triangle tri1, final Triangle tri2, final float[] tempV2) { + private final Vec2f processLineAAImpl(final Triangle tri1, final Triangle tri2, final Vec2f temp) { if( !tri1.isOnCurve() || !tri2.isOnCurve() || !tri1.isLine() || !tri2.isLine() ) { return null; } - final float[] rect; + final Vec2f rect; int eqCount = 0; final int[] commonIdxA = { -1, -1 }; final int[] commonIdxB = { -1, -1 }; final Vertex[] verts1 = tri1.getVertices(); final Vertex[] verts2 = tri2.getVertices(); - float[] coord = verts1[0].getCoord(); - if( VectorUtil.isVec3Equal(coord, 0, verts2[0].getCoord(), 0, FloatUtil.EPSILON) ) { + Vec3f coord = verts1[0].getCoord(); + if( coord.isEqual( verts2[0].getCoord() ) ) { commonIdxA[eqCount] = 0; commonIdxB[eqCount] = 0; eqCount++; - } else if( VectorUtil.isVec3Equal(coord, 0, verts2[1].getCoord(), 0, FloatUtil.EPSILON) ) { + } else if( coord.isEqual( verts2[1].getCoord() ) ) { commonIdxA[eqCount] = 0; commonIdxB[eqCount] = 1; eqCount++; - } else if( VectorUtil.isVec3Equal(coord, 0, verts2[2].getCoord(), 0, FloatUtil.EPSILON) ) { + } else if( coord.isEqual( verts2[2].getCoord() ) ) { commonIdxA[eqCount] = 0; commonIdxB[eqCount] = 2; eqCount++; } coord = verts1[1].getCoord(); - if( VectorUtil.isVec3Equal(coord, 0, verts2[0].getCoord(), 0, FloatUtil.EPSILON) ) { + if( coord.isEqual( verts2[0].getCoord() ) ) { commonIdxA[eqCount] = 1; commonIdxB[eqCount] = 0; eqCount++; - } else if( VectorUtil.isVec3Equal(coord, 0, verts2[1].getCoord(), 0, FloatUtil.EPSILON) ) { + } else if( coord.isEqual( verts2[1].getCoord() ) ) { commonIdxA[eqCount] = 1; commonIdxB[eqCount] = 1; eqCount++; - } else if( VectorUtil.isVec3Equal(coord, 0, verts2[2].getCoord(), 0, FloatUtil.EPSILON) ) { + } else if( coord.isEqual( verts2[2].getCoord() ) ) { commonIdxA[eqCount] = 1; commonIdxB[eqCount] = 2; eqCount++; @@ -218,15 +219,15 @@ public class CDTriangulator2DExpAddOn { otherIdxA = 3 - ( commonIdxA[0] + commonIdxA[1] ); } else { coord = verts1[2].getCoord(); - if( VectorUtil.isVec3Equal(coord, 0, verts2[0].getCoord(), 0, FloatUtil.EPSILON) ) { + if( coord.isEqual( verts2[0].getCoord() ) ) { commonIdxA[eqCount] = 2; commonIdxB[eqCount] = 0; eqCount++; - } else if( VectorUtil.isVec3Equal(coord, 0, verts2[1].getCoord(), 0, FloatUtil.EPSILON) ) { + } else if( coord.isEqual( verts2[1].getCoord() ) ) { commonIdxA[eqCount] = 2; commonIdxB[eqCount] = 1; eqCount++; - } else if( VectorUtil.isVec3Equal(coord, 0, verts2[2].getCoord(), 0, FloatUtil.EPSILON) ) { + } else if( coord.isEqual( verts2[2].getCoord() ) ) { commonIdxA[eqCount] = 2; commonIdxB[eqCount] = 2; eqCount++; @@ -265,30 +266,30 @@ public class CDTriangulator2DExpAddOn { } final float texZTag = 2f; - final float[] vOACoords = vOA.getCoord(); - final float dOC0A = VectorUtil.distVec3(vOACoords, vC0A.getCoord()); - final float dOC1A = VectorUtil.distVec3(vOACoords, vC1A.getCoord()); + final Vec3f vOACoords = vOA.getCoord(); + final float dOC0A = vOACoords.dist( vC0A.getCoord() ); + final float dOC1A = vOACoords.dist( vC1A.getCoord() ); if( false ) { - final float[] vec3Z = { 0f, 0f, -1f }; - final float[] vecLongSide, vecLineHeight; + final Vec3f vec3Z = new Vec3f(0f, 0f, -1f); + final Vec3f vecLongSide, vecLineHeight; if( dOC0A < dOC1A ) { - tempV2[0] = dOC0A; // line width - tempV2[1] = dOC1A; // long side - vecLongSide = VectorUtil.normalizeVec3( VectorUtil.subVec2(tempV3a, vOACoords, vC1A.getCoord()) ); // normal long side vector - vecLineHeight = VectorUtil.crossVec3(tempV3b, vec3Z, tempV3a); // the line-height vector (normal) + temp.set( dOC0A, // line width + dOC1A); // long side + vecLongSide = tempV3a.minus(vOACoords, vC1A.getCoord()).normalize(); // normal long side vector + vecLineHeight = tempV3b.cross(vec3Z, tempV3a); // the line-height vector (normal) vOA.setTexCoord(-1f, -1f, texZTag); vC1A.setTexCoord(1f, -1f, texZTag); vOB.setTexCoord(0f, 1f, texZTag); vC0A.setTexCoord(0f, 1f, texZTag); } else { - tempV2[0] = dOC1A; // line width - tempV2[1] = dOC0A; // long side - vecLongSide = VectorUtil.normalizeVec3( VectorUtil.subVec2(tempV3a, vOACoords, vC0A.getCoord()) ); // normal long side vector - vecLineHeight = VectorUtil.crossVec3(tempV3b, vec3Z, tempV3a); // the line-height vector (normal) + temp.set( dOC1A, // line width + dOC0A); // long side + vecLongSide = tempV3a.minus(vOACoords, vC0A.getCoord()).normalize(); // normal long side vector + vecLineHeight = tempV3b.cross(vec3Z, tempV3a); // the line-height vector (normal) } if(CDTriangulator2D.DEBUG){ - System.err.println("RECT.0 : long-side-vec "+vecLongSide[0]+", "+vecLongSide[1]+", "+vecLongSide[2]); - System.err.println("RECT.0 : line-height-vec "+vecLineHeight[0]+", "+vecLineHeight[1]+", "+vecLineHeight[2]); + System.err.println("RECT.0 : long-side-vec "+vecLongSide); + System.err.println("RECT.0 : line-height-vec "+vecLineHeight); } } else { @@ -303,16 +304,16 @@ public class CDTriangulator2DExpAddOn { final Vertex vL1, vL2, vR1, vR2; if( dOC0A < dOC1A ) { lineWidth = dOC0A; // line width - tempV2[0] = dOC0A; // line width - tempV2[1] = dOC1A; // long side + temp.set( dOC0A, // line width + dOC1A); // long side // Left: vOA, vC1A // Right: vOB, vC0A vL1 = vOA; vL2 = vC1A; vR1 = vOB; vR2 = vC0A; } else { lineWidth = dOC1A; // line width - tempV2[0] = dOC1A; // line width - tempV2[1] = dOC0A; // long side + temp.set( dOC1A, // line width + dOC0A); // long side // Left: vOB, vC1A // Right: vOA, vC0A vL1 = vOB; vL2 = vC1A; @@ -331,7 +332,7 @@ public class CDTriangulator2DExpAddOn { System.err.println("RECT Right.0: "+vR1+", "+vR2); } } - rect = tempV2; + rect = temp; } else { rect = null; } diff --git a/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java b/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java index 391e71011..275abda23 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/GraphVertex.java @@ -30,6 +30,7 @@ package jogamp.graph.curve.tess; import java.util.ArrayList; import com.jogamp.graph.geom.Vertex; +import com.jogamp.opengl.math.Vec3f; public class GraphVertex { private Vertex point; @@ -44,18 +45,18 @@ public class GraphVertex { return point; } - public float getX(){ - return point.getX(); + public float x(){ + return point.x(); } - public float getY(){ - return point.getY(); + public float y(){ + return point.y(); } - public float getZ(){ - return point.getZ(); + public float z(){ + return point.z(); } - public float[] getCoord() { + public Vec3f getCoord() { return point.getCoord(); } @@ -121,6 +122,7 @@ public class GraphVertex { this.boundaryContained = boundaryContained; } + @Override public String toString() { return "GraphVertex[contained "+boundaryContained+", "+point+"]"; } diff --git a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java index 155fbd18d..1939dcb1e 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/Loop.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/Loop.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.plane.Winding; import com.jogamp.graph.geom.Triangle; +import com.jogamp.opengl.math.Vec3f; import com.jogamp.opengl.math.VectorUtil; import com.jogamp.opengl.math.Vert2fImmutable; import com.jogamp.opengl.math.geom.AABBox; @@ -96,9 +97,9 @@ public class Loop { final int n = vertices.size(); float area = 0.0f; for (int p = n - 1, q = 0; q < n; p = q++) { - final float[] pCoord = vertices.get(p).getCoord(); - final float[] qCoord = vertices.get(q).getCoord(); - area += pCoord[0] * qCoord[1] - qCoord[0] * pCoord[1]; + final Vec3f pCoord = vertices.get(p).getCoord(); + final Vec3f qCoord = vertices.get(q).getCoord(); + area += pCoord.x() * qCoord.y() - qCoord.x() * pCoord.y(); } return area; } @@ -136,7 +137,7 @@ public class Loop { final int max = vertices.size() - 1; for(int index = 0; index <= max; ++index) { final GraphVertex v1 = vertices.get(index); - box.resize(v1.getX(), v1.getY(), v1.getZ()); + box.resize(v1.x(), v1.y(), v1.z()); final HEdge edge = new HEdge(v1, edgeType); @@ -157,7 +158,7 @@ public class Loop { // CCW -> CW for(int index = vertices.size() - 1; index >= 0; --index) { final GraphVertex v1 = vertices.get(index); - box.resize(v1.getX(), v1.getY(), v1.getZ()); + box.resize(v1.x(), v1.y(), v1.z()); final HEdge edge = new HEdge(v1, edgeType); @@ -222,7 +223,7 @@ public class Loop { final GraphVertex nextV = initVertices.get(i+1); for(int pos=0; pos<vertices.size(); pos++) { final GraphVertex cand = vertices.get(pos); - final float distance = VectorUtil.distVec3(v.getCoord(), cand.getCoord()); + final float distance = v.getCoord().dist( cand.getCoord() ); if(distance < minDistance){ for (final GraphVertex vert:vertices){ if(vert == v || vert == nextV || vert == cand) @@ -312,7 +313,7 @@ public class Loop { } public boolean checkInside(final Vertex v) { - if(!box.contains(v.getX(), v.getY(), v.getZ())){ + if(!box.contains(v.x(), v.y(), v.z())){ return false; } @@ -323,8 +324,8 @@ public class Loop { final Vertex v2 = current.getGraphPoint().getPoint(); final Vertex v1 = next.getGraphPoint().getPoint(); - if ( ((v1.getY() > v.getY()) != (v2.getY() > v.getY())) && - (v.getX() < (v2.getX() - v1.getX()) * (v.getY() - v1.getY()) / (v2.getY() - v1.getY()) + v1.getX()) ){ + if ( ((v1.y() > v.y()) != (v2.y() > v.y())) && + (v.x() < (v2.x() - v1.x()) * (v.y() - v1.y()) / (v2.y() - v1.y()) + v1.x()) ){ inside = !inside; } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java index 8a9ad8bab..f7c10c335 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java @@ -213,7 +213,7 @@ class TypecastFont implements Font { glyph_advance = glyph.getAdvanceWidth(); glyph_leftsidebearings = glyph.getLeftSideBearing(); final AABBox sb = glyph.getBBox(); - final OutlineShape s = TypecastRenderer.buildShape(metrics.getUnitsPerEM(), glyph, OutlineShape.getDefaultVertexFactory()); + final OutlineShape s = TypecastRenderer.buildShape(metrics.getUnitsPerEM(), glyph); if( 0 < s.getOutlineVectexCount() ) { glyph_bbox = sb; shape = s; @@ -221,7 +221,7 @@ class TypecastFont implements Font { } else { // non-contour glyph -> whitespace glyph_bbox = new AABBox(0f,0f,0f, glyph_advance, glyph_height, 0f); - shape = TypecastRenderer.buildEmptyShape(metrics.getUnitsPerEM(), glyph_bbox, OutlineShape.getDefaultVertexFactory()); + shape = TypecastRenderer.buildEmptyShape(metrics.getUnitsPerEM(), glyph_bbox); isWhiteSpace = true; } } else { @@ -229,7 +229,7 @@ class TypecastFont implements Font { glyph_advance = getAdvanceWidthFU(glyph_id); glyph_leftsidebearings = 0; glyph_bbox = new AABBox(0f,0f,0f, glyph_advance, glyph_height, 0f); - shape = TypecastRenderer.buildEmptyShape(metrics.getUnitsPerEM(), glyph_bbox, OutlineShape.getDefaultVertexFactory()); + shape = TypecastRenderer.buildEmptyShape(metrics.getUnitsPerEM(), glyph_bbox); isWhiteSpace = true; } KernSubtable kernSub = null; diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java index 7b0e1b5c9..3aa9a1c12 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java @@ -34,7 +34,6 @@ import jogamp.opengl.Debug; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.geom.Vertex; -import com.jogamp.graph.geom.Vertex.Factory; import com.jogamp.opengl.math.geom.AABBox; /** @@ -137,8 +136,8 @@ public class TypecastRenderer { shape.addVertex(0, p3.x/unitsPerEM, p3.y/unitsPerEM, true); } - public static OutlineShape buildEmptyShape(final int unitsPerEM, final AABBox box, final Factory<? extends Vertex> vertexFactory) { - final OutlineShape shape = new OutlineShape(vertexFactory); + public static OutlineShape buildEmptyShape(final int unitsPerEM, final AABBox box) { + final OutlineShape shape = new OutlineShape(); if( PRINT_CODE ) { System.err.printf("%n// Start Empty Shape%n"); } final float x1 = box.getMinX() / unitsPerEM; final float x2 = box.getMaxX() / unitsPerEM; @@ -169,11 +168,11 @@ public class TypecastRenderer { return shape; } - public static OutlineShape buildShape(final int unitsPerEM, final Glyph glyph, final Factory<? extends Vertex> vertexFactory) { + public static OutlineShape buildShape(final int unitsPerEM, final Glyph glyph) { if (glyph == null) { return null; } - final OutlineShape shape = new OutlineShape(vertexFactory); + final OutlineShape shape = new OutlineShape(); if (glyph instanceof T2Glyph) { // Type 1/2: Cubic if( PRINT_CODE ) { System.err.printf("%n// Start Type-2 Shape for Glyph %d%n", glyph.getID()); } |