mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 00:53:52 +00:00
feat(editor): scroll wheel zoom, clickable minimap navigation
- Scroll wheel now zooms camera (moves along look direction) instead of adjusting speed. Much more intuitive for terrain editing. - Shift+scroll adjusts camera speed (old behavior preserved) - Click on minimap to teleport camera to that location on the terrain - Zoom speed scales with current camera speed for consistent feel
This commit is contained in:
parent
f891bd02a5
commit
12acbfb2d5
4 changed files with 23 additions and 4 deletions
|
|
@ -382,7 +382,7 @@ void EditorApp::processEvents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type == SDL_MOUSEWHEEL && !io.WantCaptureMouse)
|
if (event.type == SDL_MOUSEWHEEL && !io.WantCaptureMouse)
|
||||||
camera_.processMouseWheel(event.wheel.y);
|
camera_.processMouseWheel(event.wheel.y, (SDL_GetModState() & KMOD_SHIFT) != 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,14 @@ void EditorCamera::processMouseMotion(int dx, int dy) {
|
||||||
camera_.setRotation(yaw_, pitch_);
|
camera_.setRotation(yaw_, pitch_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorCamera::processMouseWheel(float delta) {
|
void EditorCamera::processMouseWheel(float delta, bool shiftHeld) {
|
||||||
speed_ = std::clamp(speed_ + delta * 20.0f, 10.0f, 2000.0f);
|
if (shiftHeld) {
|
||||||
|
speed_ = std::clamp(speed_ + delta * 20.0f, 10.0f, 2000.0f);
|
||||||
|
} else {
|
||||||
|
glm::vec3 pos = camera_.getPosition();
|
||||||
|
pos += camera_.getForward() * delta * speed_ * 0.3f;
|
||||||
|
camera_.setPosition(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorCamera::processKeyEvent(const SDL_KeyboardEvent& event) {
|
void EditorCamera::processKeyEvent(const SDL_KeyboardEvent& event) {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ public:
|
||||||
|
|
||||||
void update(float deltaTime);
|
void update(float deltaTime);
|
||||||
void processMouseMotion(int dx, int dy);
|
void processMouseMotion(int dx, int dy);
|
||||||
void processMouseWheel(float delta);
|
void processMouseWheel(float delta, bool shiftHeld);
|
||||||
void processKeyEvent(const SDL_KeyboardEvent& event);
|
void processKeyEvent(const SDL_KeyboardEvent& event);
|
||||||
void processMouseButton(const SDL_MouseButtonEvent& event);
|
void processMouseButton(const SDL_MouseButtonEvent& event);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1134,6 +1134,19 @@ void EditorUI::renderMinimap(EditorApp& app) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Dummy(ImVec2(avail.x, 16 * cellH));
|
ImGui::Dummy(ImVec2(avail.x, 16 * cellH));
|
||||||
|
// Click minimap to move camera
|
||||||
|
if (ImGui::IsWindowHovered() && ImGui::IsMouseClicked(0)) {
|
||||||
|
ImVec2 mousePos = ImGui::GetMousePos();
|
||||||
|
float mu = (mousePos.y - origin.y) / (16 * cellH);
|
||||||
|
float mv = (mousePos.x - origin.x) / avail.x;
|
||||||
|
if (mu >= 0 && mu <= 1 && mv >= 0 && mv <= 1) {
|
||||||
|
float wx = tileNW_X - mu * 533.33333f;
|
||||||
|
float wy = tileNW_Y - mv * 533.33333f;
|
||||||
|
app.getEditorCamera().setPosition(glm::vec3(wx, wy,
|
||||||
|
app.getEditorCamera().getCamera().getPosition().z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Camera indicator as white cross
|
// Camera indicator as white cross
|
||||||
auto camPos = app.getEditorCamera().getCamera().getPosition();
|
auto camPos = app.getEditorCamera().getCamera().getPosition();
|
||||||
float camU = (tileNW_X - camPos.x) / 533.33333f;
|
float camU = (tileNW_X - camPos.x) / 533.33333f;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue