BatchNode now preserves the lineWidth for Line meshes when batching.

experimental
Nehon 9 years ago
parent a68a9747bb
commit a655acb8f0
  1. 13
      jme3-core/src/main/java/com/jme3/scene/BatchNode.java

@ -444,6 +444,7 @@ public class BatchNode extends GeometryGroupNode {
int maxWeights = -1;
Mesh.Mode mode = null;
float lineWidth = 1f;
for (Geometry geom : geometries) {
totalVerts += geom.getVertexCount();
totalTris += geom.getTriangleCount();
@ -452,6 +453,7 @@ public class BatchNode extends GeometryGroupNode {
maxVertCount = geom.getVertexCount();
}
Mesh.Mode listMode;
float listLineWidth = 1f;
int components;
switch (geom.getMesh().getMode()) {
case Points:
@ -462,6 +464,7 @@ public class BatchNode extends GeometryGroupNode {
case LineStrip:
case Lines:
listMode = Mesh.Mode.Lines;
listLineWidth = geom.getMesh().getLineWidth();
components = 2;
break;
case TriangleFan:
@ -491,13 +494,21 @@ public class BatchNode extends GeometryGroupNode {
if (mode != null && mode != listMode) {
throw new UnsupportedOperationException("Cannot combine different"
+ " primitive types: " + mode + " != " + listMode);
}
}
mode = listMode;
if (mode == Mesh.Mode.Lines) {
if (lineWidth != 1f && listLineWidth != lineWidth) {
throw new UnsupportedOperationException("When using Mesh Line mode, cannot combine meshes with different line width "
+ lineWidth + " != " + listLineWidth);
}
lineWidth = listLineWidth;
}
compsForBuf[VertexBuffer.Type.Index.ordinal()] = components;
}
outMesh.setMaxNumWeights(maxWeights);
outMesh.setMode(mode);
outMesh.setLineWidth(lineWidth);
if (totalVerts >= 65536) {
// make sure we create an UnsignedInt buffer so
// we can fit all of the meshes

Loading…
Cancel
Save