Recast: add option to disable rendering of shape volumes

This commit is contained in:
Kawe Mazidjatari 2024-10-25 00:40:40 +02:00
parent 349f7bd3b9
commit 563427ae63
2 changed files with 30 additions and 9 deletions

View File

@ -260,6 +260,11 @@ void Editor_StaticTileMeshCommon::renderRecastDebugMenu()
ImGui::EndDisabled();
isEnabled = getTileMeshDrawFlags() & DU_DRAW_RECASTMESH_SHAPE_VOLUMES;
if (ImGui::Checkbox("Shape Volumes", &isEnabled))
toggleTileMeshDrawFlag(DU_DRAW_RECASTMESH_SHAPE_VOLUMES);
//if (intermediateDataUnavailable) // todo(amos): tool tip
//{
// ImGui::Separator();
@ -382,16 +387,20 @@ void Editor_StaticTileMeshCommon::renderTileMeshData()
}
int selectedVolumeIndex = -1;
if (m_tool->type() == TOOL_SHAPE_VOLUME)
const bool isShapeVolumeTool = (m_tool->type() == TOOL_SHAPE_VOLUME);
if (isShapeVolumeTool)
{
const ShapeVolumeTool* volTool = (const ShapeVolumeTool*)m_tool;
selectedVolumeIndex = volTool->getSelectedVolumeIndex();
}
// TODO: also add flags for this
m_geom->drawBoxVolumes(&m_dd, recastDrawOffset, selectedVolumeIndex);
m_geom->drawCylinderVolumes(&m_dd, recastDrawOffset, selectedVolumeIndex);
m_geom->drawConvexVolumes(&m_dd, recastDrawOffset, selectedVolumeIndex);
if ((recastDrawFlags & DU_DRAW_RECASTMESH_SHAPE_VOLUMES) || isShapeVolumeTool)
{
m_geom->drawBoxVolumes(&m_dd, recastDrawOffset, selectedVolumeIndex);
m_geom->drawCylinderVolumes(&m_dd, recastDrawOffset, selectedVolumeIndex);
m_geom->drawConvexVolumes(&m_dd, recastDrawOffset, selectedVolumeIndex);
}
// NOTE: commented out because this already gets rendered when the off-mesh
// connection tool is activated. And if we generated an off-mesh link, this
@ -586,10 +595,21 @@ void Editor_DynamicTileMeshCommon::renderTileMeshData()
}
}
// TODO: also add flags for this
m_geom->drawBoxVolumes(&m_dd, recastDrawOffset);
m_geom->drawCylinderVolumes(&m_dd, recastDrawOffset);
m_geom->drawConvexVolumes(&m_dd, recastDrawOffset);
int selectedVolumeIndex = -1;
const bool isShapeVolumeTool = (m_tool->type() == TOOL_SHAPE_VOLUME);
if (isShapeVolumeTool)
{
const ShapeVolumeTool* volTool = (const ShapeVolumeTool*)m_tool;
selectedVolumeIndex = volTool->getSelectedVolumeIndex();
}
if ((recastDrawFlags & DU_DRAW_RECASTMESH_SHAPE_VOLUMES) || isShapeVolumeTool)
{
m_geom->drawBoxVolumes(&m_dd, recastDrawOffset, selectedVolumeIndex);
m_geom->drawCylinderVolumes(&m_dd, recastDrawOffset, selectedVolumeIndex);
m_geom->drawConvexVolumes(&m_dd, recastDrawOffset, selectedVolumeIndex);
}
// NOTE: commented out because this already gets rendered when the off-mesh
// connection tool is activated. And if we generated an off-mesh link, this

View File

@ -33,6 +33,7 @@ enum DrawRecastMeshFlags
DU_DRAW_RECASTMESH_CONTOURS = 1<<9,
DU_DRAW_RECASTMESH_POLYMESH = 1<<10,
DU_DRAW_RECASTMESH_POLYMESH_DETAIL = 1<<11,
DU_DRAW_RECASTMESH_SHAPE_VOLUMES = 1<<12,
};
void duDebugDrawTriMesh(struct duDebugDraw* dd, const float* verts, int nverts, const int* tris, const float* normals, int ntris,