Added texture loading.
This commit is contained in:
@ -96,18 +96,24 @@ void chunkListShift(chunklist_t *list, int32_t x, int32_t y, int32_t z) {
|
||||
// Load the chunk if we need to. We also use this to calculate new absolutes
|
||||
if(
|
||||
(ax = lx + nx) != chunk->x ||
|
||||
(ay = ly + ny) != chunk->y ||
|
||||
(az = lz + nz) != chunk->z
|
||||
(ly + ny) != chunk->y ||
|
||||
(lz + nz) != chunk->z
|
||||
) {
|
||||
// Calculate those things that may have not been done within the if
|
||||
ay = ly + ny;
|
||||
az = lz + nz;
|
||||
|
||||
// Load new chunk.
|
||||
chunkUnload(chunk);
|
||||
chunkLoad(chunk, ax, ay, az);
|
||||
|
||||
// Update the absolute coordinates.
|
||||
chunk->x = ax;
|
||||
chunk->y = ay;
|
||||
chunk->z = az;
|
||||
}
|
||||
|
||||
//Now, based off those new local positions, calculate the new index.
|
||||
// Now, based off those new local positions, calculate the new index.
|
||||
ni = (
|
||||
nx +
|
||||
(ny * list->width) +
|
||||
@ -116,6 +122,11 @@ void chunkListShift(chunklist_t *list, int32_t x, int32_t y, int32_t z) {
|
||||
chunkList[ni] = chunk;
|
||||
}
|
||||
|
||||
// Update Absolutes.
|
||||
list->x = lx;
|
||||
list->y = ly;
|
||||
list->z = lz;
|
||||
|
||||
// Now copy that array over.
|
||||
memcpy(list->chunkList, chunkList, sizeof(chunk_t *) * list->count);
|
||||
free(chunkList);
|
||||
|
@ -9,8 +9,6 @@
|
||||
#include "chunk.h"
|
||||
#include "./../util/math.h"
|
||||
|
||||
#define CHUNK_INDEX_NULL = 0
|
||||
|
||||
typedef struct {
|
||||
/** Dimensions of the chunk list */
|
||||
int32_t width, height, depth;
|
||||
|
Reference in New Issue
Block a user