diff --git a/Library/source/playrho/d2/AabbTreeWorld.cpp b/Library/source/playrho/d2/AabbTreeWorld.cpp index cbc880c41f..3226e13a8d 100644 --- a/Library/source/playrho/d2/AabbTreeWorld.cpp +++ b/Library/source/playrho/d2/AabbTreeWorld.cpp @@ -679,8 +679,9 @@ auto FindContacts(pmr::memory_resource& resource, -> std::vector> { std::vector> proxyKeys{&resource}; - static constexpr auto DefaultReserveSize = 512u; - proxyKeys.reserve(DefaultReserveSize); // upper bound is current size of tree + // Never need more than tree.GetLeafCount(), but in case big, use smaller default... + static constexpr auto DefaultReserveSize = 256u; + proxyKeys.reserve(std::min(tree.GetLeafCount(), DefaultReserveSize)); // Accumalate contact keys for pairs of nodes that are overlapping and aren't identical. // Note that if the dynamic tree node provides the body index, it's assumed to be faster diff --git a/UnitTests/AabbTreeWorld.cpp b/UnitTests/AabbTreeWorld.cpp index 526ccf41f2..c0a41507e2 100644 --- a/UnitTests/AabbTreeWorld.cpp +++ b/UnitTests/AabbTreeWorld.cpp @@ -260,12 +260,12 @@ TEST(AabbTreeWorld, GetResourceStatsWhenOn) Step(world, stepConf); stats = GetResourceStats(world); ASSERT_TRUE(stats.has_value()); - EXPECT_GT(stats->blocksAllocated, oldstats->blocksAllocated); - EXPECT_GT(stats->bytesAllocated, oldstats->bytesAllocated); - EXPECT_GT(stats->maxBlocksAllocated, oldstats->maxBlocksAllocated); - EXPECT_GT(stats->maxBytesAllocated, oldstats->maxBytesAllocated); - EXPECT_GT(stats->maxBytes, oldstats->maxBytes); - EXPECT_GT(stats->maxAlignment, oldstats->maxAlignment); + EXPECT_EQ(stats->blocksAllocated, oldstats->blocksAllocated); + EXPECT_EQ(stats->bytesAllocated, oldstats->bytesAllocated); + EXPECT_EQ(stats->maxBlocksAllocated, oldstats->maxBlocksAllocated); + EXPECT_EQ(stats->maxBytesAllocated, oldstats->maxBytesAllocated); + EXPECT_EQ(stats->maxBytes, oldstats->maxBytes); + EXPECT_EQ(stats->maxAlignment, oldstats->maxAlignment); } TEST(AabbTreeWorld, CreateDestroyEmptyStaticBody) diff --git a/UnitTests/World.cpp b/UnitTests/World.cpp index 1d8efc301a..092c4f3b9a 100644 --- a/UnitTests/World.cpp +++ b/UnitTests/World.cpp @@ -3749,10 +3749,10 @@ TEST(World, GetResourceStatsWhenOn) Step(world, stepConf); stats = GetResourceStats(world); ASSERT_TRUE(stats.has_value()); - EXPECT_GT(stats->blocksAllocated, oldstats->blocksAllocated); - EXPECT_GT(stats->bytesAllocated, oldstats->bytesAllocated); - EXPECT_GT(stats->maxBlocksAllocated, oldstats->maxBlocksAllocated); - EXPECT_GT(stats->maxBytesAllocated, oldstats->maxBytesAllocated); - EXPECT_GT(stats->maxBytes, oldstats->maxBytes); - EXPECT_GT(stats->maxAlignment, oldstats->maxAlignment); + EXPECT_EQ(stats->blocksAllocated, oldstats->blocksAllocated); + EXPECT_EQ(stats->bytesAllocated, oldstats->bytesAllocated); + EXPECT_EQ(stats->maxBlocksAllocated, oldstats->maxBlocksAllocated); + EXPECT_EQ(stats->maxBytesAllocated, oldstats->maxBytesAllocated); + EXPECT_EQ(stats->maxBytes, oldstats->maxBytes); + EXPECT_EQ(stats->maxAlignment, oldstats->maxAlignment); }