BatchNode and GeometryBatchFactory now can handle normalized buffers.
Also added a check in BatchNode that was present in GeometryBatchFactory
This commit is contained in:
parent
e5cba265eb
commit
d17bdb6485
@ -478,6 +478,7 @@ public class BatchNode extends GeometryGroupNode implements Savable {
|
|||||||
private void mergeGeometries(Mesh outMesh, List<Geometry> geometries) {
|
private void mergeGeometries(Mesh outMesh, List<Geometry> geometries) {
|
||||||
int[] compsForBuf = new int[VertexBuffer.Type.values().length];
|
int[] compsForBuf = new int[VertexBuffer.Type.values().length];
|
||||||
VertexBuffer.Format[] formatForBuf = new VertexBuffer.Format[compsForBuf.length];
|
VertexBuffer.Format[] formatForBuf = new VertexBuffer.Format[compsForBuf.length];
|
||||||
|
boolean[] normForBuf = new boolean[VertexBuffer.Type.values().length];
|
||||||
|
|
||||||
int totalVerts = 0;
|
int totalVerts = 0;
|
||||||
int totalTris = 0;
|
int totalTris = 0;
|
||||||
@ -516,8 +517,15 @@ public class BatchNode extends GeometryGroupNode implements Savable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (VertexBuffer vb : geom.getMesh().getBufferList().getArray()) {
|
for (VertexBuffer vb : geom.getMesh().getBufferList().getArray()) {
|
||||||
|
int currentCompsForBuf = compsForBuf[vb.getBufferType().ordinal()];
|
||||||
|
if (vb.getBufferType() != VertexBuffer.Type.Index && currentCompsForBuf != 0 && currentCompsForBuf != vb.getNumComponents()) {
|
||||||
|
throw new UnsupportedOperationException("The geometry " + geom + " buffer " + vb.getBufferType()
|
||||||
|
+ " has different number of components than the rest of the meshes "
|
||||||
|
+ "(this: " + vb.getNumComponents() + ", expected: " + currentCompsForBuf + ")");
|
||||||
|
}
|
||||||
compsForBuf[vb.getBufferType().ordinal()] = vb.getNumComponents();
|
compsForBuf[vb.getBufferType().ordinal()] = vb.getNumComponents();
|
||||||
formatForBuf[vb.getBufferType().ordinal()] = vb.getFormat();
|
formatForBuf[vb.getBufferType().ordinal()] = vb.getFormat();
|
||||||
|
normForBuf[vb.getBufferType().ordinal()] = vb.isNormalized();
|
||||||
}
|
}
|
||||||
|
|
||||||
maxWeights = Math.max(maxWeights, geom.getMesh().getMaxNumWeights());
|
maxWeights = Math.max(maxWeights, geom.getMesh().getMaxNumWeights());
|
||||||
@ -555,6 +563,7 @@ public class BatchNode extends GeometryGroupNode implements Savable {
|
|||||||
|
|
||||||
VertexBuffer vb = new VertexBuffer(VertexBuffer.Type.values()[i]);
|
VertexBuffer vb = new VertexBuffer(VertexBuffer.Type.values()[i]);
|
||||||
vb.setupData(VertexBuffer.Usage.Dynamic, compsForBuf[i], formatForBuf[i], data);
|
vb.setupData(VertexBuffer.Usage.Dynamic, compsForBuf[i], formatForBuf[i], data);
|
||||||
|
vb.setNormalized(normForBuf[i]);
|
||||||
outMesh.setBuffer(vb);
|
outMesh.setBuffer(vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ public class GeometryBatchFactory {
|
|||||||
public static void mergeGeometries(Collection<Geometry> geometries, Mesh outMesh) {
|
public static void mergeGeometries(Collection<Geometry> geometries, Mesh outMesh) {
|
||||||
int[] compsForBuf = new int[VertexBuffer.Type.values().length];
|
int[] compsForBuf = new int[VertexBuffer.Type.values().length];
|
||||||
Format[] formatForBuf = new Format[compsForBuf.length];
|
Format[] formatForBuf = new Format[compsForBuf.length];
|
||||||
|
boolean[] normForBuf = new boolean[VertexBuffer.Type.values().length];
|
||||||
|
|
||||||
int totalVerts = 0;
|
int totalVerts = 0;
|
||||||
int totalTris = 0;
|
int totalTris = 0;
|
||||||
@ -140,6 +141,7 @@ public class GeometryBatchFactory {
|
|||||||
}
|
}
|
||||||
compsForBuf[vb.getBufferType().ordinal()] = vb.getNumComponents();
|
compsForBuf[vb.getBufferType().ordinal()] = vb.getNumComponents();
|
||||||
formatForBuf[vb.getBufferType().ordinal()] = vb.getFormat();
|
formatForBuf[vb.getBufferType().ordinal()] = vb.getFormat();
|
||||||
|
normForBuf[vb.getBufferType().ordinal()] = vb.isNormalized();
|
||||||
}
|
}
|
||||||
|
|
||||||
maxWeights = Math.max(maxWeights, geom.getMesh().getMaxNumWeights());
|
maxWeights = Math.max(maxWeights, geom.getMesh().getMaxNumWeights());
|
||||||
@ -177,6 +179,7 @@ public class GeometryBatchFactory {
|
|||||||
|
|
||||||
VertexBuffer vb = new VertexBuffer(Type.values()[i]);
|
VertexBuffer vb = new VertexBuffer(Type.values()[i]);
|
||||||
vb.setupData(Usage.Static, compsForBuf[i], formatForBuf[i], data);
|
vb.setupData(Usage.Static, compsForBuf[i], formatForBuf[i], data);
|
||||||
|
vb.setNormalized(normForBuf[i]);
|
||||||
outMesh.setBuffer(vb);
|
outMesh.setBuffer(vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user