Ambient Occlusion (#3419)

Adds an implementation of Europa's wall ambient occlusion, extended to operate on openturfs as well.
This commit is contained in:
Lohikar
2017-09-15 09:49:53 -05:00
committed by GitHub
parent 86220edeb3
commit fe8d586b31
24 changed files with 351 additions and 43 deletions
+3
View File
@@ -104,6 +104,9 @@
if (new_opacity == TRUE)
T.has_opaque_atom = TRUE
T.reconsider_lights()
#ifdef AO_USE_LIGHTING_OPACITY
T.regenerate_ao()
#endif
else
var/old_has_opaque_atom = T.has_opaque_atom
T.recalc_atom_opacity()
+26 -5
View File
@@ -119,20 +119,38 @@
// Can't think of a good name, this proc will recalculate the has_opaque_atom variable.
/turf/proc/recalc_atom_opacity()
#ifdef AO_USE_LIGHTING_OPACITY
var/old = has_opaque_atom
#endif
has_opaque_atom = FALSE
for (var/atom/A in src.contents + src) // Loop through every movable atom on our tile PLUS ourselves (we matter too...)
if (A.opacity)
has_opaque_atom = TRUE
return // No need to continue if we find something opaque.
if (opacity)
has_opaque_atom = TRUE
else
for (var/thing in src) // Loop through every movable atom on our tile
var/atom/movable/A = thing
if (A.opacity)
has_opaque_atom = TRUE
break // No need to continue if we find something opaque.
#ifdef AO_USE_LIGHTING_OPACITY
if (old != has_opaque_atom)
queue_ao()
#endif
// If an opaque movable atom moves around we need to potentially update visibility.
/turf/Entered(atom/movable/Obj, atom/OldLoc)
. = ..()
if (Obj && Obj.opacity)
if (Obj && Obj.opacity && !has_opaque_atom)
has_opaque_atom = TRUE // Make sure to do this before reconsider_lights(), incase we're on instant updates. Guaranteed to be on in this case.
reconsider_lights()
#ifdef AO_USE_LIGHTING_OPACITY
// Hook for AO.
regenerate_ao()
#endif
/turf/Exited(atom/movable/Obj, atom/newloc)
. = ..()
@@ -187,9 +205,12 @@
var/list/old_affecting_lights = affecting_lights
var/old_lighting_overlay = lighting_overlay
var/list/old_corners = corners
var/old_ao_neighbors = ao_neighbors
. = ..()
ao_neighbors = old_ao_neighbors
recalc_atom_opacity()
lighting_overlay = old_lighting_overlay
if (lighting_overlay && lighting_overlay.loc != src)