[DEBUG] Display mesh/aabb of a ImDrawCmd
| 17258 | |
| 17259 | // [DEBUG] Display mesh/aabb of a ImDrawCmd |
| 17260 | void 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. |
| 17290 | static int CalcFontGlyphSrcOverlapMask(ImFontAtlas* atlas, ImFont* font, unsigned int codepoint) |
nothing calls this directly
no test coverage detected