From 35beb67d6acd93b9d578b28fb8400e2a5385f1a8 Mon Sep 17 00:00:00 2001 From: Goodlyay Date: Tue, 7 May 2024 00:41:31 -0700 Subject: [PATCH] Buggy but compiles sans Windows_WiiU.cpp change --- src/Builder.c | 26 +++++++++++++------------- src/Lighting.c | 41 +++++++++++++++++++++++++---------------- src/Lighting.h | 11 +++++++---- src/Menus.c | 5 ++--- 4 files changed, 47 insertions(+), 36 deletions(-) diff --git a/src/Builder.c b/src/Builder.c index a6b1b0d19..62e23f29d 100644 --- a/src/Builder.c +++ b/src/Builder.c @@ -566,7 +566,7 @@ static PackedCol Normal_LightColor(int x, int y, int z, Face face, BlockID block case FACE_YMIN: return Lighting.Color_YMin_Fast(x, y - offset, z); case FACE_YMAX: - return Lighting.Color_Fast(x, y + offset, z); + return Lighting.Color_YMax_Fast(x, y + offset, z); } return 0; /* should never happen */ } @@ -1337,13 +1337,13 @@ static void Modern_DrawXMin(int count, int x, int y, int z) { col1_1 = PackedCol_Tint(col1_1, tint); col0_1 = PackedCol_Tint(col0_1, tint); } - vertices = part->fVertices[FACE_XMIN]; + vertices = part->faces.vertices[FACE_XMIN]; v.x = adv_x1; v.y = adv_y2; v.z = adv_z2 + (count - 1); v.U = u2; v.V = v1; v.Col = col1_1; *vertices++ = v; v.z = adv_z1; v.U = u1; v.Col = col1_0; *vertices++ = v; v.y = adv_y1; v.V = v2; v.Col = col0_0; *vertices++ = v; v.z = adv_z2 + (count - 1); v.U = u2; v.Col = col0_1; *vertices++ = v; - part->fVertices[FACE_XMIN] = vertices; + part->faces.vertices[FACE_XMIN] = vertices; } static void Modern_DrawXMax(int count, int x, int y, int z) { @@ -1370,13 +1370,13 @@ static void Modern_DrawXMax(int count, int x, int y, int z) { col1_1 = PackedCol_Tint(col1_1, tint); col0_1 = PackedCol_Tint(col0_1, tint); } - vertices = part->fVertices[FACE_XMAX]; + vertices = part->faces.vertices[FACE_XMAX]; v.x = adv_x2; v.y = adv_y2; v.z = adv_z2 + (count - 1); v.U = u2; v.V = v1; v.Col = col1_1; *vertices++ = v; v.y = adv_y1; v.V = v2; v.Col = col0_1; *vertices++ = v; v.z = adv_z1; v.U = u1; v.Col = col0_0; *vertices++ = v; v.y = adv_y2; v.V = v1; v.Col = col1_0; *vertices++ = v; - part->fVertices[FACE_XMAX] = vertices; + part->faces.vertices[FACE_XMAX] = vertices; } static PackedCol Modern_GetColorZ(PackedCol orig, int x, int y, int z, int oX, int oY) { @@ -1416,13 +1416,13 @@ static void Modern_DrawZMin(int count, int x, int y, int z) { col1_1 = PackedCol_Tint(col1_1, tint); col0_1 = PackedCol_Tint(col0_1, tint); } - vertices = part->fVertices[FACE_ZMIN]; + vertices = part->faces.vertices[FACE_ZMIN]; v.z = adv_z1; v.x = adv_x1; v.y = adv_y1; v.U = u1; v.V = v2; v.Col = col0_0; *vertices++ = v; v.y = adv_y2; v.V = v1; v.Col = col0_1; *vertices++ = v; v.x = adv_x2 + (count - 1); v.U = u2; v.Col = col1_1; *vertices++ = v; v.y = adv_y1; v.V = v2; v.Col = col1_0; *vertices++ = v; - part->fVertices[FACE_ZMIN] = vertices; + part->faces.vertices[FACE_ZMIN] = vertices; } static void Modern_DrawZMax(int count, int x, int y, int z) { @@ -1449,13 +1449,13 @@ static void Modern_DrawZMax(int count, int x, int y, int z) { col1_1 = PackedCol_Tint(col1_1, tint); col0_1 = PackedCol_Tint(col0_1, tint); } - vertices = part->fVertices[FACE_ZMAX]; + vertices = part->faces.vertices[FACE_ZMAX]; v.z = adv_z2; v.x = adv_x2 + (count - 1); v.y = adv_y2; v.U = u2; v.V = v1; v.Col = col1_1; *vertices++ = v; v.x = adv_x1; v.U = u1; v.Col = col0_1; *vertices++ = v; v.y = adv_y1; v.V = v2; v.Col = col0_0; *vertices++ = v; v.x = adv_x2 + (count - 1); v.U = u2; v.Col = col1_0; *vertices++ = v; - part->fVertices[FACE_ZMAX] = vertices; + part->faces.vertices[FACE_ZMAX] = vertices; } static PackedCol Modern_GetColorYMin(PackedCol orig, int x, int y, int z, int oX, int oZ) { @@ -1495,13 +1495,13 @@ static void Modern_DrawYMin(int count, int x, int y, int z) { col1_1 = PackedCol_Tint(col1_1, tint); col0_1 = PackedCol_Tint(col0_1, tint); } - vertices = part->fVertices[FACE_YMIN]; + vertices = part->faces.vertices[FACE_YMIN]; v.y = adv_y1; v.x = adv_x1; v.z = adv_z2; v.U = u1; v.V = v2; v.Col = col0_1; *vertices++ = v; v.z = adv_z1; v.V = v1; v.Col = col0_0; *vertices++ = v; v.x = adv_x2 + (count - 1); v.U = u2; v.Col = col1_0; *vertices++ = v; v.z = adv_z2; v.V = v2; v.Col = col1_1; *vertices++ = v; - part->fVertices[FACE_YMIN] = vertices; + part->faces.vertices[FACE_YMIN] = vertices; } static PackedCol Modern_GetColorYMax(PackedCol orig, int x, int y, int z, int oX, int oZ) { @@ -1542,13 +1542,13 @@ static void Modern_DrawYMax(int count, int x, int y, int z) { col1_1 = PackedCol_Tint(col1_1, tint); col0_1 = PackedCol_Tint(col0_1, tint); } - vertices = part->fVertices[FACE_YMAX]; + vertices = part->faces.vertices[FACE_YMAX]; v.y = adv_y2; v.x = adv_x1; v.z = adv_z1; v.U = u1; v.V = v1; v.Col = col0_0; *vertices++ = v; v.z = adv_z2; v.V = v2; v.Col = col0_1; *vertices++ = v; v.x = adv_x2 + (count - 1); v.U = u2; v.Col = col1_1; *vertices++ = v; v.z = adv_z1; v.V = v1; v.Col = col1_0; *vertices++ = v; - part->fVertices[FACE_YMAX] = vertices; + part->faces.vertices[FACE_YMAX] = vertices; } static void Modern_RenderBlock(int index, int x, int y, int z) { diff --git a/src/Lighting.c b/src/Lighting.c index 5589061fe..6efb9e06f 100644 --- a/src/Lighting.c +++ b/src/Lighting.c @@ -214,7 +214,11 @@ static PackedCol ClassicLighting_Color_XSide(int x, int y, int z) { return y > Heightmap_GetLightHeight(x, z) ? Env.SunXSide : Env.ShadowXSide; } -static PackedCol ClassicLighting_Color_Fast(int x, int y, int z) { +static PackedCol ClassicLighting_Color_Sprite_Fast(int x, int y, int z) { + return y > heightmap[Heightmap_Pack(x, z)] ? Env.SunCol : Env.ShadowCol; +} + +static PackedCol ClassicLighting_Color_YMax_Fast(int x, int y, int z) { return y > heightmap[Heightmap_Pack(x, z)] ? Env.SunCol : Env.ShadowCol; } @@ -378,16 +382,17 @@ static void ClassicLighting_OnBlockChanged(int x, int y, int z, BlockID oldBlock static void ClassicLighting_SetActive(void) { Lighting.OnBlockChanged = ClassicLighting_OnBlockChanged; - Lighting.Refresh = Heightmap_Reset;; + Lighting.Refresh = Heightmap_Reset; Lighting.IsLit = ClassicLighting_IsLit; Lighting.Color = ClassicLighting_Color; Lighting.Color_XSide = ClassicLighting_Color_XSide; - Lighting.IsLit_Fast = ClassicLighting_IsLit_Fast; - Lighting.Color_Fast = ClassicLighting_Color_Fast; - Lighting.Color_YMin_Fast = ClassicLighting_Color_YMin_Fast; - Lighting.Color_XSide_Fast = ClassicLighting_Color_XSide_Fast; - Lighting.Color_ZSide_Fast = ClassicLighting_Color_ZSide_Fast; + Lighting.IsLit_Fast = ClassicLighting_IsLit_Fast; + Lighting.Color_Sprite_Fast = ClassicLighting_Color_Sprite_Fast; + Lighting.Color_YMax_Fast = ClassicLighting_Color_YMax_Fast; + Lighting.Color_YMin_Fast = ClassicLighting_Color_YMin_Fast; + Lighting.Color_XSide_Fast = ClassicLighting_Color_XSide_Fast; + Lighting.Color_ZSide_Fast = ClassicLighting_Color_ZSide_Fast; Lighting.FreeState = Heightmap_Free; Lighting.AllocState = Heightmap_Allocate; @@ -929,15 +934,18 @@ static PackedCol ModernLighting_Color_Core(int x, int y, int z, PackedCol* palet static PackedCol ModernLighting_Color(int x, int y, int z) { return ModernLighting_Color_Core(x, y, z, modernLighting_palette, Env.SunCol); } +static PackedCol ModernLighting_Color_YMaxSide(int x, int y, int z) { + return ModernLighting_Color_Core(x, y, z, modernLighting_palette, Env.SunCol); +} +static PackedCol ModernLighting_Color_YMinSide(int x, int y, int z) { + return ModernLighting_Color_Core(x, y, z, modernLighting_paletteY, Env.SunYMin); +} static PackedCol ModernLighting_Color_XSide(int x, int y, int z) { return ModernLighting_Color_Core(x, y, z, modernLighting_paletteX, Env.SunXSide); } static PackedCol ModernLighting_Color_ZSide(int x, int y, int z) { return ModernLighting_Color_Core(x, y, z, modernLighting_paletteZ, Env.SunZSide); } -static PackedCol ModernLighting_Color_YMinSide(int x, int y, int z) { - return ModernLighting_Color_Core(x, y, z, modernLighting_paletteY, Env.SunYMin); -} static void ModernLighting_LightHint(int startX, int startY, int startZ) { int cx, cy, cz, curX, curY, curZ; @@ -958,13 +966,14 @@ static void ModernLighting_LightHint(int startX, int startY, int startZ) { static void ModernLighting_SetActive(void) { Lighting.OnBlockChanged = ModernLighting_OnBlockChanged; - Lighting.Refresh = ModernLighting_Refresh; - Lighting.IsLit = ModernLighting_IsLit; - Lighting.Color = ModernLighting_Color; - Lighting.Color_XSide = ModernLighting_Color_XSide; + Lighting.Refresh = ModernLighting_Refresh; + Lighting.IsLit = ModernLighting_IsLit; + Lighting.Color = ModernLighting_Color; + Lighting.Color_XSide = ModernLighting_Color_XSide; - Lighting.IsLit_Fast = ModernLighting_IsLit_Fast; - Lighting.Color_Fast = ModernLighting_Color; + Lighting.IsLit_Fast = ModernLighting_IsLit_Fast; + Lighting.Color_Sprite_Fast = ModernLighting_Color; + Lighting.Color_YMax_Fast = ModernLighting_Color; Lighting.Color_YMin_Fast = ModernLighting_Color_YMinSide; Lighting.Color_XSide_Fast = ModernLighting_Color_XSide; Lighting.Color_ZSide_Fast = ModernLighting_Color_ZSide; diff --git a/src/Lighting.h b/src/Lighting.h index 488457fc4..c2142de69 100644 --- a/src/Lighting.h +++ b/src/Lighting.h @@ -27,9 +27,11 @@ CC_VAR extern struct _Lighting { /* Allocates the per-level lighting state */ /* (called after map has been fully loaded) */ void (*AllocState)(void); - /* Quickly calculates lighting between - /* (startX, startY, startZ) to (startX + 18, startY + 18, startZ + 18) */ - void (*LightHint)(int startX, int startY, int startZ); + /* Equivalent to (but far more optimised form of) + * for x = startX; x < startX + 18; x++ + * for z = startZ; z < startZ + 18; z++ + * CalcLight(x, maxY, z) */ + void (*LightHint)(int startX, int startZ); /* Called when a block is changed to update internal lighting state. */ /* NOTE: Implementations ***MUST*** mark all chunks affected by this lighting change as needing to be refreshed. */ @@ -51,7 +53,8 @@ CC_VAR extern struct _Lighting { /* _Fast functions also do NOT check coordinates are inside the map */ cc_bool (*IsLit_Fast)(int x, int y, int z); - PackedCol (*Color_Fast)(int x, int y, int z); + PackedCol (*Color_Sprite_Fast)(int x, int y, int z); + PackedCol (*Color_YMax_Fast)(int x, int y, int z); PackedCol (*Color_YMin_Fast)(int x, int y, int z); PackedCol (*Color_XSide_Fast)(int x, int y, int z); PackedCol (*Color_ZSide_Fast)(int x, int y, int z); diff --git a/src/Menus.c b/src/Menus.c index 623761648..ea623087a 100644 --- a/src/Menus.c +++ b/src/Menus.c @@ -2923,7 +2923,6 @@ static void GraphicsOptionsScreen_InitWidgets(struct MenuOptionsScreen* s) { GraphicsOptionsScreen_GetSmooth, GraphicsOptionsScreen_SetSmooth }, { -1, 50, "Modern lighting", MenuOptionsScreen_Bool, GraphicsOptionsScreen_GetModernLighting, GraphicsOptionsScreen_SetModernLighting }, - { 1, -150, "Smooth camera", MenuOptionsScreen_Bool, GraphicsOptionsScreen_GetCamera, GraphicsOptionsScreen_SetCamera }, { 1, -100, "Names", MenuOptionsScreen_Enum, @@ -2967,8 +2966,8 @@ void GraphicsOptionsScreen_Show(void) { MenuInput_Float(menuOpts_descs[0], 1, 100, 20); MenuInput_Enum(menuOpts_descs[1], FpsLimit_Names, FPS_LIMIT_COUNT); MenuInput_Int(menuOpts_descs[2], 8, 4096, 512); - MenuInput_Enum(menuOpts_descs[5], NameMode_Names, NAME_MODE_COUNT); - MenuInput_Enum(menuOpts_descs[6], ShadowMode_Names, SHADOW_MODE_COUNT); + MenuInput_Enum(menuOpts_descs[6], NameMode_Names, NAME_MODE_COUNT); + MenuInput_Enum(menuOpts_descs[7], ShadowMode_Names, SHADOW_MODE_COUNT); MenuOptionsScreen_Show(GraphicsOptionsScreen_InitWidgets); }