mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Adv lighting: make entities lit in fully bright blocks
This commit is contained in:
parent
577d69153a
commit
dc59fc318a
@ -7,6 +7,7 @@
|
|||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
#include "Options.h"
|
||||||
struct _Lighting Lighting;
|
struct _Lighting Lighting;
|
||||||
#define Lighting_Pack(x, z) ((x) + World.Width * (z))
|
#define Lighting_Pack(x, z) ((x) + World.Width * (z))
|
||||||
|
|
||||||
@ -66,6 +67,12 @@ static PackedCol ClassicLighting_Color(int x, int y, int z) {
|
|||||||
return y > ClassicLighting_GetLightHeight(x, z) ? Env.SunCol : Env.ShadowCol;
|
return y > ClassicLighting_GetLightHeight(x, z) ? Env.SunCol : Env.ShadowCol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PackedCol SmoothLighting_Color(int x, int y, int z) {
|
||||||
|
if (!World_Contains(x, y, z)) return Env.SunCol;
|
||||||
|
if (Blocks.FullBright[World_GetBlock(x, y, z)]) return Env.SunCol;
|
||||||
|
return y > ClassicLighting_GetLightHeight(x, z) ? Env.SunCol : Env.ShadowCol;
|
||||||
|
}
|
||||||
|
|
||||||
static PackedCol ClassicLighting_Color_XSide(int x, int y, int z) {
|
static PackedCol ClassicLighting_Color_XSide(int x, int y, int z) {
|
||||||
if (!World_Contains(x, y, z)) return Env.SunXSide;
|
if (!World_Contains(x, y, z)) return Env.SunXSide;
|
||||||
return y > ClassicLighting_GetLightHeight(x, z) ? Env.SunXSide : Env.ShadowXSide;
|
return y > ClassicLighting_GetLightHeight(x, z) ? Env.SunXSide : Env.ShadowXSide;
|
||||||
@ -375,10 +382,13 @@ static void ClassicLighting_AllocState(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ClassicLighting_SetActive(void) {
|
static void ClassicLighting_SetActive(void) {
|
||||||
|
cc_bool smoothLighting = false;
|
||||||
|
if (!Game_ClassicMode) smoothLighting = Options_GetBool(OPT_SMOOTH_LIGHTING, false);
|
||||||
|
|
||||||
Lighting.OnBlockChanged = ClassicLighting_OnBlockChanged;
|
Lighting.OnBlockChanged = ClassicLighting_OnBlockChanged;
|
||||||
Lighting.Refresh = ClassicLighting_Refresh;
|
Lighting.Refresh = ClassicLighting_Refresh;
|
||||||
Lighting.IsLit = ClassicLighting_IsLit;
|
Lighting.IsLit = ClassicLighting_IsLit;
|
||||||
Lighting.Color = ClassicLighting_Color;
|
Lighting.Color = smoothLighting ? SmoothLighting_Color : ClassicLighting_Color;
|
||||||
Lighting.Color_XSide = ClassicLighting_Color_XSide;
|
Lighting.Color_XSide = ClassicLighting_Color_XSide;
|
||||||
|
|
||||||
Lighting.IsLit_Fast = ClassicLighting_IsLit_Fast;
|
Lighting.IsLit_Fast = ClassicLighting_IsLit_Fast;
|
||||||
@ -398,6 +408,10 @@ static void ClassicLighting_SetActive(void) {
|
|||||||
*---------------------------------------------------Lighting component----------------------------------------------------*
|
*---------------------------------------------------Lighting component----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
|
|
||||||
|
void Lighting_ApplyActive() {
|
||||||
|
ClassicLighting_SetActive();
|
||||||
|
}
|
||||||
|
|
||||||
static void OnInit(void) { ClassicLighting_SetActive(); }
|
static void OnInit(void) { ClassicLighting_SetActive(); }
|
||||||
static void OnReset(void) { Lighting.FreeState(); }
|
static void OnReset(void) { Lighting.FreeState(); }
|
||||||
static void OnNewMapLoaded(void) { Lighting.AllocState(); }
|
static void OnNewMapLoaded(void) { Lighting.AllocState(); }
|
||||||
|
@ -49,4 +49,6 @@ CC_VAR extern struct _Lighting {
|
|||||||
PackedCol (*Color_XSide_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);
|
PackedCol (*Color_ZSide_Fast)(int x, int y, int z);
|
||||||
} Lighting;
|
} Lighting;
|
||||||
|
|
||||||
|
void Lighting_ApplyActive(void);
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "Errors.h"
|
#include "Errors.h"
|
||||||
#include "SystemFonts.h"
|
#include "SystemFonts.h"
|
||||||
|
#include "Lighting.h"
|
||||||
|
|
||||||
/* Describes a menu option button */
|
/* Describes a menu option button */
|
||||||
struct MenuOptionDesc {
|
struct MenuOptionDesc {
|
||||||
@ -2872,6 +2873,7 @@ static void GraphicsOptionsScreen_SetViewDist(const cc_string* v) { Game_UserSet
|
|||||||
static void GraphicsOptionsScreen_GetSmooth(cc_string* v) { Menu_GetBool(v, Builder_SmoothLighting); }
|
static void GraphicsOptionsScreen_GetSmooth(cc_string* v) { Menu_GetBool(v, Builder_SmoothLighting); }
|
||||||
static void GraphicsOptionsScreen_SetSmooth(const cc_string* v) {
|
static void GraphicsOptionsScreen_SetSmooth(const cc_string* v) {
|
||||||
Builder_SmoothLighting = Menu_SetBool(v, OPT_SMOOTH_LIGHTING);
|
Builder_SmoothLighting = Menu_SetBool(v, OPT_SMOOTH_LIGHTING);
|
||||||
|
Lighting_ApplyActive();
|
||||||
Builder_ApplyActive();
|
Builder_ApplyActive();
|
||||||
MapRenderer_Refresh();
|
MapRenderer_Refresh();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user