Fixed Transform::AbsolutePosition to take scale into account properly maybe?
This commit is contained in:
@@ -24,7 +24,7 @@ glm::vec3 Transform::AbsolutePosition(World* world, EntityID entity)
|
|||||||
while (entity != EntityID_Invalid) {
|
while (entity != EntityID_Invalid) {
|
||||||
ComponentWrapper transform = world->GetComponent(entity, "Transform");
|
ComponentWrapper transform = world->GetComponent(entity, "Transform");
|
||||||
EntityID parent = world->GetParent(entity);
|
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;
|
entity = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,12 +89,12 @@ glm::mat4 Transform::ModelMatrix(EntityID entity, World* world)
|
|||||||
{
|
{
|
||||||
return AbsoluteTransformation(EntityWrapper(world, entity));
|
return AbsoluteTransformation(EntityWrapper(world, entity));
|
||||||
|
|
||||||
glm::vec3 position = Transform::AbsolutePosition(world, entity);
|
//glm::vec3 position = Transform::AbsolutePosition(world, entity);
|
||||||
glm::quat orientation = Transform::AbsoluteOrientation(world, entity);
|
//glm::quat orientation = Transform::AbsoluteOrientation(world, entity);
|
||||||
glm::vec3 scale = Transform::AbsoluteScale(world, entity);
|
//glm::vec3 scale = Transform::AbsoluteScale(world, entity);
|
||||||
|
|
||||||
glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(orientation) * glm::scale(scale);
|
//glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(orientation) * glm::scale(scale);
|
||||||
return modelMatrix;
|
//return modelMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 Transform::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)
|
glm::vec3 Transform::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)
|
||||||
|
|||||||
Reference in New Issue
Block a user