From a80051c1ceeb54b84da53b324c243ada64574f6b Mon Sep 17 00:00:00 2001 From: jmekaelthas Date: Mon, 9 Nov 2015 22:17:39 +0100 Subject: [PATCH] Bugfix: very small wight values caused severe animation artifacts. --- .../scene/plugins/blender/meshes/TemporalMesh.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java index d4ef0d1bc..da20d3fb4 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java @@ -46,7 +46,9 @@ import com.jme3.scene.plugins.blender.objects.Properties; */ public class TemporalMesh extends Geometry { private static final Logger LOGGER = Logger.getLogger(TemporalMesh.class.getName()); - + /** A minimum weight value. */ + private static final double MINIMUM_BONE_WEIGHT = FastMath.DBL_EPSILON; + /** The blender context. */ protected final BlenderContext blenderContext; @@ -530,7 +532,11 @@ public class TemporalMesh extends Geometry { for (Entry entry : boneIndexes.entrySet()) { if (vertexGroupsForVertex.containsKey(entry.getKey())) { float weight = vertexGroupsForVertex.get(entry.getKey()); - if (weight > 0) {// no need to use such weights + if (weight > MINIMUM_BONE_WEIGHT) { + // only values of weight greater than MINIMUM_BONE_WEIGHT are used + // if all non zero weights were used, and they were samm enough, problems with normalisation would occur + // because adding a very small value to 1.0 will give 1.0 + // so in order to avoid such errors, which can cause severe animation artifacts we need to use some minimum weight value boneBuffersForVertex.put(weight, entry.getValue()); } }