MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / DebugNodeDrawCmdShowMeshAndBoundingBox

Method DebugNodeDrawCmdShowMeshAndBoundingBox

KBotExt/imgui/imgui.cpp:14262–14289  ·  view source on GitHub ↗

[DEBUG] Display mesh/aabb of a ImDrawCmd

Source from the content-addressed store, hash-verified

14260
14261// [DEBUG] Display mesh/aabb of a ImDrawCmd
14262void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb)
14263{
14264 IM_ASSERT(show_mesh || show_aabb);
14265
14266 // Draw wire-frame version of all triangles
14267 ImRect clip_rect = draw_cmd->ClipRect;
14268 ImRect vtxs_rect(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
14269 ImDrawListFlags backup_flags = out_draw_list->Flags;
14270 out_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles.
14271 for (unsigned int idx_n = draw_cmd->IdxOffset, idx_end = draw_cmd->IdxOffset + draw_cmd->ElemCount; idx_n < idx_end; )
14272 {
14273 ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; // We don't hold on those pointers past iterations as ->AddPolyline() may invalidate them if out_draw_list==draw_list
14274 ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + draw_cmd->VtxOffset;
14275
14276 ImVec2 triangle[3];
14277 for (int n = 0; n < 3; n++, idx_n++)
14278 vtxs_rect.Add((triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos));
14279 if (show_mesh)
14280 out_draw_list->AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), ImDrawFlags_Closed, 1.0f); // In yellow: mesh triangles
14281 }
14282 // Draw bounding boxes
14283 if (show_aabb)
14284 {
14285 out_draw_list->AddRect(ImFloor(clip_rect.Min), ImFloor(clip_rect.Max), IM_COL32(255, 0, 255, 255)); // In pink: clipping rectangle submitted to GPU
14286 out_draw_list->AddRect(ImFloor(vtxs_rect.Min), ImFloor(vtxs_rect.Max), IM_COL32(0, 255, 255, 255)); // In cyan: bounding box of triangles
14287 }
14288 out_draw_list->Flags = backup_flags;
14289}
14290
14291// [DEBUG] Display details for a single font, called by ShowStyleEditor().
14292void ImGui::DebugNodeFont(ImFont* font)

Callers

nothing calls this directly

Calls 4

ImFloorFunction · 0.85
AddMethod · 0.80
AddPolylineMethod · 0.80
AddRectMethod · 0.80

Tested by

no test coverage detected