box3d/src/block_allocator.h
Erin Catto 7216822064
Bug fixes and minor features (#2)
- API to query compounds directly.
- Fix some uninitialized stuff (thanks MSAN).
- Fix for store impulses on overflow.
- AABB margin reduced for small shapes
- body contact recycling option
- angular threshold for contact recycling
- reduce AABB margin on smaller shapes
- fix for hull vs tri when axis aligned
- fully locked rotation uses zero inverse inertia
2026-05-12 15:24:20 -07:00

35 lines
805 B
C

// SPDX-FileCopyrightText: 2026 Erin Catto
// SPDX-License-Identifier: MIT
#pragma once
#include "container.h"
#include "box3d/base.h"
#define B3_BLOCK_EXPONENT 8
#define B3_BLOCK_SIZE ( 1 << B3_BLOCK_EXPONENT )
typedef struct b3Block
{
char* memory;
} b3Block;
b3DeclareArray( b3Block );
typedef struct b3BlockAllocator
{
b3ArrayC( b3Block ) blocks;
void* freeList;
int elementSize;
int nextIndex;
int allocationCount;
} b3BlockAllocator;
// Element must be large enough to hold a pointer
b3BlockAllocator b3CreateBlockAllocator( int elementSize, int initialCount );
void b3DestroyBlockAllocator( b3BlockAllocator* allocator );
// Elements are guaranteed contiguous.
void* b3AllocateElement( b3BlockAllocator* allocator );
void b3FreeElement( b3BlockAllocator* allocator, void* element );