MCPcopy Create free account
hub / github.com/clementgallet/libTAS / DebugNodeDrawCmdShowMeshAndBoundingBox

Method DebugNodeDrawCmdShowMeshAndBoundingBox

src/external/imgui/imgui.cpp:14580–14607  ·  view source on GitHub ↗

[DEBUG] Display mesh/aabb of a ImDrawCmd

Source from the content-addressed store, hash-verified

14578
14579// [DEBUG] Display mesh/aabb of a ImDrawCmd
14580void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb)
14581{
14582 IM_ASSERT(show_mesh || show_aabb);
14583
14584 // Draw wire-frame version of all triangles
14585 ImRect clip_rect = draw_cmd->ClipRect;
14586 ImRect vtxs_rect(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
14587 ImDrawListFlags backup_flags = out_draw_list->Flags;
14588 out_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles.
14589 for (unsigned int idx_n = draw_cmd->IdxOffset, idx_end = draw_cmd->IdxOffset + draw_cmd->ElemCount; idx_n < idx_end; )
14590 {
14591 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
14592 ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + draw_cmd->VtxOffset;
14593
14594 ImVec2 triangle[3];
14595 for (int n = 0; n < 3; n++, idx_n++)
14596 vtxs_rect.Add((triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos));
14597 if (show_mesh)
14598 out_draw_list->AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), ImDrawFlags_Closed, 1.0f); // In yellow: mesh triangles
14599 }
14600 // Draw bounding boxes
14601 if (show_aabb)
14602 {
14603 out_draw_list->AddRect(ImTrunc(clip_rect.Min), ImTrunc(clip_rect.Max), IM_COL32(255, 0, 255, 255)); // In pink: clipping rectangle submitted to GPU
14604 out_draw_list->AddRect(ImTrunc(vtxs_rect.Min), ImTrunc(vtxs_rect.Max), IM_COL32(0, 255, 255, 255)); // In cyan: bounding box of triangles
14605 }
14606 out_draw_list->Flags = backup_flags;
14607}
14608
14609// [DEBUG] Display details for a single font, called by ShowStyleEditor().
14610void ImGui::DebugNodeFont(ImFont* font)

Callers

nothing calls this directly

Calls 4

ImTruncFunction · 0.85
AddMethod · 0.80
AddPolylineMethod · 0.80
AddRectMethod · 0.80

Tested by

no test coverage detected