Add another render pass ESNRP_GUI which is drawn last and is p.E. useful for rendering gui nodes in the scenemanager.

UI and scenenodes are often connected. And while it was possible to work around this already by using custom draw functions
or deriving from gui and scene-nodes at the same time, it did already lead a few times to uglier code for me. 
So I guess adding one more pass to the engine has it's uses.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6107 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2020-03-30 16:04:53 +00:00
parent bca8023261
commit a67b616fc9
4 changed files with 51 additions and 2 deletions

@ -1,5 +1,6 @@
--------------------------
Changes in 1.9 (not yet released)
- Add another render pass ESNRP_GUI which is drawn last and is p.E. useful for rendering gui nodes in the scenemanager.
- BurningVideo: 0.51
- 10 year anniversary update
- Lighting model reworked. moved to eyespace like openGL. [Specular Highlights, Fog, Sphere/Reflection Map]

@ -52,7 +52,9 @@ namespace scene
{
//! Enumeration for render passes.
/** A parameter passed to the registerNodeForRendering() method of the ISceneManager,
specifying when the node wants to be drawn in relation to the other nodes. */
specifying when the node wants to be drawn in relation to the other nodes.
Note: Despite the numbering this is not used as bit-field.
*/
enum E_SCENE_NODE_RENDER_PASS
{
//! No pass currently active
@ -92,7 +94,11 @@ namespace scene
ESNRP_TRANSPARENT_EFFECT =32,
//! Drawn after the solid nodes, before the transparent nodes, the time for drawing shadow volumes
ESNRP_SHADOW =64
ESNRP_SHADOW =64,
//! Drawn after transparent effect nodes. For custom gui's. Unsorted (in order nodes registered themselves).
ESNRP_GUI = 128
};
class IAnimatedMesh;
@ -1122,6 +1128,8 @@ namespace scene
\param pass: Specifies when the node wants to be drawn in relation to the other nodes.
For example, if the node is a shadow, it usually wants to be drawn after all other nodes
and will use ESNRP_SHADOW for this. See scene::E_SCENE_NODE_RENDER_PASS for details.
Note: This is _not_ a bitfield. If you want to register a note for several render passes, then
call this function once for each pass.
\return scene will be rendered ( passed culling ) */
virtual u32 registerNodeForRendering(ISceneNode* node,
E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC) = 0;

@ -357,6 +357,7 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs,
getProfiler().add(EPID_SM_RENDER_SHADOWS, L"shadows", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_TRANSPARENT, L"transp.nodes", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_EFFECT, L"effectnodes", L"Irrlicht scene");
getProfiler().add(EPID_SM_RENDER_GUI_NODES, L"guinodes", L"Irrlicht scene");
getProfiler().add(EPID_SM_REGISTER, L"reg.render.node", L"Irrlicht scene");
}
)
@ -1403,6 +1404,13 @@ u32 CSceneManager::registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDE
}
break;
case ESNRP_GUI:
if (!isCulled(node))
{
GuiNodeList.push_back(node);
taken = 1;
}
case ESNRP_NONE: // ignore this one
break;
}
@ -1430,6 +1438,7 @@ void CSceneManager::clearAllRegisteredNodesForRendering()
TransparentNodeList.clear();
TransparentEffectNodeList.clear();
ShadowNodeList.clear();
GuiNodeList.clear();
}
//! This method is called just before the rendering process of the whole scene.
@ -1711,6 +1720,36 @@ void CSceneManager::drawAll()
TransparentEffectNodeList.set_used(0);
}
// render custom gui nodes
{
IRR_PROFILE(CProfileScope psEffect(EPID_SM_RENDER_GUI_NODES);)
CurrentRenderPass = ESNRP_GUI;
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
if (LightManager)
{
LightManager->OnRenderPassPreRender(CurrentRenderPass);
for (i=0; i<GuiNodeList.size(); ++i)
{
ISceneNode* node = GuiNodeList[i];
LightManager->OnNodePreRender(node);
node->render();
LightManager->OnNodePostRender(node);
}
}
else
{
for (i=0; i<GuiNodeList.size(); ++i)
GuiNodeList[i]->render();
}
#ifdef _IRR_SCENEMANAGER_DEBUG
Parameters->setAttribute("drawn_gui_nodes", (s32) GuiNodeList.size());
#endif
GuiNodeList.set_used(0);
}
if (LightManager)
LightManager->OnPostRender();

@ -632,6 +632,7 @@ namespace scene
core::array<DefaultNodeEntry> SolidNodeList;
core::array<TransparentNodeEntry> TransparentNodeList;
core::array<TransparentNodeEntry> TransparentEffectNodeList;
core::array<ISceneNode*> GuiNodeList;
core::array<IMeshLoader*> MeshLoaderList;
core::array<ISceneLoader*> SceneLoaderList;