3rd person animations idle bug fixed

This commit is contained in:
viktorljung
2016-03-12 15:47:19 +01:00
parent 060585a388
commit 0b26f23188
8 changed files with 67 additions and 153 deletions
@@ -163,6 +163,7 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
aeb.Duration = 0.1;
aeb.NodeName = "Run";
aeb.RootNode = firstPersonModel;
aeb.SingleLevelBlend = true;
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
@@ -172,6 +173,7 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
aeb.Duration = 0.1;
aeb.NodeName = "Run";
aeb.RootNode = firstPersonModel;
aeb.SingleLevelBlend = true;
aeb.Start = true;
aeb.Reverse = true;
m_EventBroker->Publish(aeb);
@@ -211,10 +213,10 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
}
}
//Animation
if (glm::length2(m_Movement) < 0.25f) {
//Blend to Idle
if (m_PlayerEntity.Valid()) {
if (m_PlayerEntity.Valid()) {
glm::vec2 movementXZ = glm::vec2(m_Movement.x, m_Movement.z);
if (glm::length(movementXZ) < 0.1f) {
//Blend to Idle
EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel");
if (playerModel.Valid()) {
Events::AutoAnimationBlend aeb;
@@ -233,10 +235,8 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
}
} else {
//Blend to movement
if (m_PlayerEntity.Valid()) {
} else {
//Blend to movement
EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel");
if (playerModel.Valid()) {
Events::AutoAnimationBlend aeb;
@@ -248,8 +248,7 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
}
}
if (glm::length2(m_Movement) > 0) {
if (glm::length(m_Movement) > 0) {
m_Movement = glm::normalize(m_Movement);
//Animation
+1 -2
View File
@@ -49,9 +49,7 @@ public:
next = next->Child[0];
}
}
return next;
}
};
@@ -82,6 +80,7 @@ public:
BlendTree::Node* FirstCommonParent(Node* node1, Node* node2);
EntityWrapper GetSubTreeRoot(std::string nodeName);
std::vector<EntityWrapper> GetSubTreeRoots(std::string nodeName);
std::vector<EntityWrapper> GetSingleLevelRoots(std::string name);
std::vector<EntityWrapper> GetEntitesByName(std::string name);
+24 -70
View File
@@ -583,8 +583,8 @@
<EntityFile>Schema/Entities/WeaponAssaultBlueWorld.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.128669754" Y="1.08486295" Z="-0.361068189"/>
<Orientation X="-0.0353791788" Y="-0.0854677409" Z="0.133094966"/>
<Position X="0.128669813" Y="1.08486295" Z="-0.361068189"/>
<Orientation X="-0.0353792347" Y="-0.0854677409" Z="0.133094937"/>
</c:Transform>
<c:WeaponAttachment>
<Weapon>AssaultWeapon</Weapon>
@@ -604,8 +604,8 @@
<EntityFile>Schema/Entities/SidearmWeaponBlueWorld.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.128669754" Y="1.08486295" Z="-0.361068189"/>
<Orientation X="-0.0353791788" Y="-0.0854677409" Z="0.133094966"/>
<Position X="0.128669813" Y="1.08486295" Z="-0.361068189"/>
<Orientation X="-0.0353792347" Y="-0.0854677409" Z="0.133094937"/>
</c:Transform>
<c:WeaponAttachment>
<Weapon>SidearmWeapon</Weapon>
@@ -959,7 +959,7 @@
<Entity name="WeaponBlend">
<Components>
<c:BlendAdditive>
<Adder>MovementBlend</Adder>
<Adder>IdleAssault</Adder>
<Receiver>ActionBlend</Receiver>
</c:BlendAdditive>
<c:Transform/>
@@ -998,41 +998,17 @@
</Entity>
</Children>
</Entity>
<Entity name="MovementBlend2">
<Entity name="IdleAssault">
<Components>
<c:Blend>
<Pose1>Idle</Pose1>
<Pose2>Run</Pose2>
<Weight>0</Weight>
</c:Blend>
<c:Animation>
<AnimationName>IdleAssaultRifleU</AnimationName>
<Time>1.9871198993639698</Time>
<Play>true</Play>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children>
<Entity name="Run">
<Components>
<c:Animation>
<AnimationName>IdleAssaultRifleU</AnimationName>
<Time>1.9871198993639698</Time>
<Play>true</Play>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="Idle">
<Components>
<c:Animation>
<AnimationName>IdleAssaultRifleU</AnimationName>
<Time>1.9871198993639698</Time>
<Play>true</Play>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
<Children/>
</Entity>
</Children>
</Entity>
@@ -1063,44 +1039,12 @@
<Entity name="WeaponBlend">
<Components>
<c:BlendAdditive>
<Adder>MovementBlend2</Adder>
<Adder>IdleSidearm</Adder>
<Receiver>ActionBlend</Receiver>
</c:BlendAdditive>
<c:Transform/>
</Components>
<Children>
<Entity name="MovementBlend2">
<Components>
<c:Blend>
<Pose1>Idle</Pose1>
<Pose2>Run</Pose2>
<Weight>0</Weight>
</c:Blend>
<c:Transform/>
</Components>
<Children>
<Entity name="Idle">
<Components>
<c:Animation>
<AnimationName>IdleSecWepU</AnimationName>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="Run">
<Components>
<c:Animation>
<AnimationName>IdleSecWepU</AnimationName>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="ActionBlend">
<Components>
<c:Blend>
@@ -1133,6 +1077,16 @@
</Entity>
</Children>
</Entity>
<Entity name="IdleSidearm">
<Components>
<c:Animation>
<AnimationName>IdleSecWepU</AnimationName>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="Aim">
@@ -857,48 +857,12 @@
<Entity name="WeaponBlend">
<Components>
<c:BlendAdditive>
<Adder>MovementBlend2</Adder>
<Adder>IdleDefender</Adder>
<Receiver>FinalBlend</Receiver>
</c:BlendAdditive>
<c:Transform/>
</Components>
<Children>
<Entity name="MovementBlend2">
<Components>
<c:Blend>
<Pose1>Idle</Pose1>
<Pose2>Run</Pose2>
<Weight>0</Weight>
</c:Blend>
<c:Transform/>
</Components>
<Children>
<Entity name="Run">
<Components>
<c:Animation>
<AnimationName>IdleAssaultRifleU</AnimationName>
<Time>0.74083502154680936</Time>
<Play>true</Play>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="Idle">
<Components>
<c:Animation>
<AnimationName>IdleAssaultRifleU</AnimationName>
<Time>0.74083502154680936</Time>
<Play>true</Play>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="FinalBlend">
<Components>
<c:Blend>
@@ -980,6 +944,18 @@
</Entity>
</Children>
</Entity>
<Entity name="IdleDefender">
<Components>
<c:Animation>
<AnimationName>IdleAssaultRifleU</AnimationName>
<Time>0.74083502154680936</Time>
<Play>true</Play>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="Aim">
@@ -1007,7 +983,7 @@
<Entity name="WeaponBlend">
<Components>
<c:BlendAdditive>
<Adder>MovementBlend2</Adder>
<Adder>IdleSidearm</Adder>
<Receiver>ActionBlend</Receiver>
</c:BlendAdditive>
<c:Transform/>
@@ -1044,36 +1020,15 @@
</Entity>
</Children>
</Entity>
<Entity name="MovementBlend2">
<Entity name="IdleSidearm">
<Components>
<c:Blend>
<Pose1>Idle</Pose1>
<Pose2>Run</Pose2>
</c:Blend>
<c:Animation>
<AnimationName>IdleSecWepU</AnimationName>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children>
<Entity name="Idle">
<Components>
<c:Animation>
<AnimationName>IdleSecWepU</AnimationName>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="Run">
<Components>
<c:Animation>
<AnimationName>IdleSecWepU</AnimationName>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
<Children/>
</Entity>
</Children>
</Entity>
+9 -3
View File
@@ -127,8 +127,8 @@ void AnimationSystem::UpdateAnimations(double dt)
void AnimationSystem::UpdateWeights(double dt)
{
for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) {
/* LOG_INFO("%s", it->first.Name().c_str());
it->second.PrintQueue();*/
//LOG_INFO("%s", it->first.Name().c_str());
//it->second.PrintQueue();
if(it->second.HasActiveBlendJob()) {
AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob();
@@ -158,12 +158,13 @@ void AnimationSystem::UpdateWeights(double dt)
bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
{
if (!e.RootNode.Valid()) {
LOG_ERROR("%s, RootNode invalid %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
if (!e.RootNode.HasComponent("Model")) {
LOG_ERROR("%s, RootNode has no model %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
@@ -171,11 +172,13 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
try {
model = ResourceManager::Load<::Model, true>((std::string)e.RootNode["Model"]["Resource"]);
} catch (const std::exception&) {
LOG_ERROR("%s, RootNode model not finished loading %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
if (skeleton == nullptr) {
LOG_ERROR("%s, RootNode skeleton invalid %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
@@ -183,6 +186,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
if (skeleton->BlendTrees.find(e.RootNode) != skeleton->BlendTrees.end()) {
blendTree = skeleton->BlendTrees.at(e.RootNode);
} else {
LOG_ERROR("%s, No blendtree was found invalid %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
@@ -193,6 +197,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
subTreeRoot = blendTree->GetSubTreeRoot(e.NodeName);
if (!subTreeRoot.Valid()) {
LOG_ERROR("%s, subTreeRoot invalid", e.NodeName);
return false;
}
@@ -237,6 +242,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
subTreeRoot = entity;
if (!subTreeRoot.Valid()) {
LOG_ERROR("%s, subTreeRoot invalid", e.NodeName);
return false;
}
@@ -24,6 +24,8 @@ void PlayerMovementSystem::Update(double dt)
if (LocalPlayer.Valid()){
updateVelocity(LocalPlayer, dt);
}
m_SprintEffectTimer += dt;
if (m_SprintEffectTimer < 0.016f) {
return;
@@ -74,7 +74,7 @@ void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo&
float animationWeight = glm::min(speed, movementSpeed) / movementSpeed;
EntityWrapper rootNode = wi.FirstPersonEntity;
if (rootNode.Valid()) {
EntityWrapper blend = rootNode.FirstChildByName("MovementBlend");
EntityWrapper blend = rootNode.FirstChildByName("MovementBlendAssault");
if (blend.Valid()) {
(double&)blend["Blend"]["Weight"] = animationWeight;
}
@@ -14,7 +14,6 @@ void SidearmWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWra
void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt)
{
CheckAmmo(cWeapon, wi);
// Start reloading automatically if at 0 mag ammo
@@ -64,7 +63,7 @@ void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo&
float animationWeight = glm::min(speed, movementSpeed) / movementSpeed;
EntityWrapper rootNode = wi.FirstPersonEntity;
if (rootNode.Valid()) {
EntityWrapper blend = rootNode.FirstChildByName("MovementBlend");
EntityWrapper blend = rootNode.FirstChildByName("MovementBlendSidearm");
if (blend.Valid()) {
(double&)blend["Blend"]["Weight"] = animationWeight;
}