MCPcopy Create free account
hub / github.com/Wemino/EchoPatch / DebugNodeDrawCmdShowMeshAndBoundingBox

Method DebugNodeDrawCmdShowMeshAndBoundingBox

include/imgui/imgui.cpp:17260–17287  ·  view source on GitHub ↗

[DEBUG] Display mesh/aabb of a ImDrawCmd

Source from the content-addressed store, hash-verified

17258
17259// [DEBUG] Display mesh/aabb of a ImDrawCmd
17260void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb)
17261{
17262 IM_ASSERT(show_mesh || show_aabb);
17263
17264 // Draw wire-frame version of all triangles
17265 ImRect clip_rect = draw_cmd->ClipRect;
17266 ImRect vtxs_rect(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
17267 ImDrawListFlags backup_flags = out_draw_list->Flags;
17268 out_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles.
17269 for (unsigned int idx_n = draw_cmd->IdxOffset, idx_end = draw_cmd->IdxOffset + draw_cmd->ElemCount; idx_n < idx_end; )
17270 {
17271 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
17272 ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + draw_cmd->VtxOffset;
17273
17274 ImVec2 triangle[3];
17275 for (int n = 0; n < 3; n++, idx_n++)
17276 vtxs_rect.Add((triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos));
17277 if (show_mesh)
17278 out_draw_list->AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), ImDrawFlags_Closed, 1.0f); // In yellow: mesh triangles
17279 }
17280 // Draw bounding boxes
17281 if (show_aabb)
17282 {
17283 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
17284 out_draw_list->AddRect(ImTrunc(vtxs_rect.Min), ImTrunc(vtxs_rect.Max), IM_COL32(0, 255, 255, 255)); // In cyan: bounding box of triangles
17285 }
17286 out_draw_list->Flags = backup_flags;
17287}
17288
17289// [DEBUG] Compute mask of inputs with the same codepoint.
17290static int CalcFontGlyphSrcOverlapMask(ImFontAtlas* atlas, ImFont* font, unsigned int codepoint)

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