fixed issue when saving a mesh in hw skinning mode was not restoring the buffers.
restored the code to enforce BoneIndex and BoneWeight to be in the heap for software anim because it was failing on android, until I find a proper solution git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10659 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
68fa1b7084
commit
a67786c58e
@ -353,6 +353,27 @@ public class Mesh implements Savable, Cloneable {
|
||||
*/
|
||||
public void prepareForAnim(boolean forSoftwareAnim){
|
||||
if (forSoftwareAnim) {
|
||||
// convert indices to ubytes on the heap
|
||||
VertexBuffer indices = getBuffer(Type.BoneIndex);
|
||||
if (!indices.getData().hasArray()) {
|
||||
ByteBuffer originalIndex = (ByteBuffer) indices.getData();
|
||||
ByteBuffer arrayIndex = ByteBuffer.allocate(originalIndex.capacity());
|
||||
originalIndex.clear();
|
||||
arrayIndex.put(originalIndex);
|
||||
indices.updateData(arrayIndex);
|
||||
}
|
||||
indices.setUsage(Usage.CpuOnly);
|
||||
|
||||
// convert weights on the heap
|
||||
VertexBuffer weights = getBuffer(Type.BoneWeight);
|
||||
if (!weights.getData().hasArray()) {
|
||||
FloatBuffer originalWeight = (FloatBuffer) weights.getData();
|
||||
FloatBuffer arrayWeight = FloatBuffer.allocate(originalWeight.capacity());
|
||||
originalWeight.clear();
|
||||
arrayWeight.put(originalWeight);
|
||||
weights.updateData(arrayWeight);
|
||||
}
|
||||
weights.setUsage(Usage.CpuOnly);
|
||||
// position, normal, and tanget buffers to be in "Stream" mode
|
||||
VertexBuffer positions = getBuffer(Type.Position);
|
||||
VertexBuffer normals = getBuffer(Type.Normal);
|
||||
@ -1305,18 +1326,32 @@ public class Mesh implements Savable, Cloneable {
|
||||
out.write(modeStart, "modeStart", null);
|
||||
out.write(pointSize, "pointSize", 1f);
|
||||
|
||||
if(isAnimated()){
|
||||
VertexBuffer vb = getBuffer(Type.HWBoneIndex);
|
||||
if(vb!=null){
|
||||
//Removing HW skinning buffers to not save them
|
||||
VertexBuffer hwBoneIndex = null;
|
||||
VertexBuffer hwBoneWeight = null;
|
||||
if (isAnimated()) {
|
||||
hwBoneIndex = getBuffer(Type.HWBoneIndex);
|
||||
if (hwBoneIndex != null) {
|
||||
buffers.remove(Type.HWBoneIndex.ordinal());
|
||||
}
|
||||
vb = getBuffer(Type.HWBoneWeight);
|
||||
if(vb!=null){
|
||||
hwBoneWeight = getBuffer(Type.HWBoneWeight);
|
||||
if (hwBoneWeight != null) {
|
||||
buffers.remove(Type.HWBoneWeight.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
out.writeIntSavableMap(buffers, "buffers", null);
|
||||
|
||||
//restoring Hw skinning buffers.
|
||||
if (isAnimated()) {
|
||||
if (hwBoneIndex != null) {
|
||||
buffers.put(hwBoneIndex.getBufferType().ordinal(), hwBoneIndex);
|
||||
}
|
||||
if (hwBoneWeight != null) {
|
||||
buffers.put(hwBoneWeight.getBufferType().ordinal(), hwBoneWeight);
|
||||
}
|
||||
}
|
||||
|
||||
out.write(lodLevels, "lodLevels", null);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user