mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Remove MapRenderer_ from most static functions
This commit is contained in:
parent
e0042c7646
commit
15ca271e98
@ -685,7 +685,7 @@ static void Blocks_Reset(void) {
|
|||||||
Block_RecalculateAllSpriteBB();
|
Block_RecalculateAllSpriteBB();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Blocks_AtlasChanged(void* obj) { Block_RecalculateAllSpriteBB(); }
|
static void OnAtlasChanged(void* obj) { Block_RecalculateAllSpriteBB(); }
|
||||||
static void Blocks_Init(void) {
|
static void Blocks_Init(void) {
|
||||||
int block;
|
int block;
|
||||||
for (block = BLOCK_AIR; block <= BLOCK_MAX_DEFINED; block++) {
|
for (block = BLOCK_AIR; block <= BLOCK_MAX_DEFINED; block++) {
|
||||||
@ -695,7 +695,7 @@ static void Blocks_Init(void) {
|
|||||||
|
|
||||||
AutoRotate_Enabled = true;
|
AutoRotate_Enabled = true;
|
||||||
Blocks_Reset();
|
Blocks_Reset();
|
||||||
Event_RegisterVoid(&TextureEvents.AtlasChanged, NULL, Blocks_AtlasChanged);
|
Event_RegisterVoid(&TextureEvents.AtlasChanged, NULL, OnAtlasChanged);
|
||||||
|
|
||||||
Blocks.CanPlace[BLOCK_AIR] = false; Blocks.CanDelete[BLOCK_AIR] = false;
|
Blocks.CanPlace[BLOCK_AIR] = false; Blocks.CanDelete[BLOCK_AIR] = false;
|
||||||
Blocks.CanPlace[BLOCK_LAVA] = false; Blocks.CanDelete[BLOCK_LAVA] = false;
|
Blocks.CanPlace[BLOCK_LAVA] = false; Blocks.CanDelete[BLOCK_LAVA] = false;
|
||||||
@ -706,7 +706,7 @@ static void Blocks_Init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void Blocks_Free(void) {
|
static void Blocks_Free(void) {
|
||||||
Event_UnregisterVoid(&TextureEvents.AtlasChanged, NULL, Blocks_AtlasChanged);
|
Event_UnregisterVoid(&TextureEvents.AtlasChanged, NULL, OnAtlasChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IGameComponent Blocks_Component = {
|
struct IGameComponent Blocks_Component = {
|
||||||
|
@ -123,7 +123,7 @@ if (drawMin && drawMax) { \
|
|||||||
Game_Vertices += part.Counts[maxFace]; \
|
Game_Vertices += part.Counts[maxFace]; \
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_RenderNormalBatch(int batch) {
|
static void RenderNormalBatch(int batch) {
|
||||||
int batchOffset = MapRenderer_ChunksCount * batch;
|
int batchOffset = MapRenderer_ChunksCount * batch;
|
||||||
struct ChunkInfo* info;
|
struct ChunkInfo* info;
|
||||||
struct ChunkPartInfo part;
|
struct ChunkPartInfo part;
|
||||||
@ -201,7 +201,7 @@ void MapRenderer_RenderNormal(double delta) {
|
|||||||
if (normPartsCount[batch] <= 0) continue;
|
if (normPartsCount[batch] <= 0) continue;
|
||||||
if (hasNormParts[batch] || checkNormParts[batch]) {
|
if (hasNormParts[batch] || checkNormParts[batch]) {
|
||||||
Gfx_BindTexture(Atlas1D.TexIds[batch]);
|
Gfx_BindTexture(Atlas1D.TexIds[batch]);
|
||||||
MapRenderer_RenderNormalBatch(batch);
|
RenderNormalBatch(batch);
|
||||||
checkNormParts[batch] = false;
|
checkNormParts[batch] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ if (drawMin && drawMax) { \
|
|||||||
Game_Vertices += part.Counts[maxFace]; \
|
Game_Vertices += part.Counts[maxFace]; \
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_RenderTranslucentBatch(int batch) {
|
static void RenderTranslucentBatch(int batch) {
|
||||||
int batchOffset = MapRenderer_ChunksCount * batch;
|
int batchOffset = MapRenderer_ChunksCount * batch;
|
||||||
struct ChunkInfo* info;
|
struct ChunkInfo* info;
|
||||||
struct ChunkPartInfo part;
|
struct ChunkPartInfo part;
|
||||||
@ -277,7 +277,7 @@ void MapRenderer_RenderTranslucent(double delta) {
|
|||||||
for (batch = 0; batch < MapRenderer_1DUsedCount; batch++) {
|
for (batch = 0; batch < MapRenderer_1DUsedCount; batch++) {
|
||||||
if (tranPartsCount[batch] <= 0) continue;
|
if (tranPartsCount[batch] <= 0) continue;
|
||||||
if (hasTranParts[batch] || checkTranParts[batch]) {
|
if (hasTranParts[batch] || checkTranParts[batch]) {
|
||||||
MapRenderer_RenderTranslucentBatch(batch);
|
RenderTranslucentBatch(batch);
|
||||||
checkTranParts[batch] = false;
|
checkTranParts[batch] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,7 +294,7 @@ void MapRenderer_RenderTranslucent(double delta) {
|
|||||||
if (tranPartsCount[batch] <= 0) continue;
|
if (tranPartsCount[batch] <= 0) continue;
|
||||||
if (!hasTranParts[batch]) continue;
|
if (!hasTranParts[batch]) continue;
|
||||||
Gfx_BindTexture(Atlas1D.TexIds[batch]);
|
Gfx_BindTexture(Atlas1D.TexIds[batch]);
|
||||||
MapRenderer_RenderTranslucentBatch(batch);
|
RenderTranslucentBatch(batch);
|
||||||
}
|
}
|
||||||
Gfx_DisableMipmaps();
|
Gfx_DisableMipmaps();
|
||||||
|
|
||||||
@ -313,14 +313,14 @@ void MapRenderer_RenderTranslucent(double delta) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*----------------------------------------------------Chunks mangagement---------------------------------------------------*
|
*----------------------------------------------------Chunks mangagement---------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static void MapRenderer_FreeParts(void) {
|
static void FreeParts(void) {
|
||||||
Mem_Free(partsBuffer_Raw);
|
Mem_Free(partsBuffer_Raw);
|
||||||
partsBuffer_Raw = NULL;
|
partsBuffer_Raw = NULL;
|
||||||
MapRenderer_PartsNormal = NULL;
|
MapRenderer_PartsNormal = NULL;
|
||||||
MapRenderer_PartsTranslucent = NULL;
|
MapRenderer_PartsTranslucent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_FreeChunks(void) {
|
static void FreeChunks(void) {
|
||||||
Mem_Free(mapChunks);
|
Mem_Free(mapChunks);
|
||||||
Mem_Free(sortedChunks);
|
Mem_Free(sortedChunks);
|
||||||
Mem_Free(renderChunks);
|
Mem_Free(renderChunks);
|
||||||
@ -332,7 +332,7 @@ static void MapRenderer_FreeChunks(void) {
|
|||||||
distances = NULL;
|
distances = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_AllocateParts(void) {
|
static void AllocateParts(void) {
|
||||||
cc_uint32 count = MapRenderer_ChunksCount * MapRenderer_1DUsedCount;
|
cc_uint32 count = MapRenderer_ChunksCount * MapRenderer_1DUsedCount;
|
||||||
partsBuffer_Raw = (struct ChunkPartInfo*)Mem_AllocCleared(count * 2, sizeof(struct ChunkPartInfo), "chunk parts");
|
partsBuffer_Raw = (struct ChunkPartInfo*)Mem_AllocCleared(count * 2, sizeof(struct ChunkPartInfo), "chunk parts");
|
||||||
|
|
||||||
@ -340,14 +340,14 @@ static void MapRenderer_AllocateParts(void) {
|
|||||||
MapRenderer_PartsTranslucent = partsBuffer_Raw + count;
|
MapRenderer_PartsTranslucent = partsBuffer_Raw + count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_AllocateChunks(void) {
|
static void AllocateChunks(void) {
|
||||||
mapChunks = (struct ChunkInfo*) Mem_Alloc(MapRenderer_ChunksCount, sizeof(struct ChunkInfo), "chunk info");
|
mapChunks = (struct ChunkInfo*) Mem_Alloc(MapRenderer_ChunksCount, sizeof(struct ChunkInfo), "chunk info");
|
||||||
sortedChunks = (struct ChunkInfo**)Mem_Alloc(MapRenderer_ChunksCount, sizeof(struct ChunkInfo*), "sorted chunk info");
|
sortedChunks = (struct ChunkInfo**)Mem_Alloc(MapRenderer_ChunksCount, sizeof(struct ChunkInfo*), "sorted chunk info");
|
||||||
renderChunks = (struct ChunkInfo**)Mem_Alloc(MapRenderer_ChunksCount, sizeof(struct ChunkInfo*), "render chunk info");
|
renderChunks = (struct ChunkInfo**)Mem_Alloc(MapRenderer_ChunksCount, sizeof(struct ChunkInfo*), "render chunk info");
|
||||||
distances = (cc_uint32*)Mem_Alloc(MapRenderer_ChunksCount, 4, "chunk distances");
|
distances = (cc_uint32*)Mem_Alloc(MapRenderer_ChunksCount, 4, "chunk distances");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_ResetPartFlags(void) {
|
static void ResetPartFlags(void) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < ATLAS1D_MAX_ATLASES; i++) {
|
for (i = 0; i < ATLAS1D_MAX_ATLASES; i++) {
|
||||||
checkNormParts[i] = true;
|
checkNormParts[i] = true;
|
||||||
@ -357,7 +357,7 @@ static void MapRenderer_ResetPartFlags(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_ResetPartCounts(void) {
|
static void ResetPartCounts(void) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < ATLAS1D_MAX_ATLASES; i++) {
|
for (i = 0; i < ATLAS1D_MAX_ATLASES; i++) {
|
||||||
normPartsCount[i] = 0;
|
normPartsCount[i] = 0;
|
||||||
@ -365,7 +365,7 @@ static void MapRenderer_ResetPartCounts(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_InitChunks(void) {
|
static void InitChunks(void) {
|
||||||
int x, y, z, index = 0;
|
int x, y, z, index = 0;
|
||||||
for (z = 0; z < World.Length; z += CHUNK_SIZE) {
|
for (z = 0; z < World.Length; z += CHUNK_SIZE) {
|
||||||
for (y = 0; y < World.Height; y += CHUNK_SIZE) {
|
for (y = 0; y < World.Height; y += CHUNK_SIZE) {
|
||||||
@ -380,7 +380,7 @@ static void MapRenderer_InitChunks(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_ResetChunks(void) {
|
static void ResetChunks(void) {
|
||||||
int x, y, z, index = 0;
|
int x, y, z, index = 0;
|
||||||
for (z = 0; z < World.Length; z += CHUNK_SIZE) {
|
for (z = 0; z < World.Length; z += CHUNK_SIZE) {
|
||||||
for (y = 0; y < World.Height; y += CHUNK_SIZE) {
|
for (y = 0; y < World.Height; y += CHUNK_SIZE) {
|
||||||
@ -392,14 +392,14 @@ static void MapRenderer_ResetChunks(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_DeleteChunks(void) {
|
static void DeleteChunks(void) {
|
||||||
int i;
|
int i;
|
||||||
if (!mapChunks) return;
|
if (!mapChunks) return;
|
||||||
|
|
||||||
for (i = 0; i < MapRenderer_ChunksCount; i++) {
|
for (i = 0; i < MapRenderer_ChunksCount; i++) {
|
||||||
MapRenderer_DeleteChunk(&mapChunks[i]);
|
MapRenderer_DeleteChunk(&mapChunks[i]);
|
||||||
}
|
}
|
||||||
MapRenderer_ResetPartCounts();
|
ResetPartCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapRenderer_Refresh(void) {
|
void MapRenderer_Refresh(void) {
|
||||||
@ -407,18 +407,18 @@ void MapRenderer_Refresh(void) {
|
|||||||
chunkPos = IVec3_MaxValue();
|
chunkPos = IVec3_MaxValue();
|
||||||
|
|
||||||
if (mapChunks && World.Blocks) {
|
if (mapChunks && World.Blocks) {
|
||||||
MapRenderer_DeleteChunks();
|
DeleteChunks();
|
||||||
MapRenderer_ResetChunks();
|
ResetChunks();
|
||||||
|
|
||||||
oldCount = MapRenderer_1DUsedCount;
|
oldCount = MapRenderer_1DUsedCount;
|
||||||
MapRenderer_1DUsedCount = MapRenderer_UsedAtlases();
|
MapRenderer_1DUsedCount = MapRenderer_UsedAtlases();
|
||||||
/* Need to reallocate parts array in this case */
|
/* Need to reallocate parts array in this case */
|
||||||
if (MapRenderer_1DUsedCount != oldCount) {
|
if (MapRenderer_1DUsedCount != oldCount) {
|
||||||
MapRenderer_FreeParts();
|
FreeParts();
|
||||||
MapRenderer_AllocateParts();
|
AllocateParts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MapRenderer_ResetPartCounts();
|
ResetPartCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapRenderer_RefreshBorders(int maxHeight) {
|
void MapRenderer_RefreshBorders(int maxHeight) {
|
||||||
@ -456,18 +456,18 @@ static int renderDistSquared;
|
|||||||
/* Chunks past this distance are automatically unloaded */
|
/* Chunks past this distance are automatically unloaded */
|
||||||
static int buildDistSquared;
|
static int buildDistSquared;
|
||||||
|
|
||||||
static int MapRenderer_AdjustDist(int dist) {
|
static int AdjustDist(int dist) {
|
||||||
if (dist < CHUNK_SIZE) dist = CHUNK_SIZE;
|
if (dist < CHUNK_SIZE) dist = CHUNK_SIZE;
|
||||||
dist = Utils_AdjViewDist(dist);
|
dist = Utils_AdjViewDist(dist);
|
||||||
return (dist + 24) * (dist + 24);
|
return (dist + 24) * (dist + 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_CalcViewDists(void) {
|
static void CalcViewDists(void) {
|
||||||
buildDistSquared = MapRenderer_AdjustDist(Game_UserViewDistance);
|
buildDistSquared = AdjustDist(Game_UserViewDistance);
|
||||||
renderDistSquared = MapRenderer_AdjustDist(Game_ViewDistance);
|
renderDistSquared = AdjustDist(Game_ViewDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MapRenderer_UpdateChunksAndVisibility(int* chunkUpdates) {
|
static int UpdateChunksAndVisibility(int* chunkUpdates) {
|
||||||
int renderDistSqr = renderDistSquared;
|
int renderDistSqr = renderDistSquared;
|
||||||
int buildDistSqr = buildDistSquared;
|
int buildDistSqr = buildDistSquared;
|
||||||
|
|
||||||
@ -500,7 +500,7 @@ static int MapRenderer_UpdateChunksAndVisibility(int* chunkUpdates) {
|
|||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MapRenderer_UpdateChunksStill(int* chunkUpdates) {
|
static int UpdateChunksStill(int* chunkUpdates) {
|
||||||
int renderDistSqr = renderDistSquared;
|
int renderDistSqr = renderDistSquared;
|
||||||
int buildDistSqr = buildDistSquared;
|
int buildDistSqr = buildDistSquared;
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ static int MapRenderer_UpdateChunksStill(int* chunkUpdates) {
|
|||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_UpdateChunks(double delta) {
|
static void UpdateChunks(double delta) {
|
||||||
struct LocalPlayer* p;
|
struct LocalPlayer* p;
|
||||||
cc_bool samePos;
|
cc_bool samePos;
|
||||||
int chunkUpdates = 0;
|
int chunkUpdates = 0;
|
||||||
@ -550,19 +550,17 @@ static void MapRenderer_UpdateChunks(double delta) {
|
|||||||
&& p->Base.Pitch == lastPitch && p->Base.Yaw == lastYaw;
|
&& p->Base.Pitch == lastPitch && p->Base.Yaw == lastYaw;
|
||||||
|
|
||||||
renderChunksCount = samePos ?
|
renderChunksCount = samePos ?
|
||||||
MapRenderer_UpdateChunksStill(&chunkUpdates) :
|
UpdateChunksStill(&chunkUpdates) :
|
||||||
MapRenderer_UpdateChunksAndVisibility(&chunkUpdates);
|
UpdateChunksAndVisibility(&chunkUpdates);
|
||||||
|
|
||||||
lastCamPos = Camera.CurrentPos;
|
lastCamPos = Camera.CurrentPos;
|
||||||
lastPitch = p->Base.Pitch;
|
lastPitch = p->Base.Pitch;
|
||||||
lastYaw = p->Base.Yaw;
|
lastYaw = p->Base.Yaw;
|
||||||
|
|
||||||
if (!samePos || chunkUpdates) {
|
if (!samePos || chunkUpdates) ResetPartFlags();
|
||||||
MapRenderer_ResetPartFlags();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_QuickSort(int left, int right) {
|
static void SortMapChunks(int left, int right) {
|
||||||
struct ChunkInfo** values = sortedChunks; struct ChunkInfo* value;
|
struct ChunkInfo** values = sortedChunks; struct ChunkInfo* value;
|
||||||
cc_uint32* keys = distances; cc_uint32 key;
|
cc_uint32* keys = distances; cc_uint32 key;
|
||||||
|
|
||||||
@ -577,7 +575,7 @@ static void MapRenderer_QuickSort(int left, int right) {
|
|||||||
QuickSort_Swap_KV_Maybe();
|
QuickSort_Swap_KV_Maybe();
|
||||||
}
|
}
|
||||||
/* recurse into the smaller subset */
|
/* recurse into the smaller subset */
|
||||||
QuickSort_Recurse(MapRenderer_QuickSort)
|
QuickSort_Recurse(SortMapChunks)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -616,15 +614,15 @@ static void MapRenderer_UpdateSortOrder(void) {
|
|||||||
info->DrawYMin = dy >= 0; info->DrawYMax = dy <= 0;
|
info->DrawYMin = dy >= 0; info->DrawYMax = dy <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapRenderer_QuickSort(0, MapRenderer_ChunksCount - 1);
|
SortMapChunks(0, MapRenderer_ChunksCount - 1);
|
||||||
MapRenderer_ResetPartFlags();
|
ResetPartFlags();
|
||||||
/*SimpleOcclusionCulling();*/
|
/*SimpleOcclusionCulling();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapRenderer_Update(double delta) {
|
void MapRenderer_Update(double delta) {
|
||||||
if (!mapChunks) return;
|
if (!mapChunks) return;
|
||||||
MapRenderer_UpdateSortOrder();
|
MapRenderer_UpdateSortOrder();
|
||||||
MapRenderer_UpdateChunks(delta);
|
UpdateChunks(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -710,7 +708,7 @@ void MapRenderer_BuildChunk(struct ChunkInfo* info, int* chunkUpdates) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_EnvVariableChanged(void* obj, int envVar) {
|
static void OnEnvVariableChanged(void* obj, int envVar) {
|
||||||
if (envVar == ENV_VAR_SUN_COL || envVar == ENV_VAR_SHADOW_COL) {
|
if (envVar == ENV_VAR_SUN_COL || envVar == ENV_VAR_SHADOW_COL) {
|
||||||
MapRenderer_Refresh();
|
MapRenderer_Refresh();
|
||||||
} else if (envVar == ENV_VAR_EDGE_HEIGHT || envVar == ENV_VAR_SIDES_OFFSET) {
|
} else if (envVar == ENV_VAR_EDGE_HEIGHT || envVar == ENV_VAR_SIDES_OFFSET) {
|
||||||
@ -723,7 +721,7 @@ static void MapRenderer_EnvVariableChanged(void* obj, int envVar) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_TerrainAtlasChanged(void* obj) {
|
static void OnTerrainAtlasChanged(void* obj) {
|
||||||
static int tilesPerAtlas;
|
static int tilesPerAtlas;
|
||||||
/* e.g. If old atlas was 256x256 and new is 256x256, don't need to refresh */
|
/* e.g. If old atlas was 256x256 and new is 256x256, don't need to refresh */
|
||||||
if (MapRenderer_1DUsedCount && tilesPerAtlas != Atlas1D.TilesPerAtlas) {
|
if (MapRenderer_1DUsedCount && tilesPerAtlas != Atlas1D.TilesPerAtlas) {
|
||||||
@ -732,30 +730,30 @@ static void MapRenderer_TerrainAtlasChanged(void* obj) {
|
|||||||
|
|
||||||
MapRenderer_1DUsedCount = MapRenderer_UsedAtlases();
|
MapRenderer_1DUsedCount = MapRenderer_UsedAtlases();
|
||||||
tilesPerAtlas = Atlas1D.TilesPerAtlas;
|
tilesPerAtlas = Atlas1D.TilesPerAtlas;
|
||||||
MapRenderer_ResetPartFlags();
|
ResetPartFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_BlockDefinitionChanged(void* obj) {
|
static void OnBlockDefinitionChanged(void* obj) {
|
||||||
MapRenderer_Refresh();
|
MapRenderer_Refresh();
|
||||||
MapRenderer_1DUsedCount = MapRenderer_UsedAtlases();
|
MapRenderer_1DUsedCount = MapRenderer_UsedAtlases();
|
||||||
MapRenderer_ResetPartFlags();
|
ResetPartFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_RecalcVisibility(void* obj) {
|
static void OnVisibilityChanged(void* obj) {
|
||||||
lastCamPos = Vec3_BigPos();
|
lastCamPos = Vec3_BigPos();
|
||||||
MapRenderer_CalcViewDists();
|
CalcViewDists();
|
||||||
}
|
}
|
||||||
static void MapRenderer_DeleteChunks_(void* obj) { MapRenderer_DeleteChunks(); }
|
static void MapRenderer_DeleteChunks_(void* obj) { DeleteChunks(); }
|
||||||
static void MapRenderer_Refresh_(void* obj) { MapRenderer_Refresh(); }
|
static void MapRenderer_Refresh_(void* obj) { MapRenderer_Refresh(); }
|
||||||
|
|
||||||
static void MapRenderer_OnNewMap(void) {
|
static void MapRenderer_OnNewMap(void) {
|
||||||
Game.ChunkUpdates = 0;
|
Game.ChunkUpdates = 0;
|
||||||
MapRenderer_DeleteChunks();
|
DeleteChunks();
|
||||||
MapRenderer_ResetPartCounts();
|
ResetPartCounts();
|
||||||
|
|
||||||
chunkPos = IVec3_MaxValue();
|
chunkPos = IVec3_MaxValue();
|
||||||
MapRenderer_FreeChunks();
|
FreeChunks();
|
||||||
MapRenderer_FreeParts();
|
FreeParts();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_OnNewMapLoaded(void) {
|
static void MapRenderer_OnNewMapLoaded(void) {
|
||||||
@ -768,23 +766,23 @@ static void MapRenderer_OnNewMapLoaded(void) {
|
|||||||
/* TODO: Only perform reallocation when map volume has changed */
|
/* TODO: Only perform reallocation when map volume has changed */
|
||||||
/*if (MapRenderer_ChunksCount != count) { */
|
/*if (MapRenderer_ChunksCount != count) { */
|
||||||
MapRenderer_ChunksCount = count;
|
MapRenderer_ChunksCount = count;
|
||||||
MapRenderer_FreeChunks();
|
FreeChunks();
|
||||||
MapRenderer_FreeParts();
|
FreeParts();
|
||||||
MapRenderer_AllocateChunks();
|
AllocateChunks();
|
||||||
MapRenderer_AllocateParts();
|
AllocateParts();
|
||||||
/*}*/
|
/*}*/
|
||||||
|
|
||||||
MapRenderer_InitChunks();
|
InitChunks();
|
||||||
lastCamPos = Vec3_BigPos();
|
lastCamPos = Vec3_BigPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_Init(void) {
|
static void MapRenderer_Init(void) {
|
||||||
Event_RegisterVoid(&TextureEvents.AtlasChanged, NULL, MapRenderer_TerrainAtlasChanged);
|
Event_RegisterVoid(&TextureEvents.AtlasChanged, NULL, OnTerrainAtlasChanged);
|
||||||
Event_RegisterInt(&WorldEvents.EnvVarChanged, NULL, MapRenderer_EnvVariableChanged);
|
Event_RegisterInt(&WorldEvents.EnvVarChanged, NULL, OnEnvVariableChanged);
|
||||||
Event_RegisterVoid(&BlockEvents.BlockDefChanged, NULL, MapRenderer_BlockDefinitionChanged);
|
Event_RegisterVoid(&BlockEvents.BlockDefChanged, NULL, OnBlockDefinitionChanged);
|
||||||
|
|
||||||
Event_RegisterVoid(&GfxEvents.ViewDistanceChanged, NULL, MapRenderer_RecalcVisibility);
|
Event_RegisterVoid(&GfxEvents.ViewDistanceChanged, NULL, OnVisibilityChanged);
|
||||||
Event_RegisterVoid(&GfxEvents.ProjectionChanged, NULL, MapRenderer_RecalcVisibility);
|
Event_RegisterVoid(&GfxEvents.ProjectionChanged, NULL, OnVisibilityChanged);
|
||||||
Event_RegisterVoid(&GfxEvents.ContextLost, NULL, MapRenderer_DeleteChunks_);
|
Event_RegisterVoid(&GfxEvents.ContextLost, NULL, MapRenderer_DeleteChunks_);
|
||||||
Event_RegisterVoid(&GfxEvents.ContextRecreated, NULL, MapRenderer_Refresh_);
|
Event_RegisterVoid(&GfxEvents.ContextRecreated, NULL, MapRenderer_Refresh_);
|
||||||
|
|
||||||
@ -792,16 +790,16 @@ static void MapRenderer_Init(void) {
|
|||||||
MapRenderer_1DUsedCount = 87; /* Atlas1D_UsedAtlasesCount(); */
|
MapRenderer_1DUsedCount = 87; /* Atlas1D_UsedAtlasesCount(); */
|
||||||
chunkPos = IVec3_MaxValue();
|
chunkPos = IVec3_MaxValue();
|
||||||
MapRenderer_MaxUpdates = Options_GetInt(OPT_MAX_CHUNK_UPDATES, 4, 1024, 30);
|
MapRenderer_MaxUpdates = Options_GetInt(OPT_MAX_CHUNK_UPDATES, 4, 1024, 30);
|
||||||
MapRenderer_CalcViewDists();
|
CalcViewDists();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MapRenderer_Free(void) {
|
static void MapRenderer_Free(void) {
|
||||||
Event_UnregisterVoid(&TextureEvents.AtlasChanged, NULL, MapRenderer_TerrainAtlasChanged);
|
Event_UnregisterVoid(&TextureEvents.AtlasChanged, NULL, OnTerrainAtlasChanged);
|
||||||
Event_UnregisterInt(&WorldEvents.EnvVarChanged, NULL, MapRenderer_EnvVariableChanged);
|
Event_UnregisterInt(&WorldEvents.EnvVarChanged, NULL, OnEnvVariableChanged);
|
||||||
Event_UnregisterVoid(&BlockEvents.BlockDefChanged, NULL, MapRenderer_BlockDefinitionChanged);
|
Event_UnregisterVoid(&BlockEvents.BlockDefChanged, NULL, OnBlockDefinitionChanged);
|
||||||
|
|
||||||
Event_UnregisterVoid(&GfxEvents.ViewDistanceChanged, NULL, MapRenderer_RecalcVisibility);
|
Event_UnregisterVoid(&GfxEvents.ViewDistanceChanged, NULL, OnVisibilityChanged);
|
||||||
Event_UnregisterVoid(&GfxEvents.ProjectionChanged, NULL, MapRenderer_RecalcVisibility);
|
Event_UnregisterVoid(&GfxEvents.ProjectionChanged, NULL, OnVisibilityChanged);
|
||||||
Event_UnregisterVoid(&GfxEvents.ContextLost, NULL, MapRenderer_DeleteChunks_);
|
Event_UnregisterVoid(&GfxEvents.ContextLost, NULL, MapRenderer_DeleteChunks_);
|
||||||
Event_UnregisterVoid(&GfxEvents.ContextRecreated, NULL, MapRenderer_Refresh_);
|
Event_UnregisterVoid(&GfxEvents.ContextRecreated, NULL, MapRenderer_Refresh_);
|
||||||
|
|
||||||
|
@ -137,8 +137,6 @@ CC_API cc_result Directory_Enum(const String* path, void* obj, Directory_EnumCal
|
|||||||
CC_API int File_Exists(const String* path);
|
CC_API int File_Exists(const String* path);
|
||||||
/* Sets the last time the file was modified, as number of milliseconds since 1/1/0001 */
|
/* Sets the last time the file was modified, as number of milliseconds since 1/1/0001 */
|
||||||
CC_API cc_result File_SetModifiedTime(const String* path, TimeMS ms);
|
CC_API cc_result File_SetModifiedTime(const String* path, TimeMS ms);
|
||||||
/* Marks a file as being executable. */
|
|
||||||
CC_API cc_result File_MarkExecutable(const String* path);
|
|
||||||
|
|
||||||
/* Attempts to create a new (or overwrite) file for writing. */
|
/* Attempts to create a new (or overwrite) file for writing. */
|
||||||
/* NOTE: If the file already exists, its contents are discarded. */
|
/* NOTE: If the file already exists, its contents are discarded. */
|
||||||
|
@ -33,8 +33,8 @@ static cc_result Ogg_NextPage(struct OggState* ctx) {
|
|||||||
cc_uint8 header[27];
|
cc_uint8 header[27];
|
||||||
struct Stream* source;
|
struct Stream* source;
|
||||||
cc_uint32 sig, size;
|
cc_uint32 sig, size;
|
||||||
int i, numSegments;
|
|
||||||
cc_result res;
|
cc_result res;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* OGG page format:
|
/* OGG page format:
|
||||||
* header[0] (4) page signature
|
* header[0] (4) page signature
|
||||||
|
Loading…
x
Reference in New Issue
Block a user