Fixed a IndexOutOfBoundsException when residual weights are present

empirephoenix-patch-1
NemesisMate 8 years ago committed by Rémy Bouquet
parent 893741701b
commit 5d729af1c4
  1. 37
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java

@ -291,27 +291,30 @@ public class MeshHelper extends AbstractBlenderHelper {
Structure defbase = (Structure) parent.getFieldValue("defbase"); Structure defbase = (Structure) parent.getFieldValue("defbase");
List<String> groupNames = new ArrayList<String>(); List<String> groupNames = new ArrayList<String>();
List<Structure> defs = defbase.evaluateListBase(); List<Structure> defs = defbase.evaluateListBase();
for (Structure def : defs) {
groupNames.add(def.getFieldValue("name").toString());
}
Pointer pDvert = (Pointer) meshStructure.getFieldValue("dvert");// dvert = DeformVERTices if(!defs.isEmpty()) {
if (pDvert.isNotNull()) {// assigning weights and bone indices for (Structure def : defs) {
List<Structure> dverts = pDvert.fetchData(); groupNames.add(def.getFieldValue("name").toString());
for (Structure dvert : dverts) { }
Map<String, Float> weightsForVertex = new HashMap<String, Float>();
Pointer pDW = (Pointer) dvert.getFieldValue("dw"); Pointer pDvert = (Pointer) meshStructure.getFieldValue("dvert");// dvert = DeformVERTices
if (pDW.isNotNull()) { if (pDvert.isNotNull()) {// assigning weights and bone indices
List<Structure> dw = pDW.fetchData(); List<Structure> dverts = pDvert.fetchData();
for (Structure deformWeight : dw) { for (Structure dvert : dverts) {
int groupIndex = ((Number) deformWeight.getFieldValue("def_nr")).intValue(); Map<String, Float> weightsForVertex = new HashMap<String, Float>();
float weight = ((Number) deformWeight.getFieldValue("weight")).floatValue(); Pointer pDW = (Pointer) dvert.getFieldValue("dw");
String groupName = groupNames.get(groupIndex); if (pDW.isNotNull()) {
List<Structure> dw = pDW.fetchData();
for (Structure deformWeight : dw) {
int groupIndex = ((Number) deformWeight.getFieldValue("def_nr")).intValue();
float weight = ((Number) deformWeight.getFieldValue("weight")).floatValue();
String groupName = groupNames.get(groupIndex);
weightsForVertex.put(groupName, weight); weightsForVertex.put(groupName, weight);
}
} }
result.add(weightsForVertex);
} }
result.add(weightsForVertex);
} }
} }
} }

Loading…
Cancel
Save