Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions jme3-core/src/main/java/com/jme3/anim/SkinningControl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2025 jMonkeyEngine
* Copyright (c) 2009-2026 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -522,8 +522,10 @@ private void applySkinning(Mesh mesh, Matrix4f[] offsetMatrices) {
fvb.rewind();

VertexBuffer nb = mesh.getBuffer(Type.Normal);
FloatBuffer fnb = (FloatBuffer) nb.getData();
fnb.rewind();
FloatBuffer fnb = (nb == null) ? null : (FloatBuffer) nb.getData();
if (fnb != null) {
fnb.rewind();
}

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

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

fvb.position(fvb.position() - bufLength);
fvb.put(posBuf, 0, bufLength);
fnb.position(fnb.position() - bufLength);
fnb.put(normBuf, 0, bufLength);
if (fnb != null) {
fnb.position(fnb.position() - bufLength);
fnb.put(normBuf, 0, bufLength);
}
}

vars.release();

vb.updateData(fvb);
nb.updateData(fnb);
if (nb != null) {
nb.updateData(fnb);
}
}

/**
Expand Down Expand Up @@ -745,7 +753,7 @@ private void applySkinningTangents(Mesh mesh, Matrix4f[] offsetMatrices, VertexB
vars.release();

vb.updateData(fvb);
if (nb != null) {
if (fnb != null) {
nb.updateData(fnb);
}
tb.updateData(ftb);
Expand Down
Loading