Added display of editor camera position #368
|
@ -96,6 +96,8 @@ namespace SHADE
|
|||
}
|
||||
ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal);
|
||||
|
||||
if (!ImGui::IsAnyItemFocused())
|
||||
{
|
||||
if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_A))
|
||||
{
|
||||
SelectAllEntities();
|
||||
|
@ -119,7 +121,7 @@ namespace SHADE
|
|||
{
|
||||
DeleteSelectedEntities();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(ImGui::IsWindowHovered() && !ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
|
||||
{
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "Serialization/Configurations/SHConfigurationManager.h"
|
||||
#include "Editor/EditorWindow/SHEditorWindowManager.h"
|
||||
#include "Physics/System/SHPhysicsDebugDrawSystem.h"
|
||||
#include "Camera/SHCameraSystem.h"
|
||||
#include "Tools/Utilities/SHClipboardUtilities.h"
|
||||
|
||||
const std::string LAYOUT_FOLDER_PATH{ std::string(ASSET_ROOT) + "/Editor/Layouts" };
|
||||
|
||||
|
@ -154,7 +156,39 @@ namespace SHADE
|
|||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImGui::GetStyle().Colors[ImGuiCol_MenuBarBg]);
|
||||
if (ImGui::BeginViewportSideBar("MainStatusBar", ImGui::GetMainViewport(), ImGuiDir_Down, menuBarHeight, editorMenuBarFlags))
|
||||
{
|
||||
ImGui::Text("Entity count: %zu", SHEntityManager::GetEntityCount());
|
||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
std::string editorCamPosText{};
|
||||
auto editorCam = camSystem->GetEditorCamera();
|
||||
if(editorCam)
|
||||
{
|
||||
auto editorCamPos = editorCam->GetPosition();
|
||||
editorCamPosText = std::format("Editor Cam [X: {:.3f}, Y: {:.3f}, Z: {:.3f}]", editorCamPos.x, editorCamPos.y, editorCamPos.z);
|
||||
|
||||
//ImGui::Text(editorCamPosText.data());
|
||||
}
|
||||
ImGui::Text("Entity count: %zu %s", SHEntityManager::GetEntityCount(), editorCamPosText.data());
|
||||
if(ImGui::BeginPopupContextItem("EditorCamPosContext"))
|
||||
{
|
||||
if(editorCam)
|
||||
{
|
||||
if(ImGui::Selectable("Copy Editor Cam Pos X"))
|
||||
{
|
||||
auto editorCamPos = editorCam->GetPosition();
|
||||
SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}", editorCamPos.x));
|
||||
}
|
||||
if (ImGui::Selectable("Copy Editor Cam Pos Y"))
|
||||
{
|
||||
auto editorCamPos = editorCam->GetPosition();
|
||||
SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}", editorCamPos.y));
|
||||
}
|
||||
if (ImGui::Selectable("Copy Editor Cam Pos Z"))
|
||||
{
|
||||
auto editorCamPos = editorCam->GetPosition();
|
||||
SHClipboardUtilities::WriteToClipboard(std::format("{:.3f}", editorCamPos.z));
|
||||
}
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleColor();
|
||||
|
|
|
@ -122,12 +122,22 @@ namespace SHADE
|
|||
|
||||
//auto pos = ImGui::GetCursorPos();
|
||||
//windowCursorPos = {}
|
||||
|
||||
if (beginContentRegionAvailable.x == 0 || beginContentRegionAvailable.y == 0)
|
||||
{
|
||||
beginContentRegionAvailable = windowSize;
|
||||
}
|
||||
gfxSystem->PrepareResize(static_cast<uint32_t>(beginContentRegionAvailable.x), static_cast<uint32_t>(beginContentRegionAvailable.y));
|
||||
|
||||
//beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable);
|
||||
SHVec2 viewportSize = CalculateWindowSize(beginContentRegionAvailable);
|
||||
gfxSystem->PrepareResize(static_cast<uint32_t>(viewportSize.x), static_cast<uint32_t>(viewportSize.y));
|
||||
shouldUpdateCamera = true;
|
||||
//if (aspectRatio != AspectRatio::FREE && (ImGui::IsMouseDown(ImGuiMouseButton_Left) || ImGui::IsMouseReleased(ImGuiMouseButton_Left)))
|
||||
//{
|
||||
// windowSize = CalculateWindowSize(windowSize);
|
||||
// beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable);
|
||||
// ImGui::SetWindowSize(windowName.data(), CalculateWindowSize(windowSize));
|
||||
//}
|
||||
}
|
||||
|
||||
void SHEditorViewport::OnPosChange()
|
||||
|
@ -195,13 +205,73 @@ namespace SHADE
|
|||
ImGui::PopStyleColor();
|
||||
ImGui::EndDisabled();
|
||||
|
||||
//TODO: Shift to constructor
|
||||
auto arRTTRtype = rttr::type::get<SHEditorViewport::AspectRatio>();
|
||||
auto enumAlign = arRTTRtype.get_enumeration();
|
||||
auto names = enumAlign.get_names();
|
||||
std::vector<const char*> arNames;
|
||||
for (auto const& name : names)
|
||||
{
|
||||
arNames.push_back(name.data());
|
||||
}
|
||||
int currentAR = static_cast<int>(aspectRatio);
|
||||
ImGui::SetNextItemWidth(80.0f);
|
||||
if (ImGui::Combo("Aspect Ratio", ¤tAR, arNames.data(), arNames.size()))
|
||||
{
|
||||
aspectRatio = static_cast<AspectRatio>(currentAR);
|
||||
windowSize = CalculateWindowSize(windowSize);
|
||||
ImGui::SetWindowSize(windowSize);
|
||||
//beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable);
|
||||
//OnResize();
|
||||
}
|
||||
|
||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
auto editorCamera = camSystem->GetEditorCamera();
|
||||
//ImGui::SetNextItemWidth(10.0f);
|
||||
SHEditorWidgets::SliderFloat("CamSpeed", 0.0f, 5.0f, [editorCamera] {return editorCamera->movementSpeed; }, [editorCamera](float const& value) {editorCamera->movementSpeed = value; });
|
||||
SHEditorWidgets::DragVec3("TurnSpeed", { "X", "Y", "Z" }, [editorCamera] {return editorCamera->turnSpeed; }, [editorCamera](SHVec3 const& value) {editorCamera->turnSpeed = value; });
|
||||
|
||||
//if(ImGui::BeginCombo("Aspect Ratio", arNames[(uint8_t)aspectRatio].data()))
|
||||
//{
|
||||
// auto nameIt = names.begin();
|
||||
// auto valueIt = values.end();
|
||||
// while(nameIt != names.end() && valueIt != values.end())
|
||||
// {
|
||||
// if ImGui::Beg
|
||||
// }
|
||||
//}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
SHVec2 SHEditorViewport::CalculateWindowSize(SHVec2 const& rhs) noexcept
|
||||
{
|
||||
switch (aspectRatio)
|
||||
{
|
||||
case SHADE::SHEditorViewport::AspectRatio::FREE:
|
||||
return rhs;
|
||||
case SHADE::SHEditorViewport::AspectRatio::AR16_9:
|
||||
return SHVec2(rhs.x, rhs.x * 0.5625f);
|
||||
case SHADE::SHEditorViewport::AspectRatio::AR21_9:
|
||||
return SHVec2(rhs.x, rhs.x * 0.42857f);
|
||||
case SHADE::SHEditorViewport::AspectRatio::AR21_10:
|
||||
return SHVec2(rhs.x, rhs.x * 0.47619f);
|
||||
default:
|
||||
return rhs;
|
||||
}
|
||||
}
|
||||
|
||||
}//namespace SHADE
|
||||
|
||||
RTTR_REGISTRATION
|
||||
{
|
||||
using namespace rttr;
|
||||
using namespace SHADE;
|
||||
registration::enumeration<SHEditorViewport::AspectRatio>("AspectRatio")(
|
||||
value("FREE", SHEditorViewport::AspectRatio::FREE),
|
||||
value("16:9", SHEditorViewport::AspectRatio::AR16_9),
|
||||
value("21:9", SHEditorViewport::AspectRatio::AR21_9),
|
||||
value("21:10", SHEditorViewport::AspectRatio::AR21_10)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,15 @@ namespace SHADE
|
|||
{
|
||||
class SHEditorViewport final : public SHEditorWindow
|
||||
{
|
||||
|
||||
public:
|
||||
enum class AspectRatio : uint8_t
|
||||
{
|
||||
FREE,
|
||||
AR16_9,
|
||||
AR21_9,
|
||||
AR21_10
|
||||
};
|
||||
SHEditorViewport();
|
||||
void Init() override;
|
||||
void Update() override;
|
||||
|
@ -27,9 +35,12 @@ namespace SHADE
|
|||
void OnPosChange() override;
|
||||
private:
|
||||
void DrawMenuBar() noexcept;
|
||||
SHVec2 beginCursorPos;
|
||||
SHVec2 CalculateWindowSize(SHVec2 const& rhs) noexcept;
|
||||
|
||||
bool shouldUpdateCamera = false;
|
||||
bool shouldUpdateCamArm = false;
|
||||
AspectRatio aspectRatio {AspectRatio::FREE};
|
||||
SHVec2 beginCursorPos;
|
||||
SHVec3 targetPos;
|
||||
};//class SHEditorViewport
|
||||
}//namespace SHADE
|
||||
|
|
Loading…
Reference in New Issue