Blend duration can now be 0.0
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
#include "Rendering/EAutoAnimationBlend.h"
|
#include "Rendering/EAutoAnimationBlend.h"
|
||||||
#include "../Core/EntityWrapper.h"
|
#include "../Core/EntityWrapper.h"
|
||||||
#include "Rendering/AutoBlendQueue.h"
|
#include "Rendering/AutoBlendQueue.h"
|
||||||
|
#include "../Input/EInputCommand.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
class AnimationSystem : public ImpureSystem
|
class AnimationSystem : public ImpureSystem
|
||||||
@@ -28,7 +28,8 @@ private:
|
|||||||
|
|
||||||
EventRelay<AnimationSystem, Events::AutoAnimationBlend> m_EAutoAnimationBlend;
|
EventRelay<AnimationSystem, Events::AutoAnimationBlend> m_EAutoAnimationBlend;
|
||||||
bool OnAutoAnimationBlend(Events::AutoAnimationBlend& e);
|
bool OnAutoAnimationBlend(Events::AutoAnimationBlend& e);
|
||||||
|
EventRelay<AnimationSystem, Events::InputCommand> m_EInputCommand;
|
||||||
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
std::unordered_map<EntityWrapper, AutoBlendQueue> m_AutoBlendQueues;
|
std::unordered_map<EntityWrapper, AutoBlendQueue> m_AutoBlendQueues;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ AnimationSystem::AnimationSystem(SystemParams params)
|
|||||||
: System(params)
|
: System(params)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EAutoAnimationBlend, &AnimationSystem::OnAutoAnimationBlend);
|
EVENT_SUBSCRIBE_MEMBER(m_EAutoAnimationBlend, &AnimationSystem::OnAutoAnimationBlend);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &AnimationSystem::OnInputCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationSystem::Update(double dt)
|
void AnimationSystem::Update(double dt)
|
||||||
@@ -133,7 +134,12 @@ void AnimationSystem::UpdateWeights(double dt)
|
|||||||
std::shared_ptr<BlendTree> blendTree = autoBlendQueue.second.GetBlendTree();
|
std::shared_ptr<BlendTree> blendTree = autoBlendQueue.second.GetBlendTree();
|
||||||
|
|
||||||
if (blendTree != nullptr) {
|
if (blendTree != nullptr) {
|
||||||
blendJob.BlendInfo.progress = glm::clamp(blendJob.CurrentTime / blendJob.Duration, 0.0, 1.0);
|
if (blendJob.Duration != 0.0) {
|
||||||
|
blendJob.BlendInfo.progress = glm::clamp(blendJob.CurrentTime / blendJob.Duration, 0.0, 1.0);
|
||||||
|
} else {
|
||||||
|
blendJob.BlendInfo.progress = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
blendJob.BlendInfo = blendTree->AutoBlendStep(blendJob.BlendInfo);
|
blendJob.BlendInfo = blendTree->AutoBlendStep(blendJob.BlendInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,3 +221,42 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
|
|||||||
m_AutoBlendQueues[subTreeRoot].Insert(abj);
|
m_AutoBlendQueues[subTreeRoot].Insert(abj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AnimationSystem::OnInputCommand(const Events::InputCommand& e)
|
||||||
|
{
|
||||||
|
if (e.Value == 1.0f) {
|
||||||
|
if (e.Command == "Shoot") {
|
||||||
|
auto blendComponents = m_World->GetComponents("Model");
|
||||||
|
|
||||||
|
if (blendComponents == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (auto& bc : *blendComponents) {
|
||||||
|
EntityWrapper entity = EntityWrapper(m_World, bc.EntityID);
|
||||||
|
|
||||||
|
if (entity.Name() == "Hands") {
|
||||||
|
{
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.0;
|
||||||
|
aeb.NodeName = "Fire";
|
||||||
|
aeb.RootNode = entity;
|
||||||
|
aeb.Start = true;
|
||||||
|
aeb.Restart = true;
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Events::AutoAnimationBlend aeb;
|
||||||
|
aeb.Duration = 0.1;
|
||||||
|
aeb.NodeName = "Idle";
|
||||||
|
aeb.RootNode = entity;
|
||||||
|
aeb.Delay = 0.0;
|
||||||
|
aeb.Start = true;
|
||||||
|
aeb.Restart = false;
|
||||||
|
aeb.AnimationEntity = entity.FirstChildByName("PrimaryBlendTree").FirstChildByName("Fire");
|
||||||
|
m_EventBroker->Publish(aeb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user