Bugfix: fixed artifacts that were caused by adding bones with no weight
to bone index buffer.
This commit is contained in:
parent
e6787f5c2e
commit
05bdd7b1c9
@ -518,9 +518,15 @@ public class TemporalMesh extends Geometry {
|
||||
Map<String, Float> vertexGroupsForVertex = vertexGroups.get(vertIndex);
|
||||
for (Entry<String, Integer> entry : boneIndexes.entrySet()) {
|
||||
if (vertexGroupsForVertex.containsKey(entry.getKey())) {
|
||||
boneBuffersForVertex.put(vertexGroupsForVertex.get(entry.getKey()), entry.getValue());
|
||||
float weight = vertexGroupsForVertex.get(entry.getKey());
|
||||
if(weight > 0) {// no need to use such weights
|
||||
boneBuffersForVertex.put(weight, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(boneBuffersForVertex.size() == 0) {// attach the vertex to zero-indexed bone so that it does not collapse to (0, 0, 0)
|
||||
boneBuffersForVertex.put(1.0f, 0);
|
||||
}
|
||||
boneBuffers.add(boneBuffersForVertex);
|
||||
}
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ import com.jme3.scene.plugins.blender.meshes.TemporalMesh;
|
||||
modifying = useBoneEnvelopes || useVertexGroups;
|
||||
if (modifying) {// if neither option is used the modifier will not modify anything anyway
|
||||
Structure armatureObject = pArmatureObject.fetchData().get(0);
|
||||
|
||||
// load skeleton
|
||||
if(blenderContext.getSkeleton(armatureObject.getOldMemoryAddress()) == null) {
|
||||
LOGGER.fine("Creating new skeleton for armature modifier.");
|
||||
Structure armatureStructure = ((Pointer) armatureObject.getFieldValue("data")).fetchData().get(0);
|
||||
List<Structure> bonebase = ((Structure) armatureStructure.getFieldValue("bonebase")).evaluateListBase();
|
||||
List<Bone> bonesList = new ArrayList<Bone>();
|
||||
@ -65,6 +65,9 @@ import com.jme3.scene.plugins.blender.meshes.TemporalMesh;
|
||||
Bone[] bones = bonesList.toArray(new Bone[bonesList.size()]);
|
||||
skeleton = new Skeleton(bones);
|
||||
blenderContext.setSkeleton(armatureObject.getOldMemoryAddress(), skeleton);
|
||||
} else {
|
||||
skeleton = blenderContext.getSkeleton(armatureObject.getOldMemoryAddress());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
modifying = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user