Skip to content

Commit 877ab36

Browse files
committed
save the sphere detail from the renderer when creating a PShape (or pass
it as a parameter to createShape)
1 parent 58a826c commit 877ab36

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

core/src/processing/core/PShape.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ public class PShape implements PConstants {
166166
protected int emissiveColor;
167167
protected float shininess;
168168

169+
protected int sphereDetailU, sphereDetailV;
170+
169171
/** Temporary toggle for whether styles should be honored. */
170172
protected boolean style = true;
171173

core/src/processing/opengl/PGraphics3D.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static protected PShapeOpenGL createShapeImpl(PApplet parent,
277277
shape = new PShapeOpenGL(parent, PShape.PRIMITIVE);
278278
shape.setKind(BOX);
279279
} else if (kind == SPHERE) {
280-
if (len != 1) {
280+
if (len < 1 || 3 < len) {
281281
showWarning("Wrong number of parameters");
282282
return null;
283283
}

core/src/processing/opengl/PShapeOpenGL.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ public PShapeOpenGL(PApplet parent, int family) {
330330
emissiveColor = pg.emissiveColor;
331331
shininess = pg.shininess;
332332

333+
sphereDetailU = pg.sphereDetailU;
334+
sphereDetailV = pg.sphereDetailV;
335+
333336
normalX = normalY = 0;
334337
normalZ = 1;
335338

@@ -2787,12 +2790,17 @@ protected void tessellateBox() {
27872790

27882791

27892792
protected void tessellateSphere() {
2790-
// Getting sphere detail from renderer. Is this correct?
2791-
int nu = pg.sphereDetailU;
2792-
int nv = pg.sphereDetailV;
27932793
float r = 0;
2794-
if (params.length == 1) {
2794+
int nu = sphereDetailU;
2795+
int nv = sphereDetailV;
2796+
if (1 <= params.length) {
27952797
r = params[0];
2798+
if (params.length == 2) {
2799+
nu = nv = (int)params[1];
2800+
} else if (params.length == 3) {
2801+
nu = (int)params[1];
2802+
nv = (int)params[2];
2803+
}
27962804
}
27972805

27982806
inGeo.setMaterial(fillColor, strokeColor, strokeWeight,

0 commit comments

Comments
 (0)