Fixed Transform::AbsolutePosition to take scale into account properly maybe?

This commit is contained in:
2016-03-09 22:04:13 +01:00
parent e11cdaa662
commit 727b6ba871
+6 -6
View File
@@ -24,7 +24,7 @@ glm::vec3 Transform::AbsolutePosition(World* world, EntityID entity)
while (entity != EntityID_Invalid) {
ComponentWrapper transform = world->GetComponent(entity, "Transform");
EntityID parent = world->GetParent(entity);
position += Transform::AbsoluteOrientation(world, parent) * (glm::vec3)transform["Position"];
position += Transform::AbsoluteScale(world, parent) * (Transform::AbsoluteOrientation(world, parent) * (glm::vec3)transform["Position"]);
entity = parent;
}
@@ -89,12 +89,12 @@ glm::mat4 Transform::ModelMatrix(EntityID entity, World* world)
{
return AbsoluteTransformation(EntityWrapper(world, entity));
glm::vec3 position = Transform::AbsolutePosition(world, entity);
glm::quat orientation = Transform::AbsoluteOrientation(world, entity);
glm::vec3 scale = Transform::AbsoluteScale(world, entity);
//glm::vec3 position = Transform::AbsolutePosition(world, entity);
//glm::quat orientation = Transform::AbsoluteOrientation(world, entity);
//glm::vec3 scale = Transform::AbsoluteScale(world, entity);
glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(orientation) * glm::scale(scale);
return modelMatrix;
//glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(orientation) * glm::scale(scale);
//return modelMatrix;
}
glm::vec3 Transform::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)