Turns lighting objects into a datum, makes all lighting be performed with an underlay. big maptick fix very good! (#58991)

credit to zewaka for the idea of using underlays

turns the lighting object movables that were unnecessary and increased maptick into a datum which then applies and removes an underlay in update(). also applies a lot of general lighting clean ups (mostly using as anything in loops and fixing single letter var names).

multiz is a little different by necessity, now only the bottom turf's lighting matters in the brightness of the top turf unlike master where the bottom turf's lighting object is hidden from the vis_contents of the top turf. there are still some kinks to iron out here though, since currently objects suspended in openspace (like tram platforms) look bad and glass floors look bad too

only thing i have left to do is make multiz work (well)

UPDATE: multiz now appears the same as far as i can tell, its possible there are other situations in which its different but datum mats work and it automatically updates if the turf below changes. now i just need to make the system less finnicky if at all possible (and possibly merge managed_turf_vis_content with managed_overlays maybe?)

new update: its basically equivalent to normal multiz as far as i can tell (visually at least, in the circumstances ive tested so far)

NEW NEW UPDATE: turfs no longer have the VIS_HIDE vis_flag and multiz works without stacking the lighting from the floor below! so this shouldnt have any overt drawbacks to master anymore

1 needless movable per tile is terrible for maptick. this is probably a larger improvement than my emissive blocker change in terms of maptick. im guessing we'd get around 0.6 average maptick per player after this where currently we get 0.85 or so

Edit: according to lemon, sybil reached 0.71 maptick per person when tm'd with this

if this is a big enough improvement i might finally be able to get rid of the Gone discord avatar
This commit is contained in:
Kylerace
2021-06-12 21:37:29 -07:00
committed by GitHub
parent 27604af0d1
commit d3a1bea859
27 changed files with 181 additions and 207 deletions

View File

@@ -2,14 +2,21 @@
// These are the main datums that emit light.
/datum/light_source
var/atom/top_atom // The atom we're emitting light from (for example a mob if we're from a flashlight that's being held).
var/atom/source_atom // The atom that we belong to.
///The atom we're emitting light from (for example a mob if we're from a flashlight that's being held).
var/atom/top_atom
///The atom that we belong to.
var/atom/source_atom
var/turf/source_turf // The turf under the above.
var/turf/pixel_turf // The turf the top_atom appears to over.
var/light_power // Intensity of the emitter light.
var/light_range // The range of the emitted light.
var/light_color // The colour of the light, string, decomposed by parse_light_color()
///The turf under the source atom.
var/turf/source_turf
///The turf the top_atom appears to over.
var/turf/pixel_turf
///Intensity of the emitter light.
var/light_power
/// The range of the emitted light.
var/light_range
/// The colour of the light, string, decomposed by parse_light_color()
var/light_color
// Variables for keeping track of the colour.
var/lum_r
@@ -21,11 +28,14 @@
var/tmp/applied_lum_g
var/tmp/applied_lum_b
var/list/datum/lighting_corner/effect_str // List used to store how much we're affecting corners.
/// List used to store how much we're affecting corners.
var/list/datum/lighting_corner/effect_str
var/applied = FALSE // Whether we have applied our light yet or not.
/// Whether we have applied our light yet or not.
var/applied = FALSE
var/needs_update = LIGHTING_NO_UPDATE // Whether we are queued for an update.
/// whether we are to be added to SSlighting's sources_queue list for an update
var/needs_update = LIGHTING_NO_UPDATE
/datum/light_source/New(atom/owner, atom/top)
@@ -124,8 +134,7 @@
. * applied_lum_b \
);
// This is the define used to calculate falloff.
/// This is the define used to calculate falloff.
/datum/light_source/proc/remove_lum()
applied = FALSE
for (var/datum/lighting_corner/corner as anything in effect_str)
@@ -134,14 +143,14 @@
effect_str = null
/datum/light_source/proc/recalc_corner(datum/lighting_corner/C)
/datum/light_source/proc/recalc_corner(datum/lighting_corner/corner)
LAZYINITLIST(effect_str)
if (effect_str[C]) // Already have one.
REMOVE_CORNER(C)
effect_str[C] = 0
if (effect_str[corner]) // Already have one.
REMOVE_CORNER(corner)
effect_str[corner] = 0
APPLY_CORNER(C)
effect_str[C] = .
APPLY_CORNER(corner)
effect_str[corner] = .
/datum/light_source/proc/update_corners()
@@ -178,9 +187,9 @@
pixel_turf = get_turf_pixel(top_atom)
update = TRUE
else
var/P = get_turf_pixel(top_atom)
if (P != pixel_turf)
pixel_turf = P
var/pixel_loc = get_turf_pixel(top_atom)
if (pixel_loc != pixel_turf)
pixel_turf = pixel_loc
update = TRUE
if (!isturf(source_turf))
@@ -206,7 +215,7 @@
return //nothing's changed
var/list/datum/lighting_corner/corners = list()
var/list/turf/turfs = list()
var/list/turf/turfs = list()
if (source_turf)
var/oldlum = source_turf.luminosity
@@ -246,7 +255,7 @@
effect_str -= corner
var/list/datum/lighting_corner/gone_corners = effect_str - corners
for (var/datum/lighting_corner/corner as anything in gone_corners)
for (var/datum/lighting_corner/corner as anything in gone_corners)
REMOVE_CORNER(corner)
LAZYREMOVE(corner.affecting, src)
effect_str -= gone_corners