46 lines
1.8 KiB
C
46 lines
1.8 KiB
C
#ifndef _STAGE_H_
|
|
#define _STAGE_H_
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <akstdlib.h>
|
|
|
|
#include <akgl/actor.h>
|
|
|
|
#define AKGL_STAGE_PARTITION_HORIZONTAL 0
|
|
#define AKGL_STAGE_PARTITION_VERTICAL 1
|
|
#define AKGL_STAGE_PARTITION_MAXDEPTH 4
|
|
|
|
typedef struct akgl_BSPContext {
|
|
aksl_TreeNode *left;
|
|
aksl_TreeNode *right;
|
|
aksl_TreeNode *parent;
|
|
} akgl_BSPContext;
|
|
|
|
typedef struct akgl_BSPLeaf {
|
|
SDL_FRect extent;
|
|
aksl_ListNode *actors;
|
|
} akgl_BSPLeaf;
|
|
|
|
// 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;
|
|
akgl_BSPLeaf _rootleaf;
|
|
akerr_ErrorContext AKERR_NOIGNORE *(*partition)(struct akgl_Stage *self);
|
|
akerr_ErrorContext AKERR_NOIGNORE *(*partition_actor)(struct akgl_Stage *self, akgl_Actor *actor);
|
|
} akgl_Stage;
|
|
|
|
|
|
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);
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_stage_2d_partition_switchdirection(uint8_t direction, uint8_t *dest);
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_stage_2d_bsp_actoriter(aksl_ListNode *node, void *data);
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_stage_2d_bsp(aksl_TreeNode *root, aksl_ListNode *actors, SDL_FRect extents, uint8_t direction, uint8_t depth, uint8_t maxdepth);
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_stage_2d_bspfree(akgl_Stage *self);
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_stage_2d_partition(akgl_Stage *self);
|
|
akerr_ErrorContext AKERR_NOIGNORE *akgl_stage_2d_bsp_move(akgl_Stage *self, akgl_Actor *actor);
|
|
|
|
#endif // _STAGE_H_
|