Refactor codebase. Add punctual light support

This commit is contained in:
2026-01-01 21:52:41 +09:00
parent acaaa2a86e
commit b41ea60c02
19 changed files with 246 additions and 99 deletions

View File

@@ -9,47 +9,49 @@
#define INVALID_HANDLE(T) (T){ .id = UINT32_MAX, .generation = 0 }
#define IS_VALID_HANDLE(h) ((h).id != UINT32_MAX)
#define HANDLE_DEF(name) \
typedef struct \
{ \
uint32_t id; \
uint32_t generation; \
} name##_handle_t;
#define HANDLE_DEF(name) \
typedef struct \
{ \
uint32_t id; \
uint32_t generation; \
} name##_handle_t;
#define ARRAY_DEF(T, name) \
typedef struct \
{ \
uint32_t length; \
T* buffer; \
} name##_array_t; \
static inline result_t name##_array_init(name##_array_t* array, uint32_t size) \
{ \
array->length = size; \
T* temp = (T*)malloc(sizeof(T) * size); \
if (temp == NULL) \
typedef struct \
{ \
return RESULT_OUT_OF_MEMORY; \
} \
array->buffer = temp; \
return RESULT_SUCCESS; \
} \
static inline void name##_array_free(name##_array_t* array) \
{ \
if (array->buffer != NULL) \
uint32_t length; \
T* buffer; \
} name##_array_t;
#define array_init(array, size) \
do \
{ \
free(array->buffer); \
array->buffer = NULL; \
array->length = 0; \
} \
} \
static inline T* name##_array_get(name##_array_t* array, uint32_t index) \
{ \
if (index >= array->length) \
array.length = size; \
array.buffer = malloc(sizeof(*array.buffer) * size); \
} while (0)
#define array_free(array) \
do \
{ \
return NULL; \
} \
return &array->buffer[index]; \
}
if (array.buffer != NULL) \
{ \
free(array.buffer); \
array.buffer = NULL; \
array.length = 0; \
} \
} while (0)
#define array_get(array, index) \
((index) >= (array).length ? NULL : &(array).buffer[index])
#define list_init(list, capacity) \
do \
{ \
capacity = capacity == 0 ? 1 : capacity; \
list.count = 0; \
list.capacity = capacity; \
list.buffer = (T*)malloc(sizeof(T) * capacity); \
} while (0)
#define LIST_DEF(T, name) \
typedef struct \