mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -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 "Event.h"
|
||||
#include "Game.h"
|
||||
#include "Options.h"
|
||||
struct _Lighting Lighting;
|
||||
#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;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (!World_Contains(x, y, z)) return Env.SunXSide;
|
||||
return y > ClassicLighting_GetLightHeight(x, z) ? Env.SunXSide : Env.ShadowXSide;
|
||||
@ -375,10 +382,13 @@ static void ClassicLighting_AllocState(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.Refresh = ClassicLighting_Refresh;
|
||||
Lighting.IsLit = ClassicLighting_IsLit;
|
||||
Lighting.Color = ClassicLighting_Color;
|
||||
Lighting.Color = smoothLighting ? SmoothLighting_Color : ClassicLighting_Color;
|
||||
Lighting.Color_XSide = ClassicLighting_Color_XSide;
|
||||
|
||||
Lighting.IsLit_Fast = ClassicLighting_IsLit_Fast;
|
||||
@ -398,6 +408,10 @@ static void ClassicLighting_SetActive(void) {
|
||||
*---------------------------------------------------Lighting component----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
|
||||
void Lighting_ApplyActive() {
|
||||
ClassicLighting_SetActive();
|
||||
}
|
||||
|
||||
static void OnInit(void) { ClassicLighting_SetActive(); }
|
||||
static void OnReset(void) { Lighting.FreeState(); }
|
||||
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_ZSide_Fast)(int x, int y, int z);
|
||||
} Lighting;
|
||||
|
||||
void Lighting_ApplyActive(void);
|
||||
#endif
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "Utils.h"
|
||||
#include "Errors.h"
|
||||
#include "SystemFonts.h"
|
||||
#include "Lighting.h"
|
||||
|
||||
/* Describes a menu option button */
|
||||
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_SetSmooth(const cc_string* v) {
|
||||
Builder_SmoothLighting = Menu_SetBool(v, OPT_SMOOTH_LIGHTING);
|
||||
Lighting_ApplyActive();
|
||||
Builder_ApplyActive();
|
||||
MapRenderer_Refresh();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user