From a655acb8f0b6ac291ad0aa7f89de74e8a8ad1f21 Mon Sep 17 00:00:00 2001 From: Nehon Date: Fri, 7 Aug 2015 08:34:11 +0200 Subject: [PATCH] BatchNode now preserves the lineWidth for Line meshes when batching. --- .../src/main/java/com/jme3/scene/BatchNode.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/BatchNode.java b/jme3-core/src/main/java/com/jme3/scene/BatchNode.java index 9a920093d..c3a0ab4bb 100644 --- a/jme3-core/src/main/java/com/jme3/scene/BatchNode.java +++ b/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