Kelsidavis-WoWee/tools/editor/editor_camera.hpp
Kelsi 496f97f9db feat(editor): middle mouse orbit camera around terrain point
- Middle mouse drag orbits camera around the terrain point under cursor
  (or 100 units ahead if no terrain hit)
- Maintains distance from pivot while rotating yaw/pitch
- Much more intuitive for inspecting terrain features, placed objects,
  and NPC positions from different angles
- Works alongside right-drag (free look) and WASD (fly)
2026-05-05 06:48:05 -07:00

41 lines
1.2 KiB
C++

#pragma once
#include "rendering/camera.hpp"
#include <SDL2/SDL.h>
#include <glm/glm.hpp>
namespace wowee {
namespace editor {
class EditorCamera {
public:
EditorCamera();
void update(float deltaTime);
void processMouseMotion(int dx, int dy);
void processMouseWheel(float delta, bool shiftHeld);
void processKeyEvent(const SDL_KeyboardEvent& event);
void processMouseButton(const SDL_MouseButtonEvent& event);
void processMiddleMouseMotion(int dx, int dy, const glm::vec3& pivotPoint);
rendering::Camera& getCamera() { return camera_; }
const rendering::Camera& getCamera() const { return camera_; }
float getSpeed() const { return speed_; }
void setSpeed(float s) { speed_ = s; }
void setPosition(const glm::vec3& pos);
void setYawPitch(float yaw, float pitch);
private:
rendering::Camera camera_;
float speed_ = 100.0f;
float yaw_ = 0.0f;
float pitch_ = 0.0f;
bool keyW_ = false, keyA_ = false, keyS_ = false, keyD_ = false;
bool keyQ_ = false, keyE_ = false, keyShift_ = false;
bool rightMouseDown_ = false;
bool middleMouseDown_ = false;
};
} // namespace editor
} // namespace wowee