fixed crashes

This commit is contained in:
viktorljung
2016-01-24 21:12:41 +01:00
parent 8cf9caf7aa
commit a304b00038
5 changed files with 59 additions and 40 deletions
+1 -1
Submodule assets updated: 068fbb2d20...5f3ab8b35d
+1 -1
View File
@@ -41,7 +41,7 @@ struct ModelJob : RenderJob
Skeleton = Model->m_RawModel->m_Skeleton;
if (world->HasComponent(Entity, "Animation")) {
if (world->HasComponent(Entity, "Animation") && Skeleton != nullptr) {
auto animationComponent = world->GetComponent(Entity, "Animation");
Animation = model->m_RawModel->m_Skeleton->GetAnimation(animationComponent["Name"]);
AnimationTime = (double)animationComponent["Time"];
+27 -21
View File
@@ -17,25 +17,46 @@
<c:RaptorCopter>
<Axis X="1.50000012" Y="-2.20000005" Z="2.10000014"/>
</c:RaptorCopter>
<c:Transform/>
<c:Transform>
<Position X="0" Y="2.87819886" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Animation>
<Name>running</Name>
<Time>0.9981707605223491</Time>
<Speed>1</Speed>
<Name>Crouch Walk</Name>
<Time>701.10570384634161</Time>
<Speed>32</Speed>
</c:Animation>
<c:Model>
<Resource>Models/Animtest.mesh</Resource>
<Resource>Models/AssaultAnimated.mesh</Resource>
<Color A="1" B="392156.875" G="1" R="1"/>
</c:Model>
<c:Transform>
<Position X="0" Y="0.5" Z="0"/>
</c:Transform>
</Components>
<Children/>
<Children>
<Entity>
<Components>
<c:Text>
<Content>pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew pew </Content>
<Resource>Fonts/DroidSans.ttf,60</Resource>
<Color A="0" B="0.972549021" G="3.92156863" R="39.2156868"/>
<Alignment>
<Left/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="0.245514169" Y="0.817000031" Z="-0.883219421"/>
<Scale X="0.300000012" Y="0.300000012" Z="1"/>
<Orientation X="0" Y="1.52600002" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
@@ -46,21 +67,6 @@
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Text>
<Content>Got to Go FAST!!!!</Content>
<Resource>Fonts/DroidSans.ttf,60</Resource>
<Color A="0" B="0.972549021" G="3.92156863" R="39.2156868"/>
</c:Text>
<c:Transform>
<Position X="0" Y="0.616941631" Z="0"/>
<Scale X="0.5" Y="0.5" Z="1"/>
<Orientation X="0" Y="4.47399998" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+4 -2
View File
@@ -80,7 +80,7 @@
</c:RaptorCopter>
<c:Transform>
<Position X="0" Y="2.37320328" Z="0"/>
<Orientation X="0" Y="9447.45117" Z="0"/>
<Orientation X="0" Y="9868.3418" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -275,7 +275,9 @@
<Entity>
<Components>
<c:Animation>
<Name></Name>
<Name>running</Name>
<Time>0.93047409991569907</Time>
<Speed>1</Speed>
</c:Animation>
<c:Model>
<Resource>Models/Animtest.mesh</Resource>
+26 -15
View File
@@ -6,31 +6,42 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
return;
}
Model* model = ResourceManager::Load<Model>(entity["Model"]["Resource"]);
Model* model;
try {
model = ResourceManager::Load<::Model, true>(entity["Model"]["Resource"]);
} catch (const std::exception&) {
return;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["Name"]);
double animationSpeed = (double)animationComponent["Speed"];
if(animation != nullptr) {
double animationSpeed = (double)animationComponent["Speed"];
if( animationSpeed != 0.0) {
double nextTime = (double)animationComponent["Time"] + animationSpeed * dt;
if (animationSpeed != 0.0) {
double nextTime = (double)animationComponent["Time"] + animationSpeed * dt;
if (!(bool)animationComponent["Loop"] && glm::abs(nextTime) > animation->Duration) {
(double&)animationComponent["Time"] = glm::sign(nextTime) * animation->Duration;
(double&)animationComponent["Speed"] = 0.0;
Events::AnimationComplete e;
e.Entity = entity;
e.Name = (std::string)animationComponent["Name"];
m_EventBroker->Publish(e);
} else {
if (glm::abs(nextTime) > animation->Duration) {
(double&)animationComponent["Time"] = glm::abs(nextTime) - animation->Duration;
if (!(bool)animationComponent["Loop"] && glm::abs(nextTime) > animation->Duration) {
(double&)animationComponent["Time"] = glm::sign(nextTime) * animation->Duration;
(double&)animationComponent["Speed"] = 0.0;
Events::AnimationComplete e;
e.Entity = entity;
e.Name = (std::string)animationComponent["Name"];
m_EventBroker->Publish(e);
} else {
(double&)animationComponent["Time"] = nextTime;
if (glm::abs(nextTime) > animation->Duration) {
(double&)animationComponent["Time"] = glm::abs(nextTime) - animation->Duration;
} else {
(double&)animationComponent["Time"] = nextTime;
}
}
}
}
}