From bebdacabb4ee15da79b33ac3ea7c57f256c49751 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Thu, 3 Mar 2016 23:41:08 +0100 Subject: [PATCH] Clean up --- include/Engine/Rendering/AnimationSystem.h | 5 - .../Schema/Entities/AssaultBlendTree.xml | 513 ++++++++++++++++++ resources/Schema/Entities/BlendTreeTest.xml | 42 +- src/Engine/Rendering/AnimationSystem.cpp | 373 ------------- src/Engine/Rendering/AutoBlendQueue.cpp | 5 - 5 files changed, 538 insertions(+), 400 deletions(-) create mode 100644 resources/Schema/Entities/AssaultBlendTree.xml diff --git a/include/Engine/Rendering/AnimationSystem.h b/include/Engine/Rendering/AnimationSystem.h index 4f18b4a4..a04aa3c5 100644 --- a/include/Engine/Rendering/AnimationSystem.h +++ b/include/Engine/Rendering/AnimationSystem.h @@ -10,7 +10,6 @@ #include "Rendering/Skeleton.h" #include "Rendering/BlendTree.h" #include "Rendering/EAutoAnimationBlend.h" -#include "../Input/EInputCommand.h" #include "../Core/EntityWrapper.h" #include "Rendering/AutoBlendQueue.h" @@ -30,10 +29,6 @@ private: EventRelay m_EAutoAnimationBlend; bool OnAutoAnimationBlend(Events::AutoAnimationBlend& e); - - EventRelay m_EInputCommand; - bool OnInputCommand(const Events::InputCommand& e); - std::unordered_map m_AutoBlendQueues; }; diff --git a/resources/Schema/Entities/AssaultBlendTree.xml b/resources/Schema/Entities/AssaultBlendTree.xml new file mode 100644 index 00000000..e8dcff8a --- /dev/null +++ b/resources/Schema/Entities/AssaultBlendTree.xml @@ -0,0 +1,513 @@ + + + + + + AimBlend + FinalBlend + + + 5 + Models/Characters/Assault/AssaultBlue.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + + + AimPrimary + AimSecondary + 0 + true + + + + + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + + + + ReloadSwitchBlend + MovementBlend + + + + + + + + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 + true + + + + + + + + StandMovement + CrouchMovement + 0.012867419418159054 + true + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + MovementBlend + Idle + 0 + + + + + + + + Walk + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + + 1 + true + + + + + + + + + + + CrouchWalkF + + 1 + true + + + + + + + + + + + CrouchF + + 1 + + + + + + + + + + + + + Jump + DashBlend + 1 + true + + + + + + + + JumpF + + 1 + false + + + + + + + + + DashFBBlend + DashLRBlend + 0.014621149736541383 + + + + + + + + DashForward + DashBackward + 0.014363533804961248 + + + + + + + + DashForwardF + + 1 + false + + + + + + + + + DashBackwardF + + 1 + false + + + + + + + + + + + DashLeft + DashRight + 4.3244885367500671e-16 + + + + + + + + DashLeftF + + 1 + false + + + + + + + + + DashRightF + + 1 + false + + + + + + + + + + + + + + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + 1 + true + + + + + + + + + IdleSecWepU + + 1 + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/BlendTreeTest.xml b/resources/Schema/Entities/BlendTreeTest.xml index a3188348..79e2e223 100644 --- a/resources/Schema/Entities/BlendTreeTest.xml +++ b/resources/Schema/Entities/BlendTreeTest.xml @@ -68,8 +68,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -86,11 +86,11 @@ - + - AimRifleA - + AimSecWepA + false true @@ -98,10 +98,10 @@ - + - AimSecWepA + AimRifleA false true @@ -148,7 +148,7 @@ MovementBlend Idle - 0 + 1 @@ -177,7 +177,7 @@ WalkF - + 1 true @@ -189,7 +189,7 @@ RunF - + 1 true @@ -213,7 +213,7 @@ StrafeLeftF - + 1 true @@ -225,7 +225,7 @@ StrafeRightF - + 1 true @@ -241,8 +241,9 @@ IdleF - + 1 + true @@ -284,7 +285,7 @@ CrouchStrafeLeftF - + 1 true @@ -296,7 +297,7 @@ CrouchStrafeRightF - + 1 true @@ -310,7 +311,7 @@ CrouchWalkF - + 1 true @@ -473,7 +474,7 @@ IdleBlend ShootBlend - 1 + 0 @@ -483,6 +484,7 @@ IdlePrimary IdleSecondary + 0 @@ -491,6 +493,9 @@ IdleAssaultRifleU + + 1 + true @@ -500,6 +505,9 @@ IdleSecWepU + + 1 + true diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 5c048fed..99643997 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -4,7 +4,6 @@ AnimationSystem::AnimationSystem(SystemParams params) : System(params) { EVENT_SUBSCRIBE_MEMBER(m_EAutoAnimationBlend, &AnimationSystem::OnAutoAnimationBlend); - EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &AnimationSystem::OnInputCommand); } void AnimationSystem::Update(double dt) @@ -16,7 +15,6 @@ void AnimationSystem::Update(double dt) for(auto& autoBlendQueue : m_AutoBlendQueues) { autoBlendQueue.second.UpdateTime(dt); - // autoBlendQueue.second.PrintQueue(); } } @@ -136,7 +134,6 @@ void AnimationSystem::UpdateWeights(double dt) if (blendTree != nullptr) { blendJob.BlendInfo.progress = glm::clamp(blendJob.CurrentTime / blendJob.Duration, 0.0, 1.0); - LOG_INFO("Progress: %f, %s", blendJob.BlendInfo.progress, blendJob.BlendInfo.NodeName.c_str()); blendJob.BlendInfo = blendTree->AutoBlendStep(blendJob.BlendInfo); } @@ -215,376 +212,6 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) } } } - - - LOG_INFO("Inserting %s blendJob into %s subtree", e.NodeName.c_str(), subTreeRoot.Name().c_str()); m_AutoBlendQueues[subTreeRoot].Insert(abj); - - LOG_INFO("\n"); - m_AutoBlendQueues.at(subTreeRoot).PrintQueue(); - LOG_INFO("\n"); - - return true; } - -bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) -{ - - if (e.Value == 1.f) { - if(e.Command == "DashForward") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.2; - aeb.NodeName = "DashForward"; - aeb.RootNode = entity; - aeb.Restart = true; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandCrouchBlend"; - aeb.RootNode = entity; - aeb.Delay = -0.3; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("DashForward"); - m_EventBroker->Publish(aeb); - } - } - } - - } else if (e.Command == "DashBackward") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "DashBackward"; - aeb.RootNode = entity; - aeb.Restart = true; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandCrouchBlend"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = false; - aeb.Delay = -0.3; - aeb.AnimationEntity = entity.FirstChildByName("DashBackward"); - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "DashLeft") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "DashLeft"; - aeb.RootNode = entity; - aeb.Restart = true; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandCrouchBlend"; - aeb.RootNode = entity; - aeb.Delay = -0.3; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("DashLeft"); - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "DashRight") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "DashRight"; - aeb.RootNode = entity; - aeb.Restart = true; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandCrouchBlend"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("DashRight"); - aeb.Delay = -0.3; - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "Jump") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.25; - aeb.NodeName = "Jump"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandCrouchBlend"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("Jump"); - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "Reload") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.2; - aeb.NodeName = "ReloadSwitch"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.2; - aeb.NodeName = "IdlePrimary"; - aeb.RootNode = entity; - aeb.Delay = -0.1; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("ReloadSwitch"); - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "Crouch") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "CrouchMovement"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = true; - aeb.SingleLevelBlend = true; - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "Shoot") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "ShootPrimary"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "IdlePrimary"; - aeb.RootNode = entity; - aeb.Delay = 0.0; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("ShootPrimary"); - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "LeftTest") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "Left"; - aeb.RootNode = entity; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "RightTest") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "Right"; - aeb.RootNode = entity; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - - } - } - } else if (e.Command == "ForwardTest") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "Walk"; - aeb.RootNode = entity; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - } - } - } - } else if (e.Command == "BackwardTest") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "Walk"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Reverse = true; - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Value == 0.f) { - if (e.Command == "Crouch") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandMovement"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = true; - aeb.SingleLevelBlend = true; - m_EventBroker->Publish(aeb); - } - } - } - } - } -} - diff --git a/src/Engine/Rendering/AutoBlendQueue.cpp b/src/Engine/Rendering/AutoBlendQueue.cpp index 7ea79383..cafb7ee5 100644 --- a/src/Engine/Rendering/AutoBlendQueue.cpp +++ b/src/Engine/Rendering/AutoBlendQueue.cpp @@ -45,7 +45,6 @@ void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob) AnimationDuration = (animation->Duration * animationSpeed) - animationTime; } - LOG_INFO("Animation Duration %f", AnimationDuration); blendNode.StartTime += AnimationDuration; blendNode.EndTime += AnimationDuration; if (m_BlendQueue.size() == 0) { @@ -61,16 +60,13 @@ void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob) if (next != m_BlendQueue.end()) { if (it->StartTime >= blendNode.StartTime && next->StartTime <= blendNode.StartTime) { - LOG_INFO("Inserted %s between %s and %s", blendNode.BlendJob.BlendInfo.NodeName.c_str(), it->BlendJob.BlendInfo.NodeName.c_str(), next->BlendJob.BlendInfo.NodeName.c_str()); m_BlendQueue.insert(next, blendNode); return; } } else if(it->StartTime > blendNode.StartTime){ - LOG_INFO("Inserted %s after %s", blendNode.BlendJob.BlendInfo.NodeName.c_str(), it->BlendJob.BlendInfo.NodeName.c_str()); m_BlendQueue.push_front(blendNode); return; } else if (it->StartTime <= blendNode.StartTime) { - LOG_INFO("Inserted %s after %s", blendNode.BlendJob.BlendInfo.NodeName.c_str(), it->BlendJob.BlendInfo.NodeName.c_str()); m_BlendQueue.push_back(blendNode); return; } @@ -80,7 +76,6 @@ void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob) } - LOG_INFO("Cleared BlendQueue and inserted %s", blendNode.BlendJob.BlendInfo.NodeName.c_str()); m_BlendQueue.clear(); m_BlendQueue.push_back(blendNode); }