From 36db85980bb608e2d427831183cae6dc68c64bde Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Sat, 11 Jun 2011 04:55:03 +0000 Subject: [PATCH] * Fixed issue where Ogre3D models with more than 4 bones per vertex would crash git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7575 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../ogre/com/jme3/scene/plugins/ogre/MeshLoader.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java b/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java index 0e630203c..1ca35b98d 100644 --- a/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java +++ b/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java @@ -359,7 +359,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { weightsFloatData = FloatBuffer.allocate(vertCount * 4); indicesData = ByteBuffer.allocate(vertCount * 4); } - + VertexBuffer weights = new VertexBuffer(Type.BoneWeight); VertexBuffer indices = new VertexBuffer(Type.BoneIndex); @@ -536,18 +536,23 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { int vert = parseInt(vertIndex); float w = parseFloat(weight); byte bone = (byte) parseInt(boneIndex); - + assert bone >= 0; assert vert >= 0 && vert < mesh.getVertexCount(); int i; + float v = 0; // see which weights are unused for a given bone for (i = vert * 4; i < vert * 4 + 4; i++) { - float v = weightsFloatData.get(i); + v = weightsFloatData.get(i); if (v == 0) { break; } } + if (v != 0){ + logger.log(Level.WARNING, "Vertex {0} has more than 4 weights per vertex! Ignoring..", vert); + return; + } weightsFloatData.put(i, w); indicesData.put(i, bone);