mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Make Rain_RemoveAt/Terrain_RemoveAt slightly faster
This commit is contained in:
parent
e933ec2298
commit
c1c3731385
@ -81,7 +81,7 @@ CC_NOINLINE static int MapRenderer_UsedAtlases(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-------------------------------------------------------Map rendering-----------------------------------------------------*
|
*-------------------------------------------------------Map rendering-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static void MapRenderer_CheckWeather(double delta) {
|
static void CheckWeather(double delta) {
|
||||||
IVec3 pos;
|
IVec3 pos;
|
||||||
BlockID block;
|
BlockID block;
|
||||||
cc_bool outside;
|
cc_bool outside;
|
||||||
@ -99,24 +99,24 @@ static void MapRenderer_CheckWeather(double delta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CC_BUILD_GL11
|
#ifdef CC_BUILD_GL11
|
||||||
#define MapRenderer_DrawFace(face, ign) Gfx_DrawIndexedVb_TrisT2fC4b(part.Vbs[face], 0);
|
#define DrawFace(face, ign) Gfx_DrawIndexedVb_TrisT2fC4b(part.Vbs[face], 0);
|
||||||
#define MapRenderer_DrawFaces(f1, f2, ign) MapRenderer_DrawFace(f1, ign); MapRenderer_DrawFace(f2, ign);
|
#define DrawFaces(f1, f2, ign) MapRenderer_DrawFace(f1, ign); MapRenderer_DrawFace(f2, ign);
|
||||||
#else
|
#else
|
||||||
#define MapRenderer_DrawFace(face, offset) Gfx_DrawIndexedVb_TrisT2fC4b(part.Counts[face], offset);
|
#define DrawFace(face, offset) Gfx_DrawIndexedVb_TrisT2fC4b(part.Counts[face], offset);
|
||||||
#define MapRenderer_DrawFaces(f1, f2, offset) Gfx_DrawIndexedVb_TrisT2fC4b(part.Counts[f1] + part.Counts[f2], offset);
|
#define DrawFaces(f1, f2, offset) Gfx_DrawIndexedVb_TrisT2fC4b(part.Counts[f1] + part.Counts[f2], offset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MapRenderer_DrawNormalFaces(minFace, maxFace) \
|
#define DrawNormalFaces(minFace, maxFace) \
|
||||||
if (drawMin && drawMax) { \
|
if (drawMin && drawMax) { \
|
||||||
Gfx_SetFaceCulling(true); \
|
Gfx_SetFaceCulling(true); \
|
||||||
MapRenderer_DrawFaces(minFace, maxFace, offset); \
|
DrawFaces(minFace, maxFace, offset); \
|
||||||
Gfx_SetFaceCulling(false); \
|
Gfx_SetFaceCulling(false); \
|
||||||
Game_Vertices += (part.Counts[minFace] + part.Counts[maxFace]); \
|
Game_Vertices += (part.Counts[minFace] + part.Counts[maxFace]); \
|
||||||
} else if (drawMin) { \
|
} else if (drawMin) { \
|
||||||
MapRenderer_DrawFace(minFace, offset); \
|
DrawFace(minFace, offset); \
|
||||||
Game_Vertices += part.Counts[minFace]; \
|
Game_Vertices += part.Counts[minFace]; \
|
||||||
} else if (drawMax) { \
|
} else if (drawMax) { \
|
||||||
MapRenderer_DrawFace(maxFace, offset + part.Counts[minFace]); \
|
DrawFace(maxFace, offset + part.Counts[minFace]); \
|
||||||
Game_Vertices += part.Counts[maxFace]; \
|
Game_Vertices += part.Counts[maxFace]; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,17 +142,17 @@ static void RenderNormalBatch(int batch) {
|
|||||||
offset = part.Offset + part.SpriteCount;
|
offset = part.Offset + part.SpriteCount;
|
||||||
drawMin = info->DrawXMin && part.Counts[FACE_XMIN];
|
drawMin = info->DrawXMin && part.Counts[FACE_XMIN];
|
||||||
drawMax = info->DrawXMax && part.Counts[FACE_XMAX];
|
drawMax = info->DrawXMax && part.Counts[FACE_XMAX];
|
||||||
MapRenderer_DrawNormalFaces(FACE_XMIN, FACE_XMAX);
|
DrawNormalFaces(FACE_XMIN, FACE_XMAX);
|
||||||
|
|
||||||
offset += part.Counts[FACE_XMIN] + part.Counts[FACE_XMAX];
|
offset += part.Counts[FACE_XMIN] + part.Counts[FACE_XMAX];
|
||||||
drawMin = info->DrawZMin && part.Counts[FACE_ZMIN];
|
drawMin = info->DrawZMin && part.Counts[FACE_ZMIN];
|
||||||
drawMax = info->DrawZMax && part.Counts[FACE_ZMAX];
|
drawMax = info->DrawZMax && part.Counts[FACE_ZMAX];
|
||||||
MapRenderer_DrawNormalFaces(FACE_ZMIN, FACE_ZMAX);
|
DrawNormalFaces(FACE_ZMIN, FACE_ZMAX);
|
||||||
|
|
||||||
offset += part.Counts[FACE_ZMIN] + part.Counts[FACE_ZMAX];
|
offset += part.Counts[FACE_ZMIN] + part.Counts[FACE_ZMAX];
|
||||||
drawMin = info->DrawYMin && part.Counts[FACE_YMIN];
|
drawMin = info->DrawYMin && part.Counts[FACE_YMIN];
|
||||||
drawMax = info->DrawYMax && part.Counts[FACE_YMAX];
|
drawMax = info->DrawYMax && part.Counts[FACE_YMAX];
|
||||||
MapRenderer_DrawNormalFaces(FACE_YMIN, FACE_YMAX);
|
DrawNormalFaces(FACE_YMIN, FACE_YMAX);
|
||||||
|
|
||||||
if (!part.SpriteCount) continue;
|
if (!part.SpriteCount) continue;
|
||||||
offset = part.Offset;
|
offset = part.Offset;
|
||||||
@ -204,7 +204,7 @@ void MapRenderer_RenderNormal(double delta) {
|
|||||||
}
|
}
|
||||||
Gfx_DisableMipmaps();
|
Gfx_DisableMipmaps();
|
||||||
|
|
||||||
MapRenderer_CheckWeather(delta);
|
CheckWeather(delta);
|
||||||
Gfx_SetAlphaTest(false);
|
Gfx_SetAlphaTest(false);
|
||||||
Gfx_SetTexturing(false);
|
Gfx_SetTexturing(false);
|
||||||
#if DEBUG_OCCLUSION
|
#if DEBUG_OCCLUSION
|
||||||
@ -212,15 +212,15 @@ void MapRenderer_RenderNormal(double delta) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MapRenderer_DrawTranslucentFaces(minFace, maxFace) \
|
#define DrawTranslucentFaces(minFace, maxFace) \
|
||||||
if (drawMin && drawMax) { \
|
if (drawMin && drawMax) { \
|
||||||
MapRenderer_DrawFaces(minFace, maxFace, offset); \
|
DrawFaces(minFace, maxFace, offset); \
|
||||||
Game_Vertices += (part.Counts[minFace] + part.Counts[maxFace]); \
|
Game_Vertices += (part.Counts[minFace] + part.Counts[maxFace]); \
|
||||||
} else if (drawMin) { \
|
} else if (drawMin) { \
|
||||||
MapRenderer_DrawFace(minFace, offset); \
|
DrawFace(minFace, offset); \
|
||||||
Game_Vertices += part.Counts[minFace]; \
|
Game_Vertices += part.Counts[minFace]; \
|
||||||
} else if (drawMax) { \
|
} else if (drawMax) { \
|
||||||
MapRenderer_DrawFace(maxFace, offset + part.Counts[minFace]); \
|
DrawFace(maxFace, offset + part.Counts[minFace]); \
|
||||||
Game_Vertices += part.Counts[maxFace]; \
|
Game_Vertices += part.Counts[maxFace]; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,17 +246,17 @@ static void RenderTranslucentBatch(int batch) {
|
|||||||
offset = part.Offset;
|
offset = part.Offset;
|
||||||
drawMin = (inTranslucent || info->DrawXMin) && part.Counts[FACE_XMIN];
|
drawMin = (inTranslucent || info->DrawXMin) && part.Counts[FACE_XMIN];
|
||||||
drawMax = (inTranslucent || info->DrawXMax) && part.Counts[FACE_XMAX];
|
drawMax = (inTranslucent || info->DrawXMax) && part.Counts[FACE_XMAX];
|
||||||
MapRenderer_DrawTranslucentFaces(FACE_XMIN, FACE_XMAX);
|
DrawTranslucentFaces(FACE_XMIN, FACE_XMAX);
|
||||||
|
|
||||||
offset += part.Counts[FACE_XMIN] + part.Counts[FACE_XMAX];
|
offset += part.Counts[FACE_XMIN] + part.Counts[FACE_XMAX];
|
||||||
drawMin = (inTranslucent || info->DrawZMin) && part.Counts[FACE_ZMIN];
|
drawMin = (inTranslucent || info->DrawZMin) && part.Counts[FACE_ZMIN];
|
||||||
drawMax = (inTranslucent || info->DrawZMax) && part.Counts[FACE_ZMAX];
|
drawMax = (inTranslucent || info->DrawZMax) && part.Counts[FACE_ZMAX];
|
||||||
MapRenderer_DrawTranslucentFaces(FACE_ZMIN, FACE_ZMAX);
|
DrawTranslucentFaces(FACE_ZMIN, FACE_ZMAX);
|
||||||
|
|
||||||
offset += part.Counts[FACE_ZMIN] + part.Counts[FACE_ZMAX];
|
offset += part.Counts[FACE_ZMIN] + part.Counts[FACE_ZMAX];
|
||||||
drawMin = (inTranslucent || info->DrawYMin) && part.Counts[FACE_YMIN];
|
drawMin = (inTranslucent || info->DrawYMin) && part.Counts[FACE_YMIN];
|
||||||
drawMax = (inTranslucent || info->DrawYMax) && part.Counts[FACE_YMAX];
|
drawMax = (inTranslucent || info->DrawYMax) && part.Counts[FACE_YMAX];
|
||||||
MapRenderer_DrawTranslucentFaces(FACE_YMIN, FACE_YMAX);
|
DrawTranslucentFaces(FACE_YMIN, FACE_YMAX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,14 +171,10 @@ static void Rain_Render(float t) {
|
|||||||
Gfx_DrawVb_IndexedTris(rain_count * 4);
|
Gfx_DrawVb_IndexedTris(rain_count * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Rain_RemoveAt(int index) {
|
static void Rain_RemoveAt(int i) {
|
||||||
struct Particle removed = rain_Particles[index];
|
for (; i < rain_count - 1; i++) {
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = index; i < rain_count - 1; i++) {
|
|
||||||
rain_Particles[i] = rain_Particles[i + 1];
|
rain_Particles[i] = rain_Particles[i + 1];
|
||||||
}
|
}
|
||||||
rain_Particles[rain_count - 1] = removed;
|
|
||||||
rain_count--;
|
rain_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,14 +269,10 @@ static void Terrain_Render(float t) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Terrain_RemoveAt(int index) {
|
static void Terrain_RemoveAt(int i) {
|
||||||
struct TerrainParticle removed = terrain_particles[index];
|
for (; i < terrain_count - 1; i++) {
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = index; i < terrain_count - 1; i++) {
|
|
||||||
terrain_particles[i] = terrain_particles[i + 1];
|
terrain_particles[i] = terrain_particles[i + 1];
|
||||||
}
|
}
|
||||||
terrain_particles[terrain_count - 1] = removed;
|
|
||||||
terrain_count--;
|
terrain_count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user