瀏覽代碼

SkeletonControl: fix #207

Kirill Vainer 10 年之前
父節點
當前提交
17bf0f8ab3
共有 1 個文件被更改,包括 14 次插入3 次删除
  1. 14 3
      jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java

+ 14 - 3
jme3-core/src/main/java/com/jme3/animation/SkeletonControl.java

@@ -347,11 +347,22 @@ public class SkeletonControl extends AbstractControl implements Cloneable {
 
     public Control cloneForSpatial(Spatial spatial) {
         Node clonedNode = (Node) spatial;
-        AnimControl ctrl = spatial.getControl(AnimControl.class);
         SkeletonControl clone = new SkeletonControl();
 
-        clone.skeleton = ctrl.getSkeleton();
-
+        AnimControl ctrl = spatial.getControl(AnimControl.class);
+        if (ctrl != null) {
+            // AnimControl is responsible for cloning the skeleton, not
+            // SkeletonControl.
+            clone.skeleton = ctrl.getSkeleton();
+        } else {
+            // If there's no AnimControl, create the clone ourselves.
+            clone.skeleton = new Skeleton(skeleton);
+        }
+        clone.hwSkinningDesired = this.hwSkinningDesired;
+        clone.hwSkinningEnabled = this.hwSkinningEnabled;
+        clone.hwSkinningSupported = this.hwSkinningSupported;
+        clone.hwSkinningTested = this.hwSkinningTested;
+        
         clone.setSpatial(clonedNode);
 
         // Fix attachments for the cloned node