mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-04 11:35:06 +03:00
Calculate Forward and Right vector fixed gizmo stutter
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -204,8 +204,9 @@ namespace Nuake {
|
||||
ParentComponent& parent = Selection.Entity.GetComponent<ParentComponent>();
|
||||
if (parent.HasParent)
|
||||
{
|
||||
Matrix4 inverseParent = glm::inverse(parent.Parent.GetComponent<TransformComponent>().GetGlobalTransform());
|
||||
localTransform = inverseParent * localTransform;
|
||||
const auto& parentTransformComponent = parent.Parent.GetComponent<TransformComponent>();
|
||||
const Matrix4& parentTransform = parentTransformComponent.GetGlobalTransform();
|
||||
localTransform = glm::inverse(parentTransform) * localTransform;
|
||||
}
|
||||
|
||||
// Decompose local transform
|
||||
@@ -217,20 +218,17 @@ namespace Nuake {
|
||||
glm::decompose(localTransform, scale, rotation, pos, skew, pesp);
|
||||
|
||||
tc.Translation = pos;
|
||||
|
||||
rotation.w *= -1.0f;
|
||||
tc.Rotation = rotation;
|
||||
tc.Scale = scale;
|
||||
tc.LocalTransform = localTransform;
|
||||
tc.Dirty = true;
|
||||
//tc.Dirty = true;
|
||||
|
||||
const Matrix4& translationMatrix = glm::translate(Matrix4(1.0f), pos);
|
||||
const Matrix4& rotationMatrix = glm::mat4_cast(rotation);
|
||||
const Matrix4& scaleMatrix = glm::scale(Matrix4(1.0f), scale);
|
||||
const Matrix4& newLocalTransform = translationMatrix * rotationMatrix * scaleMatrix;
|
||||
|
||||
//tc.SetLocalPosition(pos);
|
||||
//tc.SetLocalRotation(-rotationQuaternion);
|
||||
//tc.SetLocalScale(scale);
|
||||
//tc.SetLocalTransform(localTransform);
|
||||
|
||||
// Decompose global trasnform
|
||||
Vector3 gscale = Vector3();
|
||||
|
||||
@@ -89,6 +89,7 @@ namespace Nuake
|
||||
void Camera::SetTransform(const Matrix4& transform)
|
||||
{
|
||||
m_View = transform;
|
||||
|
||||
}
|
||||
|
||||
Matrix4 Camera::GetTransform()
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace Nuake
|
||||
Vector3 Rotation = { 0.0f, 0.0f, 0.0f };
|
||||
Vector3 Scale = { 1.0f, 1.0f, 1.0f };
|
||||
Vector3 Up = Vector3(0, 1, 0);
|
||||
Vector3 Right = Vector3(1, 0, 0);
|
||||
Matrix4 m_Perspective;
|
||||
Matrix4 m_View;
|
||||
|
||||
@@ -32,6 +31,8 @@ namespace Nuake
|
||||
float AspectRatio = 16.0f / 9.0f;
|
||||
|
||||
Vector3 Direction = Vector3(0, 0, 1);
|
||||
Vector3 Right = Vector3(1, 0, 0);
|
||||
|
||||
Vector3 Translation = { 0.0f, 0.0f, 0.0f };
|
||||
float Fov = 88.0f;
|
||||
float Exposure = 1.0f;
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Nuake
|
||||
auto& localScale = transform.GetLocalScale();
|
||||
|
||||
const Matrix4& translationMatrix = glm::translate(Matrix4(1.0f), localTranslate);
|
||||
localRot.w *= -1.0f;
|
||||
//localRot.w *= -1.0f;
|
||||
const Matrix4& rotationMatrix = glm::mat4_cast(localRot);
|
||||
const Matrix4& scaleMatrix = glm::scale(Matrix4(1.0f), localScale);
|
||||
const Matrix4& newLocalTransform = translationMatrix * rotationMatrix * scaleMatrix;
|
||||
@@ -116,7 +116,14 @@ namespace Nuake
|
||||
auto globalRotation = transform.GetGlobalRotation();
|
||||
auto& trnaslationMatrix = glm::translate(Matrix4(1.0f), transform.GetGlobalPosition());
|
||||
const Matrix4& rotationMatrix = glm::mat4_cast(globalRotation);
|
||||
camera.CameraInstance->SetTransform(glm::inverse(trnaslationMatrix * rotationMatrix));
|
||||
Vector4 forward = Vector4(0, 0, -1, 1);
|
||||
const auto globalForward = rotationMatrix * forward;
|
||||
|
||||
Vector4 right = Vector4(1, 0, 0, 1);
|
||||
const auto globalRight = rotationMatrix * right;
|
||||
camera.CameraInstance->Direction = globalForward;
|
||||
camera.CameraInstance->Right = globalRight;
|
||||
; camera.CameraInstance->SetTransform(glm::inverse(trnaslationMatrix * rotationMatrix));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user