mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Add debug mode that shows mesh buffer bounding boxes
This commit is contained in:
parent
9554e3d43a
commit
4e2ca05f08
8 changed files with 70 additions and 46 deletions
|
@ -34,7 +34,7 @@ enum E_DEBUG_SCENE_TYPE
|
|||
EDS_BBOX_ALL = EDS_BBOX | EDS_BBOX_BUFFERS,
|
||||
|
||||
//! Show all debug infos
|
||||
EDS_FULL = 0xffffffff
|
||||
EDS_FULL = 0xffff
|
||||
};
|
||||
|
||||
} // end namespace scene
|
||||
|
|
|
@ -387,6 +387,14 @@ public:
|
|||
pass currently is active they can render the correct part of their geometry. */
|
||||
virtual E_SCENE_NODE_RENDER_PASS getSceneNodeRenderPass() const = 0;
|
||||
|
||||
/**
|
||||
* Sets debug data flags that will be set on every rendered scene node.
|
||||
* Refer to `E_DEBUG_SCENE_TYPE`.
|
||||
* @param setBits bit mask of types to enable
|
||||
* @param unsetBits bit mask of types to disable
|
||||
*/
|
||||
virtual void setGlobalDebugData(u16 setBits, u16 unsetBits) = 0;
|
||||
|
||||
//! Creates a new scene manager.
|
||||
/** This can be used to easily draw and/or store two
|
||||
independent scenes at the same time. The mesh cache will be
|
||||
|
|
|
@ -403,14 +403,14 @@ public:
|
|||
their geometry because it is their only reason for existence,
|
||||
for example the OctreeSceneNode.
|
||||
\param state The culling state to be used. Check E_CULLING_TYPE for possible values.*/
|
||||
void setAutomaticCulling(u32 state)
|
||||
void setAutomaticCulling(u16 state)
|
||||
{
|
||||
AutomaticCullingState = state;
|
||||
}
|
||||
|
||||
//! Gets the automatic culling state.
|
||||
/** \return The automatic culling state. */
|
||||
u32 getAutomaticCulling() const
|
||||
u16 getAutomaticCulling() const
|
||||
{
|
||||
return AutomaticCullingState;
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ public:
|
|||
/** A bitwise OR of the types from @ref irr::scene::E_DEBUG_SCENE_TYPE.
|
||||
Please note that not all scene nodes support all debug data types.
|
||||
\param state The debug data visibility state to be used. */
|
||||
virtual void setDebugDataVisible(u32 state)
|
||||
virtual void setDebugDataVisible(u16 state)
|
||||
{
|
||||
DebugDataVisible = state;
|
||||
}
|
||||
|
@ -427,7 +427,7 @@ public:
|
|||
//! Returns if debug data like bounding boxes are drawn.
|
||||
/** \return A bitwise OR of the debug data values from
|
||||
@ref irr::scene::E_DEBUG_SCENE_TYPE that are currently visible. */
|
||||
u32 isDebugDataVisible() const
|
||||
u16 isDebugDataVisible() const
|
||||
{
|
||||
return DebugDataVisible;
|
||||
}
|
||||
|
@ -581,10 +581,10 @@ protected:
|
|||
s32 ID;
|
||||
|
||||
//! Automatic culling state
|
||||
u32 AutomaticCullingState;
|
||||
u16 AutomaticCullingState;
|
||||
|
||||
//! Flag if debug data should be drawn, such as Bounding Boxes.
|
||||
u32 DebugDataVisible;
|
||||
u16 DebugDataVisible;
|
||||
|
||||
//! Is the node visible?
|
||||
bool IsVisible;
|
||||
|
|
|
@ -276,9 +276,6 @@ void CAnimatedMeshSceneNode::render()
|
|||
debug_mat.ZBuffer = video::ECFN_DISABLED;
|
||||
driver->setMaterial(debug_mat);
|
||||
|
||||
if (DebugDataVisible & scene::EDS_BBOX)
|
||||
driver->draw3DBox(Box, video::SColor(255, 255, 255, 255));
|
||||
|
||||
// show bounding box
|
||||
if (DebugDataVisible & scene::EDS_BBOX_BUFFERS) {
|
||||
for (u32 g = 0; g < m->getMeshBufferCount(); ++g) {
|
||||
|
@ -290,6 +287,9 @@ void CAnimatedMeshSceneNode::render()
|
|||
}
|
||||
}
|
||||
|
||||
if (DebugDataVisible & scene::EDS_BBOX)
|
||||
driver->draw3DBox(Box, video::SColor(255, 255, 255, 255));
|
||||
|
||||
// show skeleton
|
||||
if (DebugDataVisible & scene::EDS_SKELETON) {
|
||||
if (Mesh->getMeshType() == EAMT_SKINNED) {
|
||||
|
|
|
@ -110,11 +110,9 @@ void CMeshSceneNode::render()
|
|||
if (DebugDataVisible && PassCount == 1) {
|
||||
video::SMaterial m;
|
||||
m.AntiAliasing = 0;
|
||||
m.ZBuffer = video::ECFN_DISABLED;
|
||||
driver->setMaterial(m);
|
||||
|
||||
if (DebugDataVisible & scene::EDS_BBOX) {
|
||||
driver->draw3DBox(Box, video::SColor(255, 255, 255, 255));
|
||||
}
|
||||
if (DebugDataVisible & scene::EDS_BBOX_BUFFERS) {
|
||||
for (u32 g = 0; g < Mesh->getMeshBufferCount(); ++g) {
|
||||
driver->draw3DBox(
|
||||
|
@ -123,6 +121,10 @@ void CMeshSceneNode::render()
|
|||
}
|
||||
}
|
||||
|
||||
if (DebugDataVisible & scene::EDS_BBOX) {
|
||||
driver->draw3DBox(Box, video::SColor(255, 255, 255, 255));
|
||||
}
|
||||
|
||||
if (DebugDataVisible & scene::EDS_NORMALS) {
|
||||
// draw normals
|
||||
const f32 debugNormalLength = 1.f;
|
||||
|
|
|
@ -490,13 +490,19 @@ void CSceneManager::drawAll()
|
|||
// let all nodes register themselves
|
||||
OnRegisterSceneNode();
|
||||
|
||||
const auto &render_node = [this] (ISceneNode *node) {
|
||||
u32 flags = node->isDebugDataVisible();
|
||||
node->setDebugDataVisible((flags & DebugDataMask) | DebugDataBits);
|
||||
node->render();
|
||||
};
|
||||
|
||||
// render camera scenes
|
||||
{
|
||||
CurrentRenderPass = ESNRP_CAMERA;
|
||||
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
|
||||
|
||||
for (auto *node : CameraList)
|
||||
node->render();
|
||||
render_node(node);
|
||||
|
||||
CameraList.clear();
|
||||
}
|
||||
|
@ -507,7 +513,7 @@ void CSceneManager::drawAll()
|
|||
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
|
||||
|
||||
for (auto *node : SkyBoxList)
|
||||
node->render();
|
||||
render_node(node);
|
||||
|
||||
SkyBoxList.clear();
|
||||
}
|
||||
|
@ -520,7 +526,7 @@ void CSceneManager::drawAll()
|
|||
std::sort(SolidNodeList.begin(), SolidNodeList.end());
|
||||
|
||||
for (auto &it : SolidNodeList)
|
||||
it.Node->render();
|
||||
render_node(it.Node);
|
||||
|
||||
SolidNodeList.clear();
|
||||
}
|
||||
|
@ -533,7 +539,7 @@ void CSceneManager::drawAll()
|
|||
std::sort(TransparentNodeList.begin(), TransparentNodeList.end());
|
||||
|
||||
for (auto &it : TransparentNodeList)
|
||||
it.Node->render();
|
||||
render_node(it.Node);
|
||||
|
||||
TransparentNodeList.clear();
|
||||
}
|
||||
|
@ -546,7 +552,7 @@ void CSceneManager::drawAll()
|
|||
std::sort(TransparentEffectNodeList.begin(), TransparentEffectNodeList.end());
|
||||
|
||||
for (auto &it : TransparentEffectNodeList)
|
||||
it.Node->render();
|
||||
render_node(it.Node);
|
||||
|
||||
TransparentEffectNodeList.clear();
|
||||
}
|
||||
|
@ -557,7 +563,7 @@ void CSceneManager::drawAll()
|
|||
Driver->getOverrideMaterial().Enabled = ((Driver->getOverrideMaterial().EnablePasses & CurrentRenderPass) != 0);
|
||||
|
||||
for (auto *node : GuiNodeList)
|
||||
node->render();
|
||||
render_node(node);
|
||||
|
||||
GuiNodeList.clear();
|
||||
}
|
||||
|
|
|
@ -179,6 +179,11 @@ public:
|
|||
//! Set current render time.
|
||||
void setCurrentRenderPass(E_SCENE_NODE_RENDER_PASS nextPass) override { CurrentRenderPass = nextPass; }
|
||||
|
||||
void setGlobalDebugData(u16 setBits, u16 unsetBits) override {
|
||||
DebugDataMask = ~unsetBits;
|
||||
DebugDataBits = setBits;
|
||||
}
|
||||
|
||||
//! returns if node is culled
|
||||
bool isCulled(const ISceneNode *node) const override;
|
||||
|
||||
|
@ -268,6 +273,9 @@ private:
|
|||
//! Mesh cache
|
||||
IMeshCache *MeshCache;
|
||||
|
||||
//! Global debug render state
|
||||
u16 DebugDataMask = 0, DebugDataBits = 0;
|
||||
|
||||
E_SCENE_NODE_RENDER_PASS CurrentRenderPass;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue