mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-07-16 09:34:52 +01:00
Merge branch 'dev-freeze' of https://github.com/Baystation12/Baystation12 into dev
This commit is contained in:
@@ -51,7 +51,7 @@ turf: (lighting_turf.dm)
|
||||
- proc/lighting_clear_overlays():
|
||||
- Delete (manual GC) all light overlays on this turf, used when changing turf to space
|
||||
- proc/lighting_build_overlays():
|
||||
- Create lighting overlays for this turf
|
||||
- Create lighting overlays for this turf. Called by ChangeTurf in case the turf is being changed to use dynamic lighting.
|
||||
|
||||
|
||||
atom/movable/lighting_overlay: (lighting_overlay.dm)
|
||||
|
||||
@@ -246,6 +246,45 @@
|
||||
effect_turf.Cut(idx, idx + 1)
|
||||
effect_str.Cut(idx, idx + 1)
|
||||
|
||||
//Whoop yet not another copy pasta because speed ~~~~BYOND.
|
||||
//Calculates and applies lighting for a single turf. This is intended for when a turf switches to
|
||||
//using dynamic lighting when it was not doing so previously (when constructing a floor on space, for example).
|
||||
//Assumes the turf is visible and such.
|
||||
//For the love of god don't call this proc when it's not needed! Lighting artifacts WILL happen!
|
||||
/datum/light_source/proc/calc_turf(var/turf/T)
|
||||
var/idx = effect_turf.Find(T)
|
||||
if(!idx)
|
||||
return //WHY.
|
||||
|
||||
if(T.lighting_overlay)
|
||||
#if LIGHTING_FALLOFF == 1 // circular
|
||||
. = (T.lighting_overlay.x - source_turf.x)**2 + (T.lighting_overlay.y - source_turf.y)**2 + LIGHTING_HEIGHT
|
||||
#if LIGHTING_LAMBERTIAN == 1
|
||||
. = CLAMP01((1 - CLAMP01(sqrt(.) / light_range)) * (1 / (sqrt(. + 1))))
|
||||
#else
|
||||
. = 1 - CLAMP01(sqrt(.) / light_range)
|
||||
#endif
|
||||
|
||||
#elif LIGHTING_FALLOFF == 2 // square
|
||||
. = abs(T.lighting_overlay.x - source_turf.x) + abs(T.lighting_overlay.y - source_turf.y) + LIGHTING_HEIGHT
|
||||
#if LIGHTING_LAMBERTIAN == 1
|
||||
. = CLAMP01((1 - CLAMP01(. / light_range)) * (1 / (sqrt(.)**2 + )))
|
||||
#else
|
||||
. = 1 - CLAMP01(. / light_range)
|
||||
#endif
|
||||
#endif
|
||||
. *= light_power
|
||||
|
||||
. = round(., LIGHTING_ROUND_VALUE)
|
||||
|
||||
effect_str[idx] = .
|
||||
|
||||
T.lighting_overlay.update_lumcount(
|
||||
lum_r * .,
|
||||
lum_g * .,
|
||||
lum_b * .
|
||||
)
|
||||
|
||||
#undef LUM_FALLOFF
|
||||
#undef LUM_DISTANCE
|
||||
#undef LUM_ATTENUATION
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
var/atom/movable/lighting_overlay/O = PoolOrNew(/atom/movable/lighting_overlay, src)
|
||||
lighting_overlay = O
|
||||
|
||||
//Make the light sources recalculate us so the lighting overlay updates immediately
|
||||
for(var/datum/light_source/L in affecting_lights)
|
||||
L.calc_turf(src)
|
||||
|
||||
/turf/Entered(atom/movable/obj)
|
||||
. = ..()
|
||||
if(obj && obj.opacity)
|
||||
|
||||
Reference in New Issue
Block a user