Skip to content

Commit f0dd68b

Browse files
avoid an NPE in GltfLoader.findChildren() (#1471)
* Update GltfLoader.java null pointer exception if the GLTF file references a node that doesn't exist. I got this problem while tring to convert my GLTF file, i got 440 animations on the file with 3 animation that have joint index missmatch. Maybe it's better to log the errors detail so the user have all the information to correct the error * Update GltfLoader.java * format added code per the proposal at PR #1098 * log any missing JointWrapper This seems to be how model issues are reported by GltfLoader. Co-authored-by: Stephen Gold <[email protected]>
1 parent 1ee04e1 commit f0dd68b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,12 @@ public Joint readNodeAsBone(int nodeIndex, int jointIndex, int skinIndex, Matrix
10851085

10861086
private void findChildren(int nodeIndex) throws IOException {
10871087
JointWrapper jw = fetchFromCache("nodes", nodeIndex, JointWrapper.class);
1088+
if (jw == null) {
1089+
logger.log(Level.WARNING,
1090+
"No JointWrapper found for nodeIndex={0}.", nodeIndex);
1091+
return;
1092+
}
1093+
10881094
JsonObject nodeData = nodes.get(nodeIndex).getAsJsonObject();
10891095
JsonArray children = nodeData.getAsJsonArray("children");
10901096

0 commit comments

Comments
 (0)