OSDN Git Service

Ensure we deep copy the bone structure when making a new skeleton so that AVs change...
authorRobin Cornelius <robin.cornelius@gmail.com>
Mon, 18 Jul 2011 10:58:19 +0000 (10:58 +0000)
committerRobin Cornelius <robin.cornelius@gmail.com>
Mon, 18 Jul 2011 10:58:19 +0000 (10:58 +0000)
git-svn-id: https://radegast.googlecode.com/svn/trunk@991 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/GUI/Rendering/RenderingHelpers.cs

index 4c0ca47..ec67460 100644 (file)
@@ -1697,7 +1697,23 @@ namespace Radegast.Rendering
 \r
         public skeleton()\r
         {\r
-            mBones = new Dictionary<string, Bone>(Bone.mBones); //copy from the static defines\r
+\r
+            mBones = new Dictionary<string, Bone>();\r
+\r
+            foreach (Bone src in Bone.mBones.Values)\r
+            {\r
+                Bone newbone = new Bone(src);\r
+                mBones.Add(newbone.name, newbone);\r
+            }\r
+\r
+            //rebuild the skeleton structure on the new copy\r
+            foreach (Bone src in mBones.Values)\r
+            {\r
+                if (src.mParentBone != null)\r
+                {\r
+                    src.parent = mBones[src.mParentBone];\r
+                }\r
+            }\r
 \r
             //FUDGE\r
             if (mUpperMeshMapping.Count == 0)\r
@@ -1871,6 +1887,8 @@ namespace Radegast.Rendering
         private Vector3 mDeltaPos;\r
         private Quaternion mDeltaRot;\r
 \r
+        public string mParentBone = null;\r
+\r
         public Bone()\r
         {\r
         }\r
@@ -1888,6 +1906,8 @@ namespace Radegast.Rendering
             orig_rot = source.orig_rot;\r
             orig_scale = source.orig_scale;\r
 \r
+            mParentBone = source.mParentBone;\r
+\r
             mDeformMatrix = new Matrix4(source.mDeformMatrix);\r
         }\r
 \r
@@ -1931,9 +1951,11 @@ namespace Radegast.Rendering
             //TODO piviot\r
 \r
             b.parent = parent;\r
-\r
             if (parent != null)\r
+            {\r
+                b.mParentBone = parent.name;\r
                 parent.children.Add(b);\r
+            }               \r
 \r
             mBones.Add(b.name, b);\r
             mIndexedBones.Add(boneaddindex++, b);\r