From d8682c94c3891370f9c8515e85fc69b7d41e80d4 Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Tue, 8 Nov 2011 01:11:29 +0000 Subject: [PATCH] * Fixed crash that happens when an Ogre3D mesh.xml model has an empty boneassignments tag * Fixed issue with AnimControl clones sharing references to the list of AnimEventListeners git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8590 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../src/core/com/jme3/animation/AnimControl.java | 1 + .../com/jme3/scene/plugins/ogre/MeshLoader.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/engine/src/core/com/jme3/animation/AnimControl.java b/engine/src/core/com/jme3/animation/AnimControl.java index ad56f3096..718866345 100644 --- a/engine/src/core/com/jme3/animation/AnimControl.java +++ b/engine/src/core/com/jme3/animation/AnimControl.java @@ -120,6 +120,7 @@ public final class AnimControl extends AbstractControl implements Cloneable { AnimControl clone = (AnimControl) super.clone(); clone.spatial = spatial; clone.channels = new ArrayList(); + clone.listeners = new ArrayList(); if (skeleton != null){ clone.skeleton = new Skeleton(skeleton); 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 db5eba180..016c30c44 100644 --- a/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java +++ b/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java @@ -110,6 +110,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { private Geometry geom; private ByteBuffer indicesData; private FloatBuffer weightsFloatData; + private boolean actuallyHasWeights = false; private int vertCount; private boolean usesSharedVerts; private boolean usesBigIndices; @@ -147,6 +148,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { animData = null; + actuallyHasWeights = false; indicesData = null; weightsFloatData = null; } @@ -278,6 +280,18 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { return; } + if (!actuallyHasWeights){ + // No weights were actually written (the tag didn't have any entries) + // remove those buffers + mesh.clearBuffer(Type.BoneIndex); + mesh.clearBuffer(Type.BoneWeight); + + weightsFloatData = null; + indicesData = null; + + return; + } + //int vertCount = mesh.getVertexCount(); int maxWeightsPerVert = 0; weightsFloatData.rewind(); @@ -310,6 +324,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { } weightsFloatData.rewind(); + actuallyHasWeights = false; weightsFloatData = null; indicesData = null; @@ -531,6 +546,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { weightsFloatData.put(i, w); indicesData.put(i, bone); + actuallyHasWeights = true; } private void startSkeleton(String name) {