mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-25 22:12:58 +01:00
Lighting Performance Tweaks & Fixes (#3325)
changes: SSlighting is now FIFO - lights are processed in the order they are received instead of by whatever one was queued most recently. Instant lighting updates now check CURRENT_TICKLIMIT instead of ITL. ITL has been removed due to it no longer being used. SSlighting will no longer double-process lighting datums that have already been processed by instant lighting. Instant/Intelligent lighting updates can now be disabled via. compile-time define. Sunlight should no longer shine indoors. Directional lighting now properly updates on direction changes again. /datum/light_source/novis has been renamed to /datum/light_source/sunlight. More lighting microoptimizations. Converted two storage lists to be lazy.
This commit is contained in:
@@ -73,7 +73,7 @@
|
||||
if (light) // Update the light or create it if it does not exist.
|
||||
light.update(.)
|
||||
else if (light_novis)
|
||||
light = new/datum/light_source/novis(src, .)
|
||||
light = new/datum/light_source/sunlight(src, .)
|
||||
else
|
||||
light = new/datum/light_source(src, .)
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
if (!force)
|
||||
return QDEL_HINT_IWILLGC
|
||||
|
||||
#ifdef USE_INTELLIGENT_LIGHTING_UPDATES
|
||||
// Picks either scheduled or instant updates based on current server load.
|
||||
#define INTELLIGENT_UPDATE(level) \
|
||||
var/_should_update = needs_update == LIGHTING_NO_UPDATE; \
|
||||
@@ -92,7 +93,7 @@
|
||||
needs_update = level; \
|
||||
} \
|
||||
if (_should_update) { \
|
||||
if (world.tick_usage > SSlighting.instant_tick_limit || SSlighting.force_queued) { \
|
||||
if (world.tick_usage > CURRENT_TICKLIMIT || SSlighting.force_queued) { \
|
||||
SSlighting.light_queue += src; \
|
||||
} \
|
||||
else { \
|
||||
@@ -100,6 +101,13 @@
|
||||
needs_update = LIGHTING_NO_UPDATE; \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define INTELLIGENT_UPDATE(level) \
|
||||
if (needs_update == LIGHTING_NO_UPDATE) \
|
||||
SSlighting.light_queue += src; \
|
||||
if (needs_update < level) \
|
||||
needs_update = level;
|
||||
#endif
|
||||
|
||||
// This proc will cause the light source to update the top atom, and add itself to the update queue.
|
||||
/datum/light_source/proc/update(atom/new_top_atom)
|
||||
@@ -154,15 +162,18 @@
|
||||
/datum/light_source/proc/update_angle()
|
||||
var/turf/T = get_turf(top_atom)
|
||||
|
||||
var/ndir
|
||||
if (istype(top_atom, /mob) && top_atom:facing_dir)
|
||||
old_direction = top_atom:facing_dir
|
||||
ndir = top_atom:facing_dir
|
||||
else
|
||||
old_direction = top_atom.dir
|
||||
ndir = top_atom.dir
|
||||
|
||||
// Don't do anything if nothing is different, trig ain't free.
|
||||
if (T.x == cached_origin_x && T.y == cached_origin_y && old_direction == top_atom.dir)
|
||||
if (T.x == cached_origin_x && T.y == cached_origin_y && old_direction == ndir)
|
||||
return
|
||||
|
||||
old_direction = ndir
|
||||
|
||||
var/turf/front = get_step(T, old_direction)
|
||||
facing_opaque = (front && front.has_opaque_atom)
|
||||
|
||||
@@ -344,9 +355,10 @@
|
||||
Tcorners[i] = new /datum/lighting_corner(T, LIGHTING_CORNER_DIAGONAL[i])
|
||||
|
||||
if (!T.has_opaque_atom)
|
||||
for (thing in Tcorners)
|
||||
C = thing
|
||||
corners[C] = 0
|
||||
corners[Tcorners[1]] = 0
|
||||
corners[Tcorners[2]] = 0
|
||||
corners[Tcorners[3]] = 0
|
||||
corners[Tcorners[4]] = 0
|
||||
|
||||
turfs += T
|
||||
|
||||
|
||||
+19
-18
@@ -1,6 +1,6 @@
|
||||
/datum/light_source/novis
|
||||
/datum/light_source/sunlight
|
||||
|
||||
/datum/light_source/novis/update_corners()
|
||||
/datum/light_source/sunlight/update_corners()
|
||||
var/update = FALSE
|
||||
|
||||
if (QDELETED(source_atom))
|
||||
@@ -63,11 +63,14 @@
|
||||
var/list/Tcorners
|
||||
var/Sx = source_turf.x
|
||||
var/Sy = source_turf.y
|
||||
var/actual_range = light_range // novis sources don't support directional lighting.
|
||||
var/actual_range = light_range // sunlight sources don't support directional lighting.
|
||||
|
||||
// We don't need no damn vis checks!
|
||||
for (Tthing in RANGE_TURFS(Ceiling(light_range), source_turf))
|
||||
T = Tthing
|
||||
if (the_station_areas[T.loc])
|
||||
continue
|
||||
|
||||
check_t:
|
||||
|
||||
if (T.dynamic_lighting || T.light_sources)
|
||||
@@ -86,9 +89,10 @@
|
||||
Tcorners[i] = new /datum/lighting_corner(T, LIGHTING_CORNER_DIAGONAL[i])
|
||||
|
||||
if (!T.has_opaque_atom)
|
||||
for (thing in Tcorners)
|
||||
C = thing
|
||||
corners[C] = 0
|
||||
corners[Tcorners[1]] = 0
|
||||
corners[Tcorners[2]] = 0
|
||||
corners[Tcorners[3]] = 0
|
||||
corners[Tcorners[4]] = 0
|
||||
|
||||
turfs += T
|
||||
|
||||
@@ -157,19 +161,16 @@
|
||||
UNSETEMPTY(effect_str)
|
||||
UNSETEMPTY(affecting_turfs)
|
||||
|
||||
/datum/light_source/novis/update_angle()
|
||||
/datum/light_source/sunlight/update_angle()
|
||||
return
|
||||
|
||||
#define QUEUE_UPDATE(level) \
|
||||
var/_should_update = needs_update == LIGHTING_NO_UPDATE; \
|
||||
if (needs_update < level) { \
|
||||
needs_update = level; \
|
||||
} \
|
||||
if (_should_update) { \
|
||||
SSlighting.light_queue += src; \
|
||||
}
|
||||
#define QUEUE_UPDATE(level) \
|
||||
if (needs_update == LIGHTING_NO_UPDATE) \
|
||||
SSlighting.light_queue += src; \
|
||||
if (needs_update < level) \
|
||||
needs_update = level;
|
||||
|
||||
/datum/light_source/novis/update(atom/new_top_atom)
|
||||
/datum/light_source/sunlight/update(atom/new_top_atom)
|
||||
// This top atom is different.
|
||||
if (new_top_atom && new_top_atom != top_atom)
|
||||
if(top_atom != source_atom) // Remove ourselves from the light sources of that top atom.
|
||||
@@ -184,10 +185,10 @@
|
||||
|
||||
QUEUE_UPDATE(LIGHTING_CHECK_UPDATE)
|
||||
|
||||
/datum/light_source/novis/force_update()
|
||||
/datum/light_source/sunlight/force_update()
|
||||
QUEUE_UPDATE(LIGHTING_FORCE_UPDATE)
|
||||
|
||||
/datum/light_source/novis/vis_update()
|
||||
/datum/light_source/sunlight/vis_update()
|
||||
QUEUE_UPDATE(LIGHTING_VIS_UPDATE)
|
||||
|
||||
#undef QUEUE_UPDATE
|
||||
Reference in New Issue
Block a user