mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-02 15:53:51 +00:00
Prevent target deselection during camera rotation
Left-click targeting now fires on mouse-up with a drag threshold so camera rotation drags no longer clear the current target.
This commit is contained in:
parent
0ae38a59c8
commit
e234ac8d7a
2 changed files with 64 additions and 48 deletions
|
|
@ -173,6 +173,10 @@ private:
|
|||
// Action bar drag state (-1 = not dragging)
|
||||
int actionBarDragSlot_ = -1;
|
||||
GLuint actionBarDragIcon_ = 0;
|
||||
|
||||
// Left-click targeting: distinguish click from camera drag
|
||||
glm::vec2 leftClickPressPos_ = glm::vec2(0.0f);
|
||||
bool leftClickWasPress_ = false;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
|
|
|||
|
|
@ -566,19 +566,30 @@ void GameScreen::processTargetInput(game::GameHandler& gameHandler) {
|
|||
refocusChatInput = true;
|
||||
}
|
||||
|
||||
// Left-click targeting (when mouse not captured by UI)
|
||||
// Suppress when right button is held (both-button run)
|
||||
// Left-click targeting: only on mouse-up if the mouse didn't drag (camera rotate)
|
||||
// Record press position on mouse-down
|
||||
if (!io.WantCaptureMouse && input.isMouseButtonJustPressed(SDL_BUTTON_LEFT) && !input.isMouseButtonPressed(SDL_BUTTON_RIGHT)) {
|
||||
leftClickPressPos_ = input.getMousePosition();
|
||||
leftClickWasPress_ = true;
|
||||
}
|
||||
|
||||
// On mouse-up, check if it was a click (not a drag)
|
||||
if (leftClickWasPress_ && input.isMouseButtonJustReleased(SDL_BUTTON_LEFT)) {
|
||||
leftClickWasPress_ = false;
|
||||
glm::vec2 releasePos = input.getMousePosition();
|
||||
float dragDist = glm::length(releasePos - leftClickPressPos_);
|
||||
constexpr float CLICK_THRESHOLD = 5.0f; // pixels
|
||||
|
||||
if (dragDist < CLICK_THRESHOLD) {
|
||||
auto* renderer = core::Application::getInstance().getRenderer();
|
||||
auto* camera = renderer ? renderer->getCamera() : nullptr;
|
||||
auto* window = core::Application::getInstance().getWindow();
|
||||
|
||||
if (camera && window) {
|
||||
glm::vec2 mousePos = input.getMousePosition();
|
||||
float screenW = static_cast<float>(window->getWidth());
|
||||
float screenH = static_cast<float>(window->getHeight());
|
||||
|
||||
rendering::Ray ray = camera->screenToWorldRay(mousePos.x, mousePos.y, screenW, screenH);
|
||||
rendering::Ray ray = camera->screenToWorldRay(leftClickPressPos_.x, leftClickPressPos_.y, screenW, screenH);
|
||||
|
||||
float closestT = 1e30f;
|
||||
uint64_t closestGuid = 0;
|
||||
|
|
@ -627,6 +638,7 @@ void GameScreen::processTargetInput(game::GameHandler& gameHandler) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Right-click: select NPC (if needed) then interact / loot / auto-attack
|
||||
// Suppress when left button is held (both-button run)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue