hover_tracker.cpp 839 B

1234567891011121314151617181920212223242526
  1. #include "hover_tracker.h"
  2. #include "game/core/world.h"
  3. #include "render/gl/camera.h"
  4. #include "systems/picking_service.h"
  5. HoverTracker::HoverTracker(Game::Systems::PickingService *pickingService)
  6. : m_pickingService(pickingService) {}
  7. auto HoverTracker::update_hover(float sx, float sy, Engine::Core::World &world,
  8. const Render::GL::Camera &camera,
  9. int viewportWidth,
  10. int viewportHeight) -> Engine::Core::EntityID {
  11. if (m_pickingService == nullptr) {
  12. return 0;
  13. }
  14. if (sx < 0 || sy < 0 || sx >= viewportWidth || sy >= viewportHeight) {
  15. m_hoveredEntityId = 0;
  16. return 0;
  17. }
  18. m_hoveredEntityId = m_pickingService->update_hover(
  19. sx, sy, world, camera, viewportWidth, viewportHeight);
  20. return m_hoveredEntityId;
  21. }