SkeletonControl : check hasArray for both BoneWeight and BoneIndex buffers before prep them for anim (convert them to non direct).

This to avoid an UnsupportedOperationException on android 4.0 when fetching the backing array on the BoneWeight buffer.
Before, only the BoneIndex was checked, and, for some mysterious reason, this ByteBuffer can be direct AND have a backing array on android 4.0. thus the preping wasn't done on the BoneWeight buffer that was kept as Direct. Hence the exception when fetching the array.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9371 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 13 years ago
parent 583cf61d37
commit 2b097ebdfc
  1. 6
      engine/src/core/com/jme3/animation/SkeletonControl.java

@ -156,9 +156,9 @@ public class SkeletonControl extends AbstractControl implements Cloneable {
void resetToBind() { void resetToBind() {
for (Mesh mesh : targets) { for (Mesh mesh : targets) {
if (isMeshAnimated(mesh)) { if (isMeshAnimated(mesh)) {
VertexBuffer bi = mesh.getBuffer(Type.BoneIndex); FloatBuffer bwBuff = (FloatBuffer) mesh.getBuffer(Type.BoneWeight).getData();
ByteBuffer bib = (ByteBuffer) bi.getData(); ByteBuffer biBuff = (ByteBuffer)mesh.getBuffer(Type.BoneIndex).getData();
if (!bib.hasArray()) { if (!biBuff.hasArray() || !bwBuff.hasArray()) {
mesh.prepareForAnim(true); // prepare for software animation mesh.prepareForAnim(true); // prepare for software animation
} }
VertexBuffer bindPos = mesh.getBuffer(Type.BindPosePosition); VertexBuffer bindPos = mesh.getBuffer(Type.BindPosePosition);

Loading…
Cancel
Save