Blending queues now working
This commit is contained in:
@@ -7,13 +7,12 @@
|
||||
#include "../Core/System.h"
|
||||
#include "../Core/ResourceManager.h"
|
||||
#include "Rendering/Model.h"
|
||||
#include "Rendering/EAnimationComplete.h"
|
||||
#include "Rendering/Skeleton.h"
|
||||
#include "Rendering/BlendTree.h"
|
||||
#include "Rendering/EAnimationBlend.h"
|
||||
#include "Rendering/EAutoAnimationBlend.h"
|
||||
#include "../Input/EInputCommand.h"
|
||||
#include "../Core/EntityWrapper.h"
|
||||
#include "Rendering/AutoBlendQueue.h"
|
||||
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
@@ -27,10 +26,7 @@ private:
|
||||
void CreateBlendTrees();
|
||||
void UpdateAnimations(double dt);
|
||||
void UpdateWeights(double dt);
|
||||
void AnimationComplete(EntityWrapper animationEntity);
|
||||
|
||||
EventRelay<AnimationSystem, Events::AnimationBlend> m_EAnimationBlend;
|
||||
bool OnAnimationBlend(Events::AnimationBlend& e);
|
||||
EventRelay<AnimationSystem, Events::AutoAnimationBlend> m_EAutoAnimationBlend;
|
||||
bool OnAutoAnimationBlend(Events::AutoAnimationBlend& e);
|
||||
|
||||
@@ -38,40 +34,7 @@ private:
|
||||
EventRelay<AnimationSystem, Events::InputCommand> m_EInputCommand;
|
||||
bool OnInputCommand(const Events::InputCommand& e);
|
||||
|
||||
struct BlendJob
|
||||
{
|
||||
EntityWrapper BlendEntity = EntityWrapper::Invalid;
|
||||
double StartWeight;
|
||||
double GoalWeight;
|
||||
double Duration;
|
||||
double CurrentTime = 0.0;
|
||||
};
|
||||
|
||||
struct QueuedBlendJob : BlendJob
|
||||
{
|
||||
EntityWrapper AnimationEntity = EntityWrapper::Invalid;
|
||||
};
|
||||
|
||||
struct AutoBlendJob
|
||||
{
|
||||
EntityWrapper RootNode = EntityWrapper::Invalid;
|
||||
double Duration;
|
||||
double CurrentTime = 0.0;
|
||||
double Delay = 0.0;
|
||||
BlendTree::AutoBlendInfo BlendInfo;
|
||||
};
|
||||
|
||||
|
||||
std::list<AutoBlendJob> m_AutoBlendJobs;
|
||||
std::unordered_map<EntityWrapper, AutoBlendJob> m_QueuedAutoBlendJobs;
|
||||
std::list<BlendJob> m_BlendJobs;
|
||||
std::list<QueuedBlendJob> m_QueuedBlendJobs;
|
||||
|
||||
char m_AnimationName1[20] = "Run";
|
||||
float m_BlendTime1 = 0.5f;
|
||||
|
||||
char m_AnimationName2[20] = "Jump";
|
||||
float m_BlendTime2 = 0.5f;
|
||||
std::unordered_map<EntityWrapper, AutoBlendQueue> m_AutoBlendQueues;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Skeleton.h"
|
||||
#include "Model.h"
|
||||
#include "BlendTree.h"
|
||||
#include "../Core/EntityWrapper.h"
|
||||
|
||||
class AutoBlendQueue
|
||||
{
|
||||
@@ -15,11 +16,29 @@ public:
|
||||
double Duration;
|
||||
double CurrentTime = 0.0;
|
||||
double Delay = 0.0;
|
||||
EntityWrapper AnimationEntity = EntityWrapper::Invalid;
|
||||
BlendTree::AutoBlendInfo BlendInfo;
|
||||
};
|
||||
|
||||
struct AutoblendNode
|
||||
{
|
||||
AutoBlendJob BlendJob;
|
||||
double StartTime;
|
||||
double EndTime;
|
||||
};
|
||||
|
||||
AutoBlendQueue() { };
|
||||
|
||||
void Insert(AutoBlendJob autoBlendJob);
|
||||
void UpdateTime(double dt);
|
||||
|
||||
void PrintQueue();
|
||||
bool HasActiveBlendJob();
|
||||
std::shared_ptr<BlendTree> GetBlendTree();
|
||||
|
||||
AutoBlendQueue::AutoBlendJob& GetActiveBlendJob();
|
||||
private:
|
||||
std::map<double, AutoBlendJob> m_BlendQueue;
|
||||
std::list<AutoblendNode> m_BlendQueue;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -60,8 +60,7 @@ public:
|
||||
{
|
||||
std::string NodeName;
|
||||
double progress;
|
||||
bool Restart;
|
||||
double AnimationSpeed;
|
||||
bool Start;
|
||||
std::unordered_map<EntityWrapper, double> StartWeights;
|
||||
};
|
||||
|
||||
@@ -78,6 +77,11 @@ public:
|
||||
void PrintTree();
|
||||
BlendTree::AutoBlendInfo AutoBlendStep(AutoBlendInfo blendInfo);
|
||||
|
||||
BlendTree::Node* GetCommonParent(std::string NodeName1, std::string NodeName2);
|
||||
BlendTree::Node* FirstCommonParent(Node* node1, Node* node2);
|
||||
|
||||
EntityWrapper GetSubTreeRoot(std::string nodeName);
|
||||
|
||||
private:
|
||||
Skeleton* m_Skeleton = nullptr;
|
||||
Node* m_Root = nullptr;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef Events_AnimationBlend_h__
|
||||
#define Events_AnimationBlend_h__
|
||||
|
||||
#include "../Core/EventBroker.h"
|
||||
#include "../Core/EntityWrapper.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct AnimationBlend : Event
|
||||
{
|
||||
EntityWrapper BlendEntity = EntityWrapper::Invalid;
|
||||
double GoalWeight;
|
||||
double Duration;
|
||||
|
||||
EntityWrapper AnimationEntity = EntityWrapper::Invalid;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -13,9 +13,9 @@ struct AutoAnimationBlend : Event
|
||||
std::string NodeName;
|
||||
double Duration = 0.0;
|
||||
double Delay = 0.0;
|
||||
|
||||
|
||||
double AnimationSpeed = 1.0;
|
||||
|
||||
bool Start = false;
|
||||
bool Reverse = false;
|
||||
bool Restart = false;
|
||||
|
||||
EntityWrapper AnimationEntity = EntityWrapper::Invalid;
|
||||
|
||||
Reference in New Issue
Block a user