Skip to content

Commit 677338e

Browse files
committed
Handle 2D PATH shapes in PShapeOpenGL
1 parent a498e26 commit 677338e

File tree

1 file changed

+32
-61
lines changed

1 file changed

+32
-61
lines changed

core/src/processing/opengl/PShapeOpenGL.java

Lines changed: 32 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -988,20 +988,32 @@ public void solid(boolean solid) {
988988

989989
@Override
990990
protected void beginContourImpl() {
991+
if (family == PShape.PATH) {
992+
super.beginContourImpl();
993+
return;
994+
}
991995
breakShape = true;
992996
}
993997

994998

995999
@Override
9961000
protected void endContourImpl() {
1001+
if (family == PShape.PATH) {
1002+
super.endContourImpl();
1003+
}
9971004
}
9981005

9991006

10001007
@Override
10011008
public void vertex(float x, float y) {
1009+
if (family == PShape.PATH) {
1010+
super.vertex(x, y);
1011+
return;
1012+
}
10021013
vertexImpl(x, y, 0, 0, 0);
1003-
if (image != null)
1014+
if (image != null) {
10041015
PGraphics.showWarning(PGraphicsOpenGL.MISSING_UV_TEXCOORDS_ERROR);
1016+
}
10051017
}
10061018

10071019

@@ -1013,9 +1025,14 @@ public void vertex(float x, float y, float u, float v) {
10131025

10141026
@Override
10151027
public void vertex(float x, float y, float z) {
1028+
if (family == PShape.PATH) {
1029+
super.vertex(x, y);
1030+
return;
1031+
}
10161032
vertexImpl(x, y, z, 0, 0);
1017-
if (image != null)
1033+
if (image != null) {
10181034
PGraphics.showWarning(PGraphicsOpenGL.MISSING_UV_TEXCOORDS_ERROR);
1035+
}
10191036
}
10201037

10211038

@@ -1493,6 +1510,10 @@ public void bezierDetail(int detail) {
14931510
public void bezierVertex(float x2, float y2,
14941511
float x3, float y3,
14951512
float x4, float y4) {
1513+
if (family == PShape.PATH) {
1514+
super.bezierVertex(x2, y2, x3, y3, x4, y4);
1515+
return;
1516+
}
14961517
bezierVertexImpl(x2, y2, 0,
14971518
x3, y3, 0,
14981519
x4, y4, 0);
@@ -1524,6 +1545,10 @@ protected void bezierVertexImpl(float x2, float y2, float z2,
15241545
@Override
15251546
public void quadraticVertex(float cx, float cy,
15261547
float x3, float y3) {
1548+
if (family == PShape.PATH) {
1549+
super.quadraticVertex(cx, cy, x3, y3);
1550+
return;
1551+
}
15271552
quadraticVertexImpl(cx, cy, 0,
15281553
x3, y3, 0);
15291554
}
@@ -1576,6 +1601,10 @@ public void curveTightness(float tightness) {
15761601

15771602
@Override
15781603
public void curveVertex(float x, float y) {
1604+
if (family == PShape.PATH) {
1605+
super.curveVertex(x, y);
1606+
return;
1607+
}
15791608
curveVertexImpl(x, y, 0);
15801609
}
15811610

@@ -3001,9 +3030,7 @@ protected void tessellateImpl() {
30013030
tessellateSphere();
30023031
}
30033032
} else if (family == PATH) {
3004-
// TODO workaround for vertices being wiped out,
3005-
// but need to identify the real problem here
3006-
if (vertices != null) inGeo.clear();
3033+
inGeo.clear();
30073034
tessellatePath();
30083035
}
30093036

@@ -3385,11 +3412,6 @@ protected void tessellatePath() {
33853412
for (int i = 0; i < vertexCount; i++) {
33863413
inGeo.addVertex(vertices[i][X], vertices[i][Y], VERTEX, false);
33873414
}
3388-
} else { // drawing 3D vertices
3389-
for (int i = 0; i < vertexCount; i++) {
3390-
inGeo.addVertex(vertices[i][X], vertices[i][Y], vertices[i][Z],
3391-
VERTEX, false);
3392-
}
33933415
}
33943416
} else { // coded set of vertices
33953417
int idx = 0;
@@ -3429,57 +3451,6 @@ protected void tessellatePath() {
34293451
idx++;
34303452
break;
34313453

3432-
case BREAK:
3433-
brk = true;
3434-
}
3435-
}
3436-
} else { // tessellating a 3D path
3437-
for (int j = 0; j < vertexCodeCount; j++) {
3438-
switch (vertexCodes[j]) {
3439-
3440-
case VERTEX:
3441-
inGeo.addVertex(vertices[idx][X], vertices[idx][Y],
3442-
vertices[idx][Z], brk);
3443-
brk = false;
3444-
idx++;
3445-
break;
3446-
3447-
case QUADRATIC_VERTEX:
3448-
inGeo.addQuadraticVertex(vertices[idx+0][X],
3449-
vertices[idx+0][Y],
3450-
vertices[idx+0][Z],
3451-
vertices[idx+1][X],
3452-
vertices[idx+1][Y],
3453-
vertices[idx+0][Z],
3454-
brk);
3455-
brk = false;
3456-
idx += 2;
3457-
break;
3458-
3459-
case BEZIER_VERTEX:
3460-
inGeo.addBezierVertex(vertices[idx+0][X],
3461-
vertices[idx+0][Y],
3462-
vertices[idx+0][Z],
3463-
vertices[idx+1][X],
3464-
vertices[idx+1][Y],
3465-
vertices[idx+1][Z],
3466-
vertices[idx+2][X],
3467-
vertices[idx+2][Y],
3468-
vertices[idx+2][Z],
3469-
brk);
3470-
brk = false;
3471-
idx += 3;
3472-
break;
3473-
3474-
case CURVE_VERTEX:
3475-
inGeo.addCurveVertex(vertices[idx][X],
3476-
vertices[idx][Y],
3477-
vertices[idx][Z],
3478-
brk);
3479-
brk = false;
3480-
idx++;
3481-
break;
3482-
34833454
case BREAK:
34843455
brk = true;
34853456
}

0 commit comments

Comments
 (0)