more minor style tidyup

This commit is contained in:
UnknownShadow200 2021-06-11 22:02:48 +10:00
parent dc8381d76b
commit 18b09bcfad
7 changed files with 30 additions and 43 deletions

View file

@ -28,7 +28,6 @@ static int Builder_X, Builder_Y, Builder_Z;
static BlockID Builder_Block;
static int Builder_ChunkIndex;
static cc_bool Builder_FullBright;
static cc_bool Builder_Tinted;
static int Builder_ChunkEndX, Builder_ChunkEndZ;
static int Builder_Offsets[FACE_COUNT] = { -1,1, -EXTCHUNK_SIZE,EXTCHUNK_SIZE, -EXTCHUNK_SIZE_2,EXTCHUNK_SIZE_2 };
@ -468,9 +467,8 @@ static RNGState spriteRng;
static void Builder_DrawSprite(int x, int y, int z) {
struct Builder1DPart* part;
struct VertexTextured v;
PackedCol white = PACKEDCOL_WHITE;
cc_uint8 offsetType;
cc_bool bright;
TextureLoc loc;
float v1, v2;
int index;
@ -501,8 +499,9 @@ static void Builder_DrawSprite(int x, int y, int z) {
if (offsetType == 7) { y1 -= valY; y2 -= valY; }
}
part = &Builder_Parts[Atlas1D_Index(loc)];
v.Col = Builder_FullBright ? white : Lighting_Col_Sprite_Fast(x, y, z);
bright = Blocks.FullBright[Builder_Block];
part = &Builder_Parts[Atlas1D_Index(loc)];
v.Col = bright ? PACKEDCOL_WHITE : Lighting_Col_Sprite_Fast(x, y, z);
Block_Tint(v.Col, Builder_Block);
/* Draw Z axis */
@ -631,7 +630,6 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) {
int count_ZMax, count_YMin, count_YMax;
/* block state */
PackedCol white = PACKEDCOL_WHITE;
Vec3 min, max;
int baseOffset, lightFlags;
cc_bool fullBright;
@ -643,10 +641,7 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) {
int offset;
if (Blocks.Draw[Builder_Block] == DRAW_SPRITE) {
Builder_FullBright = Blocks.FullBright[Builder_Block];
Builder_Tinted = Blocks.Tinted[Builder_Block];
Builder_DrawSprite(x, y, z);
return;
Builder_DrawSprite(x, y, z); return;
}
count_XMin = Builder_Counts[index + FACE_XMIN];
@ -678,7 +673,7 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) {
offset = (lightFlags >> FACE_XMIN) & 1;
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];
col = fullBright ? white :
col = fullBright ? PACKEDCOL_WHITE :
x >= offset ? Lighting_Col_XSide_Fast(x - offset, y, z) : Env.SunXSide;
Drawer_XMin(count_XMin, col, loc, &part->fVertices[FACE_XMIN]);
}
@ -688,7 +683,7 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) {
offset = (lightFlags >> FACE_XMAX) & 1;
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];
col = fullBright ? white :
col = fullBright ? PACKEDCOL_WHITE :
x <= (World.MaxX - offset) ? Lighting_Col_XSide_Fast(x + offset, y, z) : Env.SunXSide;
Drawer_XMax(count_XMax, col, loc, &part->fVertices[FACE_XMAX]);
}
@ -698,7 +693,7 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) {
offset = (lightFlags >> FACE_ZMIN) & 1;
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];
col = fullBright ? white :
col = fullBright ? PACKEDCOL_WHITE :
z >= offset ? Lighting_Col_ZSide_Fast(x, y, z - offset) : Env.SunZSide;
Drawer_ZMin(count_ZMin, col, loc, &part->fVertices[FACE_ZMIN]);
}
@ -708,7 +703,7 @@ static void NormalBuilder_RenderBlock(int index, int x, int y, int z) {
offset = (lightFlags >> FACE_ZMAX) & 1;
part = &Builder_Parts[baseOffset + Atlas1D_Index(loc)];
col = fullBright ? white :
col = fullBright ? PACKEDCOL_WHITE :
z <= (World.MaxZ - offset) ? Lighting_Col_ZSide_Fast(x, y, z + offset) : Env.SunZSide;
Drawer_ZMax(count_ZMax, col, loc, &part->fVertices[FACE_ZMAX]);
}
@ -718,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 ? white : Lighting_Col_YMin_Fast(x, y - offset, z);
col = fullBright ? PACKEDCOL_WHITE : Lighting_Col_YMin_Fast(x, y - offset, z);
Drawer_YMin(count_YMin, col, loc, &part->fVertices[FACE_YMIN]);
}
@ -727,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 ? white : Lighting_Col_YMax_Fast(x, (y + 1) - offset, z);
col = fullBright ? PACKEDCOL_WHITE : Lighting_Col_YMax_Fast(x, (y + 1) - offset, z);
Drawer_YMax(count_YMax, col, loc, &part->fVertices[FACE_YMAX]);
}
}
@ -760,6 +755,7 @@ static int adv_initBitFlags, adv_lightFlags, adv_baseOffset;
static int* adv_bitFlags;
static float adv_x1, adv_y1, adv_z1, adv_x2, adv_y2, adv_z2;
static PackedCol adv_lerp[5], adv_lerpX[5], adv_lerpZ[5], adv_lerpY[5];
static cc_bool adv_tinted;
enum ADV_MASK {
/* z-1 cube points */
@ -950,7 +946,7 @@ static void Adv_DrawXMin(int count) {
PackedCol col1_1 = Builder_FullBright ? white : adv_lerpX[aY1_Z1], col0_1 = Builder_FullBright ? white : adv_lerpX[aY0_Z1];
struct VertexTextured* vertices, v;
if (Builder_Tinted) {
if (adv_tinted) {
tint = Blocks.FogCol[Builder_Block];
col0_0 = PackedCol_Tint(col0_0, tint); col1_0 = PackedCol_Tint(col1_0, tint);
col1_1 = PackedCol_Tint(col1_1, tint); col0_1 = PackedCol_Tint(col0_1, tint);
@ -992,7 +988,7 @@ static void Adv_DrawXMax(int count) {
PackedCol col1_1 = Builder_FullBright ? white : adv_lerpX[aY1_Z1], col0_1 = Builder_FullBright ? white : adv_lerpX[aY0_Z1];
struct VertexTextured* vertices, v;
if (Builder_Tinted) {
if (adv_tinted) {
tint = Blocks.FogCol[Builder_Block];
col0_0 = PackedCol_Tint(col0_0, tint); col1_0 = PackedCol_Tint(col1_0, tint);
col1_1 = PackedCol_Tint(col1_1, tint); col0_1 = PackedCol_Tint(col0_1, tint);
@ -1034,7 +1030,7 @@ static void Adv_DrawZMin(int count) {
PackedCol col1_1 = Builder_FullBright ? white : adv_lerpZ[aX1_Y1], col0_1 = Builder_FullBright ? white : adv_lerpZ[aX0_Y1];
struct VertexTextured* vertices, v;
if (Builder_Tinted) {
if (adv_tinted) {
tint = Blocks.FogCol[Builder_Block];
col0_0 = PackedCol_Tint(col0_0, tint); col1_0 = PackedCol_Tint(col1_0, tint);
col1_1 = PackedCol_Tint(col1_1, tint); col0_1 = PackedCol_Tint(col0_1, tint);
@ -1076,7 +1072,7 @@ static void Adv_DrawZMax(int count) {
PackedCol col0_0 = Builder_FullBright ? white : adv_lerpZ[aX0_Y0], col0_1 = Builder_FullBright ? white : adv_lerpZ[aX0_Y1];
struct VertexTextured* vertices, v;
if (Builder_Tinted) {
if (adv_tinted) {
tint = Blocks.FogCol[Builder_Block];
col0_0 = PackedCol_Tint(col0_0, tint); col1_0 = PackedCol_Tint(col1_0, tint);
col1_1 = PackedCol_Tint(col1_1, tint); col0_1 = PackedCol_Tint(col0_1, tint);
@ -1118,7 +1114,7 @@ static void Adv_DrawYMin(int count) {
PackedCol col1_0 = Builder_FullBright ? white : adv_lerpY[aX1_Z0], col0_0 = Builder_FullBright ? white : adv_lerpY[aX0_Z0];
struct VertexTextured* vertices, v;
if (Builder_Tinted) {
if (adv_tinted) {
tint = Blocks.FogCol[Builder_Block];
col0_0 = PackedCol_Tint(col0_0, tint); col1_0 = PackedCol_Tint(col1_0, tint);
col1_1 = PackedCol_Tint(col1_1, tint); col0_1 = PackedCol_Tint(col0_1, tint);
@ -1160,7 +1156,7 @@ static void Adv_DrawYMax(int count) {
PackedCol col1_1 = Builder_FullBright ? white : adv_lerp[aX1_Z1], col0_1 = Builder_FullBright ? white : adv_lerp[aX0_Z1];
struct VertexTextured* vertices, v;
if (Builder_Tinted) {
if (adv_tinted) {
tint = Blocks.FogCol[Builder_Block];
col0_0 = PackedCol_Tint(col0_0, tint); col1_0 = PackedCol_Tint(col1_0, tint);
col1_1 = PackedCol_Tint(col1_1, tint); col0_1 = PackedCol_Tint(col0_1, tint);
@ -1188,10 +1184,7 @@ static void Adv_RenderBlock(int index, int x, int y, int z) {
int count_ZMax, count_YMin, count_YMax;
if (Blocks.Draw[Builder_Block] == DRAW_SPRITE) {
Builder_FullBright = Blocks.FullBright[Builder_Block];
Builder_Tinted = Blocks.Tinted[Builder_Block];
Builder_DrawSprite(x, y, z);
return;
Builder_DrawSprite(x, y, z); return;
}
count_XMin = Builder_Counts[index + FACE_XMIN];
@ -1207,7 +1200,7 @@ static void Adv_RenderBlock(int index, int x, int y, int z) {
Builder_FullBright = Blocks.FullBright[Builder_Block];
adv_baseOffset = (Blocks.Draw[Builder_Block] == DRAW_TRANSLUCENT) * ATLAS1D_MAX_ATLASES;
adv_lightFlags = Blocks.LightOffset[Builder_Block];
Builder_Tinted = Blocks.Tinted[Builder_Block];
adv_tinted = Blocks.Tinted[Builder_Block];
min = Blocks.RenderMinBB[Builder_Block]; max = Blocks.RenderMaxBB[Builder_Block];
adv_x1 = x + min.X; adv_y1 = y + min.Y; adv_z1 = z + min.Z;

View file

@ -272,8 +272,6 @@ static void MakeNameTexture(struct Entity* e) {
static void DrawName(struct Entity* e) {
struct VertexTextured vertices[4];
PackedCol col = PACKEDCOL_WHITE;
struct Model* model;
struct Matrix mat;
Vec3 pos;
@ -298,7 +296,7 @@ static void DrawName(struct Entity* e) {
size.X *= scale * 0.2f; size.Y *= scale * 0.2f;
}
Particle_DoRender(&size, &pos, &e->NameTex.uv, col, vertices);
Particle_DoRender(&size, &pos, &e->NameTex.uv, PACKEDCOL_WHITE, vertices);
Gfx_SetVertexFormat(VERTEX_FORMAT_TEXTURED);
Gfx_UpdateDynamicVb_IndexedTris(Gfx_texVb, vertices, 4);
}

View file

@ -664,7 +664,7 @@ static void DrawBorderY(int x1, int z1, int x2, int z2, float y, PackedCol col,
static void UpdateMapSides(void) {
Rect2D rects[4], r;
BlockID block;
PackedCol col, white = PACKEDCOL_WHITE;
PackedCol col;
int y, y1, y2;
int i;
struct VertexTextured* data;
@ -690,7 +690,7 @@ static void UpdateMapSides(void) {
VERTEX_FORMAT_TEXTURED, sides_vertices);
sides_fullBright = Blocks.FullBright[block];
col = sides_fullBright ? white : Env.ShadowCol;
col = sides_fullBright ? PACKEDCOL_WHITE : Env.ShadowCol;
Block_Tint(col, block)
for (i = 0; i < 4; i++) {
@ -715,7 +715,7 @@ static void UpdateMapSides(void) {
static void UpdateMapEdges(void) {
Rect2D rects[4], r;
BlockID block;
PackedCol col, white = PACKEDCOL_WHITE;
PackedCol col;
float y;
int i;
struct VertexTextured* data;
@ -736,7 +736,7 @@ static void UpdateMapEdges(void) {
VERTEX_FORMAT_TEXTURED, edges_vertices);
edges_fullBright = Blocks.FullBright[block];
col = edges_fullBright ? white : Env.SunCol;
col = edges_fullBright ? PACKEDCOL_WHITE : Env.SunCol;
Block_Tint(col, block)
y = (float)Env.EdgeHeight;

View file

@ -298,9 +298,8 @@ static CC_NOINLINE int CalcMipmapsLevels(int width, int height) {
}
void Texture_Render(const struct Texture* tex) {
PackedCol white = PACKEDCOL_WHITE;
Gfx_BindTexture(tex->ID);
Gfx_Draw2DTexture(tex, white);
Gfx_Draw2DTexture(tex, PACKEDCOL_WHITE);
}
void Texture_RenderShaded(const struct Texture* tex, PackedCol shadeCol) {

View file

@ -322,15 +322,14 @@ void TextAtlas_Free(struct TextAtlas* atlas) { Gfx_DeleteTexture(&atlas->tex.ID)
void TextAtlas_Add(struct TextAtlas* atlas, int charI, struct VertexTextured** vertices) {
struct Texture part = atlas->tex;
int width = atlas->widths[charI];
PackedCol white = PACKEDCOL_WHITE;
int width = atlas->widths[charI];
part.X = atlas->curX; part.Width = width;
part.uv.U1 = atlas->offsets[charI] * atlas->uScale;
part.uv.U2 = part.uv.U1 + width * atlas->uScale;
atlas->curX += width;
Gfx_Make2DQuad(&part, white, vertices);
Gfx_Make2DQuad(&part, PACKEDCOL_WHITE, vertices);
}
void TextAtlas_AddInt(struct TextAtlas* atlas, int value, struct VertexTextured** vertices) {

View file

@ -105,7 +105,6 @@ static void HUDScreen_UpdateLine1(struct HUDScreen* s) {
static void HUDScreen_DrawPosition(struct HUDScreen* s) {
struct VertexTextured vertices[4 * 64];
struct VertexTextured* ptr = vertices;
PackedCol col = PACKEDCOL_WHITE;
struct TextAtlas* atlas = &s->posAtlas;
struct Texture tex;
@ -115,7 +114,7 @@ static void HUDScreen_DrawPosition(struct HUDScreen* s) {
/* Make "Position: " prefix */
tex = atlas->tex;
tex.X = 2; tex.Width = atlas->offset;
Gfx_Make2DQuad(&tex, col, &ptr);
Gfx_Make2DQuad(&tex, PACKEDCOL_WHITE, &ptr);
IVec3_Floor(&pos, &LocalPlayer_Instance.Base.Position);
atlas->curX = atlas->offset + 2;

View file

@ -392,7 +392,6 @@ void ScrollbarWidget_Create(struct ScrollbarWidget* w) {
#define HotbarWidget_TileX(w, idx) (int)(w->x + w->slotXOffset + w->slotWidth * (idx))
static void HotbarWidget_RenderHotbarOutline(struct HotbarWidget* w) {
PackedCol white = PACKEDCOL_WHITE;
GfxResourceID tex;
int x;
@ -403,7 +402,7 @@ static void HotbarWidget_RenderHotbarOutline(struct HotbarWidget* w) {
x = HotbarWidget_TileX(w, Inventory.SelectedIndex);
w->selTex.ID = tex;
w->selTex.X = (int)(x - w->selWidth / 2);
Gfx_Draw2DTexture(&w->selTex, white);
Gfx_Draw2DTexture(&w->selTex, PACKEDCOL_WHITE);
}
static void HotbarWidget_RenderHotbarBlocks(struct HotbarWidget* w) {