MCPcopy Create free account
hub / github.com/RenderKit/embree / DebugNodeDrawCmdShowMeshAndBoundingBox

Method DebugNodeDrawCmdShowMeshAndBoundingBox

tutorials/common/imgui/imgui.cpp:13570–13597  ·  view source on GitHub ↗

[DEBUG] Display mesh/aabb of a ImDrawCmd

Source from the content-addressed store, hash-verified

13568
13569// [DEBUG] Display mesh/aabb of a ImDrawCmd
13570void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb)
13571{
13572 IM_ASSERT(show_mesh || show_aabb);
13573
13574 // Draw wire-frame version of all triangles
13575 ImRect clip_rect = draw_cmd->ClipRect;
13576 ImRect vtxs_rect(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
13577 ImDrawListFlags backup_flags = out_draw_list->Flags;
13578 out_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles.
13579 for (unsigned int idx_n = draw_cmd->IdxOffset, idx_end = draw_cmd->IdxOffset + draw_cmd->ElemCount; idx_n < idx_end; )
13580 {
13581 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
13582 ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + draw_cmd->VtxOffset;
13583
13584 ImVec2 triangle[3];
13585 for (int n = 0; n < 3; n++, idx_n++)
13586 vtxs_rect.Add((triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos));
13587 if (show_mesh)
13588 out_draw_list->AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), ImDrawFlags_Closed, 1.0f); // In yellow: mesh triangles
13589 }
13590 // Draw bounding boxes
13591 if (show_aabb)
13592 {
13593 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
13594 out_draw_list->AddRect(ImFloor(vtxs_rect.Min), ImFloor(vtxs_rect.Max), IM_COL32(0, 255, 255, 255)); // In cyan: bounding box of triangles
13595 }
13596 out_draw_list->Flags = backup_flags;
13597}
13598
13599// [DEBUG] Display details for a single font, called by ShowStyleEditor().
13600void 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