fixed layer problem, remove 'default' layer to serialize, remove Transform class, using translation rotation scale instead
This commit is contained in:
@ -3,11 +3,12 @@
|
||||
//
|
||||
|
||||
#include "EditorLayer.h"
|
||||
#include "ImGuizmo.h"
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include <ImGuizmo.h>
|
||||
#include <filesystem>
|
||||
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
#include "glm/gtx/matrix_decompose.hpp"
|
||||
|
||||
#include "Prism/Core/Input.h"
|
||||
#include "Prism/Editor/PhysicsSettingsWindow.h"
|
||||
#include "Prism/Physics/Physics3D.h"
|
||||
@ -218,7 +219,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>().Transformation.GetMatrix() * selection.Mesh->Transform, color);
|
||||
Renderer::DrawAABB(selection.Mesh->BoundingBox, selection.Entity.GetComponent<TransformComponent>().GetTransform() * selection.Mesh->Transform, color);
|
||||
Renderer2D::EndScene();
|
||||
Renderer::EndRenderPass();
|
||||
}
|
||||
@ -231,7 +232,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>().Transformation.GetMatrix());
|
||||
auto [translation, rotationQuat, scale] = GetTransformDecomposition(selection.Entity.GetComponent<TransformComponent>().GetTransform());
|
||||
const glm::vec3 rotation = glm::eulerAngles(rotationQuat);
|
||||
|
||||
Renderer::BeginRenderPass(SceneRenderer::GetFinalRenderPass(), false);
|
||||
@ -786,12 +787,12 @@ namespace Prism
|
||||
|
||||
bool snap = Input::IsKeyPressed(Key::LEFT_CONTROL);
|
||||
|
||||
Transform& entityTransform = selection.Entity.Transformation();
|
||||
TransformComponent& entityTransform = selection.Entity.Transform();
|
||||
float snapValue = GetSnapValue();
|
||||
float snapValues[3] = { snapValue, snapValue, snapValue };
|
||||
if (m_SelectionMode == SelectionMode::Entity)
|
||||
{
|
||||
glm::mat4 transform = entityTransform.GetMatrix();
|
||||
glm::mat4 transform = entityTransform.GetTransform();
|
||||
ImGuizmo::Manipulate(glm::value_ptr(m_EditorCamera.GetViewMatrix()),
|
||||
glm::value_ptr(m_EditorCamera.GetProjectionMatrix()),
|
||||
(ImGuizmo::OPERATION)m_GizmoType,
|
||||
@ -801,12 +802,12 @@ namespace Prism
|
||||
snap ? snapValues : nullptr);
|
||||
|
||||
auto [translation, rotation, scale] = GetTransformDecomposition(transform);
|
||||
entityTransform.SetTranslation(translation);
|
||||
entityTransform.SetRotation(rotation);
|
||||
entityTransform.SetScale(scale);
|
||||
entityTransform.Translation = translation;
|
||||
entityTransform.Rotation = glm::degrees(glm::eulerAngles(rotation));
|
||||
entityTransform.Scale = scale;
|
||||
}else
|
||||
{
|
||||
glm::mat4 transformBase = entityTransform.GetMatrix() * selection.Mesh->Transform;
|
||||
glm::mat4 transformBase = entityTransform.GetTransform() * selection.Mesh->Transform;
|
||||
ImGuizmo::Manipulate(glm::value_ptr(m_EditorCamera.GetViewMatrix()),
|
||||
glm::value_ptr(m_EditorCamera.GetProjectionMatrix()),
|
||||
(ImGuizmo::OPERATION)m_GizmoType,
|
||||
@ -815,7 +816,7 @@ namespace Prism
|
||||
nullptr,
|
||||
snap ? snapValues : nullptr);
|
||||
|
||||
selection.Mesh->Transform = glm::inverse(entityTransform.GetMatrix()) * transformBase;
|
||||
selection.Mesh->Transform = glm::inverse(entityTransform.GetTransform()) * transformBase;
|
||||
}
|
||||
}
|
||||
|
||||
@ -951,9 +952,10 @@ namespace Prism
|
||||
for (uint32_t i = 0; i < submeshes.size(); i++)
|
||||
{
|
||||
auto& submesh = submeshes[i];
|
||||
const auto transform = entity.Transform().GetTransform();
|
||||
Ray ray = {
|
||||
glm::inverse(entity.Transformation().GetMatrix() * submesh.Transform) * glm::vec4(origin, 1.0f),
|
||||
glm::inverse(glm::mat3(entity.Transformation().GetMatrix()) * glm::mat3(submesh.Transform)) * direction
|
||||
glm::inverse(transform * submesh.Transform) * glm::vec4(origin, 1.0f),
|
||||
glm::inverse(glm::mat3(transform) * glm::mat3(submesh.Transform)) * direction
|
||||
};
|
||||
|
||||
float t = 0;
|
||||
|
||||
@ -6,130 +6,6 @@ Environment:
|
||||
Radiance: [1, 1, 1]
|
||||
Multiplier: 0.515
|
||||
Entities:
|
||||
- Entity: 18306113171518048249
|
||||
TagComponent:
|
||||
Tag: Box
|
||||
TransformComponent:
|
||||
Position: [0, 0, 0]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [50, 1, 50]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Cube1m.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 0
|
||||
Mass: 1
|
||||
IsKinematic: false
|
||||
Layer: 1
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: false
|
||||
LockRotationY: false
|
||||
LockRotationZ: false
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 1
|
||||
DynamicFriction: 1
|
||||
Bounciness: 0
|
||||
BoxColliderComponent:
|
||||
Offset: [0, 0, 0]
|
||||
Size: [1, 1, 1]
|
||||
IsTrigger: false
|
||||
- Entity: 5178862374589434728
|
||||
TagComponent:
|
||||
Tag: Camera
|
||||
TransformComponent:
|
||||
Position: [2.808, 2.25, 0]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
CameraComponent:
|
||||
Camera: some camera data...
|
||||
Primary: true
|
||||
- Entity: 14057422478420564497
|
||||
TagComponent:
|
||||
Tag: Sphere
|
||||
TransformComponent:
|
||||
Position: [-3.9876995, 1, -1.9669533e-06]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Sphere1m.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 1
|
||||
Mass: 1
|
||||
IsKinematic: false
|
||||
Layer: 1
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: false
|
||||
LockRotationY: false
|
||||
LockRotationZ: false
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 0.1
|
||||
DynamicFriction: 0.1
|
||||
Bounciness: 0.1
|
||||
SphereColliderComponent:
|
||||
Radius: 0.5
|
||||
IsTrigger: false
|
||||
- Entity: 10169503531257462571
|
||||
TagComponent:
|
||||
Tag: Box
|
||||
TransformComponent:
|
||||
Position: [0, 1.5, 0]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [2, 2, 2]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Cube1m.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 1
|
||||
Mass: 0.5
|
||||
IsKinematic: false
|
||||
Layer: 1
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: false
|
||||
LockRotationY: false
|
||||
LockRotationZ: false
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 1
|
||||
DynamicFriction: 1
|
||||
Bounciness: 0
|
||||
BoxColliderComponent:
|
||||
Offset: [0, 0, 0]
|
||||
Size: [1, 1, 1]
|
||||
IsTrigger: false
|
||||
- Entity: 11149966982516343187
|
||||
TagComponent:
|
||||
Tag: Mesh Collider
|
||||
TransformComponent:
|
||||
Position: [-2.6045518, 1, -0.0017139912]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Sphere1m.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 1
|
||||
Mass: 0.1
|
||||
IsKinematic: false
|
||||
Layer: 1
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: false
|
||||
LockRotationY: false
|
||||
LockRotationZ: false
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 1
|
||||
DynamicFriction: 1
|
||||
Bounciness: 0.1
|
||||
MeshColliderComponent:
|
||||
AssetPath: assets/meshes/Sphere1m.fbx
|
||||
IsTrigger: false
|
||||
- Entity: 3247025703490125974
|
||||
TagComponent:
|
||||
Tag: Player
|
||||
@ -176,10 +52,131 @@ Entities:
|
||||
MeshColliderComponent:
|
||||
AssetPath: assets/meshes/Capsule.fbx
|
||||
IsTrigger: false
|
||||
- Entity: 11149966982516343187
|
||||
TagComponent:
|
||||
Tag: Mesh Collider
|
||||
TransformComponent:
|
||||
Position: [-2.6045518, 1, -0.0017139912]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Sphere1m.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 1
|
||||
Mass: 0.1
|
||||
IsKinematic: false
|
||||
Layer: 1
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: false
|
||||
LockRotationY: false
|
||||
LockRotationZ: false
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 1
|
||||
DynamicFriction: 1
|
||||
Bounciness: 0.1
|
||||
MeshColliderComponent:
|
||||
AssetPath: assets/meshes/Sphere1m.fbx
|
||||
IsTrigger: false
|
||||
- Entity: 10169503531257462571
|
||||
TagComponent:
|
||||
Tag: Box
|
||||
TransformComponent:
|
||||
Position: [0, 1.5, 0]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [2, 2, 2]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Cube1m.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 1
|
||||
Mass: 0.5
|
||||
IsKinematic: false
|
||||
Layer: 1
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: false
|
||||
LockRotationY: false
|
||||
LockRotationZ: false
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 1
|
||||
DynamicFriction: 1
|
||||
Bounciness: 0
|
||||
BoxColliderComponent:
|
||||
Offset: [0, 0, 0]
|
||||
Size: [1, 1, 1]
|
||||
IsTrigger: false
|
||||
- Entity: 14057422478420564497
|
||||
TagComponent:
|
||||
Tag: Sphere
|
||||
TransformComponent:
|
||||
Position: [-3.9876995, 1, -1.9669533e-06]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Sphere1m.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 1
|
||||
Mass: 1
|
||||
IsKinematic: false
|
||||
Layer: 1
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: false
|
||||
LockRotationY: false
|
||||
LockRotationZ: false
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 0.1
|
||||
DynamicFriction: 0.1
|
||||
Bounciness: 0.1
|
||||
SphereColliderComponent:
|
||||
Radius: 0.5
|
||||
IsTrigger: false
|
||||
- Entity: 5178862374589434728
|
||||
TagComponent:
|
||||
Tag: Camera
|
||||
TransformComponent:
|
||||
Position: [2.808, 2.25, 0]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
CameraComponent:
|
||||
Camera: some camera data...
|
||||
Primary: true
|
||||
- Entity: 18306113171518048249
|
||||
TagComponent:
|
||||
Tag: Box
|
||||
TransformComponent:
|
||||
Position: [0, 0, 0]
|
||||
Rotation: [0, 0, 0]
|
||||
Scale: [50, 1, 50]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Cube1m.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 0
|
||||
Mass: 1
|
||||
IsKinematic: false
|
||||
Layer: 1
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: false
|
||||
LockRotationY: false
|
||||
LockRotationZ: false
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 1
|
||||
DynamicFriction: 1
|
||||
Bounciness: 0
|
||||
BoxColliderComponent:
|
||||
Offset: [0, 0, 0]
|
||||
Size: [1, 1, 1]
|
||||
IsTrigger: false
|
||||
PhysicsLayers:
|
||||
- Name: Default
|
||||
CollidesWith:
|
||||
- Name: Box
|
||||
- Name: Box
|
||||
CollidesWith:
|
||||
- Name: Default
|
||||
Reference in New Issue
Block a user