From 6aefda2e38750234aa6fb2710747b24ad89603b4 Mon Sep 17 00:00:00 2001 From: "Sha..rd" Date: Mon, 10 Sep 2012 23:09:52 +0000 Subject: [PATCH] * BatchNode / GeometryBatchFactory now batch animated models correctly. Note that any control(s) are removed during the batching process, and must be re-added after batching for animation to work. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9712 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core/com/jme3/scene/BatchNode.java | 4 ++++ engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/engine/src/core/com/jme3/scene/BatchNode.java b/engine/src/core/com/jme3/scene/BatchNode.java index 6be339992..2f7d983e1 100644 --- a/engine/src/core/com/jme3/scene/BatchNode.java +++ b/engine/src/core/com/jme3/scene/BatchNode.java @@ -414,6 +414,7 @@ public class BatchNode extends Node implements Savable { int totalVerts = 0; int totalTris = 0; int totalLodLevels = 0; + int maxWeights = -1; Mesh.Mode mode = null; for (Geometry geom : geometries) { @@ -450,6 +451,8 @@ public class BatchNode extends Node implements Savable { compsForBuf[vb.getBufferType().ordinal()] = vb.getNumComponents(); formatForBuf[vb.getBufferType().ordinal()] = vb.getFormat(); } + + maxWeights = Math.max(maxWeights, geom.getMesh().getMaxNumWeights()); if (mode != null && mode != listMode) { throw new UnsupportedOperationException("Cannot combine different" @@ -459,6 +462,7 @@ public class BatchNode extends Node implements Savable { compsForBuf[VertexBuffer.Type.Index.ordinal()] = components; } + outMesh.setMaxNumWeights(maxWeights); outMesh.setMode(mode); if (totalVerts >= 65536) { // make sure we create an UnsignedInt buffer so diff --git a/engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java b/engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java index 7cc09ef15..ef9f2bbbc 100644 --- a/engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java +++ b/engine/src/tools/jme3tools/optimize/GeometryBatchFactory.java @@ -99,6 +99,7 @@ public class GeometryBatchFactory { int totalVerts = 0; int totalTris = 0; int totalLodLevels = 0; + int maxWeights = -1; Mode mode = null; for (Geometry geom : geometries) { @@ -133,6 +134,8 @@ public class GeometryBatchFactory { compsForBuf[vb.getBufferType().ordinal()] = vb.getNumComponents(); formatForBuf[vb.getBufferType().ordinal()] = vb.getFormat(); } + + maxWeights = Math.max(maxWeights, geom.getMesh().getMaxNumWeights()); if (mode != null && mode != listMode) { throw new UnsupportedOperationException("Cannot combine different" @@ -142,6 +145,7 @@ public class GeometryBatchFactory { compsForBuf[Type.Index.ordinal()] = components; } + outMesh.setMaxNumWeights(maxWeights); outMesh.setMode(mode); if (totalVerts >= 65536) { // make sure we create an UnsignedInt buffer so