mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
update tex cache when tessellating lines, points
This commit is contained in:
@@ -9140,9 +9140,10 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
if (PGL.MAX_VERTEX_INDEX1 <= nPtVert) {
|
||||
throw new RuntimeException("P3D: error in point tessellation.");
|
||||
}
|
||||
updateTex();
|
||||
int nvertTot = nPtVert * nInVert;
|
||||
int nindTot = 3 * (nPtVert - 1) * nInVert;
|
||||
if (is3D) {
|
||||
if (is3D) {
|
||||
tessellateRoundPoints3D(nvertTot, nindTot, nPtVert);
|
||||
} else if (is2D) {
|
||||
beginNoTex();
|
||||
@@ -9262,7 +9263,8 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
void tessellateSquarePoints() {
|
||||
int nInVert = in.lastVertex - in.firstVertex + 1;
|
||||
if (stroke && 1 <= nInVert) {
|
||||
if (stroke && 1 <= nInVert) {
|
||||
updateTex();
|
||||
int quadCount = nInVert; // Each point generates a separate quad.
|
||||
// Each quad is formed by 5 vertices, the center one
|
||||
// is the input vertex, and the other 4 define the
|
||||
@@ -9271,8 +9273,8 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
// So the quad is formed by 4 triangles, each requires
|
||||
// 3 indices.
|
||||
int nindTot = 12 * quadCount;
|
||||
if (is3D) {
|
||||
tessellateSquarePoints3D(nvertTot, nindTot);
|
||||
if (is3D) {
|
||||
tessellateSquarePoints3D(nvertTot, nindTot);
|
||||
} else if (is2D) {
|
||||
beginNoTex();
|
||||
tessellateSquarePoints2D(nvertTot, nindTot);
|
||||
@@ -9385,12 +9387,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
void tessellateLines() {
|
||||
int nInVert = in.lastVertex - in.firstVertex + 1;
|
||||
if (stroke && 2 <= nInVert) {
|
||||
// Each individual line is formed by two consecutive input vertices.
|
||||
int lineCount = nInVert / 2;
|
||||
if (is3D) {
|
||||
updateTex();
|
||||
int lineCount = nInVert / 2; // Each individual line is formed by two consecutive input vertices.
|
||||
if (is3D) {
|
||||
tessellateLines3D(lineCount);
|
||||
} else if (is2D) {
|
||||
beginNoTex();
|
||||
beginNoTex(); // Line geometry in 2D are stored in the poly array next to the fill triangles, but w/out textures.
|
||||
tessellateLines2D(lineCount);
|
||||
endNoTex();
|
||||
}
|
||||
@@ -9449,8 +9451,9 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
void tessellateLineStrip() {
|
||||
int nInVert = in.lastVertex - in.firstVertex + 1;
|
||||
if (stroke && 2 <= nInVert) {
|
||||
updateTex();
|
||||
int lineCount = nInVert - 1;
|
||||
if (is3D) {
|
||||
if (is3D) {
|
||||
tessellateLineStrip3D(lineCount);
|
||||
} else if (is2D) {
|
||||
beginNoTex();
|
||||
@@ -9510,8 +9513,9 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
void tessellateLineLoop() {
|
||||
int nInVert = in.lastVertex - in.firstVertex + 1;
|
||||
if (stroke && 2 <= nInVert) {
|
||||
updateTex();
|
||||
int lineCount = nInVert;
|
||||
if (is3D) {
|
||||
if (is3D) {
|
||||
tessellateLineLoop3D(lineCount);
|
||||
} else if (is2D) {
|
||||
beginNoTex();
|
||||
@@ -9814,7 +9818,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
// Polygon primitives tessellation
|
||||
|
||||
void tessellateTriangles() {
|
||||
setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1);
|
||||
beginTex();
|
||||
int nInVert = in.lastVertex - in.firstVertex + 1;
|
||||
if (fill && 3 <= nInVert) {
|
||||
int nInInd = nInVert;
|
||||
@@ -9825,12 +9829,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
}
|
||||
partitionRawIndices();
|
||||
}
|
||||
setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1);
|
||||
endTex();
|
||||
tessellateEdges();
|
||||
}
|
||||
|
||||
void tessellateTriangles(int[] indices) {
|
||||
setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1);
|
||||
beginTex();
|
||||
int nInVert = in.lastVertex - in.firstVertex + 1;
|
||||
if (fill && 3 <= nInVert) {
|
||||
int nInInd = indices.length;
|
||||
@@ -9838,12 +9842,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
PApplet.arrayCopy(indices, rawIndices, nInInd);
|
||||
partitionRawIndices();
|
||||
}
|
||||
setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1);
|
||||
endTex();
|
||||
tessellateEdges();
|
||||
}
|
||||
|
||||
void tessellateTriangleFan() {
|
||||
setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1);
|
||||
beginTex();
|
||||
int nInVert = in.lastVertex - in.firstVertex + 1;
|
||||
if (fill && 3 <= nInVert) {
|
||||
int nInInd = 3 * (nInVert - 2);
|
||||
@@ -9856,12 +9860,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
}
|
||||
partitionRawIndices();
|
||||
}
|
||||
setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1);
|
||||
endTex();
|
||||
tessellateEdges();
|
||||
}
|
||||
|
||||
void tessellateTriangleStrip() {
|
||||
setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1);
|
||||
beginTex();
|
||||
int nInVert = in.lastVertex - in.firstVertex + 1;
|
||||
if (fill && 3 <= nInVert) {
|
||||
int nInInd = 3 * (nInVert - 2);
|
||||
@@ -9879,12 +9883,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
}
|
||||
partitionRawIndices();
|
||||
}
|
||||
setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1);
|
||||
endTex();
|
||||
tessellateEdges();
|
||||
}
|
||||
|
||||
void tessellateQuads() {
|
||||
setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1);
|
||||
beginTex();
|
||||
int nInVert = in.lastVertex - in.firstVertex + 1;
|
||||
if (fill && 4 <= nInVert) {
|
||||
int quadCount = nInVert / 4;
|
||||
@@ -9907,12 +9911,12 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
}
|
||||
partitionRawIndices();
|
||||
}
|
||||
setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1);
|
||||
endTex();
|
||||
tessellateEdges();
|
||||
}
|
||||
|
||||
void tessellateQuadStrip() {
|
||||
setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1);
|
||||
beginTex();
|
||||
int nInVert = in.lastVertex - in.firstVertex + 1;
|
||||
if (fill && 4 <= nInVert) {
|
||||
int quadCount = nInVert / 2 - 1;
|
||||
@@ -9935,7 +9939,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
}
|
||||
partitionRawIndices();
|
||||
}
|
||||
setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1);
|
||||
endTex();
|
||||
tessellateEdges();
|
||||
}
|
||||
|
||||
@@ -10063,6 +10067,29 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
rawIndices = temp;
|
||||
}
|
||||
|
||||
void beginTex() {
|
||||
setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1);
|
||||
}
|
||||
|
||||
void endTex() {
|
||||
setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1);
|
||||
}
|
||||
|
||||
void beginNoTex() {
|
||||
prevTexImage = newTexImage;
|
||||
newTexImage = null;
|
||||
setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1);
|
||||
}
|
||||
|
||||
void endNoTex() {
|
||||
setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1);
|
||||
}
|
||||
|
||||
void updateTex() {
|
||||
beginTex();
|
||||
endTex();
|
||||
}
|
||||
|
||||
void setFirstTexIndex(int firstIndex, int firstCache) {
|
||||
if (texCache != null) {
|
||||
firstTexIndex = firstIndex;
|
||||
@@ -10078,24 +10105,14 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
texCache.setLastIndex(lastIndex, lastCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void beginNoTex() {
|
||||
prevTexImage = newTexImage;
|
||||
newTexImage = null;
|
||||
setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1);
|
||||
}
|
||||
|
||||
void endNoTex() {
|
||||
setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
//
|
||||
// Polygon tessellation
|
||||
|
||||
void tessellatePolygon(boolean solid, boolean closed, boolean calcNormals) {
|
||||
setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1);
|
||||
beginTex();
|
||||
|
||||
int nInVert = in.lastVertex - in.firstVertex + 1;
|
||||
|
||||
@@ -10158,8 +10175,8 @@ public class PGraphicsOpenGL extends PGraphics {
|
||||
|
||||
gluTess.endPolygon();
|
||||
}
|
||||
|
||||
setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1);
|
||||
endTex();
|
||||
|
||||
tessellateEdges();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user