Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ImGuiNET.Unity/Renderer/ImGuiRendererMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Profiling;
using System.Collections.Generic;

namespace ImGuiNET.Unity
{
Expand Down Expand Up @@ -32,7 +33,7 @@ sealed class ImGuiRendererMesh : IImGuiRenderer
const MeshUpdateFlags NoMeshChecks = MeshUpdateFlags.DontNotifyMeshUsers | MeshUpdateFlags.DontRecalculateBounds
| MeshUpdateFlags.DontResetBoneBounds | MeshUpdateFlags.DontValidateIndices;
int _prevSubMeshCount = 1; // number of sub meshes used previously

List<SubMeshDescriptor> descriptors = new List<SubMeshDescriptor>();
static readonly ProfilerMarker s_updateMeshPerfMarker = new ProfilerMarker("DearImGui.RendererMesh.UpdateMesh");
static readonly ProfilerMarker s_createDrawComandsPerfMarker = new ProfilerMarker("DearImGui.RendererMesh.CreateDrawCommands");

Expand Down Expand Up @@ -96,7 +97,7 @@ unsafe void UpdateMesh(ImDrawDataPtr drawData, Vector2 fbSize)
// upload data into mesh
int vtxOf = 0;
int idxOf = 0;
int subOf = 0;

for (int n = 0, nMax = drawData.CmdListsCount; n < nMax; ++n)
{
ImDrawListPtr drawList = drawData.CmdListsRange[n];
Expand All @@ -112,7 +113,7 @@ unsafe void UpdateMesh(ImDrawDataPtr drawData, Vector2 fbSize)
// upload vertex/index data
_mesh.SetVertexBufferData(vtxArray, 0, vtxOf, vtxArray.Length, 0, NoMeshChecks);
_mesh.SetIndexBufferData (idxArray, 0, idxOf, idxArray.Length, NoMeshChecks);

descriptors.Clear();
// define subMeshes
for (int i = 0, iMax = drawList.CmdBuffer.Size; i < iMax; ++i)
{
Expand All @@ -124,11 +125,12 @@ unsafe void UpdateMesh(ImDrawDataPtr drawData, Vector2 fbSize)
indexCount = (int)cmd.ElemCount,
baseVertex = vtxOf + (int)cmd.VtxOffset,
};
_mesh.SetSubMesh(subOf++, descriptor, NoMeshChecks);
descriptors.Add(descriptor);
}
vtxOf += vtxArray.Length;
idxOf += idxArray.Length;
}
_mesh.SetSubMeshes(descriptors, NoMeshChecks);
_mesh.UploadMeshData(false);
}

Expand Down
3 changes: 3 additions & 0 deletions Plugins/System.Runtime.CompilerServices.Unsafe.dll
Git LFS file not shown
33 changes: 33 additions & 0 deletions Plugins/System.Runtime.CompilerServices.Unsafe.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.