* Merge revision 11060 from experimental branch

- Throw exception if user is attempting to share materials between hardware skinned models
experimental
shadowislord 11 years ago
parent 3838216207
commit 6aeb694b71
  1. 16
      jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java

@ -32,6 +32,7 @@
package com.jme3.animation; package com.jme3.animation;
import com.jme3.export.*; import com.jme3.export.*;
import com.jme3.material.MatParam;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.math.FastMath; import com.jme3.math.FastMath;
import com.jme3.math.Matrix4f; import com.jme3.math.Matrix4f;
@ -279,6 +280,21 @@ public class SkeletonControl extends AbstractControl implements Cloneable {
private void controlRenderHardware() { private void controlRenderHardware() {
offsetMatrices = skeleton.computeSkinningMatrices(); offsetMatrices = skeleton.computeSkinningMatrices();
for (Material m : materials) { for (Material m : materials) {
MatParam currentParam = m.getParam("BoneMatrices");
if (currentParam != null) {
if (currentParam.getValue() != offsetMatrices) {
// Check to see if other SkeletonControl
// is operating on this material, in that case, user
// is sharing materials between models which is NOT allowed
// when hardware skinning used.
throw new UnsupportedOperationException(
"Material instances cannot be shared when hardware skinning is used. " +
"Ensure all models use unique material instances."
);
}
}
m.setParam("BoneMatrices", VarType.Matrix4Array, offsetMatrices); m.setParam("BoneMatrices", VarType.Matrix4Array, offsetMatrices);
} }
} }

Loading…
Cancel
Save