transfered from codeberg
This commit is contained in:
41
source_code/chunk_module/chunk/chunk.c
Normal file
41
source_code/chunk_module/chunk/chunk.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "chunk.h"
|
||||
#include "_internal/private_chunk.h"
|
||||
|
||||
#include "chunk_mesh_builder.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
chunk_struct* initialize_chunk(struct chunk_position_struct position_in_world) {
|
||||
chunk_struct *chunk = malloc(sizeof(chunk_struct));
|
||||
|
||||
if ( chunk == NULL )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_initialize_chunk(chunk, position_in_world);
|
||||
return chunk;
|
||||
}
|
||||
|
||||
void destroy_chunk(struct chunk_struct* chunk)
|
||||
{
|
||||
destroy_chunk_mesh(chunk);
|
||||
_free_chunk_data(chunk);
|
||||
}
|
||||
|
||||
uint32_t index_chunk(int32_t x, int32_t y, int32_t z) {
|
||||
return (uint32_t)(x + y * chunk_size + z * chunk_size * chunk_size);
|
||||
}
|
||||
|
||||
chunk_position_struct offset_chunk_position(struct chunk_position_struct origin_to_offset,
|
||||
int32_t x_offset,
|
||||
int32_t y_offset,
|
||||
int32_t z_offset)
|
||||
{
|
||||
chunk_position_struct new_chunk_coordinate;
|
||||
new_chunk_coordinate.x = origin_to_offset.x + x_offset;
|
||||
new_chunk_coordinate.y = origin_to_offset.y + y_offset;
|
||||
new_chunk_coordinate.z = origin_to_offset.z + z_offset;
|
||||
|
||||
return new_chunk_coordinate;
|
||||
}
|
||||
Reference in New Issue
Block a user