transfered from codeberg
This commit is contained in:
45
source_code/chunk_module/chunk/_internal/private_chunk.c
Normal file
45
source_code/chunk_module/chunk/_internal/private_chunk.c
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "private_chunk.h"
|
||||
#include "chunk.h"
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include <stdatomic.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
void _initialize_chunk(struct chunk_struct* chunk, struct chunk_position_struct position_in_world)
|
||||
{
|
||||
memset(chunk, 0, sizeof(struct chunk_struct));
|
||||
|
||||
chunk->position = position_in_world;
|
||||
chunk->model = (Model){0};
|
||||
|
||||
chunk->bounds.min.x = (float)position_in_world.x;
|
||||
chunk->bounds.min.y = (float)position_in_world.y;
|
||||
chunk->bounds.min.z = (float)position_in_world.z;
|
||||
|
||||
chunk->bounds.max = (Vector3)
|
||||
{
|
||||
(float)position_in_world.x + chunk_size,
|
||||
(float)position_in_world.y + chunk_size,
|
||||
(float)position_in_world.z + chunk_size
|
||||
};
|
||||
|
||||
chunk->pending_mesh = NULL;
|
||||
atomic_init(&chunk->build_state, state_new);
|
||||
atomic_init(&chunk->marked_for_unload, false);
|
||||
atomic_store_explicit(&chunk->reference_counter, 1, memory_order_relaxed);
|
||||
}
|
||||
|
||||
void _free_chunk_data(struct chunk_struct* chunk)
|
||||
{
|
||||
if (chunk == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
free(chunk);
|
||||
}
|
||||
|
||||
10
source_code/chunk_module/chunk/_internal/private_chunk.h
Normal file
10
source_code/chunk_module/chunk/_internal/private_chunk.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef private_chunk_h
|
||||
#define private_chunk_h
|
||||
|
||||
struct chunk_position_struct;
|
||||
struct chunk_struct;
|
||||
|
||||
void _initialize_chunk(struct chunk_struct* chunk, struct chunk_position_struct world_position);
|
||||
void _free_chunk_data(struct chunk_struct* chunk);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user