Skip to content

Commit fe33bec

Browse files
committed
SkinningControl: add null checks for issue #2707 (SW skin w/o normals)
1 parent 6388607 commit fe33bec

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

jme3-core/src/main/java/com/jme3/anim/SkinningControl.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2025 jMonkeyEngine
2+
* Copyright (c) 2009-2026 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -522,8 +522,10 @@ private void applySkinning(Mesh mesh, Matrix4f[] offsetMatrices) {
522522
fvb.rewind();
523523

524524
VertexBuffer nb = mesh.getBuffer(Type.Normal);
525-
FloatBuffer fnb = (FloatBuffer) nb.getData();
526-
fnb.rewind();
525+
FloatBuffer fnb = (nb == null) ? null : (FloatBuffer) nb.getData();
526+
if (fnb != null) {
527+
fnb.rewind();
528+
}
527529

528530
// get boneIndexes and weights for mesh
529531
IndexBuffer ib = IndexBuffer.wrapIndexBuffer(mesh.getBuffer(Type.BoneIndex).getData());
@@ -545,7 +547,9 @@ private void applySkinning(Mesh mesh, Matrix4f[] offsetMatrices) {
545547
// read next set of positions and normals from native buffer
546548
bufLength = Math.min(posBuf.length, fvb.remaining());
547549
fvb.get(posBuf, 0, bufLength);
548-
fnb.get(normBuf, 0, bufLength);
550+
if (fnb != null) {
551+
fnb.get(normBuf, 0, bufLength);
552+
}
549553
int verts = bufLength / 3;
550554
int idxPositions = 0;
551555

@@ -593,14 +597,18 @@ private void applySkinning(Mesh mesh, Matrix4f[] offsetMatrices) {
593597

594598
fvb.position(fvb.position() - bufLength);
595599
fvb.put(posBuf, 0, bufLength);
596-
fnb.position(fnb.position() - bufLength);
597-
fnb.put(normBuf, 0, bufLength);
600+
if (fnb != null) {
601+
fnb.position(fnb.position() - bufLength);
602+
fnb.put(normBuf, 0, bufLength);
603+
}
598604
}
599605

600606
vars.release();
601607

602608
vb.updateData(fvb);
603-
nb.updateData(fnb);
609+
if (nb != null) {
610+
nb.updateData(fnb);
611+
}
604612
}
605613

606614
/**

0 commit comments

Comments
 (0)