Fixed absolute positions once and for all (maybe?)

This commit is contained in:
2015-12-13 23:39:22 +01:00
parent 2f3843e595
commit 7c1182c28f
2 changed files with 20 additions and 16 deletions
+15 -11
View File
@@ -23,15 +23,19 @@ glm::mat4 RenderQueueFactory::ModelMatrix(World* world, EntityID entity)
return modelMatrix;
}
glm::vec3 RenderQueueFactory::AbsolutePosition(World* world, EntityID entity)
{
glm::vec3 position;
do {
ComponentWrapper transform = world->GetComponent(entity, "Transform");
position += (glm::vec3)transform["Position"];
entity = world->GetParent(entity);
EntityID parent = world->GetParent(entity);
if (parent != 0) {
position += AbsoluteOrientation(world, parent) * (glm::vec3)transform["Position"];
} else {
position += (glm::vec3)transform["Position"];
}
entity = parent;
} while (entity != 0);
return position;
@@ -52,15 +56,15 @@ glm::quat RenderQueueFactory::AbsoluteOrientation(World* world, EntityID entity)
glm::vec3 RenderQueueFactory::AbsoluteScale(World* world, EntityID entity)
{
ComponentWrapper transform = world->GetComponent(entity, "Transform");
glm::vec3 scale = (glm::vec3)transform["Scale"];
glm::vec3 scale(1.f);
EntityID parent = world->GetParent(entity);
if (parent != 0) {
return AbsoluteScale(world, parent) * scale;
} else {
return scale;
}
do {
ComponentWrapper transform = world->GetComponent(entity, "Transform");
scale *= (glm::vec3)transform["Scale"];
entity = world->GetParent(entity);
} while (entity != 0);
return scale;
}
void RenderQueueFactory::FillModels(World* world, RenderQueue* renderQueue)