Skip to content

Commit 4b0d09e

Browse files
committed
setVertex() fix
1 parent 3b61f43 commit 4b0d09e

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

core/src/processing/opengl/PShapeOpenGL.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,10 @@ public void setVertex(int index, float x, float y, float z) {
16641664
}
16651665
vertices[index][X] = x;
16661666
vertices[index][Y] = y;
1667-
if (is3D) vertices[index][Z] = z;
1667+
if (is3D && vertices[index].length > 2) {
1668+
// P3D allows to modify 2D shapes, ignoring the Z coordinate.
1669+
vertices[index][Z] = z;
1670+
}
16681671
} else {
16691672
inGeo.vertices[3 * index + 0] = x;
16701673
inGeo.vertices[3 * index + 1] = y;
@@ -1681,9 +1684,22 @@ public void setVertex(int index, PVector vec) {
16811684
return;
16821685
}
16831686

1684-
inGeo.vertices[3 * index + 0] = vec.x;
1685-
inGeo.vertices[3 * index + 1] = vec.y;
1686-
inGeo.vertices[3 * index + 2] = vec.z;
1687+
if (family == PATH) {
1688+
if (vertexCodes != null && vertexCodeCount > 0 &&
1689+
vertexCodes[index] != VERTEX) {
1690+
PGraphics.showWarning(NOT_A_SIMPLE_VERTEX, "setVertex()");
1691+
return;
1692+
}
1693+
vertices[index][X] = vec.x;
1694+
vertices[index][Y] = vec.y;
1695+
if (is3D && vertices[index].length > 2) {
1696+
vertices[index][Z] = vec.z;
1697+
}
1698+
} else {
1699+
inGeo.vertices[3 * index + 0] = vec.x;
1700+
inGeo.vertices[3 * index + 1] = vec.y;
1701+
inGeo.vertices[3 * index + 2] = vec.z;
1702+
}
16871703
markForTessellation();
16881704
}
16891705

0 commit comments

Comments
 (0)