From 6aeb694b71110c3b6ff8efde2c243a9801967c16 Mon Sep 17 00:00:00 2001 From: shadowislord Date: Sat, 31 May 2014 10:54:36 -0400 Subject: [PATCH] * Merge revision 11060 from experimental branch - Throw exception if user is attempting to share materials between hardware skinned models --- .../java/com/jme3/animation/SkeletonControl.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java b/jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java index 468330827..0f5913695 100644 --- a/jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java +++ b/jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java @@ -32,6 +32,7 @@ package com.jme3.animation; import com.jme3.export.*; +import com.jme3.material.MatParam; import com.jme3.material.Material; import com.jme3.math.FastMath; import com.jme3.math.Matrix4f; @@ -279,6 +280,21 @@ public class SkeletonControl extends AbstractControl implements Cloneable { private void controlRenderHardware() { offsetMatrices = skeleton.computeSkinningMatrices(); 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); } }