From bbcc2afa61216177db5c9c2f737179537b417ae0 Mon Sep 17 00:00:00 2001 From: auria Date: Tue, 7 Jan 2014 02:12:17 +0000 Subject: [PATCH] Use light absolute position for culling, the relative position was incorrectly used git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14957 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/graphics/light.cpp | 13 +++++++++++++ src/graphics/light.hpp | 6 ++++++ src/graphics/render.cpp | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/graphics/light.cpp b/src/graphics/light.cpp index 671fb0d99..196799f4d 100644 --- a/src/graphics/light.cpp +++ b/src/graphics/light.cpp @@ -42,6 +42,10 @@ LightNode::LightNode(scene::ISceneManager* mgr, scene::ISceneNode* parent, float m_color[0] = r; m_color[1] = g; m_color[2] = b; + +#ifdef __LIGHT_NODE_VISUALISATION__ + m_viz_added = false; +#endif } LightNode::~LightNode() @@ -94,4 +98,13 @@ void LightNode::renderLightSet(const std::vector &positions, const std::v void LightNode::OnRegisterSceneNode() { // This node is only drawn manually. + +#ifdef __LIGHT_NODE_VISUALISATION__ + if (!m_viz_added) + { + scene::IMeshSceneNode* viz = irr_driver->addSphere(0.5f, video::SColor(255, m_color[0]*255, m_color[1]*255, m_color[2]*255)); + viz->setPosition(this->getAbsolutePosition()); + m_viz_added = true; + } +#endif } diff --git a/src/graphics/light.hpp b/src/graphics/light.hpp index 05e6ee210..b6309f56e 100644 --- a/src/graphics/light.hpp +++ b/src/graphics/light.hpp @@ -30,9 +30,15 @@ namespace irr namespace scene { class IMesh; } } +//#define __LIGHT_NODE_VISUALISATION__ + // The actual node class LightNode: public scene::ISceneNode { +#ifdef __LIGHT_NODE_VISUALISATION__ + bool m_viz_added; +#endif + public: LightNode(scene::ISceneManager* mgr, scene::ISceneNode* parent, float energy, float r, float g, float b); virtual ~LightNode(); diff --git a/src/graphics/render.cpp b/src/graphics/render.cpp index 276a5e046..df00e8972 100644 --- a/src/graphics/render.cpp +++ b/src/graphics/render.cpp @@ -706,7 +706,7 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox, m_lights[i]->render(); continue; } - const core::vector3df &lightpos = (m_lights[i]->getPosition() - campos); + const core::vector3df &lightpos = (m_lights[i]->getAbsolutePosition() - campos); unsigned idx = (unsigned)(lightpos.getLength() / 10); if (idx > 14) continue;