aboutsummaryrefslogtreecommitdiff
path: root/source/EditorCorePrivate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/EditorCorePrivate.cpp')
-rw-r--r--source/EditorCorePrivate.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/source/EditorCorePrivate.cpp b/source/EditorCorePrivate.cpp
index 38ba8f6..de48ea2 100644
--- a/source/EditorCorePrivate.cpp
+++ b/source/EditorCorePrivate.cpp
@@ -318,9 +318,8 @@ EditorInstance::EditorInstance(App* app)
: mApp{ app }
, mEdContentBrowser(&mEdInspector) {
mEditorCamera.name = "Editor Camera"s;
- mEditorCamera.SetEyePos(glm::vec3(0, 0, 200));
- mEditorCamera.SetTargetPos(glm::vec3(0, 0, 0));
- mEditorCamera.SetHasPerspective(true);
+ mEditorCamera.SetEyePos(glm::vec3(0, 0, 1));
+ mEditorCamera.SetTargetDirection(glm::vec3(0, 0, -1));
app->BindActiveCamera(&mEditorCamera);
}
@@ -449,12 +448,10 @@ void EditorInstance::Show() {
if (mDragCam_Happening) {
auto newPos = ImGui::GetMousePos();
// NOTE: we are emulating as if the mouse is dragging the "canvas", through moving the camera in the opposite direction of the natural position delta
- cameraPos.x = mDragCam_CamInitial.x + mDragCam_CursorInitial.x - newPos.x;
- cameraPos.y = mDragCam_CamInitial.y + -(mDragCam_CursorInitial.y - newPos.y); // Invert Y delta because ImGui uses top-left origin (mouse moving down translates to positive value, but in our coordinate system down is negative)
-
- // Draw movement indicator
- auto drawList = ImGui::GetForegroundDrawList();
- ImGui::DrawArrow(drawList, ImVec2(mDragCam_CursorInitial.x, mDragCam_CursorInitial.y), newPos, IM_COL32(0, 255, 255, 255));
+ float deltaX = mDragCam_CursorInitial.x - newPos.x;
+ cameraPos.x = mDragCam_CamInitial.x + deltaX / camera.pixelsPerMeter;
+ float deltaY = -(mDragCam_CursorInitial.y - newPos.y); // Invert Y delta because ImGui uses top-left origin (mouse moving down translates to positive value, but in our coordinate system down is negative)
+ cameraPos.y = mDragCam_CamInitial.y + deltaY / camera.pixelsPerMeter;
}
if (ImGui::IsMouseReleased(ImGuiMouseButton_Right)) {
mDragCam_Happening = false;
@@ -626,7 +623,7 @@ void EditorInstance::ShowWorldProperties() {
vec.x = std::cos(60.0f);
vec.y = 0.0f;
vec.z = std::sin(60.0f);
- camera.eye = camera.target + 200.0f * vec;
+ camera.eye = camera.target + 4.0f * vec;
camera.SetHasPerspective(true);
}
@@ -641,6 +638,10 @@ void EditorInstance::ShowWorldProperties() {
ImGui::Checkbox("Move camera with scoll wheel", &mMoveCamScrollWheel);
ImGui::SliderFloat("Camera scroll speed", &mMoveCamScrollSpeed, 0.01, 10.0f);
+ if (ImGui::InputFloat("Pixels per meter", &camera.pixelsPerMeter)) {
+ camera.pixelsPerMeter = std::max(camera.pixelsPerMeter, 0.0f);
+ }
+
ImGui::Unindent();
}