Cross-Z Lighting (#2281)

This PR edits the lighting engine's turf selection algorithm to also include turfs below openturf tiles, allowing for cross-Z lighting.

changes:

Lights now will now shine down Z-levels when they light up an open turf.
Commented-out openturf starlight pending making it not pummel SSlighting.
Openspace overlays are now only queued if they are not already in the queue.
Lighting overlays will now also update their associated openturf overlay on update if they have one.
Removed an old unused message from the asteroid generation subsystem.
This commit is contained in:
Lohikar
2017-05-20 06:24:04 -05:00
committed by skull132
parent e912700bc0
commit 58b953a3fc
9 changed files with 70 additions and 68 deletions

View File

@@ -1693,7 +1693,6 @@
#include "code\modules\multiz\basic.dm" #include "code\modules\multiz\basic.dm"
#include "code\modules\multiz\movement.dm" #include "code\modules\multiz\movement.dm"
#include "code\modules\multiz\openspace.dm" #include "code\modules\multiz\openspace.dm"
#include "code\modules\multiz\openspace_overlay.dm"
#include "code\modules\multiz\pipes.dm" #include "code\modules\multiz\pipes.dm"
#include "code\modules\multiz\structures.dm" #include "code\modules\multiz\structures.dm"
#include "code\modules\multiz\turf.dm" #include "code\modules\multiz\turf.dm"

View File

@@ -14,9 +14,9 @@
#define SS_INIT_SMOOTHING 6 // Object icon smoothing. Creates overlays. #define SS_INIT_SMOOTHING 6 // Object icon smoothing. Creates overlays.
#define SS_INIT_ICON_UPDATE 5 // Icon update queue flush. Should run before overlays. #define SS_INIT_ICON_UPDATE 5 // Icon update queue flush. Should run before overlays.
#define SS_INIT_OVERLAY 4 // Overlay flush. #define SS_INIT_OVERLAY 4 // Overlay flush.
#define SS_INIT_OPENTURF 3 // Openturf flush. Should run after SSoverlay & SSicon_smooth so it copies the smoothed sprites. Causes lighting updates if starlight is enabled. #define SS_INIT_MISC 3 // Subsystems without an explicitly set initialization order start here.
#define SS_INIT_MISC 2 // Subsystems without an explicitly set initialization order start here. #define SS_INIT_LIGHTING 2 // Generation of lighting overlays and pre-bake.
#define SS_INIT_LIGHTING 1 // Generation of lighting overlays and pre-bake. #define SS_INIT_OPENTURF 1 // Openturf flush. Should run after SSoverlay & SSicon_smooth so it copies the smoothed sprites. Causes lighting updates if starlight is enabled.
#define SS_INIT_LOBBY 0 // Lobby timer starts here. #define SS_INIT_LOBBY 0 // Lobby timer starts here.
// Something to remember when setting priorities: SS_TICKER runs before Normal, which runs before SS_BACKGROUND. // Something to remember when setting priorities: SS_TICKER runs before Normal, which runs before SS_BACKGROUND.

View File

@@ -6,7 +6,7 @@
/datum/controller/subsystem/asteroid/Initialize(timeofday) /datum/controller/subsystem/asteroid/Initialize(timeofday)
if(config.generate_asteroid) if(config.generate_asteroid)
// These values determine the specific area that the map is applied to. // These values determine the specific area that the map is applied to.
// If you do not use the official Baycode moonbase map, you will need to change them.
// Create the chasms. // Create the chasms.
new /datum/random_map/automata/cave_system/chasms(null,0,0,3,255,255) new /datum/random_map/automata/cave_system/chasms(null,0,0,3,255,255)
new /datum/random_map/automata/cave_system(null,0,0,3,255,255) new /datum/random_map/automata/cave_system(null,0,0,3,255,255)
@@ -15,12 +15,9 @@
new /datum/random_map/automata/cave_system/chasms(null,0,0,5,255,255) new /datum/random_map/automata/cave_system/chasms(null,0,0,5,255,255)
new /datum/random_map/automata/cave_system/high_yield(null,0,0,5,255,255) new /datum/random_map/automata/cave_system/high_yield(null,0,0,5,255,255)
new /datum/random_map/automata/cave_system/chasms/surface(null,0,0,6,255,255) new /datum/random_map/automata/cave_system/chasms/surface(null,0,0,6,255,255)
// Create the deep mining ore distribution map. // Create the deep mining ore distribution map.
new /datum/random_map/noise/ore(null, 0, 0, 5, 64, 64) new /datum/random_map/noise/ore(null, 0, 0, 5, 64, 64)
new /datum/random_map/noise/ore(null, 0, 0, 4, 64, 64) new /datum/random_map/noise/ore(null, 0, 0, 4, 64, 64)
new /datum/random_map/noise/ore(null, 0, 0, 3, 64, 64) new /datum/random_map/noise/ore(null, 0, 0, 3, 64, 64)
var/counting_result = "Total number of chasms: [SSopenturf.openspace_turfs.len]"
admin_notice(span("danger", counting_result))
game_log("ASGEN", counting_result)
..() ..()

View File

@@ -97,18 +97,12 @@
// Handle space parallax & starlight. // Handle space parallax & starlight.
if (T.is_above_space()) if (T.is_above_space())
T.plane = PLANE_SPACE_BACKGROUND T.plane = PLANE_SPACE_BACKGROUND
if (config.starlight) /*if (config.starlight) // Openturf starlight is broken. SSlighting and SSopenturf will fight if this is un-commented-out. Maybe someone will fix it someday.
for (var/thing in RANGE_TURFS(1, T)) T.set_light(config.starlight, 0.5)*/
var/turf/RT = thing
if (!RT.dynamic_lighting || istype(RT, /turf/simulated/open))
continue
T.set_light(config.starlight, 0.5)
break
else else
T.plane = OPENTURF_MAX_PLANE - depth T.plane = OPENTURF_MAX_PLANE - depth
if (config.starlight && T.light_range != 0) /*if (config.starlight && T.light_range != 0)
T.set_light(0) T.set_light(0)*/
// Add everything below us to the update queue. // Add everything below us to the update queue.
for (var/thing in T.below) for (var/thing in T.below)
@@ -167,11 +161,10 @@
OO.dir = OO.associated_atom.dir OO.dir = OO.associated_atom.dir
OO.appearance = OO.associated_atom OO.appearance = OO.associated_atom
OO.plane = OPENTURF_MAX_PLANE - OO.depth OO.plane = OPENTURF_MAX_PLANE - OO.depth
OO.queued = FALSE
// Something's above us, queue it. if (OO.bound_overlay) // If we have a bound overlay, queue it too.
var/turf/oo_loc = OO.loc OO.update_oo()
if (istype(oo_loc.above))
oo_loc.above.update_icon()
if (no_mc_tick) if (no_mc_tick)
CHECK_TICK CHECK_TICK

View File

@@ -119,6 +119,9 @@
) )
#endif #endif
if (bound_overlay)
update_oo()
// Variety of overrides so the overlays don't get affected by weird things. // Variety of overrides so the overlays don't get affected by weird things.
/atom/movable/lighting_overlay/ex_act(severity) /atom/movable/lighting_overlay/ex_act(severity)

