Skip to content

Commit d7609e9

Browse files
authored
solve issue #2707 (software skinning requires mesh normals) (#2708)
* SkinningControl: add null checks for issue #2707 (SW skin w/o normals) * SkinningControl: correctly handle hypothetical nb!=null && fnb==null
1 parent b515f94 commit d7609e9

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

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

Lines changed: 16 additions & 8 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
/**
@@ -745,7 +753,7 @@ private void applySkinningTangents(Mesh mesh, Matrix4f[] offsetMatrices, VertexB
745753
vars.release();
746754

747755
vb.updateData(fvb);
748-
if (nb != null) {
756+
if (fnb != null) {
749757
nb.updateData(fnb);
750758
}
751759
tb.updateData(ftb);

0 commit comments

Comments
 (0)