Forráskód Böngészése

Allow to set Skeleton's root bone index programmatically.

Lasse Öörni 11 éve
szülő
commit
e55f92d5e2

+ 9 - 0
Source/Engine/Graphics/Skeleton.cpp

@@ -22,6 +22,7 @@
 
 #include "Precompiled.h"
 #include "Deserializer.h"
+#include "Log.h"
 #include "Serializer.h"
 #include "Skeleton.h"
 
@@ -114,6 +115,14 @@ void Skeleton::Define(const Skeleton& src)
     rootBoneIndex_ = src.rootBoneIndex_;
 }
 
+void Skeleton::SetRootBoneIndex(unsigned index)
+{
+    if (index < bones_.Size())
+        rootBoneIndex_ = index;
+    else
+        LOGERROR("Root bone index out of bounds");
+}
+
 void Skeleton::ClearBones()
 {
     bones_.Clear();

+ 2 - 0
Source/Engine/Graphics/Skeleton.h

@@ -92,6 +92,8 @@ public:
     bool Save(Serializer& dest) const;
     /// Define from another skeleton.
     void Define(const Skeleton& src);
+    /// Set root bone's index.
+    void SetRootBoneIndex(unsigned index);
     /// Clear bones.
     void ClearBones();
     /// Reset all animating bones to initial positions.