View File

@@ -371,6 +371,7 @@
var/Sy = source_turf.y var/Sy = source_turf.y
FOR_DVIEW(T, Ceiling(light_range), source_turf, 0) FOR_DVIEW(T, Ceiling(light_range), source_turf, 0)
check_t:
if (light_angle && check_light_cone(T.x, T.y)) if (light_angle && check_light_cone(T.x, T.y))
continue continue
@@ -379,6 +380,11 @@
corners[C] = 0 corners[C] = 0
turfs += T turfs += T
if (istype(T, /turf/simulated/open) && T:below)
T = T:below // Consider the turf below us as well. (Z-lights)
goto check_t
END_FOR_DVIEW END_FOR_DVIEW
LAZYINITLIST(affecting_turfs) LAZYINITLIST(affecting_turfs)

View File

@@ -49,7 +49,7 @@
return return
// check_existence returns TRUE if the overlay is valid. // check_existence returns TRUE if the overlay is valid.
if (bound_overlay.check_existence()) if (bound_overlay.check_existence() && !bound_overlay.queued)
SSopenturf.queued_overlays += bound_overlay SSopenturf.queued_overlays += bound_overlay
/atom/movable/proc/get_above_oo() /atom/movable/proc/get_above_oo()
@@ -105,4 +105,47 @@
return ..() return ..()
// /atom/movable/openspace/overlay is in openspace_overlay.dm // The visual representation of an atom under an openspace turf.
/atom/movable/openspace/overlay
plane = OPENTURF_MAX_PLANE
var/atom/movable/associated_atom
var/depth
var/queued = FALSE
/atom/movable/openspace/overlay/New()
SSopenturf.openspace_overlays += src
/atom/movable/openspace/overlay/Destroy()
SSopenturf.openspace_overlays -= src
if (associated_atom)
associated_atom.bound_overlay = null
associated_atom = null
return ..()
/atom/movable/openspace/overlay/attackby(obj/item/W, mob/user)
user << span("notice", "\The [src] is too far away.")
/atom/movable/openspace/overlay/attack_hand(mob/user as mob)
user << span("notice", "You cannot reach \the [src] from here.")
/atom/movable/openspace/overlay/attack_generic(mob/user as mob)
user << span("notice", "You cannot reach \the [src] from here.")
/atom/movable/openspace/overlay/forceMove(atom/dest)
. = ..()
check_existence()
/atom/movable/openspace/overlay/Move()
. = ..()
check_existence()
// Checks if we've moved off of an openturf.
// Returns TRUE if we're continuing to exist, FALSE if we're deleting ourselves.
/atom/movable/openspace/overlay/proc/check_existence()
if (!istype(loc, /turf/simulated/open))
qdel(src)
return FALSE
else
return TRUE

View File

@@ -1,43 +0,0 @@
// The visual representation of an atom under an openspace turf.
/atom/movable/openspace/overlay
plane = OPENTURF_MAX_PLANE
var/atom/movable/associated_atom
var/depth
/atom/movable/openspace/overlay/New()
SSopenturf.openspace_overlays += src
/atom/movable/openspace/overlay/Destroy()
SSopenturf.openspace_overlays -= src
if (associated_atom)
associated_atom.bound_overlay = null
associated_atom = null
return ..()
/atom/movable/openspace/overlay/attackby(obj/item/W, mob/user)
user << span("notice", "\The [src] is too far away.")
/atom/movable/openspace/overlay/attack_hand(mob/user as mob)
user << span("notice", "You cannot reach \the [src] from here.")
/atom/movable/openspace/overlay/attack_generic(mob/user as mob)
user << span("notice", "You cannot reach \the [src] from here.")
/atom/movable/openspace/overlay/forceMove(atom/dest)
. = ..()
check_existence()
/atom/movable/openspace/overlay/Move()
. = ..()
check_existence()
// Checks if we've moved off of an openturf.
// Returns TRUE if we're continuing to exist, FALSE if we're deleting ourselves.
/atom/movable/openspace/overlay/proc/check_existence()
if (!istype(loc, /turf/simulated/open))
qdel(src)
return FALSE
else
return TRUE

View File

@@ -0,0 +1,4 @@
author: Lohikar
delete-after: True
changes:
- tweak: "Lights will now shine through Z-holes (openturfs)."