Move World_Contains checks to within Lighting_Col, rename Lighting_Col_XYZ to Lighting_Color_XYZ

This commit is contained in:
UnknownShadow200 2021-06-16 20:16:52 +10:00
parent c767738d04
commit 0b4dc84271
6 changed files with 37 additions and 36 deletions

View File

@ -501,7 +501,7 @@ static void Builder_DrawSprite(int x, int y, int z) {
bright = Blocks.FullBright[Builder_Block];
part = &Builder_Parts[Atlas1D_Index(loc)];
v.Col = bright ? PACKEDCOL_WHITE : Lighting_Col_Sprite_Fast(x, y, z);
v.Col = bright ? PACKEDCOL_WHITE : Lighting_Color_Sprite_Fast(x, y, z);
Block_Tint(v.Col, Builder_Block);
/* Draw Z axis */
@ -544,17 +544,17 @@ static PackedCol Normal_LightCol(int x, int y, int z, Face face, BlockID block)
switch (face) {
case FACE_XMIN:
return x < offset ? Env.SunXSide : Lighting_Col_XSide_Fast(x - offset, y, z);
return x < offset ? Env.SunXSide : Lighting_Color_XSide_Fast(x - offset, y, z);
case FACE_XMAX:
return x > (World.MaxX - offset) ? Env.SunXSide : Lighting_Col_XSide_Fast(x + offset, y, z);
return x > (World.MaxX - offset) ? Env.SunXSide : Lighting_Color_XSide_Fast(x + offset, y, z);
case FACE_ZMIN:
return z < offset ? Env.SunZSide : Lighting_Col_ZSide_Fast(x, y, z - offset);
return z < offset ? Env.SunZSide : Lighting_Color_ZSide_Fast(x, y, z - offset);
case FACE_ZMAX:
return z > (World.MaxZ - offset) ? Env.SunZSide : Lighting_Col_ZSide_Fast(x, y, z + offset);
return z > (World.MaxZ - offset) ? Env.SunZSide : Lighting_Color_ZSide_Fast(x, y, z + offset);
case FACE_YMIN:
return y <= 0 ? Env.SunYMin : Lighting_Col_YMin_Fast(x, y - offset, z);
return y <= 0 ? Env.SunYMin : Lighting_Color_YMin_Fast(x, y - offset, z);
case FACE_YMAX:
return y >= World.MaxY ? Env.SunCol : Lighting_Col_YMax_Fast(x, (y + 1) - offset, z);
return y >= World.MaxY ? Env.SunCol : Lighting_Color_YMax_Fast(x, (y + 1) - offset, z);
}
return 0; /* should never happen */
}
@ -674,7 +674,7 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) {
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];
col = fullBright ? PACKEDCOL_WHITE :
x >= offset ? Lighting_Col_XSide_Fast(x - offset, y, z) : Env.SunXSide;
x >= offset ? Lighting_Color_XSide_Fast(x - offset, y, z) : Env.SunXSide;
Drawer_XMin(count_XMin, col, loc, &part->fVertices[FACE_XMIN]);
}
@ -684,7 +684,7 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) {
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];
col = fullBright ? PACKEDCOL_WHITE :
x <= (World.MaxX - offset) ? Lighting_Col_XSide_Fast(x + offset, y, z) : Env.SunXSide;
x <= (World.MaxX - offset) ? Lighting_Color_XSide_Fast(x + offset, y, z) : Env.SunXSide;
Drawer_XMax(count_XMax, col, loc, &part->fVertices[FACE_XMAX]);
}
@ -694,7 +694,7 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) {
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];
col = fullBright ? PACKEDCOL_WHITE :
z >= offset ? Lighting_Col_ZSide_Fast(x, y, z - offset) : Env.SunZSide;
z >= offset ? Lighting_Color_ZSide_Fast(x, y, z - offset) : Env.SunZSide;
Drawer_ZMin(count_ZMin, col, loc, &part->fVertices[FACE_ZMIN]);
}
@ -704,7 +704,7 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) {
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];
col = fullBright ? PACKEDCOL_WHITE :
z <= (World.MaxZ - offset) ? Lighting_Col_ZSide_Fast(x, y, z + offset) : Env.SunZSide;
z <= (World.MaxZ - offset) ? Lighting_Color_ZSide_Fast(x, y, z + offset) : Env.SunZSide;
Drawer_ZMax(count_ZMax, col, loc, &part->fVertices[FACE_ZMAX]);
}
@ -713,7 +713,7 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) {
offset = (lightFlags >> FACE_YMIN) & 1;
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];
col = fullBright ? PACKEDCOL_WHITE : Lighting_Col_YMin_Fast(x, y - offset, z);
col = fullBright ? PACKEDCOL_WHITE : Lighting_Color_YMin_Fast(x, y - offset, z);
Drawer_YMin(count_YMin, col, loc, &part->fVertices[FACE_YMIN]);
}
@ -722,7 +722,7 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) {
offset = (lightFlags >> FACE_YMAX) & 1;
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];
col = fullBright ? PACKEDCOL_WHITE : Lighting_Col_YMax_Fast(x, (y + 1) - offset, z);
col = fullBright ? PACKEDCOL_WHITE : Lighting_Color_YMax_Fast(x, (y + 1) - offset, z);
Drawer_YMax(count_YMax, col, loc, &part->fVertices[FACE_YMAX]);
}
}

