Bugfix: fixed an error that could create wrogn vertex to bone group assignment. This caused animation to be played badly because some vertices remained in their places instead of moving with the proper bone.
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10463 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
23c1fddf8f
commit
3888036176
@ -31,17 +31,6 @@
|
||||
*/
|
||||
package com.jme3.scene.plugins.blender.animations;
|
||||
|
||||
import com.jme3.animation.Bone;
|
||||
import com.jme3.animation.BoneTrack;
|
||||
import com.jme3.animation.Skeleton;
|
||||
import com.jme3.math.Matrix4f;
|
||||
import com.jme3.scene.Spatial;
|
||||
import com.jme3.scene.plugins.blender.AbstractBlenderHelper;
|
||||
import com.jme3.scene.plugins.blender.BlenderContext;
|
||||
import com.jme3.scene.plugins.blender.curves.BezierCurve;
|
||||
import com.jme3.scene.plugins.blender.exceptions.BlenderFileException;
|
||||
import com.jme3.scene.plugins.blender.file.Pointer;
|
||||
import com.jme3.scene.plugins.blender.file.Structure;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -49,6 +38,17 @@ import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.jme3.animation.Bone;
|
||||
import com.jme3.animation.BoneTrack;
|
||||
import com.jme3.animation.Skeleton;
|
||||
import com.jme3.math.Matrix4f;
|
||||
import com.jme3.scene.plugins.blender.AbstractBlenderHelper;
|
||||
import com.jme3.scene.plugins.blender.BlenderContext;
|
||||
import com.jme3.scene.plugins.blender.curves.BezierCurve;
|
||||
import com.jme3.scene.plugins.blender.exceptions.BlenderFileException;
|
||||
import com.jme3.scene.plugins.blender.file.Pointer;
|
||||
import com.jme3.scene.plugins.blender.file.Structure;
|
||||
|
||||
/**
|
||||
* This class defines the methods to calculate certain aspects of animation and
|
||||
* armature functionalities.
|
||||
|
@ -314,9 +314,10 @@ import com.jme3.util.BufferUtils;
|
||||
List<Structure> dw = pDW.fetchData(blenderContext.getInputStream());
|
||||
for (Structure deformWeight : dw) {
|
||||
Integer boneIndex = groupToBoneIndexMap.get(((Number) deformWeight.getFieldValue("def_nr")).intValue());
|
||||
// null here means that we came accross group that has no bone attached to
|
||||
if (boneIndex != null) {
|
||||
float weight = ((Number) deformWeight.getFieldValue("weight")).floatValue();
|
||||
float weight = ((Number) deformWeight.getFieldValue("weight")).floatValue();
|
||||
// boneIndex == null: it here means that we came accross group that has no bone attached to, so simply ignore it
|
||||
// if weight == 0 and weightIndex == 0 then ignore the weight (do not set weight = 0 as a first weight)
|
||||
if (boneIndex != null && (weight > 0.0f || weightIndex > 0)) {
|
||||
if (weightIndex < MAXIMUM_WEIGHTS_PER_VERTEX) {
|
||||
if (weight == 0.0f) {
|
||||
boneIndex = Integer.valueOf(0);
|
||||
@ -341,8 +342,8 @@ import com.jme3.util.BufferUtils;
|
||||
weightToIndexMap.put(weight, lowestWeightAndIndex.getValue());
|
||||
}
|
||||
}
|
||||
++weightIndex;
|
||||
}
|
||||
++weightIndex;
|
||||
}
|
||||
} else {
|
||||
// 0.0 weight indicates, do not transform this vertex, but keep it in bind pose.
|
||||
|
Loading…
x
Reference in New Issue
Block a user