Quellcode durchsuchen

Merge pull request #810 from germinator/master

Animation properties and cloning.
Sean Paul Taylor vor 13 Jahren
Ursprung
Commit
8fa597df88

+ 6 - 0
gameplay/src/Animation.cpp

@@ -453,6 +453,12 @@ Animation* Animation::clone(Channel* channel, AnimationTarget* target)
     GP_ASSERT(animation->getRefCount() == 1);
 
     // Clone the clips
+    
+    if (_defaultClip)
+    {
+        animation->_defaultClip = _defaultClip->clone(animation);
+    }
+    
     if (_clips)
     {
         for (std::vector<AnimationClip*>::iterator it = _clips->begin(); it != _clips->end(); ++it)

+ 0 - 1
gameplay/src/AnimationClip.cpp

@@ -598,7 +598,6 @@ AnimationClip* AnimationClip::clone(Animation* animation) const
 {
     // Don't clone the elapsed time, listeners or crossfade information.
     AnimationClip* newClip = new AnimationClip(getId(), animation, getStartTime(), getEndTime());
-    newClip->setRepeatCount(getRepeatCount());
     newClip->setSpeed(getSpeed());
     newClip->setRepeatCount(getRepeatCount());
     newClip->setBlendWeight(getBlendWeight());

+ 18 - 1
gameplay/src/AnimationTarget.cpp

@@ -4,6 +4,8 @@
 #include "Game.h"
 #include "Node.h"
 
+#define ANIMATION_TARGET_INDEFINITE_STR "INDEFINITE"
+
 namespace gameplay
 {
 
@@ -261,6 +263,21 @@ Animation* AnimationTarget::createAnimation(const char* id, Properties* animatio
         animation = createAnimation(id, propertyId, keyCount, keyTimes, keyValues, (Curve::InterpolationType) curve);
     }
 
+    const char* repeat = animationProperties->getString("repeatCount");
+    if (repeat)
+    {
+        if (strcmp(repeat, ANIMATION_TARGET_INDEFINITE_STR) == 0)
+        {
+            animation->getClip()->setRepeatCount(AnimationClip::REPEAT_INDEFINITE);
+        }
+        else
+        {
+            float value;
+            sscanf(repeat, "%f", &value);
+            animation->getClip()->setRepeatCount(value);
+        }
+    }
+    
     SAFE_DELETE_ARRAY(keyOut);
     SAFE_DELETE_ARRAY(keyIn);
     SAFE_DELETE_ARRAY(keyValues);
@@ -277,7 +294,7 @@ Animation* AnimationTarget::createAnimation(const char* id, Properties* animatio
         }
         animation->createClips(animationProperties, (unsigned int) frameCount);
     }
-
+    
     return animation;
 }
 

+ 3 - 0
gameplay/src/MaterialParameter.cpp

@@ -663,6 +663,9 @@ void MaterialParameter::cloneInto(MaterialParameter* materialParameter) const
         GP_ERROR("Unsupported material parameter type(%d).", _type);
         break;
     }
+    
+    NodeCloneContext context;
+    this->AnimationTarget::cloneInto(materialParameter, context);
 }
 
 }