[DEBUG] Display mesh/aabb of a ImDrawCmd
| 13568 | |
| 13569 | // [DEBUG] Display mesh/aabb of a ImDrawCmd |
| 13570 | void 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(). |
| 13600 | void ImGui::DebugNodeFont(ImFont* font) |
nothing calls this directly
no test coverage detected