Fixed how Hardware BoneIndex and BoneWeight buffers are handled in extractVertexData when used for a shared mesh.

All buffers are now properly initialized and data copied over if needed.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10855 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
rem..om 12 years ago
parent 27a7fde24d
commit f6ca843f03
  1. 14
      engine/src/core/com/jme3/scene/Mesh.java

@ -1166,19 +1166,20 @@ public class Mesh implements Savable, Cloneable {
// Now, create the vertex buffers // Now, create the vertex buffers
SafeArrayList<VertexBuffer> oldVertexData = other.getBufferList(); SafeArrayList<VertexBuffer> oldVertexData = other.getBufferList();
for (VertexBuffer oldVb : oldVertexData) { for (VertexBuffer oldVb : oldVertexData) {
if (oldVb.getBufferType() == VertexBuffer.Type.Index if (oldVb.getBufferType() == VertexBuffer.Type.Index) {
||oldVb.getBufferType() == VertexBuffer.Type.HWBoneIndex
|| oldVb.getBufferType() == VertexBuffer.Type.HWBoneWeight ) {
// ignore the index buffer // ignore the index buffer
continue; continue;
} }
VertexBuffer newVb = new VertexBuffer(oldVb.getBufferType());
newVb.setNormalized(oldVb.isNormalized());
//check for data before copying, some buffers are just empty shells
//for caching purpose (HW skinning buffers), and will be filled when
//needed
if(oldVb.getData()!=null){
// Create a new vertex buffer with similar configuration, but // Create a new vertex buffer with similar configuration, but
// with the capacity of number of unique vertices // with the capacity of number of unique vertices
Buffer buffer = VertexBuffer.createBuffer(oldVb.getFormat(), oldVb.getNumComponents(), newNumVerts); Buffer buffer = VertexBuffer.createBuffer(oldVb.getFormat(), oldVb.getNumComponents(), newNumVerts);
VertexBuffer newVb = new VertexBuffer(oldVb.getBufferType());
newVb.setNormalized(oldVb.isNormalized());
newVb.setupData(oldVb.getUsage(), oldVb.getNumComponents(), oldVb.getFormat(), buffer); newVb.setupData(oldVb.getUsage(), oldVb.getNumComponents(), oldVb.getFormat(), buffer);
// Copy the vertex data from the old buffer into the new buffer // Copy the vertex data from the old buffer into the new buffer
@ -1189,6 +1190,7 @@ public class Mesh implements Savable, Cloneable {
// to the new index // to the new index
oldVb.copyElement(oldIndex, newVb, i); oldVb.copyElement(oldIndex, newVb, i);
} }
}
// Set the buffer on the mesh // Set the buffer on the mesh
clearBuffer(newVb.getBufferType()); clearBuffer(newVb.getBufferType());

Loading…
Cancel
Save