From d489393ff8acdc9bf28cc75a7d33d9f5009603e8 Mon Sep 17 00:00:00 2001 From: konstin Date: Wed, 4 Feb 2015 19:31:11 +0100 Subject: [PATCH] set "Adjust Lights" base position to camera position --- src/utils/debug.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp index 72e869954..8e03f0cce 100644 --- a/src/utils/debug.cpp +++ b/src/utils/debug.cpp @@ -153,24 +153,14 @@ void addAttachment(Attachment::AttachmentType type) * nitro emitters) */ LightNode* findNearestLight() { - World* world = World::getWorld(); - if (!world) return NULL; - AbstractKart* player_kart = NULL; - for (unsigned int i = 0; i < world->getNumKarts(); i++) - { - AbstractKart *kart = world->getKart(i); - if (kart->getController()->isPlayerController()) - player_kart = kart; - } - - if (!player_kart) - { - Log::error("Debug", "No player kart found."); + Camera* camera = Camera::getActiveCamera(); + if (camera == NULL) { + Log::error("[Debug Menu]", "No camera found."); return NULL; } - core::vector3df kart_pos = player_kart->getNode()->getAbsolutePosition(); + core::vector3df cam_pos = camera->getCameraSceneNode()->getAbsolutePosition(); LightNode* nearest = 0; float nearest_dist = 1000000.0; // big enough for (unsigned int i = 0; i < irr_driver->getLights().size(); i++) @@ -182,10 +172,10 @@ LightNode* findNearestLight() continue; core::vector3df light_pos = light->getAbsolutePosition(); - if ( kart_pos.getDistanceFrom(light_pos) < nearest_dist) + if ( cam_pos.getDistanceFrom(light_pos) < nearest_dist) { nearest = irr_driver->getLights()[i]; - nearest_dist = kart_pos.getDistanceFrom(light_pos); + nearest_dist = cam_pos.getDistanceFrom(light_pos); } }