diff --git a/assets b/assets
index 172b3ad5..c56f6380 160000
--- a/assets
+++ b/assets
@@ -1 +1 @@
-Subproject commit 172b3ad527fc14aa6175fa72580a66a00f04e0ba
+Subproject commit c56f6380ab05c23419beafe14190013d1432e32c
diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml
index 09573ac7..6536a839 100644
--- a/resources/Schema/Entities/AnimationTests2.xml
+++ b/resources/Schema/Entities/AnimationTests2.xml
@@ -55,498 +55,23 @@
-
+
-
+
+ R_Arm_Weapon_Joint
+
+
+
+ Models/Weapons/Blue/AssaultWeapon.mesh
+
+ true
+
+
+
+
+
-
-
-
-
- R_Arm_Weapon_Joint
-
-
-
- Models/Weapons/Blue/AssaultWeapon.mesh
-
- true
-
-
-
-
-
-
-
-
-
-
-
- R_Hand
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- R_Arm
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- R_Shoulder
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- Neck
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- Spine_3
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- Spine_2
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- Spine_1
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- Hip
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- L_Leg_Top
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- L_Leg_Bottom
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- L_Foot
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- L_Toe
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- L_Shoulder
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- L_Arm
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- L_Hand
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- L_Shoulder_Armor_Joint
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- Chin
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- Head
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- Perietal
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- L_Elbow
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- R_Leg_Bottom
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- R_Elbow
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- R_Leg_Top
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- R_Foot
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- R_Toe
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
-
-
- R_Shoulder_Armor_Joint
-
-
-
- Models/Core/UnitCube.mesh
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp
index 25813a63..48681e6e 100644
--- a/src/Engine/Rendering/AnimationSystem.cpp
+++ b/src/Engine/Rendering/AnimationSystem.cpp
@@ -13,9 +13,7 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
return;
}
-
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
-
if(skeleton == nullptr) {
return;
}
@@ -33,20 +31,27 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
double nextTime = (double)animationComponent["Time" + std::to_string(i)] + animationSpeed * dt;
- if (!(bool)animationComponent["Loop" + std::to_string(i)] && glm::abs(nextTime) > animation->Duration) {
- (double&)animationComponent["Time" + std::to_string(i)] = glm::sign(nextTime) * animation->Duration;
+ if (!(bool)animationComponent["Loop" + std::to_string(i)]) {
+ if (nextTime > animation->Duration) {
+ nextTime = animation->Duration;
+ } else if (nextTime < 0) {
+ nextTime = 0;
+ }
+
(double&)animationComponent["Speed" + std::to_string(i)] = 0.0;
Events::AnimationComplete e;
e.Entity = entity;
e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)];
m_EventBroker->Publish(e);
} else {
- if (glm::abs(nextTime) > animation->Duration) {
- (double&)animationComponent["Time" + std::to_string(i)] = glm::abs(nextTime) - animation->Duration;
- } else {
- (double&)animationComponent["Time" + std::to_string(i)] = nextTime;
+ if (nextTime > animation->Duration) {
+ nextTime -= animation->Duration;
+ } else if (nextTime < 0) {
+ nextTime += animation->Duration;
}
}
+
+ (double&)animationComponent["Time" + std::to_string(i)] = nextTime;
}
}
diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp
index 71f351e6..82d50522 100644
--- a/src/Engine/Rendering/Skeleton.cpp
+++ b/src/Engine/Rendering/Skeleton.cpp
@@ -96,6 +96,7 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorDuration - currentFrame.Time);
} else {
progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
@@ -225,6 +226,7 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorDuration - currentFrame.Time);
} else {
progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
@@ -343,6 +345,7 @@ glm::mat4 Skeleton::GetOffsetTransform(const Bone* bone, AnimationOffset animati
float progress;
if (nextFrame.Index == 0) {
+ nextFrame = currentFrame;
progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time);
} else {
progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
@@ -394,6 +397,7 @@ glm::mat4 Skeleton::GetBoneTransform(const Bone* bone, const Animation* animatio
float progress;
if (nextFrame.Index == 0) {
+ nextFrame = currentFrame;
progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time);
} else {
progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);