Add page support to object pool

This commit is contained in:
2023-12-13 09:31:08 +01:00
parent 72b32b1a26
commit a2c19cf65d
5 changed files with 129 additions and 48 deletions

View File

@@ -79,7 +79,7 @@ bool init(void *userData) {
// init pools
game->pools.pathData = bzObjectPoolCreate(&(BzObjectPoolDesc) {
.objectSize=sizeof(PathData),
.numObjects=512
.objectsPerPage=512
});
@@ -241,7 +241,7 @@ void imguiRender(float dt, void *userData) {
createWorker((Position) {1100, 400}, (Size) {10, 10}, game->entityGrid,
&game->map.tilesets[2], 1322);
}
igText("Num paths from pool available: %llu", bzObjectPoolCalcNumFree(game->pools.pathData));
igText("Num paths from pool available: %llu", bzObjectPoolGetNumFree(game->pools.pathData));
const char *inputState = "NONE";
switch (input->state) {
case INPUT_NONE:

View File

@@ -107,7 +107,7 @@ bool initTreesLayer(BzTileMap *map, BzTileLayer *layer) {
f32 posX = layer->offsetX + x * sizeX;
f32 posY = layer->offsetY + y * sizeY;
ecs_entity_t e = ecs_new_id(ECS);
//bzSpatialGridInsert(game->entityGrid, &e, posX, posY, sizeX, sizeY);;
bzSpatialGridInsert(game->entityGrid, &e, posX, posY, sizeX, sizeY);
posX += sizeX * 0.5f;
posY += sizeY * 0.5f;
ecs_add(ECS, e, TextureTerrain);