Add an epsilon to compression comparison to prevent degenerate loop
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Waiting to run
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Failing after 13s
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Failing after 12s

This commit is contained in:
Nic Barker 2025-01-10 21:54:13 +13:00
parent bc9ef8b02d
commit 44fb89c8b6
7 changed files with 2 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

4
clay.h
View File

@ -2088,13 +2088,13 @@ void Clay__CompressChildrenAlongAxis(bool xAxis, float totalSizeToDistribute, Cl
Clay__int32_tArray largestContainers = context->openClipElementStack; Clay__int32_tArray largestContainers = context->openClipElementStack;
largestContainers.length = 0; largestContainers.length = 0;
while (totalSizeToDistribute > 0) { while (totalSizeToDistribute > 0.1) {
float largestSize = 0; float largestSize = 0;
float targetSize = 0; float targetSize = 0;
for (int32_t i = 0; i < resizableContainerBuffer.length; ++i) { for (int32_t i = 0; i < resizableContainerBuffer.length; ++i) {
Clay_LayoutElement *childElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_Get(&resizableContainerBuffer, i)); Clay_LayoutElement *childElement = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_Get(&resizableContainerBuffer, i));
float childSize = xAxis ? childElement->dimensions.width : childElement->dimensions.height; float childSize = xAxis ? childElement->dimensions.width : childElement->dimensions.height;
if (childSize == largestSize) { if ((childSize - largestSize) < 0.1 && (childSize - largestSize) > -0.1) {
Clay__int32_tArray_Add(&largestContainers, Clay__int32_tArray_Get(&resizableContainerBuffer, i)); Clay__int32_tArray_Add(&largestContainers, Clay__int32_tArray_Get(&resizableContainerBuffer, i));
} else if (childSize > largestSize) { } else if (childSize > largestSize) {
targetSize = largestSize; targetSize = largestSize;