mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	Metrics: Fix metrics crash with viewports.
This commit is contained in:
		| @@ -15318,10 +15318,9 @@ void ImGui::ShowMetricsWindow(bool* p_open) | ||||
|             return ImRect(); | ||||
|         } | ||||
|  | ||||
|         static void NodeDrawCmdShowMeshAndBoundingBox(ImGuiWindow* window, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, int elem_offset, bool show_mesh, bool show_aabb) | ||||
|         static void NodeDrawCmdShowMeshAndBoundingBox(ImDrawList* fg_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, int elem_offset, bool show_mesh, bool show_aabb) | ||||
|         { | ||||
|             IM_ASSERT(show_mesh || show_aabb); | ||||
|             ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list | ||||
|             ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; | ||||
|  | ||||
|             // Draw wire-frame version of all triangles | ||||
| @@ -15350,6 +15349,7 @@ void ImGui::ShowMetricsWindow(bool* p_open) | ||||
|             fg_draw_list->Flags = backup_flags; | ||||
|         } | ||||
|  | ||||
|         // Note that both 'window' and 'viewport' may be NULL here. Viewport is generally null of destroyed popups which previously owned a viewport. | ||||
|         static void NodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, ImDrawList* draw_list, const char* label) | ||||
|         { | ||||
|             bool node_open = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, draw_list->CmdBuffer.Size); | ||||
| @@ -15388,7 +15388,7 @@ void ImGui::ShowMetricsWindow(bool* p_open) | ||||
|                     pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); | ||||
|                 bool pcmd_node_open = ImGui::TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); | ||||
|                 if (ImGui::IsItemHovered() && (show_drawcmd_mesh || show_drawcmd_aabb) && fg_draw_list) | ||||
|                     NodeDrawCmdShowMeshAndBoundingBox(window, draw_list, pcmd, elem_offset, show_drawcmd_mesh, show_drawcmd_aabb); | ||||
|                     NodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, elem_offset, show_drawcmd_mesh, show_drawcmd_aabb); | ||||
|                 if (!pcmd_node_open) | ||||
|                     continue; | ||||
|  | ||||
| @@ -15407,7 +15407,7 @@ void ImGui::ShowMetricsWindow(bool* p_open) | ||||
|                 ImFormatString(buf, IM_ARRAYSIZE(buf), "Mesh: ElemCount: %d, VtxOffset: +%d, IdxOffset: +%d, Area: ~%0.f px", pcmd->ElemCount, pcmd->VtxOffset, pcmd->IdxOffset, total_area); | ||||
|                 ImGui::Selectable(buf); | ||||
|                 if (ImGui::IsItemHovered() && fg_draw_list) | ||||
|                     NodeDrawCmdShowMeshAndBoundingBox(window, draw_list, pcmd, elem_offset, true, false); | ||||
|                     NodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, elem_offset, true, false); | ||||
|  | ||||
|                 // Display individual triangles/vertices. Hover on to get the corresponding triangle highlighted. | ||||
|                 ImGuiListClipper clipper(pcmd->ElemCount/3); // Manually coarse clip our print out of individual vertices to save CPU, only items that may be visible. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user