Hadrware skinning buffers are now not saved along the other buffers in a j3o file.
They are created when loading the model. This was causing issue when loading j3o files saved before the change git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10658 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
2acbdf9f84
commit
68fa1b7084
@ -122,7 +122,7 @@ public class SkeletonControl extends AbstractControl implements Cloneable {
|
|||||||
m.setInt("NumberOfBones", numBones);
|
m.setInt("NumberOfBones", numBones);
|
||||||
}
|
}
|
||||||
for (Mesh mesh : targets) {
|
for (Mesh mesh : targets) {
|
||||||
if (isMeshAnimated(mesh)) {
|
if (mesh.isAnimated()) {
|
||||||
mesh.prepareForAnim(false);
|
mesh.prepareForAnim(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ public class SkeletonControl extends AbstractControl implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Mesh mesh : targets) {
|
for (Mesh mesh : targets) {
|
||||||
if (isMeshAnimated(mesh)) {
|
if (mesh.isAnimated()) {
|
||||||
mesh.prepareForAnim(true);
|
mesh.prepareForAnim(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,9 +216,6 @@ public class SkeletonControl extends AbstractControl implements Cloneable {
|
|||||||
this.targets = new SafeArrayList<Mesh>(Mesh.class, Arrays.asList(targets));
|
this.targets = new SafeArrayList<Mesh>(Mesh.class, Arrays.asList(targets));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMeshAnimated(Mesh mesh) {
|
|
||||||
return mesh.getBuffer(Type.BindPosePosition) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void findTargets(Node node) {
|
private void findTargets(Node node) {
|
||||||
Mesh sharedMesh = null;
|
Mesh sharedMesh = null;
|
||||||
@ -232,7 +229,7 @@ public class SkeletonControl extends AbstractControl implements Cloneable {
|
|||||||
|
|
||||||
if (childSharedMesh != null) {
|
if (childSharedMesh != null) {
|
||||||
// Don’t bother with non-animated shared meshes
|
// Don’t bother with non-animated shared meshes
|
||||||
if (isMeshAnimated(childSharedMesh)) {
|
if (childSharedMesh.isAnimated()) {
|
||||||
// child is using shared mesh,
|
// child is using shared mesh,
|
||||||
// so animate the shared mesh but ignore child
|
// so animate the shared mesh but ignore child
|
||||||
if (sharedMesh == null) {
|
if (sharedMesh == null) {
|
||||||
@ -244,7 +241,7 @@ public class SkeletonControl extends AbstractControl implements Cloneable {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Mesh mesh = geom.getMesh();
|
Mesh mesh = geom.getMesh();
|
||||||
if (isMeshAnimated(mesh)) {
|
if (mesh.isAnimated()) {
|
||||||
targets.add(mesh);
|
targets.add(mesh);
|
||||||
materials.add(geom.getMaterial());
|
materials.add(geom.getMaterial());
|
||||||
}
|
}
|
||||||
@ -333,7 +330,7 @@ public class SkeletonControl extends AbstractControl implements Cloneable {
|
|||||||
//only do this for software updates
|
//only do this for software updates
|
||||||
void resetToBind() {
|
void resetToBind() {
|
||||||
for (Mesh mesh : targets) {
|
for (Mesh mesh : targets) {
|
||||||
if (isMeshAnimated(mesh)) {
|
if (mesh.isAnimated()) {
|
||||||
Buffer bwBuff = mesh.getBuffer(Type.BoneWeight).getData();
|
Buffer bwBuff = mesh.getBuffer(Type.BoneWeight).getData();
|
||||||
Buffer biBuff = mesh.getBuffer(Type.BoneIndex).getData();
|
Buffer biBuff = mesh.getBuffer(Type.BoneIndex).getData();
|
||||||
if (!biBuff.hasArray() || !bwBuff.hasArray()) {
|
if (!biBuff.hasArray() || !bwBuff.hasArray()) {
|
||||||
|
@ -1279,6 +1279,11 @@ public class Mesh implements Savable, Cloneable {
|
|||||||
public SafeArrayList<VertexBuffer> getBufferList(){
|
public SafeArrayList<VertexBuffer> getBufferList(){
|
||||||
return buffersList;
|
return buffersList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAnimated() {
|
||||||
|
return getBuffer(Type.BindPosePosition) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void write(JmeExporter ex) throws IOException {
|
public void write(JmeExporter ex) throws IOException {
|
||||||
OutputCapsule out = ex.getCapsule(this);
|
OutputCapsule out = ex.getCapsule(this);
|
||||||
@ -1299,6 +1304,17 @@ public class Mesh implements Savable, Cloneable {
|
|||||||
out.write(elementLengths, "elementLengths", null);
|
out.write(elementLengths, "elementLengths", null);
|
||||||
out.write(modeStart, "modeStart", null);
|
out.write(modeStart, "modeStart", null);
|
||||||
out.write(pointSize, "pointSize", 1f);
|
out.write(pointSize, "pointSize", 1f);
|
||||||
|
|
||||||
|
if(isAnimated()){
|
||||||
|
VertexBuffer vb = getBuffer(Type.HWBoneIndex);
|
||||||
|
if(vb!=null){
|
||||||
|
buffers.remove(Type.HWBoneIndex.ordinal());
|
||||||
|
}
|
||||||
|
vb = getBuffer(Type.HWBoneWeight);
|
||||||
|
if(vb!=null){
|
||||||
|
buffers.remove(Type.HWBoneWeight.ordinal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
out.writeIntSavableMap(buffers, "buffers", null);
|
out.writeIntSavableMap(buffers, "buffers", null);
|
||||||
out.write(lodLevels, "lodLevels", null);
|
out.write(lodLevels, "lodLevels", null);
|
||||||
@ -1324,6 +1340,16 @@ public class Mesh implements Savable, Cloneable {
|
|||||||
buffersList.add(entry.getValue());
|
buffersList.add(entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//creating hw animation buffers empty so that they are put in the cache
|
||||||
|
if(isAnimated()){
|
||||||
|
VertexBuffer hwBoneIndex = new VertexBuffer(Type.HWBoneIndex);
|
||||||
|
hwBoneIndex.setUsage(Usage.CpuOnly);
|
||||||
|
setBuffer(hwBoneIndex);
|
||||||
|
VertexBuffer hwBoneWeight = new VertexBuffer(Type.HWBoneWeight);
|
||||||
|
hwBoneWeight.setUsage(Usage.CpuOnly);
|
||||||
|
setBuffer(hwBoneWeight);
|
||||||
|
}
|
||||||
|
|
||||||
Savable[] lodLevelsSavable = in.readSavableArray("lodLevels", null);
|
Savable[] lodLevelsSavable = in.readSavableArray("lodLevels", null);
|
||||||
if (lodLevelsSavable != null) {
|
if (lodLevelsSavable != null) {
|
||||||
lodLevels = new VertexBuffer[lodLevelsSavable.length];
|
lodLevels = new VertexBuffer[lodLevelsSavable.length];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user