View File

@ -23,7 +23,8 @@ enum MsgType {
MSG_TYPE_CLIENTSTATUS_2 = 257 /* Tab list matching names */
};
extern cc_string Chat_Status[4], Chat_BottomRight[3], Chat_ClientStatus[2], Chat_Announcement, Chat_BigAnnouncement, Chat_SmallAnnouncement;
extern cc_string Chat_Status[4], Chat_BottomRight[3], Chat_ClientStatus[2];
extern cc_string Chat_Announcement, Chat_BigAnnouncement, Chat_SmallAnnouncement;
/* All chat messages received. */
extern struct StringsBuffer Chat_Log;
/* Time each chat message was received at. */

View File

@ -66,7 +66,7 @@ void LocationUpdate_MakePosAndOri(struct LocationUpdate* update, Vec3 pos, float
static PackedCol Entity_GetCol(struct Entity* e) {
Vec3 eyePos = Entity_GetEyePosition(e);
IVec3 pos; IVec3_Floor(&pos, &eyePos);
return World_Contains(pos.X, pos.Y, pos.Z) ? Lighting_Col(pos.X, pos.Y, pos.Z) : Env.SunCol;
return Lighting_Color(pos.X, pos.Y, pos.Z);
}
void Entity_Init(struct Entity* e) {

View File

@ -52,31 +52,33 @@ cc_bool Lighting_IsLit(int x, int y, int z) {
return y > Lighting_GetLightHeight(x, z);
}
PackedCol Lighting_Col(int x, int y, int z) {
PackedCol Lighting_Color(int x, int y, int z) {
if (!World_Contains(x, y, z)) return Env.SunCol;
return y > Lighting_GetLightHeight(x, z) ? Env.SunCol : Env.ShadowCol;
}
PackedCol Lighting_Col_XSide(int x, int y, int z) {
PackedCol Lighting_Color_XSide(int x, int y, int z) {
if (!World_Contains(x, y, z)) return Env.SunXSide;
return y > Lighting_GetLightHeight(x, z) ? Env.SunXSide : Env.ShadowXSide;
}
PackedCol Lighting_Col_Sprite_Fast(int x, int y, int z) {
PackedCol Lighting_Color_Sprite_Fast(int x, int y, int z) {
return y > Lighting_Heightmap[Lighting_Pack(x, z)] ? Env.SunCol : Env.ShadowCol;
}
PackedCol Lighting_Col_YMax_Fast(int x, int y, int z) {
PackedCol Lighting_Color_YMax_Fast(int x, int y, int z) {
return y > Lighting_Heightmap[Lighting_Pack(x, z)] ? Env.SunCol : Env.ShadowCol;
}
PackedCol Lighting_Col_YMin_Fast(int x, int y, int z) {
PackedCol Lighting_Color_YMin_Fast(int x, int y, int z) {
return y > Lighting_Heightmap[Lighting_Pack(x, z)] ? Env.SunYMin : Env.ShadowYMin;
}
PackedCol Lighting_Col_XSide_Fast(int x, int y, int z) {
PackedCol Lighting_Color_XSide_Fast(int x, int y, int z) {
return y > Lighting_Heightmap[Lighting_Pack(x, z)] ? Env.SunXSide : Env.ShadowXSide;
}
PackedCol Lighting_Col_ZSide_Fast(int x, int y, int z) {
PackedCol Lighting_Color_ZSide_Fast(int x, int y, int z) {
return y > Lighting_Heightmap[Lighting_Pack(x, z)] ? Env.SunZSide : Env.ShadowZSide;
}

View File

@ -25,16 +25,14 @@ void Lighting_Refresh(void);
/* Returns whether the block at the given coordinates is fully in sunlight. */
/* NOTE: Does ***NOT*** check that the coordinates are inside the map. */
cc_bool Lighting_IsLit(int x, int y, int z);
/* Returns the light colour of the block at the given coordinates. */
/* NOTE: Does ***NOT*** check that the coordinates are inside the map. */
PackedCol Lighting_Col(int x, int y, int z);
/* Returns the light colour of the block at the given coordinates. */
/* NOTE: Does ***NOT*** check that the coordinates are inside the map. */
PackedCol Lighting_Col_XSide(int x, int y, int z);
/* Returns the light colour at the given coordinates. */
PackedCol Lighting_Color(int x, int y, int z);
/* Returns the light colour at the given coordinates. */
PackedCol Lighting_Color_XSide(int x, int y, int z);
PackedCol Lighting_Col_Sprite_Fast(int x, int y, int z);
PackedCol Lighting_Col_YMax_Fast(int x, int y, int z);
PackedCol Lighting_Col_YMin_Fast(int x, int y, int z);
PackedCol Lighting_Col_XSide_Fast(int x, int y, int z);
PackedCol Lighting_Col_ZSide_Fast(int x, int y, int z);
PackedCol Lighting_Color_Sprite_Fast(int x, int y, int z);
PackedCol Lighting_Color_YMax_Fast(int x, int y, int z);
PackedCol Lighting_Color_YMin_Fast(int x, int y, int z);
PackedCol Lighting_Color_XSide_Fast(int x, int y, int z);
PackedCol Lighting_Color_ZSide_Fast(int x, int y, int z);
#endif

View File

@ -150,7 +150,7 @@ static void RainParticle_Render(struct Particle* p, float t, struct VertexTextur
size.X = p->size * 0.015625f; size.Y = size.X;
x = Math_Floor(pos.X); y = Math_Floor(pos.Y); z = Math_Floor(pos.Z);
col = World_Contains(x, y, z) ? Lighting_Col(x, y, z) : Env.SunCol;
col = Lighting_Color(x, y, z);
Particle_DoRender(&size, &pos, &rain_rec, col, vertices);
}
@ -223,7 +223,7 @@ static void TerrainParticle_Render(struct TerrainParticle* p, float t, struct Ve
if (!Blocks.FullBright[p->block]) {
x = Math_Floor(pos.X); y = Math_Floor(pos.Y); z = Math_Floor(pos.Z);
col = World_Contains(x, y, z) ? Lighting_Col_XSide(x, y, z) : Env.SunXSide;
col = Lighting_Color_XSide(x, y, z);
}
Block_Tint(col, p->block);
@ -349,7 +349,7 @@ static void CustomParticle_Render(struct CustomParticle* p, float t, struct Vert
size.X = p->base.size; size.Y = size.X;
x = Math_Floor(pos.X); y = Math_Floor(pos.Y); z = Math_Floor(pos.Z);
col = e->fullBright ? PACKEDCOL_WHITE : (World_Contains(x, y, z) ? Lighting_Col(x, y, z) : Env.SunCol);
col = e->fullBright ? PACKEDCOL_WHITE : Lighting_Color(x, y, z);
col = PackedCol_Tint(col, e->tintCol);
Particle_DoRender(&size, &pos, &rec, col, vertices);