Removed euler, only quaternion and dirty flag

This commit is contained in:
a.pilote
2022-07-14 17:45:06 -04:00
parent fb6080d734
commit 249e26dcd5
15 changed files with 203 additions and 66 deletions

View File

@@ -10,6 +10,7 @@ public:
void Draw(Nuake::Entity entity) override
{
using namespace Nuake;
Nuake::TransformComponent& component = entity.GetComponent<Nuake::TransformComponent>();
BeginComponentTable(TRANSFORM, Nuake::TransformComponent);
{
@@ -17,30 +18,63 @@ public:
ImGui::Text("Translation");
ImGui::TableNextColumn();
ImGuiHelper::DrawVec3("Translation", &component.Translation);
Vector3 position = component.GetLocalPosition();
ImGuiHelper::DrawVec3("Translation", &position);
if (position != component.GetLocalPosition())
component.SetLocalPosition(position);
ImGui::TableNextColumn();
ComponentTableReset(component.Translation, Nuake::Vector3(0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetTranslation";
if (ImGui::Button(resetLabel.c_str()))
component.SetLocalPosition(Vector3(0, 0, 0));
ImGui::PopStyleColor();
}
ImGui::TableNextColumn();
{
ImGui::Text("Rotation");
ImGui::TableNextColumn();
//ImGuiHelper::DrawVec3("Rotation", &component.Rotation);
Vector3 eulerAngles = glm::eulerAngles(component.GetLocalRotation());
ImGuiHelper::DrawVec3("Rotation", &eulerAngles);
Vector3 eulerLocal = glm::eulerAngles(component.GetLocalRotation());
if (eulerLocal != eulerAngles)
{
Quat rotation = QuatFromEuler(eulerAngles.x, eulerAngles.y, eulerAngles.z);
//component.SetLocalRotation(rotation);
}
ImGui::TableNextColumn();
//ComponentTableReset(component.Rotation, Nuake::Vector3(0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetRotation";
if (ImGui::Button(resetLabel.c_str()))
{
component.SetLocalRotation(Quat(1, 0, 0, 0));
}
ImGui::PopStyleColor();
}
ImGui::TableNextColumn();
{
ImGui::Text("Scale");
ImGui::TableNextColumn();
ImGuiHelper::DrawVec3("Scale", &component.Scale);
Vector3 localScale = component.GetLocalScale();
ImGuiHelper::DrawVec3("Scale", &localScale);
if (localScale != component.GetLocalScale())
component.SetLocalScale(localScale);
ImGui::TableNextColumn();
ComponentTableReset(component.Scale, Nuake::Vector3(1, 1, 1));
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1, 1, 1, 0));
std::string resetLabel = std::string(ICON_FA_UNDO) + "##ResetScale";
if (ImGui::Button(resetLabel.c_str()))
component.SetLocalScale(Vector3(1, 1, 1));
ImGui::PopStyleColor();
}
}
EndComponentTable();

View File

@@ -122,8 +122,8 @@ namespace Nuake {
if (ImGuizmo::IsUsing())
{
tc.LocalTransform = transform;
tc.GlobalTransform = transform;
tc.SetLocalTransform(transform);
tc.SetGlobalTransform(transform);
//Entity currentParent = Selection.Entity;
//if (parent.HasParent)
@@ -233,7 +233,7 @@ namespace Nuake {
if (ImGui::Selectable("Focus camera"))
{
Ref<EditorCamera> editorCam = Engine::GetCurrentScene()->m_EditorCamera;
editorCam->Translation = entity.GetComponent<TransformComponent>().Translation;
editorCam->Translation = entity.GetComponent<TransformComponent>().GetGlobalPosition();
Vector3 camDirection = entity.GetComponent<CameraComponent>().CameraInstance->GetDirection();
editorCam->SetDirection(camDirection);
}