add transform class, some code tweaks
This commit is contained in:
@ -218,7 +218,7 @@ namespace Prism
|
||||
auto viewProj = m_EditorCamera.GetViewProjection();
|
||||
Renderer2D::BeginScene(viewProj, false);
|
||||
glm::vec4 color = (m_SelectionMode == SelectionMode::Entity) ? glm::vec4{ 1.0f, 1.0f, 1.0f, 1.0f } : glm::vec4{ 0.2f, 0.9f, 0.2f, 1.0f };
|
||||
Renderer::DrawAABB(selection.Mesh->BoundingBox, selection.Entity.GetComponent<TransformComponent>().Transform * selection.Mesh->Transform, color);
|
||||
Renderer::DrawAABB(selection.Mesh->BoundingBox, selection.Entity.GetComponent<TransformComponent>().Transformation.GetMatrix() * selection.Mesh->Transform, color);
|
||||
Renderer2D::EndScene();
|
||||
Renderer::EndRenderPass();
|
||||
}
|
||||
@ -231,7 +231,7 @@ namespace Prism
|
||||
if (selection.Entity.HasComponent<BoxCollider2DComponent>())
|
||||
{
|
||||
const auto& size = selection.Entity.GetComponent<BoxCollider2DComponent>().Size;
|
||||
auto [translation, rotationQuat, scale] = GetTransformDecomposition(selection.Entity.GetComponent<TransformComponent>().Transform);
|
||||
auto [translation, rotationQuat, scale] = GetTransformDecomposition(selection.Entity.GetComponent<TransformComponent>().Transformation.GetMatrix());
|
||||
const glm::vec3 rotation = glm::eulerAngles(rotationQuat);
|
||||
|
||||
Renderer::BeginRenderPass(SceneRenderer::GetFinalRenderPass(), false);
|
||||
@ -786,21 +786,27 @@ namespace Prism
|
||||
|
||||
bool snap = Input::IsKeyPressed(Key::LEFT_CONTROL);
|
||||
|
||||
auto& entityTransform = selection.Entity.Transform();
|
||||
Transform& entityTransform = selection.Entity.Transformation();
|
||||
float snapValue = GetSnapValue();
|
||||
float snapValues[3] = { snapValue, snapValue, snapValue };
|
||||
if (m_SelectionMode == SelectionMode::Entity)
|
||||
{
|
||||
glm::mat4 transform = entityTransform.GetMatrix();
|
||||
ImGuizmo::Manipulate(glm::value_ptr(m_EditorCamera.GetViewMatrix()),
|
||||
glm::value_ptr(m_EditorCamera.GetProjectionMatrix()),
|
||||
(ImGuizmo::OPERATION)m_GizmoType,
|
||||
ImGuizmo::LOCAL,
|
||||
glm::value_ptr(entityTransform),
|
||||
glm::value_ptr(transform),
|
||||
nullptr,
|
||||
snap ? snapValues : nullptr);
|
||||
|
||||
auto [translation, rotation, scale] = GetTransformDecomposition(transform);
|
||||
entityTransform.SetTranslation(translation);
|
||||
entityTransform.SetRotation(rotation);
|
||||
entityTransform.SetScale(scale);
|
||||
}else
|
||||
{
|
||||
glm::mat4 transformBase = entityTransform * selection.Mesh->Transform;
|
||||
glm::mat4 transformBase = entityTransform.GetMatrix() * selection.Mesh->Transform;
|
||||
ImGuizmo::Manipulate(glm::value_ptr(m_EditorCamera.GetViewMatrix()),
|
||||
glm::value_ptr(m_EditorCamera.GetProjectionMatrix()),
|
||||
(ImGuizmo::OPERATION)m_GizmoType,
|
||||
@ -809,7 +815,7 @@ namespace Prism
|
||||
nullptr,
|
||||
snap ? snapValues : nullptr);
|
||||
|
||||
selection.Mesh->Transform = glm::inverse(entityTransform) * transformBase;
|
||||
selection.Mesh->Transform = glm::inverse(entityTransform.GetMatrix()) * transformBase;
|
||||
}
|
||||
}
|
||||
|
||||
@ -946,8 +952,8 @@ namespace Prism
|
||||
{
|
||||
auto& submesh = submeshes[i];
|
||||
Ray ray = {
|
||||
glm::inverse(entity.Transform() * submesh.Transform) * glm::vec4(origin, 1.0f),
|
||||
glm::inverse(glm::mat3(entity.Transform()) * glm::mat3(submesh.Transform)) * direction
|
||||
glm::inverse(entity.Transformation().GetMatrix() * submesh.Transform) * glm::vec4(origin, 1.0f),
|
||||
glm::inverse(glm::mat3(entity.Transformation().GetMatrix()) * glm::mat3(submesh.Transform)) * direction
|
||||
};
|
||||
|
||||
float t = 0;
|
||||
|
||||
@ -11,7 +11,7 @@ Entities:
|
||||
Tag: Box
|
||||
TransformComponent:
|
||||
Position: [0, 0, 0]
|
||||
Rotation: [1, 0, 0, 0]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [50, 1, 50]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Cube1m.fbx
|
||||
@ -40,7 +40,7 @@ Entities:
|
||||
Tag: Camera
|
||||
TransformComponent:
|
||||
Position: [2.808, 2.25, 0]
|
||||
Rotation: [1, 0, 0, 0]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
CameraComponent:
|
||||
Camera: some camera data...
|
||||
@ -50,7 +50,7 @@ Entities:
|
||||
Tag: Sphere
|
||||
TransformComponent:
|
||||
Position: [-3.9876995, 1, -1.9669533e-06]
|
||||
Rotation: [1, 0, 0, 0]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Sphere1m.fbx
|
||||
@ -78,7 +78,7 @@ Entities:
|
||||
Tag: Box
|
||||
TransformComponent:
|
||||
Position: [0, 1.5, 0]
|
||||
Rotation: [1, 0, 0, 0]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [2, 2, 2]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Cube1m.fbx
|
||||
@ -107,7 +107,7 @@ Entities:
|
||||
Tag: Mesh Collider
|
||||
TransformComponent:
|
||||
Position: [-2.6045518, 1, -0.0017139912]
|
||||
Rotation: [1, 0, 0, 0]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Sphere1m.fbx
|
||||
@ -135,7 +135,7 @@ Entities:
|
||||
Tag: Player
|
||||
TransformComponent:
|
||||
Position: [2.8080375, 1.5, 0]
|
||||
Rotation: [1, 0, 0, 0]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [2, 2, 2]
|
||||
ScriptComponent:
|
||||
ModuleName: FPSExample.FPSPlayer
|
||||
|
||||
Reference in New Issue
Block a user