Commit 52f84ab7 authored by hybrid's avatar hybrid

Change type for stored and passed lights array. In most situations, only the...

Change type for stored and passed lights array. In most situations, only the ISceneNode was used, and the type is not necessarily ILightSceneNode anyway. So generalize this interface and the storage arrays internally.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3722 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 667a64e5
...@@ -63,19 +63,17 @@ class CMyLightManager : public scene::ILightManager, public IEventReceiver ...@@ -63,19 +63,17 @@ class CMyLightManager : public scene::ILightManager, public IEventReceiver
// These data represent the state information that this light manager // These data represent the state information that this light manager
// is interested in. // is interested in.
scene::ISceneManager * SceneManager; scene::ISceneManager * SceneManager;
core::array<scene::ILightSceneNode*> * SceneLightList; core::array<scene::ISceneNode*> * SceneLightList;
scene::E_SCENE_NODE_RENDER_PASS CurrentRenderPass; scene::E_SCENE_NODE_RENDER_PASS CurrentRenderPass;
scene::ISceneNode * CurrentSceneNode; scene::ISceneNode * CurrentSceneNode;
public: public:
CMyLightManager(scene::ISceneManager* sceneManager) CMyLightManager(scene::ISceneManager* sceneManager)
: Mode(NO_MANAGEMENT), RequestedMode(NO_MANAGEMENT), : Mode(NO_MANAGEMENT), RequestedMode(NO_MANAGEMENT),
SceneManager(sceneManager), SceneLightList(0), SceneManager(sceneManager), SceneLightList(0),
CurrentRenderPass(scene::ESNRP_NONE), CurrentSceneNode(0) CurrentRenderPass(scene::ESNRP_NONE), CurrentSceneNode(0)
{ } { }
virtual ~CMyLightManager(void) { }
// The input receiver interface, which just switches light management strategy // The input receiver interface, which just switches light management strategy
bool OnEvent(const SEvent & event) bool OnEvent(const SEvent & event)
{ {
...@@ -111,7 +109,7 @@ public: ...@@ -111,7 +109,7 @@ public:
// This is called before the first scene node is rendered. // This is called before the first scene node is rendered.
virtual void OnPreRender(core::array<scene::ILightSceneNode*> & lightList) virtual void OnPreRender(core::array<scene::ISceneNode*> & lightList)
{ {
// Update the mode; changing it here ensures that it's consistent throughout a render // Update the mode; changing it here ensures that it's consistent throughout a render
Mode = RequestedMode; Mode = RequestedMode;
...@@ -127,7 +125,7 @@ public: ...@@ -127,7 +125,7 @@ public:
// lights on to ensure that they are in a consistent state. You wouldn't normally have // lights on to ensure that they are in a consistent state. You wouldn't normally have
// to do this when using a light manager, since you'd continue to do light management // to do this when using a light manager, since you'd continue to do light management
// yourself. // yourself.
for(u32 i = 0; i < SceneLightList->size(); i++) for (u32 i = 0; i < SceneLightList->size(); i++)
(*SceneLightList)[i]->setVisible(true); (*SceneLightList)[i]->setVisible(true);
} }
...@@ -140,9 +138,9 @@ public: ...@@ -140,9 +138,9 @@ public:
virtual void OnRenderPassPostRender(scene::E_SCENE_NODE_RENDER_PASS renderPass) virtual void OnRenderPassPostRender(scene::E_SCENE_NODE_RENDER_PASS renderPass)
{ {
// I only want solid nodes to be lit, so after the solid pass, turn all lights off. // I only want solid nodes to be lit, so after the solid pass, turn all lights off.
if(scene::ESNRP_SOLID == renderPass) if (scene::ESNRP_SOLID == renderPass)
{ {
for(u32 i = 0; i < SceneLightList->size(); ++i) for (u32 i = 0; i < SceneLightList->size(); ++i)
(*SceneLightList)[i]->setVisible(false); (*SceneLightList)[i]->setVisible(false);
} }
} }
...@@ -178,8 +176,8 @@ public: ...@@ -178,8 +176,8 @@ public:
u32 i; u32 i;
for(i = 0; i < SceneLightList->size(); ++i) for(i = 0; i < SceneLightList->size(); ++i)
{ {
scene::ILightSceneNode* lightNode = (*SceneLightList)[i]; scene::ISceneNode* lightNode = (*SceneLightList)[i];
f64 distance = lightNode->getAbsolutePosition().getDistanceFromSQ(nodePosition); const f64 distance = lightNode->getAbsolutePosition().getDistanceFromSQ(nodePosition);
sortingArray.push_back(LightDistanceElement(lightNode, distance)); sortingArray.push_back(LightDistanceElement(lightNode, distance));
} }
...@@ -189,7 +187,6 @@ public: ...@@ -189,7 +187,6 @@ public:
// Turn on the three nearest lights, and turn the others off. // Turn on the three nearest lights, and turn the others off.
for(i = 0; i < sortingArray.size(); ++i) for(i = 0; i < sortingArray.size(); ++i)
sortingArray[i].node->setVisible(i < 3); sortingArray[i].node->setVisible(i < 3);
} }
else if(LIGHTS_IN_ZONE == Mode) else if(LIGHTS_IN_ZONE == Mode)
{ {
...@@ -200,7 +197,9 @@ public: ...@@ -200,7 +197,9 @@ public:
// knowledge of how this particular scene graph is organised. // knowledge of how this particular scene graph is organised.
for (u32 i = 0; i < SceneLightList->size(); ++i) for (u32 i = 0; i < SceneLightList->size(); ++i)
{ {
scene::ILightSceneNode* lightNode = (*SceneLightList)[i]; if ((*SceneLightList)[i]->getType() != scene::ESNT_LIGHT)
continue;
scene::ILightSceneNode* lightNode = static_cast<scene::ILightSceneNode*>((*SceneLightList)[i]);
video::SLight & lightData = lightNode->getLightData(); video::SLight & lightData = lightNode->getLightData();
if (video::ELT_DIRECTIONAL != lightData.Type) if (video::ELT_DIRECTIONAL != lightData.Type)
...@@ -224,10 +223,10 @@ private: ...@@ -224,10 +223,10 @@ private:
// Find the empty scene node that is the parent of the specified node // Find the empty scene node that is the parent of the specified node
scene::ISceneNode * findZone(scene::ISceneNode * node) scene::ISceneNode * findZone(scene::ISceneNode * node)
{ {
if(!node) if (!node)
return 0; return 0;
if(node->getType() == scene::ESNT_EMPTY) if (node->getType() == scene::ESNT_EMPTY)
return node; return node;
return findZone(node->getParent()); return findZone(node->getParent());
...@@ -239,11 +238,10 @@ private: ...@@ -239,11 +238,10 @@ private:
{ {
core::list<scene::ISceneNode*> const & children = node->getChildren(); core::list<scene::ISceneNode*> const & children = node->getChildren();
for (core::list<scene::ISceneNode*>::ConstIterator child = children.begin(); for (core::list<scene::ISceneNode*>::ConstIterator child = children.begin();
child != children.end(); child != children.end(); ++child)
++child)
{ {
if((*child)->getType() == scene::ESNT_LIGHT) if ((*child)->getType() == scene::ESNT_LIGHT)
static_cast<scene::ILightSceneNode*>(*child)->setVisible(true); (*child)->setVisible(true);
else // Assume that lights don't have any children that are also lights else // Assume that lights don't have any children that are also lights
turnOnZoneLights(*child); turnOnZoneLights(*child);
} }
...@@ -256,10 +254,10 @@ private: ...@@ -256,10 +254,10 @@ private:
public: public:
LightDistanceElement() {}; LightDistanceElement() {};
LightDistanceElement(scene::ILightSceneNode* n, f64 d) LightDistanceElement(scene::ISceneNode* n, f64 d)
: node(n), distance(d) { } : node(n), distance(d) { }
scene::ILightSceneNode* node; scene::ISceneNode* node;
f64 distance; f64 distance;
// Lower distance elements are sorted to the start of the array // Lower distance elements are sorted to the start of the array
......
...@@ -34,7 +34,7 @@ namespace scene ...@@ -34,7 +34,7 @@ namespace scene
the light manager may modify. This reference will remain valid the light manager may modify. This reference will remain valid
until OnPostRender(). until OnPostRender().
*/ */
virtual void OnPreRender(core::array<ILightSceneNode*> & lightList) = 0; virtual void OnPreRender(core::array<ISceneNode*> & lightList) = 0;
//! Called after the last scene node is rendered. //! Called after the last scene node is rendered.
/** After this call returns, the lightList passed to OnPreRender() becomes invalid. */ /** After this call returns, the lightList passed to OnPreRender() becomes invalid. */
......
...@@ -1256,7 +1256,7 @@ u32 CSceneManager::registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDE ...@@ -1256,7 +1256,7 @@ u32 CSceneManager::registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDE
// Lighting model in irrlicht has to be redone.. // Lighting model in irrlicht has to be redone..
//if (!isCulled(node)) //if (!isCulled(node))
{ {
LightList.push_back(static_cast<ILightSceneNode*>(node)); LightList.push_back(node);
taken = 1; taken = 1;
} }
break; break;
...@@ -1433,7 +1433,7 @@ void CSceneManager::drawAll() ...@@ -1433,7 +1433,7 @@ void CSceneManager::drawAll()
SortedLights.sort(); SortedLights.sort();
for(s32 light = (s32)LightList.size() - 1; light >= 0; --light) for(s32 light = (s32)LightList.size() - 1; light >= 0; --light)
LightList[light] = static_cast<ILightSceneNode*>(SortedLights[light].Node); LightList[light] = SortedLights[light].Node;
} }
Driver->deleteAllDynamicLights(); Driver->deleteAllDynamicLights();
......
...@@ -601,7 +601,7 @@ namespace scene ...@@ -601,7 +601,7 @@ namespace scene
//! render pass lists //! render pass lists
core::array<ISceneNode*> CameraList; core::array<ISceneNode*> CameraList;
core::array<ILightSceneNode*> LightList; core::array<ISceneNode*> LightList;
core::array<ISceneNode*> ShadowNodeList; core::array<ISceneNode*> ShadowNodeList;
core::array<ISceneNode*> SkyBoxList; core::array<ISceneNode*> SkyBoxList;
core::array<DefaultNodeEntry> SolidNodeList; core::array<DefaultNodeEntry> SolidNodeList;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment