From 17d652947c0105b3385a1d16e834074b421743f7 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 18 Mar 2026 10:56:44 -0700 Subject: [PATCH] feat: extend cursor hover to NPCs and players Hand cursor now shows when hovering over any interactive entity in the 3D world (NPCs, players, game objects), not just game objects. Helps identify clickable targets at a glance. --- src/ui/game_screen.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index 2f74f899..ba2465f1 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -2873,7 +2873,7 @@ void GameScreen::processTargetInput(game::GameHandler& gameHandler) { } - // Cursor affordance: show hand cursor over interactable game objects. + // Cursor affordance: show hand cursor over interactable entities. if (!io.WantCaptureMouse) { auto* renderer = core::Application::getInstance().getRenderer(); auto* camera = renderer ? renderer->getCamera() : nullptr; @@ -2884,17 +2884,21 @@ void GameScreen::processTargetInput(game::GameHandler& gameHandler) { float screenH = static_cast(window->getHeight()); rendering::Ray ray = camera->screenToWorldRay(mousePos.x, mousePos.y, screenW, screenH); float closestT = 1e30f; - bool hoverInteractableGo = false; + bool hoverInteractable = false; for (const auto& [guid, entity] : gameHandler.getEntityManager().getEntities()) { - if (entity->getType() != game::ObjectType::GAMEOBJECT) continue; + bool isGo = (entity->getType() == game::ObjectType::GAMEOBJECT); + bool isUnit = (entity->getType() == game::ObjectType::UNIT); + bool isPlayer = (entity->getType() == game::ObjectType::PLAYER); + if (!isGo && !isUnit && !isPlayer) continue; + if (guid == gameHandler.getPlayerGuid()) continue; // skip self glm::vec3 hitCenter; float hitRadius = 0.0f; bool hasBounds = core::Application::getInstance().getRenderBoundsForGuid(guid, hitCenter, hitRadius); if (!hasBounds) { - hitRadius = 2.5f; + hitRadius = isGo ? 2.5f : 1.8f; hitCenter = core::coords::canonicalToRender(glm::vec3(entity->getX(), entity->getY(), entity->getZ())); - hitCenter.z += 1.2f; + hitCenter.z += isGo ? 1.2f : 1.0f; } else { hitRadius = std::max(hitRadius * 1.1f, 0.8f); } @@ -2902,10 +2906,10 @@ void GameScreen::processTargetInput(game::GameHandler& gameHandler) { float hitT; if (raySphereIntersect(ray, hitCenter, hitRadius, hitT) && hitT < closestT) { closestT = hitT; - hoverInteractableGo = true; + hoverInteractable = true; } } - if (hoverInteractableGo) { + if (hoverInteractable) { ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); } }