mirror of
https://github.com/processing/processing4.git
synced 2026-01-29 03:11:08 +01:00
copy geometry to root shape
This commit is contained in:
@@ -615,14 +615,8 @@ public class PShape3D extends PShape {
|
||||
}
|
||||
|
||||
if (parent == null) {
|
||||
initBuffers(vertexCount, indexCount);
|
||||
|
||||
initBuffers(vertexCount, indexCount);
|
||||
copyGeometry(0, vertexCount, vertices, texcoords, colors, normals, indices);
|
||||
|
||||
//int offset = 0;
|
||||
//int size = vertexCount;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,6 +637,7 @@ public class PShape3D extends PShape {
|
||||
}
|
||||
}
|
||||
|
||||
protected int copyOffset;
|
||||
public void aggregate() {
|
||||
if (family == GROUP && parent == null) {
|
||||
// We recursively calculate the total number of vertices and indices.
|
||||
@@ -652,6 +647,9 @@ public class PShape3D extends PShape {
|
||||
|
||||
// Now that we know, we can initialize the buffers with the correct size.
|
||||
initBuffers(vertexCount, indexCount);
|
||||
|
||||
copyOffset = 0;
|
||||
copyGeometryToRoot();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,6 +681,8 @@ public class PShape3D extends PShape {
|
||||
indices[i] = root.indexCount + i;
|
||||
}
|
||||
root.indexCount += indexCount;
|
||||
// parent.indexCount += indexCount; ?
|
||||
// parent.vertexCount += vertexCount; ?
|
||||
|
||||
return indexCount;
|
||||
}
|
||||
@@ -724,6 +724,18 @@ public class PShape3D extends PShape {
|
||||
getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
protected void copyGeometryToRoot() {
|
||||
if (family == GROUP) {
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
PShape3D child = (PShape3D)children[i];
|
||||
child.copyGeometryToRoot();
|
||||
}
|
||||
} else {
|
||||
root.copyGeometry(root.copyOffset, vertexCount, vertices, texcoords, colors, normals, indices);
|
||||
root.copyOffset += vertexCount;
|
||||
}
|
||||
}
|
||||
|
||||
protected void copyGeometry(int offset, int size, float[] vertices, float[] texcoords, float[] colors,
|
||||
float[] normals, int[] indices) {
|
||||
getGl().glBindBuffer(GL.GL_ARRAY_BUFFER, glVertexBufferID);
|
||||
|
||||
Reference in New Issue
Block a user