From 2b097ebdfcd73d41d0a15fae937fb00d4965d723 Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Wed, 9 May 2012 19:38:59 +0000 Subject: [PATCH] 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 --- .../src/core/com/jme3/animation/SkeletonControl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/engine/src/core/com/jme3/animation/SkeletonControl.java b/engine/src/core/com/jme3/animation/SkeletonControl.java index 3c8e117c0..fb39e589d 100644 --- a/engine/src/core/com/jme3/animation/SkeletonControl.java +++ b/engine/src/core/com/jme3/animation/SkeletonControl.java @@ -155,10 +155,10 @@ public class SkeletonControl extends AbstractControl implements Cloneable { void resetToBind() { for (Mesh mesh : targets) { - if (isMeshAnimated(mesh)) { - VertexBuffer bi = mesh.getBuffer(Type.BoneIndex); - ByteBuffer bib = (ByteBuffer) bi.getData(); - if (!bib.hasArray()) { + if (isMeshAnimated(mesh)) { + FloatBuffer bwBuff = (FloatBuffer) mesh.getBuffer(Type.BoneWeight).getData(); + ByteBuffer biBuff = (ByteBuffer)mesh.getBuffer(Type.BoneIndex).getData(); + if (!biBuff.hasArray() || !bwBuff.hasArray()) { mesh.prepareForAnim(true); // prepare for software animation } VertexBuffer bindPos = mesh.getBuffer(Type.BindPosePosition); @@ -420,7 +420,7 @@ public class SkeletonControl extends AbstractControl implements Cloneable { FloatBuffer ftb = (FloatBuffer) tb.getData(); ftb.rewind(); - + // get boneIndexes and weights for mesh ByteBuffer ib = (ByteBuffer) mesh.getBuffer(Type.BoneIndex).getData(); FloatBuffer wb = (FloatBuffer) mesh.getBuffer(Type.BoneWeight).getData(); @@ -440,7 +440,7 @@ public class SkeletonControl extends AbstractControl implements Cloneable { float[] tanBuf = vars.skinTangents; int iterations = (int) FastMath.ceil(fvb.capacity() / ((float) posBuf.length)); - int bufLength = 0; + int bufLength = 0; int tanLength = 0; for (int i = iterations - 1; i >= 0; i--) { // read next set of positions and normals from native buffer