Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SetNum EAllowShrinking (UE 5.5 compatibility) #38

Merged
merged 5 commits into from
Feb 2, 2025
Merged
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
4 changes: 4 additions & 0 deletions Source/ImGui/Private/ImGuiContextProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ void FImGuiContextProxy::UpdateDrawData(ImDrawData* DrawData)
{
if (DrawData && DrawData->CmdListsCount > 0)
{
#if ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING
DrawLists.SetNum(DrawData->CmdListsCount, false);
#else
DrawLists.SetNum(DrawData->CmdListsCount, EAllowShrinking::No);
#endif // ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING

for (int Index = 0; Index < DrawData->CmdListsCount; Index++)
{
Expand Down
8 changes: 8 additions & 0 deletions Source/ImGui/Private/ImGuiDrawData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ void FImGuiDrawList::CopyVertexData(TArray<FSlateVertex>& OutVertexBuffer, const
#endif // ENGINE_COMPATIBILITY_LEGACY_CLIPPING_API
{
// Reset and reserve space in destination buffer.
#if ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING
OutVertexBuffer.SetNumUninitialized(ImGuiVertexBuffer.Size, false);
#else
OutVertexBuffer.SetNumUninitialized(ImGuiVertexBuffer.Size, EAllowShrinking::No);
#endif // ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING

// Transform and copy vertex data.
for (int Idx = 0; Idx < ImGuiVertexBuffer.Size; Idx++)
Expand Down Expand Up @@ -44,7 +48,11 @@ void FImGuiDrawList::CopyVertexData(TArray<FSlateVertex>& OutVertexBuffer, const
void FImGuiDrawList::CopyIndexData(TArray<SlateIndex>& OutIndexBuffer, const int32 StartIndex, const int32 NumElements) const
{
// Reset buffer.
#if ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING
OutIndexBuffer.SetNumUninitialized(NumElements, false);
#else
OutIndexBuffer.SetNumUninitialized(NumElements, EAllowShrinking::No);
#endif // ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING

// Copy elements (slow copy because of different sizes of ImDrawIdx and SlateIndex and because SlateIndex can
// have different size on different platforms).
Expand Down
3 changes: 3 additions & 0 deletions Source/ImGui/Private/VersionCompatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@
#define ENGINE_COMPATIBILITY_LEGACY_KEY_AXIS_API BELOW_ENGINE_VERSION(4, 26)

#define ENGINE_COMPATIBILITY_LEGACY_VECTOR2F BELOW_ENGINE_VERSION(5, 0)

// Starting from version 5.4, bAllowShrinking is deprecated in favour of EAllowShrinking enum.
#define ENGINE_COMPATIBILITY_LEGACY_CONTAINER_SHRINKING BELOW_ENGINE_VERSION(5, 4)