Bugfix: very small wight values caused severe animation artifacts.

cleanup_build_scripts
jmekaelthas 9 years ago
parent 8752c42aa6
commit a80051c1ce
  1. 8
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java

@ -46,6 +46,8 @@ import com.jme3.scene.plugins.blender.objects.Properties;
*/ */
public class TemporalMesh extends Geometry { public class TemporalMesh extends Geometry {
private static final Logger LOGGER = Logger.getLogger(TemporalMesh.class.getName()); 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. */ /** The blender context. */
protected final BlenderContext blenderContext; protected final BlenderContext blenderContext;
@ -530,7 +532,11 @@ public class TemporalMesh extends Geometry {
for (Entry<String, Integer> entry : boneIndexes.entrySet()) { for (Entry<String, Integer> entry : boneIndexes.entrySet()) {
if (vertexGroupsForVertex.containsKey(entry.getKey())) { if (vertexGroupsForVertex.containsKey(entry.getKey())) {
float weight = vertexGroupsForVertex.get(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()); boneBuffersForVertex.put(weight, entry.getValue());
} }
} }

Loading…
Cancel
Save