Files
Bubberstation/code/_onclick/hud/rendering/plane_master.dm
LemonInTheDark 230d399671 Ventcrawling improvements, performance and visual (#66709)
* Initial pipecrawl work

Ok so pipecrawl images were updating EVERY TIME YOU MOVED
This was not good mojo

What I've done here is twofold
First, I ensured pipecrawl updates only when the net changes. This
breaks the current implementation, but I intend on fixing that

Second, I moved our method of getting pipes to the spatial grid
This isn't that great at the moment, but I intend on adding support for
tracking entered/exited cells, which should make this much better

* Much faster pipecrawling processing, niceties

Adds a concept called a cell tracker datum.
It manages a list of cells a passed in bound is "inside", and when
queried will return a list of new cells, and old cells.

Because we only really care about maintaining an absolute window of
"CELLS WE ARE IN" and less about always removing cells we're not in, we
can manage a second window to prevent moving up and down on a cell line
causing a ton of updates.

Uses this concept to optimize pipecrawling significantly, from 3ms per
call before to roughly 0.03ms per call.

Also moves pipecrawl images to their own plane, so they don't overlap ui
elements

* Pipecrawling effects niceties, direction help

You can now move in more then one direction when pipecrawling
This works as expected, if you hold up and left, move up for a while,
and come to a fork, you'll go left

Added some effects to pipecrawling. It'll darken the lighting plane
slightly, so you get a nice effect instead of just fullbright.
Also added a color matrix and drop shadow to the pipe images, this way
they stand out a bit more.

You now glide between pipe moves, rather then moving instantly. This
doesn't effect your actual move rate, but it no longer feels jittery
with say, 60fps

* Bounds

* Fixes runtimes, cache something somethign sonic speed

* Reworks how being interested in the spatial grid is tracked

Rather then checking multiple variables on the atom to consider, we
instead check for the existence of a string key.

This key is used by a list on the spatial grid subsystem to retrive a
cached list of all of the atoms "types"

Doing this requires doing a bit of extra work in
important_recursive_contents code, but it allows us to separate being a
part of the spatial grid from using important recursive contents, which
is very nice.

As a consequence, I've had to unroll some lazylist macros in important
recursive contents logic. It's not ""that"" bad but it's not great
either.

Oh and this adds a slight cost to enter/exit cell, but it's minimal.
Basically, rather then checking for different features of a grid member,
we just iterate the list their string key points to. Very handy

So there's an added cost of a list copy and all, but we save the
headache of more types technically increasing the cost of
addition/removal.

I also made adding/removing from the grid into one "pulbic" proc rather then two
different ones for each operation, because it was starting to get silly

* waaa waa it doesn't compile

* chord -> coord

* Ensures important_recursive_contents is actually emptied on removal

* Removes soul

* Kyler's review

Co-authored-by: Kylerace <kylerlumpkin1@gmail.com>

* Kyler's review 2

Co-authored-by: Kylerace <kylerlumpkin1@gmail.com>

* Kyler's review 3

Moves some procs around, improves some documentation, catches a few
small issues

Co-authored-by: Kylerace <kylerlumpkin1@gmail.com>
2022-05-08 21:04:44 -07:00

301 lines
11 KiB
Plaintext

/atom/movable/screen/plane_master
screen_loc = "CENTER"
icon_state = "blank"
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
blend_mode = BLEND_OVERLAY
plane = LOWEST_EVER_PLANE
var/show_alpha = 255
var/hide_alpha = 0
//--rendering relay vars--
///integer: what plane we will relay this planes render to
var/render_relay_plane = RENDER_PLANE_GAME
///bool: Whether this plane should get a render target automatically generated
var/generate_render_target = TRUE
///integer: blend mode to apply to the render relay in case you dont want to use the plane_masters blend_mode
var/blend_mode_override
///reference: current relay this plane is utilizing to render
var/atom/movable/render_plane_relay/relay
/atom/movable/screen/plane_master/proc/Show(override)
alpha = override || show_alpha
/atom/movable/screen/plane_master/proc/Hide(override)
alpha = override || hide_alpha
//Why do plane masters need a backdrop sometimes? Read https://secure.byond.com/forum/?post=2141928
//Trust me, you need one. Period. If you don't think you do, you're doing something extremely wrong.
/atom/movable/screen/plane_master/proc/backdrop(mob/mymob)
SHOULD_CALL_PARENT(TRUE)
if(!isnull(render_relay_plane))
relay_render_to_plane(mymob, render_relay_plane)
///Things rendered on "openspace"; holes in multi-z
/atom/movable/screen/plane_master/openspace_backdrop
name = "open space backdrop plane master"
plane = OPENSPACE_BACKDROP_PLANE
appearance_flags = PLANE_MASTER
blend_mode = BLEND_MULTIPLY
alpha = 255
/atom/movable/screen/plane_master/openspace
name = "open space plane master"
plane = OPENSPACE_PLANE
appearance_flags = PLANE_MASTER
/atom/movable/screen/plane_master/openspace/Initialize(mapload)
. = ..()
add_filter("first_stage_openspace", 1, drop_shadow_filter(color = "#04080FAA", size = -10))
add_filter("second_stage_openspace", 2, drop_shadow_filter(color = "#04080FAA", size = -15))
add_filter("third_stage_openspace", 3, drop_shadow_filter(color = "#04080FAA", size = -20))
///For any transparent multi-z tiles we want to render
/atom/movable/screen/plane_master/transparent
name = "transparent plane master"
plane = TRANSPARENT_FLOOR_PLANE
appearance_flags = PLANE_MASTER
///Contains just the floor
/atom/movable/screen/plane_master/floor
name = "floor plane master"
plane = FLOOR_PLANE
appearance_flags = PLANE_MASTER
blend_mode = BLEND_OVERLAY
///Contains most things in the game world
/atom/movable/screen/plane_master/game_world
name = "game world plane master"
plane = GAME_PLANE
appearance_flags = PLANE_MASTER //should use client color
blend_mode = BLEND_OVERLAY
/atom/movable/screen/plane_master/game_world/backdrop(mob/mymob)
. = ..()
remove_filter("AO")
if(istype(mymob) && mymob.client?.prefs?.read_preference(/datum/preference/toggle/ambient_occlusion))
add_filter("AO", 1, drop_shadow_filter(x = 0, y = -2, size = 4, color = "#04080FAA"))
/atom/movable/screen/plane_master/game_world_fov_hidden
name = "game world fov hidden plane master"
plane = GAME_PLANE_FOV_HIDDEN
render_relay_plane = GAME_PLANE
appearance_flags = PLANE_MASTER //should use client color
blend_mode = BLEND_OVERLAY
/atom/movable/screen/plane_master/game_world_fov_hidden/Initialize()
. = ..()
add_filter("vision_cone", 1, alpha_mask_filter(render_source = FIELD_OF_VISION_BLOCKER_RENDER_TARGET, flags = MASK_INVERSE))
/atom/movable/screen/plane_master/game_world_upper
name = "upper game world plane master"
plane = GAME_PLANE_UPPER
render_relay_plane = GAME_PLANE
appearance_flags = PLANE_MASTER //should use client color
blend_mode = BLEND_OVERLAY
/atom/movable/screen/plane_master/game_world_upper_fov_hidden
name = "upper game world fov hidden plane master"
plane = GAME_PLANE_UPPER_FOV_HIDDEN
render_relay_plane = GAME_PLANE_FOV_HIDDEN
appearance_flags = PLANE_MASTER //should use client color
blend_mode = BLEND_OVERLAY
/atom/movable/screen/plane_master/game_world_above
name = "above game world plane master"
plane = ABOVE_GAME_PLANE
render_relay_plane = GAME_PLANE
appearance_flags = PLANE_MASTER //should use client color
blend_mode = BLEND_OVERLAY
/atom/movable/screen/plane_master/massive_obj
name = "massive object plane master"
plane = MASSIVE_OBJ_PLANE
appearance_flags = PLANE_MASTER //should use client color
blend_mode = BLEND_OVERLAY
/atom/movable/screen/plane_master/ghost
name = "ghost plane master"
plane = GHOST_PLANE
appearance_flags = PLANE_MASTER //should use client color
blend_mode = BLEND_OVERLAY
render_relay_plane = RENDER_PLANE_NON_GAME
/atom/movable/screen/plane_master/point
name = "point plane master"
plane = POINT_PLANE
appearance_flags = PLANE_MASTER //should use client color
blend_mode = BLEND_OVERLAY
/**
* Plane master handling byond internal blackness
* vars are set as to replicate behavior when rendering to other planes
* do not touch this unless you know what you are doing
*/
/atom/movable/screen/plane_master/blackness
name = "darkness plane master"
plane = BLACKNESS_PLANE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
color = list(null, null, null, "#0000", "#000f")
blend_mode = BLEND_MULTIPLY
appearance_flags = PLANE_MASTER | NO_CLIENT_COLOR | PIXEL_SCALE
//byond internal end
///Contains all lighting objects
/atom/movable/screen/plane_master/lighting
name = "lighting plane master"
plane = LIGHTING_PLANE
blend_mode_override = BLEND_MULTIPLY
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/atom/movable/screen/plane_master/lighting/backdrop(mob/mymob)
. = ..()
mymob.overlay_fullscreen("lighting_backdrop_lit", /atom/movable/screen/fullscreen/lighting_backdrop/lit)
mymob.overlay_fullscreen("lighting_backdrop_unlit", /atom/movable/screen/fullscreen/lighting_backdrop/unlit)
/*!
* This system works by exploiting BYONDs color matrix filter to use layers to handle emissive blockers.
*
* Emissive overlays are pasted with an atom color that converts them to be entirely some specific color.
* Emissive blockers are pasted with an atom color that converts them to be entirely some different color.
* Emissive overlays and emissive blockers are put onto the same plane.
* The layers for the emissive overlays and emissive blockers cause them to mask eachother similar to normal BYOND objects.
* A color matrix filter is applied to the emissive plane to mask out anything that isn't whatever the emissive color is.
* This is then used to alpha mask the lighting plane.
*/
/atom/movable/screen/plane_master/lighting/Initialize(mapload)
. = ..()
add_filter("emissives", 1, alpha_mask_filter(render_source = EMISSIVE_RENDER_TARGET, flags = MASK_INVERSE))
add_filter("object_lighting", 2, alpha_mask_filter(render_source = O_LIGHTING_VISUAL_RENDER_TARGET, flags = MASK_INVERSE))
/**
* Handles emissive overlays and emissive blockers.
*/
/atom/movable/screen/plane_master/emissive
name = "emissive plane master"
plane = EMISSIVE_PLANE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
render_target = EMISSIVE_RENDER_TARGET
render_relay_plane = null
/atom/movable/screen/plane_master/emissive/Initialize(mapload)
. = ..()
add_filter("em_block_masking", 1, color_matrix_filter(GLOB.em_mask_matrix))
/atom/movable/screen/plane_master/above_lighting
name = "above lighting plane master"
plane = ABOVE_LIGHTING_PLANE
appearance_flags = PLANE_MASTER //should use client color
blend_mode = BLEND_OVERLAY
///Contains space parallax
/atom/movable/screen/plane_master/parallax
name = "parallax plane master"
plane = PLANE_SPACE_PARALLAX
blend_mode = BLEND_MULTIPLY
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/atom/movable/screen/plane_master/parallax_white
name = "parallax whitifier plane master"
plane = PLANE_SPACE
/atom/movable/screen/plane_master/pipecrawl
name = "pipecrawl plane master"
plane = PIPECRAWL_IMAGES_PLANE
appearance_flags = PLANE_MASTER
blend_mode = BLEND_OVERLAY
/atom/movable/screen/plane_master/pipecrawl/Initialize(mapload)
. = ..()
// Makes everything on this plane slightly brighter
// Has a nice effect, makes thing stand out
color = list(1.2,0,0,0, 0,1.2,0,0, 0,0,1.2,0, 0,0,0,1, 0,0,0,0)
// This serves a similar purpose, I want the pipes to pop
add_filter("pipe_dropshadow", 1, drop_shadow_filter(x = -1, y= -1, size = 1, color = "#0000007A"))
/atom/movable/screen/plane_master/camera_static
name = "camera static plane master"
plane = CAMERA_STATIC_PLANE
appearance_flags = PLANE_MASTER
blend_mode = BLEND_OVERLAY
/atom/movable/screen/plane_master/excited_turfs
name = "atmos excited turfs"
plane = ATMOS_GROUP_PLANE
appearance_flags = PLANE_MASTER
blend_mode = BLEND_OVERLAY
alpha = 0
/atom/movable/screen/plane_master/o_light_visual
name = "overlight light visual plane master"
plane = O_LIGHTING_VISUAL_PLANE
render_target = O_LIGHTING_VISUAL_RENDER_TARGET
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
blend_mode = BLEND_MULTIPLY
blend_mode_override = BLEND_MULTIPLY
/atom/movable/screen/plane_master/runechat
name = "runechat plane master"
plane = RUNECHAT_PLANE
appearance_flags = PLANE_MASTER
blend_mode = BLEND_OVERLAY
render_relay_plane = RENDER_PLANE_NON_GAME
/atom/movable/screen/plane_master/runechat/backdrop(mob/mymob)
. = ..()
remove_filter("AO")
if(istype(mymob) && mymob.client?.prefs?.read_preference(/datum/preference/toggle/ambient_occlusion))
add_filter("AO", 1, drop_shadow_filter(x = 0, y = -2, size = 4, color = "#04080FAA"))
/atom/movable/screen/plane_master/gravpulse
name = "gravpulse plane"
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
plane = GRAVITY_PULSE_PLANE
blend_mode = BLEND_ADD
blend_mode_override = BLEND_ADD
render_target = GRAVITY_PULSE_RENDER_TARGET
render_relay_plane = null
/atom/movable/screen/plane_master/area
name = "area plane"
plane = AREA_PLANE
/atom/movable/screen/plane_master/radtext
name = "radtext plane"
plane = RAD_TEXT_PLANE
render_relay_plane = RENDER_PLANE_NON_GAME
/atom/movable/screen/plane_master/balloon_chat
name = "balloon alert plane"
plane = BALLOON_CHAT_PLANE
render_relay_plane = RENDER_PLANE_NON_GAME
/atom/movable/screen/plane_master/fullscreen
name = "fullscreen alert plane"
plane = FULLSCREEN_PLANE
render_relay_plane = RENDER_PLANE_NON_GAME
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/atom/movable/screen/plane_master/field_of_vision_blocker
name = "field of vision blocker plane master"
plane = FIELD_OF_VISION_BLOCKER_PLANE
render_target = FIELD_OF_VISION_BLOCKER_RENDER_TARGET
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
render_relay_plane = null
/atom/movable/screen/plane_master/hud
name = "HUD plane"
plane = HUD_PLANE
render_relay_plane = RENDER_PLANE_NON_GAME
/atom/movable/screen/plane_master/above_hud
name = "above HUD plane"
plane = ABOVE_HUD_PLANE
render_relay_plane = RENDER_PLANE_NON_GAME
/atom/movable/screen/plane_master/splashscreen
name = "splashscreen plane"
plane = SPLASHSCREEN_PLANE
render_relay_plane = RENDER_PLANE_NON_GAME