Skip to content

Commit 4de9d85

Browse files
committed
Debugging tesselation update
1 parent 4a6edf4 commit 4de9d85

File tree

3 files changed

+110
-83
lines changed

3 files changed

+110
-83
lines changed

core/src/processing/core/PShape.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,16 +2191,16 @@ public PShape getTessellation() {
21912191
}
21922192

21932193

2194-
public void beginTessellationUpdate() {
2195-
beginTessellationUpdate(TRIANGLES);
2194+
public void beginTessellation() {
2195+
beginTessellation(TRIANGLES);
21962196
}
21972197

21982198

2199-
public void beginTessellationUpdate(int kind) {
2199+
public void beginTessellation(int kind) {
22002200
}
22012201

22022202

2203-
public void endTessellationUpdate() {
2203+
public void endTessellation() {
22042204
}
22052205

22062206

core/src/processing/opengl/PGraphicsOpenGL.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9152,9 +9152,6 @@ static protected class TessGeometry {
91529152
float[] pointOffsets;
91539153
short[] pointIndices;
91549154

9155-
// Temporary array for performance
9156-
float[] selVertices;
9157-
91589155
HashMap<String, float[]> fpolyAttribs = new HashMap<>();
91599156
HashMap<String, int[]> ipolyAttribs = new HashMap<>();
91609157
HashMap<String, byte[]> bpolyAttribs = new HashMap<>();

core/src/processing/opengl/PShapeOpenGL.java

Lines changed: 106 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ public class PShapeOpenGL extends PShape {
306306
private boolean tessUpdate = false;
307307
private int tessKind;
308308

309+
// Temporary array for performance
310+
private float[] selVertices;
309311

310312
PShapeOpenGL() {
311313
}
@@ -1629,10 +1631,10 @@ public int getVertexCount() {
16291631
public PVector getVertex(int index, PVector vec) {
16301632
if (vec == null) vec = new PVector();
16311633
if (root.tessUpdate) {
1632-
int tessIdx = firstPolyVertex + index;
1633-
vec.x = tessGeo.selVertices[4 * tessIdx + 0];
1634-
vec.y = tessGeo.selVertices[4 * tessIdx + 1];
1635-
vec.z = tessGeo.selVertices[4 * tessIdx + 2];
1634+
int tessIdx = getFirstTessVertex() + index;
1635+
vec.x = root.selVertices[4 * tessIdx + 0];
1636+
vec.y = root.selVertices[4 * tessIdx + 1];
1637+
vec.z = root.selVertices[4 * tessIdx + 2];
16361638
} else {
16371639
vec.x = inGeo.vertices[3 * index + 0];
16381640
vec.y = inGeo.vertices[3 * index + 1];
@@ -1645,7 +1647,8 @@ public PVector getVertex(int index, PVector vec) {
16451647
@Override
16461648
public float getVertexX(int index) {
16471649
if (root.tessUpdate) {
1648-
return tessGeo.selVertices[4 * (firstPolyVertex + index) + 0];
1650+
int tessIdx = getFirstTessVertex() + index;
1651+
return root.selVertices[4 * tessIdx + 0];
16491652
} else {
16501653
return inGeo.vertices[3 * index + 0];
16511654
}
@@ -1655,7 +1658,8 @@ public float getVertexX(int index) {
16551658
@Override
16561659
public float getVertexY(int index) {
16571660
if (root.tessUpdate) {
1658-
return tessGeo.selVertices[4 * (firstPolyVertex + index) + 1];
1661+
int tessIdx = getFirstTessVertex() + index;
1662+
return root.selVertices[4 * tessIdx + 1];
16591663
} else {
16601664
return inGeo.vertices[3 * index + 1];
16611665
}
@@ -1665,7 +1669,8 @@ public float getVertexY(int index) {
16651669
@Override
16661670
public float getVertexZ(int index) {
16671671
if (root.tessUpdate) {
1668-
return tessGeo.selVertices[4 * (firstPolyVertex + index) + 2];
1672+
int tessIdx = getFirstTessVertex() + index;
1673+
return root.selVertices[4 * tessIdx + 2];
16691674
} else {
16701675
return inGeo.vertices[3 * index + 2];
16711676
}
@@ -1686,17 +1691,11 @@ public void setVertex(int index, float x, float y, float z) {
16861691
}
16871692

16881693
if (root.tessUpdate) {
1689-
int tessIdx = firstPolyVertex + index;
1690-
tessGeo.selVertices[4 * tessIdx + 0] = x;
1691-
tessGeo.selVertices[4 * tessIdx + 1] = y;
1692-
tessGeo.selVertices[4 * tessIdx + 2] = z;
1693-
if (root.tessKind == TRIANGLES) {
1694-
root.setModifiedPolyVertices(tessIdx, tessIdx);
1695-
} else if (root.tessKind == POINTS) {
1696-
root.setModifiedLineVertices(tessIdx, tessIdx);
1697-
} else {
1698-
root.setModifiedPointVertices(tessIdx, tessIdx);
1699-
}
1694+
int tessIdx = getFirstTessVertex() + index;
1695+
root.selVertices[4 * tessIdx + 0] = x;
1696+
root.selVertices[4 * tessIdx + 1] = y;
1697+
root.selVertices[4 * tessIdx + 2] = z;
1698+
root.setModifiedTessVertex(tessIdx, tessIdx);
17001699
} else {
17011700
if (family == PATH) {
17021701
if (vertexCodes != null && vertexCodeCount > 0 &&
@@ -1727,17 +1726,11 @@ public void setVertex(int index, PVector vec) {
17271726
}
17281727

17291728
if (root.tessUpdate) {
1730-
int tessIdx = firstPolyVertex + index;
1731-
tessGeo.selVertices[4 * tessIdx + 0] = vec.x;
1732-
tessGeo.selVertices[4 * tessIdx + 1] = vec.y;
1733-
tessGeo.selVertices[4 * tessIdx + 2] = vec.z;
1734-
if (root.tessKind == TRIANGLES) {
1735-
root.setModifiedPolyVertices(tessIdx, tessIdx);
1736-
} else if (root.tessKind == POINTS) {
1737-
root.setModifiedLineVertices(tessIdx, tessIdx);
1738-
} else {
1739-
root.setModifiedPointVertices(tessIdx, tessIdx);
1740-
}
1729+
int tessIdx = getFirstTessVertex() + index;
1730+
root.selVertices[4 * tessIdx + 0] = vec.x;
1731+
root.selVertices[4 * tessIdx + 1] = vec.y;
1732+
root.selVertices[4 * tessIdx + 2] = vec.z;
1733+
root.setModifiedTessVertex(tessIdx, tessIdx);
17411734
} else {
17421735
if (family == PATH) {
17431736
if (vertexCodes != null && vertexCodeCount > 0 &&
@@ -1759,6 +1752,25 @@ public void setVertex(int index, PVector vec) {
17591752
}
17601753
}
17611754

1755+
private int getFirstTessVertex() {
1756+
if (root.tessKind == TRIANGLES) {
1757+
return firstPolyVertex;
1758+
} else if (root.tessKind == LINES) {
1759+
return firstLineVertex;
1760+
} else {
1761+
return firstPointVertex;
1762+
}
1763+
}
1764+
1765+
private void setModifiedTessVertex(int first, int last) {
1766+
if (root.tessKind == TRIANGLES) {
1767+
root.setModifiedPolyVertices(first, last);
1768+
} else if (root.tessKind == LINES) {
1769+
root.setModifiedLineVertices(first, last);
1770+
} else {
1771+
root.setModifiedPointVertices(first, last);
1772+
}
1773+
}
17621774

17631775
@Override
17641776
public PVector getNormal(int index, PVector vec) {
@@ -3164,7 +3176,7 @@ public PShape getTessellation() {
31643176

31653177

31663178
@Override
3167-
public void beginTessellationUpdate(int kind) {
3179+
public void beginTessellation(int kind) {
31683180
if (kind != TRIANGLES && kind != LINES && kind != POINTS) {
31693181
throw new IllegalArgumentException("The only valid kinds of geometry for tessellation update are TRIANGLES, LINES, or POINTS.");
31703182
}
@@ -3179,12 +3191,12 @@ public void beginTessellationUpdate(int kind) {
31793191
root.tessKind = is2D() ? TRIANGLES : kind;
31803192

31813193
boolean createBuffer;
3182-
if (root.tessKind == TRIANGLES) {
3194+
if (root.tessKind == TRIANGLES && hasPolys) {
31833195
createBuffer = bufPolyVertex == null;
31843196
if (createBuffer) bufPolyVertex = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
31853197
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyVertex.glId);
31863198
tessGeo.initPolyVerticesBuffer(!createBuffer, false, PGL.glUsageRetained);
3187-
tessGeo.selVertices = tessGeo.polyVertices;
3199+
root.selVertices = tessGeo.polyVertices;
31883200

31893201
createBuffer = bufPolyColor == null;
31903202
if (createBuffer) bufPolyColor = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
@@ -3228,12 +3240,12 @@ public void beginTessellationUpdate(int kind) {
32283240
pgl.bindBuffer(PGL.ARRAY_BUFFER, attrib.buf.glId);
32293241
tessGeo.initPolyAttribsBuffer(attrib, !createBuffer, false, PGL.glUsageRetained);
32303242
}
3231-
} else if (kind == LINES) {
3243+
} else if (root.tessKind == LINES && hasLines) {
32323244
createBuffer = bufLineVertex == null;
32333245
if (createBuffer) bufLineVertex = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
32343246
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineVertex.glId);
32353247
tessGeo.initLineVerticesBuffer(!createBuffer, false, PGL.glUsageRetained);
3236-
tessGeo.selVertices = tessGeo.lineVertices;
3248+
root.selVertices = tessGeo.lineVertices;
32373249

32383250
createBuffer = bufLineColor == null;
32393251
if (createBuffer) bufLineColor = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
@@ -3244,12 +3256,12 @@ public void beginTessellationUpdate(int kind) {
32443256
if (createBuffer) bufLineAttrib = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
32453257
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineAttrib.glId);
32463258
tessGeo.initLineDirectionsBuffer(!createBuffer, false, PGL.glUsageRetained);
3247-
} else if (kind == POINTS) {
3259+
} else if (root.tessKind == POINTS && hasPoints) {
32483260
createBuffer = bufPointVertex == null;
32493261
if (createBuffer) bufPointVertex = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
32503262
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPointVertex.glId);
32513263
tessGeo.initPointVerticesBuffer(!createBuffer, false, PGL.glUsageRetained);
3252-
tessGeo.selVertices = tessGeo.pointVertices;
3264+
root.selVertices = tessGeo.pointVertices;
32533265

32543266
createBuffer = bufPointColor == null;
32553267
if (createBuffer) bufPointColor = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
@@ -3267,9 +3279,9 @@ public void beginTessellationUpdate(int kind) {
32673279
}
32683280

32693281
@Override
3270-
public void endTessellationUpdate() {
3282+
public void endTessellation() {
32713283
if (root.tessUpdate) {
3272-
if (root.tessKind == TRIANGLES) {
3284+
if (root.tessKind == TRIANGLES && hasPolys) {
32733285
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyVertex.glId);
32743286
tessGeo.finalPolyVerticesBuffer(firstModifiedPolyVertex, lastModifiedPolyVertex);
32753287

@@ -3299,7 +3311,7 @@ public void endTessellationUpdate() {
32993311
pgl.bindBuffer(PGL.ARRAY_BUFFER, attrib.buf.glId);
33003312
tessGeo.finalPolyAttribsBuffer(attrib, attrib.firstModified, attrib.lastModified);
33013313
}
3302-
} else if (kind == LINES) {
3314+
} else if (root.tessKind == LINES && hasLines) {
33033315
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineVertex.glId);
33043316
tessGeo.finalLineVerticesBuffer(firstModifiedLineVertex, lastModifiedLineVertex);
33053317

@@ -3308,7 +3320,7 @@ public void endTessellationUpdate() {
33083320

33093321
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineAttrib.glId);
33103322
tessGeo.finalLineDirectionsBuffer(firstModifiedLineAttribute, lastModifiedLineAttribute);
3311-
} else if (kind == POINTS) {
3323+
} else if (root.tessKind == POINTS && hasPoints) {
33123324
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPointVertex.glId);
33133325
tessGeo.finalPointVerticesBuffer(firstModifiedPointVertex, lastModifiedPointVertex);
33143326

@@ -3318,7 +3330,7 @@ public void endTessellationUpdate() {
33183330
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPointAttrib.glId);
33193331
tessGeo.finalPointOffsetsBuffer(firstModifiedPointAttribute, lastModifiedPointAttribute);
33203332
}
3321-
tessGeo.selVertices = null;
3333+
root.selVertices = null;
33223334
root.tessUpdate = false;
33233335

33243336
// To avoid triggering a new tessellation in the draw method.
@@ -4522,93 +4534,111 @@ protected void initBuffers() {
45224534

45234535

45244536
protected void initPolyBuffers() {
4525-
if (bufPolyVertex == null) bufPolyVertex = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
4537+
boolean createBuffer = bufPolyVertex == null;
4538+
if (createBuffer) bufPolyVertex = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
45264539
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyVertex.glId);
45274540
tessGeo.initPolyVerticesBuffer(false, true, PGL.glUsageRetained);
45284541

4529-
if (bufPolyColor == null) bufPolyColor = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
4542+
createBuffer = bufPolyColor == null;
4543+
if (createBuffer) bufPolyColor = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
45304544
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyColor.glId);
4531-
tessGeo.initPolyColorsBuffer(false, true, PGL.glUsageRetained);
4545+
tessGeo.initPolyColorsBuffer(!createBuffer, true, PGL.glUsageRetained);
45324546

4533-
if (bufPolyNormal == null) bufPolyNormal = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 3, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
4547+
createBuffer = bufPolyNormal == null;
4548+
if (createBuffer) bufPolyNormal = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 3, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
45344549
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyNormal.glId);
4535-
tessGeo.initPolyNormalsBuffer(false, true, PGL.glUsageRetained);
4550+
tessGeo.initPolyNormalsBuffer(!createBuffer, true, PGL.glUsageRetained);
45364551

4537-
if (bufPolyTexCoord == null) bufPolyTexCoord = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 2, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
4552+
createBuffer = bufPolyTexCoord == null;
4553+
if (createBuffer) bufPolyTexCoord = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 2, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
45384554
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyTexCoord.glId);
4539-
tessGeo.initPolyTexCoordsBuffer(false, true, PGL.glUsageRetained);
4555+
tessGeo.initPolyTexCoordsBuffer(!createBuffer, true, PGL.glUsageRetained);
45404556

4541-
if (bufPolyAmbient == null) bufPolyAmbient = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
4557+
createBuffer = bufPolyAmbient == null;
4558+
if (createBuffer) bufPolyAmbient = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
45424559
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyAmbient.glId);
4543-
tessGeo.initPolyAmbientBuffer(false, true, PGL.glUsageRetained);
4560+
tessGeo.initPolyAmbientBuffer(!createBuffer, true, PGL.glUsageRetained);
45444561

4545-
if (bufPolySpecular == null) bufPolySpecular = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
4562+
createBuffer = bufPolySpecular == null;
4563+
if (createBuffer) bufPolySpecular = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
45464564
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolySpecular.glId);
4547-
tessGeo.initPolySpecularBuffer(false, true, PGL.glUsageRetained);
4565+
tessGeo.initPolySpecularBuffer(!createBuffer, true, PGL.glUsageRetained);
45484566

4549-
if (bufPolyEmissive == null) bufPolyEmissive = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
4567+
createBuffer = bufPolyEmissive == null;
4568+
if (createBuffer) bufPolyEmissive = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
45504569
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyEmissive.glId);
4551-
tessGeo.initPolyEmissiveBuffer(false, true, PGL.glUsageRetained);
4570+
tessGeo.initPolyEmissiveBuffer(!createBuffer, true, PGL.glUsageRetained);
45524571

4553-
if (bufPolyShininess == null) bufPolyShininess = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
4572+
createBuffer = bufPolyShininess == null;
4573+
if (createBuffer) bufPolyShininess = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
45544574
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyShininess.glId);
4555-
tessGeo.initPolyShininessBuffer(false, true, PGL.glUsageRetained);
4575+
tessGeo.initPolyShininessBuffer(!createBuffer, true, PGL.glUsageRetained);
45564576

45574577
for (String name: polyAttribs.keySet()) {
45584578
VertexAttribute attrib = polyAttribs.get(name);
4559-
if (!attrib.bufferCreated()) attrib.createBuffer(pgl);
4579+
createBuffer = !attrib.bufferCreated();
4580+
if (createBuffer) attrib.createBuffer(pgl);
45604581
pgl.bindBuffer(PGL.ARRAY_BUFFER, attrib.buf.glId);
4561-
tessGeo.initPolyAttribsBuffer(attrib, false, true, PGL.glUsageRetained);
4582+
tessGeo.initPolyAttribsBuffer(attrib, !createBuffer, true, PGL.glUsageRetained);
45624583
}
45634584

45644585
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
45654586

4566-
if (bufPolyIndex == null) bufPolyIndex = new VertexBuffer(pg, PGL.ELEMENT_ARRAY_BUFFER, 1, PGL.SIZEOF_INDEX, PGL.glUsageRetained, true);
4587+
createBuffer = bufPolyIndex == null;
4588+
if (createBuffer) bufPolyIndex = new VertexBuffer(pg, PGL.ELEMENT_ARRAY_BUFFER, 1, PGL.SIZEOF_INDEX, PGL.glUsageRetained, true);
45674589
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, bufPolyIndex.glId);
4568-
tessGeo.initPolyIndicesBuffer(false, true, PGL.glUsageRetained);
4590+
tessGeo.initPolyIndicesBuffer(!createBuffer, true, PGL.glUsageRetained);
45694591
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
45704592
}
45714593

45724594
protected void initLineBuffers() {
4573-
if (bufLineVertex == null) bufLineVertex = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
4595+
boolean createBuffer = bufLineVertex == null;
4596+
if (createBuffer) bufLineVertex = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
45744597
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineVertex.glId);
4575-
tessGeo.initLineVerticesBuffer(false, true, PGL.glUsageRetained);
4598+
tessGeo.initLineVerticesBuffer(!createBuffer, true, PGL.glUsageRetained);
45764599

4577-
if (bufLineColor == null) bufLineColor = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
4600+
createBuffer = bufLineColor == null;
4601+
if (createBuffer) bufLineColor = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
45784602
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineColor.glId);
4579-
tessGeo.initLineColorsBuffer(false, true, PGL.glUsageRetained);
4603+
tessGeo.initLineColorsBuffer(!createBuffer, true, PGL.glUsageRetained);
45804604

4581-
if (bufLineAttrib == null) bufLineAttrib = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
4605+
createBuffer = bufLineAttrib == null;
4606+
if (createBuffer) bufLineAttrib = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
45824607
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineAttrib.glId);
4583-
tessGeo.initLineDirectionsBuffer(false, true, PGL.glUsageRetained);
4608+
tessGeo.initLineDirectionsBuffer(!createBuffer, true, PGL.glUsageRetained);
45844609

45854610
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
45864611

4587-
if (bufLineIndex == null) bufLineIndex = new VertexBuffer(pg, PGL.ELEMENT_ARRAY_BUFFER, 1, PGL.SIZEOF_INDEX, PGL.glUsageRetained, true);
4612+
createBuffer = bufLineIndex == null;
4613+
if (createBuffer) bufLineIndex = new VertexBuffer(pg, PGL.ELEMENT_ARRAY_BUFFER, 1, PGL.SIZEOF_INDEX, PGL.glUsageRetained, true);
45884614
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, bufLineIndex.glId);
4589-
tessGeo.initLineIndicesBuffer(false, true, PGL.glUsageRetained);
4615+
tessGeo.initLineIndicesBuffer(!createBuffer, true, PGL.glUsageRetained);
45904616
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
45914617
}
45924618

45934619

45944620
protected void initPointBuffers() {
4595-
if (bufPointVertex == null) bufPointVertex = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
4621+
boolean createBuffer = bufPointVertex == null;
4622+
if (createBuffer) bufPointVertex = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
45964623
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPointVertex.glId);
4597-
tessGeo.initPointVerticesBuffer(false, true, PGL.glUsageRetained);
4624+
tessGeo.initPointVerticesBuffer(!createBuffer, true, PGL.glUsageRetained);
45984625

4599-
if (bufPointColor == null) bufPointColor = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
4626+
createBuffer = bufPointColor == null;
4627+
if (createBuffer) bufPointColor = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT, PGL.glUsageRetained);
46004628
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPointColor.glId);
4601-
tessGeo.initPointColorsBuffer(false, true, PGL.glUsageRetained);
4629+
tessGeo.initPointColorsBuffer(!createBuffer, true, PGL.glUsageRetained);
46024630

4603-
if (bufPointAttrib == null) bufPointAttrib = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 2, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
4631+
createBuffer = bufPointAttrib == null;
4632+
if (createBuffer) bufPointAttrib = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 2, PGL.SIZEOF_FLOAT, PGL.glUsageRetained);
46044633
pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPointAttrib.glId);
4605-
tessGeo.initPointOffsetsBuffer(false, true, PGL.glUsageRetained);
4634+
tessGeo.initPointOffsetsBuffer(!createBuffer, true, PGL.glUsageRetained);
46064635

46074636
pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
46084637

4609-
if (bufPointIndex == null) bufPointIndex = new VertexBuffer(pg, PGL.ELEMENT_ARRAY_BUFFER, 1, PGL.SIZEOF_INDEX, PGL.glUsageRetained, true);
4638+
createBuffer = bufPointIndex == null;
4639+
if (createBuffer) bufPointIndex = new VertexBuffer(pg, PGL.ELEMENT_ARRAY_BUFFER, 1, PGL.SIZEOF_INDEX, PGL.glUsageRetained, true);
46104640
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, bufPointIndex.glId);
4611-
tessGeo.initPointIndicesBuffer(false, true, PGL.glUsageRetained);
4641+
tessGeo.initPointIndicesBuffer(!createBuffer, true, PGL.glUsageRetained);
46124642
pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
46134643
}
46144644

0 commit comments

Comments
 (0)