Sanity check collisions, and increase efficiency of growingpool

This commit is contained in:
MysterD 2023-06-25 17:54:01 -07:00
parent aeb8817f0d
commit 3456e10216
2 changed files with 17 additions and 7 deletions

View file

@ -764,6 +764,10 @@ void load_object_collision_model(void) {
LOG_ERROR("Object collisions had invalid vertex count");
return;
}
if (numVertices >= 4096) {
LOG_ERROR("Object collisions had too many vertices");
return;
}
static s32 sVertexDataCount = 0;
static s16* sVertexData = NULL;

View file

@ -135,13 +135,19 @@ void* growing_pool_alloc(struct GrowingPool *pool, u32 size) {
}
// search for space in nodes
struct GrowingPoolNode* node = pool->tail;
u32 depth = 0;
while (node) {
depth++;
s64 freeSpace = (s64)pool->nodeSize - (s64)node->usedSpace;
if (freeSpace > size) { break; }
node = node->prev;
struct GrowingPoolNode* node = NULL;
if (size < pool->nodeSize) {
node = pool->tail;
u32 depth = 0;
while (node && depth < 128) {
depth++;
s64 freeSpace = (s64)pool->nodeSize - (s64)node->usedSpace;
if (freeSpace > size) { break; }
node = node->prev;
}
if (depth >= 128) {
node = NULL;
}
}
// allocate new node