Selaa lähdekoodia

Properly update speed even after an animation has been stopped

BearishSun 9 vuotta sitten
vanhempi
sitoutus
130c411451

+ 5 - 0
Source/BansheeCore/Include/BsAnimation.h

@@ -45,6 +45,11 @@ namespace BansheeEngine
 		float weight = 1.0f; /**< Determines how much of an influence does the clip have on the final pose. */
 		float weight = 1.0f; /**< Determines how much of an influence does the clip have on the final pose. */
 		/** Determines what happens to other animation clips when a new clip starts playing. */
 		/** Determines what happens to other animation clips when a new clip starts playing. */
 		AnimWrapMode wrapMode = AnimWrapMode::Loop;
 		AnimWrapMode wrapMode = AnimWrapMode::Loop;
+		/** 
+		 * Determines should the time be advanced automatically. Certain type of animation clips don't involve playback 
+		 * (e.g. for blending where animation weight controls the animation).
+		 */
+		bool stopped = false;
 	};
 	};
 
 
 	/** Internal information about a single playing animation clip within Animation. */
 	/** Internal information about a single playing animation clip within Animation. */

+ 8 - 3
Source/BansheeCore/Source/BsAnimation.cpp

@@ -407,7 +407,7 @@ namespace BansheeEngine
 		for (auto& clipInfo : mClipInfos)
 		for (auto& clipInfo : mClipInfos)
 		{
 		{
 			// Special case: Ignore non-moving ones
 			// Special case: Ignore non-moving ones
-			if(clipInfo.state.speed != 0.0f)
+			if(!clipInfo.state.stopped)
 				clipInfo.state.speed = speed;
 				clipInfo.state.speed = speed;
 		}
 		}
 
 
@@ -536,6 +536,7 @@ namespace BansheeEngine
 			if (clipInfo != nullptr)
 			if (clipInfo != nullptr)
 			{
 			{
 				clipInfo->state.time = 0.0f;
 				clipInfo->state.time = 0.0f;
+				clipInfo->state.stopped = true;
 				clipInfo->state.speed = 0.0f;
 				clipInfo->state.speed = 0.0f;
 				clipInfo->state.wrapMode = AnimWrapMode::Clamp;
 				clipInfo->state.wrapMode = AnimWrapMode::Clamp;
 
 
@@ -557,6 +558,7 @@ namespace BansheeEngine
 		if (topLeftClipInfo != nullptr)
 		if (topLeftClipInfo != nullptr)
 		{
 		{
 			topLeftClipInfo->state.time = 0.0f;
 			topLeftClipInfo->state.time = 0.0f;
+			topLeftClipInfo->state.stopped = true;
 			topLeftClipInfo->state.speed = 0.0f;
 			topLeftClipInfo->state.speed = 0.0f;
 			topLeftClipInfo->state.weight = (1.0f - t.x) * (1.0f - t.y);
 			topLeftClipInfo->state.weight = (1.0f - t.x) * (1.0f - t.y);
 			topLeftClipInfo->state.wrapMode = AnimWrapMode::Clamp;
 			topLeftClipInfo->state.wrapMode = AnimWrapMode::Clamp;
@@ -566,7 +568,8 @@ namespace BansheeEngine
 		if (topRightClipInfo != nullptr)
 		if (topRightClipInfo != nullptr)
 		{
 		{
 			topRightClipInfo->state.time = 0.0f;
 			topRightClipInfo->state.time = 0.0f;
-			topRightClipInfo->state.speed = 0.0f;
+			topRightClipInfo->state.stopped = true;
+			topLeftClipInfo->state.speed = 0.0f;
 			topRightClipInfo->state.weight = t.x * (1.0f - t.y);
 			topRightClipInfo->state.weight = t.x * (1.0f - t.y);
 			topRightClipInfo->state.wrapMode = AnimWrapMode::Clamp;
 			topRightClipInfo->state.wrapMode = AnimWrapMode::Clamp;
 		}
 		}
@@ -575,7 +578,8 @@ namespace BansheeEngine
 		if (botLeftClipInfo != nullptr)
 		if (botLeftClipInfo != nullptr)
 		{
 		{
 			botLeftClipInfo->state.time = 0.0f;
 			botLeftClipInfo->state.time = 0.0f;
-			botLeftClipInfo->state.speed = 0.0f;
+			botLeftClipInfo->state.stopped = true;
+			topLeftClipInfo->state.speed = 0.0f;
 			botLeftClipInfo->state.weight = (1.0f - t.x) * t.y;
 			botLeftClipInfo->state.weight = (1.0f - t.x) * t.y;
 			botLeftClipInfo->state.wrapMode = AnimWrapMode::Clamp;
 			botLeftClipInfo->state.wrapMode = AnimWrapMode::Clamp;
 		}
 		}
@@ -584,6 +588,7 @@ namespace BansheeEngine
 		if (botRightClipInfo != nullptr)
 		if (botRightClipInfo != nullptr)
 		{
 		{
 			botRightClipInfo->state.time = 0.0f;
 			botRightClipInfo->state.time = 0.0f;
+			botRightClipInfo->state.stopped = true;
 			botRightClipInfo->state.speed = 0.0f;
 			botRightClipInfo->state.speed = 0.0f;
 			botRightClipInfo->state.weight = t.x * t.y;
 			botRightClipInfo->state.weight = t.x * t.y;
 			botRightClipInfo->state.wrapMode = AnimWrapMode::Clamp;
 			botRightClipInfo->state.wrapMode = AnimWrapMode::Clamp;