Stage BSP partitioning written. Changes to actors to keep track of their BSP node. Actors traverse the BSP as they move. Miscellanious error code def/usage updates. WIP

This commit is contained in:
2026-06-22 08:18:15 -04:00
parent f4728bf19d
commit 71de95822c
12 changed files with 713 additions and 61 deletions

View File

@@ -1,14 +1,35 @@
#ifndef _STAGE_H_
#define _STAGE_H_
#include <SDL3/SDL.h>
#include <akstdlib.h>
#define AKGL_STAGE_PARTITION_HORIZONTAL 0
#define AKGL_STAGE_PARTITION_VERTICAL 1
#define AKGL_STAGE_PARTITION_MAXDEPTH 4
// Stages are collections of lights and cameras in a 2D or 3D space wherein actors
// and backgrounds are placed and directed for action.
typedef struct akgl_Stage {
aksl_TreeNode bsp;
akerr_ErrorContext AKERR_NOIGNORE *(*partition)(struct akgl_Stage *self);
akerr_ErrorContext AKERR_NOIGNORE *(*partition_actor)(struct akgl_Stage *self, akgl_Actor *actor);
} akgl_Stage;
// A function to divide the stage into a binary space partition tree with lists of actors in each partition
akerr_ErrorContext AKERR_NOIGNORE akgl_stage_2d_bsp(akgl_Stage *self);
typedef struct akgl_BSPContext {
aksl_TreeNode *left;
aksl_TreeNode *right;
aksl_TreeNode *parent;
} akgl_BSPContext;
#endif _STAGE_H_
typedef struct akgl_BSPLeaf {
SDL_FRect extent;
aksl_ListNode *actors;
}
akerr_ErrorContext AKERR_NOIGNORE *akgl_stage_2d(akgl_Stage *self);
// A function to divide the stage into a binary space partition tree with lists of actors in each partition
akerr_ErrorContext AKERR_NOIGNORE *akgl_stage_2d_partition(akgl_Stage *self);
#endif // _STAGE_H_