From 5d729af1c47b31f88f4eff62f22c5797e6d1314b Mon Sep 17 00:00:00 2001 From: NemesisMate Date: Fri, 14 Apr 2017 09:07:05 +0100 Subject: [PATCH] Fixed a IndexOutOfBoundsException when residual weights are present --- .../plugins/blender/meshes/MeshHelper.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java index 49482c87f..4fcab8723 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java +++ b/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"); List groupNames = new ArrayList(); List defs = defbase.evaluateListBase(); - for (Structure def : defs) { - groupNames.add(def.getFieldValue("name").toString()); - } + + if(!defs.isEmpty()) { + for (Structure def : defs) { + groupNames.add(def.getFieldValue("name").toString()); + } - Pointer pDvert = (Pointer) meshStructure.getFieldValue("dvert");// dvert = DeformVERTices - if (pDvert.isNotNull()) {// assigning weights and bone indices - List dverts = pDvert.fetchData(); - for (Structure dvert : dverts) { - Map weightsForVertex = new HashMap(); - Pointer pDW = (Pointer) dvert.getFieldValue("dw"); - if (pDW.isNotNull()) { - List 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); + Pointer pDvert = (Pointer) meshStructure.getFieldValue("dvert");// dvert = DeformVERTices + if (pDvert.isNotNull()) {// assigning weights and bone indices + List dverts = pDvert.fetchData(); + for (Structure dvert : dverts) { + Map weightsForVertex = new HashMap(); + Pointer pDW = (Pointer) dvert.getFieldValue("dw"); + if (pDW.isNotNull()) { + List 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); } } }