[DEBUG] Display mesh/aabb of a ImDrawCmd
| 17349 | |
| 17350 | // [DEBUG] Display mesh/aabb of a ImDrawCmd |
| 17351 | void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb) |
| 17352 | { |
| 17353 | IM_ASSERT(show_mesh || show_aabb); |
| 17354 | |
| 17355 | // Draw wire-frame version of all triangles |
| 17356 | ImRect clip_rect = draw_cmd->ClipRect; |
| 17357 | ImRect vtxs_rect(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX); |
| 17358 | ImDrawListFlags backup_flags = out_draw_list->Flags; |
| 17359 | out_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles. |
| 17360 | for (unsigned int idx_n = draw_cmd->IdxOffset, idx_end = draw_cmd->IdxOffset + draw_cmd->ElemCount; idx_n < idx_end; ) |
| 17361 | { |
| 17362 | 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 |
| 17363 | ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + draw_cmd->VtxOffset; |
| 17364 | |
| 17365 | ImVec2 triangle[3]; |
| 17366 | for (int n = 0; n < 3; n++, idx_n++) |
| 17367 | vtxs_rect.Add((triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos)); |
| 17368 | if (show_mesh) |
| 17369 | out_draw_list->AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), 1.0f, ImDrawFlags_Closed); // In yellow: mesh triangles |
| 17370 | } |
| 17371 | // Draw bounding boxes |
| 17372 | if (show_aabb) |
| 17373 | { |
| 17374 | 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 |
| 17375 | out_draw_list->AddRect(ImTrunc(vtxs_rect.Min), ImTrunc(vtxs_rect.Max), IM_COL32(0, 255, 255, 255)); // In cyan: bounding box of triangles |
| 17376 | } |
| 17377 | out_draw_list->Flags = backup_flags; |
| 17378 | } |
| 17379 | |
| 17380 | // [DEBUG] Compute mask of inputs with the same codepoint. |
| 17381 | static int CalcFontGlyphSrcOverlapMask(ImFontAtlas* atlas, ImFont* font, unsigned int codepoint) |
nothing calls this directly
no test coverage detected