MCPcopy Create free account
hub / github.com/Raais/ImStudio / DebugNodeDrawCmdShowMeshAndBoundingBox

Method DebugNodeDrawCmdShowMeshAndBoundingBox

src/third-party/imgui/imgui.cpp:12613–12640  ·  view source on GitHub ↗

[DEBUG] Display mesh/aabb of a ImDrawCmd

Source from the content-addressed store, hash-verified

12611
12612// [DEBUG] Display mesh/aabb of a ImDrawCmd
12613void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb)
12614{
12615 IM_ASSERT(show_mesh || show_aabb);
12616
12617 // Draw wire-frame version of all triangles
12618 ImRect clip_rect = draw_cmd->ClipRect;
12619 ImRect vtxs_rect(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
12620 ImDrawListFlags backup_flags = out_draw_list->Flags;
12621 out_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles.
12622 for (unsigned int idx_n = draw_cmd->IdxOffset, idx_end = draw_cmd->IdxOffset + draw_cmd->ElemCount; idx_n < idx_end; )
12623 {
12624 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
12625 ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + draw_cmd->VtxOffset;
12626
12627 ImVec2 triangle[3];
12628 for (int n = 0; n < 3; n++, idx_n++)
12629 vtxs_rect.Add((triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos));
12630 if (show_mesh)
12631 out_draw_list->AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), ImDrawFlags_Closed, 1.0f); // In yellow: mesh triangles
12632 }
12633 // Draw bounding boxes
12634 if (show_aabb)
12635 {
12636 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
12637 out_draw_list->AddRect(ImFloor(vtxs_rect.Min), ImFloor(vtxs_rect.Max), IM_COL32(0, 255, 255, 255)); // In cyan: bounding box of triangles
12638 }
12639 out_draw_list->Flags = backup_flags;
12640}
12641
12642// [DEBUG] Display details for a single font, called by ShowStyleEditor().
12643void 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