add serialize for RigidbodyComponent linear/angular drag and gravity, change the physx API for c++ and c#, fixed rotate bug(using radians to storage), some little code tweaks
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
#include "glm/gtx/matrix_decompose.hpp"
|
||||
|
||||
#include "Prism/Core/Input.h"
|
||||
#include "Prism/Core/Math/Math.h"
|
||||
#include "Prism/Editor/PhysicsSettingsWindow.h"
|
||||
#include "Prism/Physics/Physics3D.h"
|
||||
#include "Prism/Renderer/Renderer2D.h"
|
||||
@ -22,16 +23,6 @@ namespace Prism
|
||||
None = 0, ColorProperty = 1, SliderProperty = 2, DragProperty = 4
|
||||
};
|
||||
|
||||
static std::tuple<glm::vec3, glm::quat, glm::vec3> GetTransformDecomposition(const glm::mat4& transform)
|
||||
{
|
||||
glm::vec3 scale, translation, skew;
|
||||
glm::vec4 perspective;
|
||||
glm::quat orientation;
|
||||
glm::decompose(transform, scale, orientation, translation, skew, perspective);
|
||||
|
||||
return { translation, orientation, scale };
|
||||
}
|
||||
|
||||
bool Property(const std::string& name, bool& value)
|
||||
{
|
||||
ImGui::Text(name.c_str());
|
||||
@ -236,13 +227,12 @@ namespace Prism
|
||||
if (selection.Entity.HasComponent<BoxCollider2DComponent>())
|
||||
{
|
||||
const auto& size = selection.Entity.GetComponent<BoxCollider2DComponent>().Size;
|
||||
auto [translation, rotationQuat, scale] = GetTransformDecomposition(selection.Entity.GetComponent<TransformComponent>().GetTransform());
|
||||
const glm::vec3 rotation = glm::eulerAngles(rotationQuat);
|
||||
const auto& transform = selection.Entity.GetComponent<TransformComponent>();
|
||||
|
||||
Renderer::BeginRenderPass(SceneRenderer::GetFinalRenderPass(), false);
|
||||
const auto viewProj = m_EditorCamera.GetViewProjection();
|
||||
Renderer2D::BeginScene(viewProj, false);
|
||||
Renderer2D::DrawRotatedQuad({ translation.x, translation.y }, size * 2.0f, glm::degrees(rotation.z), { 1.0f, 0.0f, 1.0f, 1.0f });
|
||||
Renderer2D::DrawRotatedQuad({ transform.Translation.x, transform.Translation.y }, size * 2.0f, transform.Rotation.z, { 1.0f, 0.0f, 1.0f, 1.0f });
|
||||
Renderer2D::EndScene();
|
||||
Renderer::EndRenderPass();
|
||||
}
|
||||
@ -802,10 +792,18 @@ namespace Prism
|
||||
nullptr,
|
||||
snap ? snapValues : nullptr);
|
||||
|
||||
auto [translation, rotation, scale] = GetTransformDecomposition(transform);
|
||||
entityTransform.Translation = translation;
|
||||
entityTransform.Rotation = glm::degrees(glm::eulerAngles(rotation));
|
||||
entityTransform.Scale = scale;
|
||||
if (ImGuizmo::IsUsing())
|
||||
{
|
||||
glm::vec3 translation, rotation, scale;
|
||||
Math::DecomposeTransform(transform, translation,rotation,scale);
|
||||
|
||||
entityTransform.Translation = translation;
|
||||
|
||||
glm::vec3 deltaRotation = rotation - entityTransform.Rotation;
|
||||
entityTransform.Rotation += deltaRotation;
|
||||
|
||||
entityTransform.Scale = scale;
|
||||
}
|
||||
}else
|
||||
{
|
||||
glm::mat4 transformBase = entityTransform.GetTransform() * selection.Mesh->Transform;
|
||||
@ -817,7 +815,10 @@ namespace Prism
|
||||
nullptr,
|
||||
snap ? snapValues : nullptr);
|
||||
|
||||
selection.Mesh->Transform = glm::inverse(entityTransform.GetTransform()) * transformBase;
|
||||
if (ImGuizmo::IsUsing())
|
||||
{
|
||||
selection.Mesh->Transform = glm::inverse(entityTransform.GetTransform()) * transformBase;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user