mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 09:42:29 +00:00
Multiz Rework: Human Suffering Edition (Contains PLANE CUBE) (#69115)
About The Pull Request I've reworked multiz. This was done because our current implementation of multiz flattens planes down into just the openspace plane. This breaks any effects we attach to plane masters (including lighting), but it also totally kills the SIDE_MAP map format, which we NEED for wallening (A major 3/4ths resprite of all wall and wall adjacent things, making them more then one tile high. Without sidemap we would be unable to display things both in from of and behind objects on map. Stupid.) This required MASSIVE changes. Both to all uses of the plane var for reasons I'll discuss later, and to a ton of different systems that interact with rendering. I'll do my best to keep this compact, but there's only so much I can do. Sorry brother. Core idea OK: first thing. vis_contents as it works now squishes the planes of everything inside it down into the plane of the vis_loc. This is bad. But how to do better? It's trivially easy to make copies of our existing plane masters but offset, and relay them to the bottom of the plane above. Not a problem. The issue is how to get the actual atoms on the map to "land" on them properly. We could use FLOAT_PLANE to offset planes based off how they're being seen, in theory this would allow us to create lens for how objects are viewed. But that's not a stable thing to do, because properly "landing" a plane on a desired plane master would require taking into account every bit of how it's being seen, would inherently break this effect. Ok so we need to manually edit planes based off "z layer" (IE: what layer of a z stack are you on). That's the key conceit of this pr. Implementing the plane cube, and ensuring planes are always offset properly. Everything else is just gravy. About the Plane Cube Each plane master (except ones that opt out) is copied down by some constant value equal to the max absolute change between the first and the last plane. We do this based off the max z stack size detected by SSmapping. This is also where updates come from, and where all our updating logic will live. As mentioned, plane masters can choose to opt out of being mirrored down. In this case, anything that interacts with them assuming that they'll be offset will instead just get back the valid plane value. This works for render targets too, since I had to work them into the system as well. Plane masters can also be temporarily hidden from the client's screen. This is done as an attempt at optimization, and applies to anything used in niche cases, or planes only used if there's a z layer below you. About Plane Master Groups BYOND supports having different "maps" on screen at once (IE: groups of items/turfs/etc) Plane masters cannot cover 2 maps at once, since their location is determined by their screen_loc. So we need to maintain a mirror of each plane for every map we have open. This was quite messy, so I've refactored it (and maps too) to be a bit more modular. Rather then storing a list of plane masters, we store a list of plane master group datums. Each datum is in charge of the plane masters for its particular map, both creating them, and managing them. Like I mentioned, I also refactored map views. Adding a new mapview is now as simple as newing a /atom/movable/screen/map_view, calling generate_view with the appropriate map id, setting things you want to display in its vis_contents, and then calling display_to on it, passing in the mob to show ourselves to. Much better then the hardcoded pattern we used to use. So much duplicated code man. Oh and plane master controllers, that system we have that allows for applying filters to sets of plane masters? I've made it use lookups on plane master groups now, rather then hanging references to all impacted planes. This makes logic easier, and prevents the need to manage references and update the controllers. image In addition, I've added a debug ui for plane masters. It allows you to view all of your own plane masters and short descriptions of what they do, alongside tools for editing them and their relays. It ALSO supports editing someone elses plane masters, AND it supports (in a very fragile and incomplete manner) viewing literally through someone else's eyes, including their plane masters. This is very useful, because it means you can debug "hey my X is yorked" issues yourself, on live. In order to accomplish this I have needed to add setters for an ungodly amount of visual impacting vars. Sight flags, eye, see_invis, see_in_dark, etc. It also comes with an info dump about the ui, and plane masters/relays in general. Sort of on that note. I've documented everything I know that's niche/useful about our visual effects and rendering system. My hope is this will serve to bring people up to speed on what can be done more quickly, alongside making my sin here less horrible. See https://github.com/LemonInTheDark/tgstation/blob/multiz-hell/.github/guides/VISUALS.md. "Landing" planes Ok so I've explained the backend, but how do we actually land planes properly? Most of the time this is really simple. When a plane var is set, we need to provide some spokesperson for the appearance's z level. We can use this to derive their z layer, and thus what offset to use. This is just a lot of gruntwork, but it's occasionally more complex. Sometimes we need to cache a list of z layer -> effect, and then use that. Also a LOT of updating on z move. So much z move shit. Oh. and in order to make byond darkness work properly, I needed to add SEE_BLACKNESS to all sight flags. This draws darkness to plane 0, which means I'm able to relay it around and draw it on different z layers as is possible. fun darkness ripple effects incoming someday I also need to update mob overlays on move. I do this by realiizing their appearances, mutating their plane, and then readding the overlay in the correct order. The cost of this is currently 3N. I'm convinced this could be improved, but I've not got to it yet. It can also occasionally cause overlays to corrupt. This is fixed by laying a protective ward of overlays.Copy in the sand, but that spell makes the compiler confused, so I'll have to bully lummy about fixing it at some point. Behavior changes We've had to give up on the already broken gateway "see through" effect. Won't work without managing gateway plane masters or something stupid. Not worth it. So instead we display the other side as a ui element. It's worse, but not that bad. Because vis_contents no longer flattens planes (most of the time), some uses of it now have interesting behavior. The main thing that comes to mind is alert popups that display mobs. They can impact the lighting plane. I don't really care, but it should be fixable, I think, given elbow grease. Ah and I've cleaned up layers and plane defines to make them a bit easier to read/reason about, at least I think. Why It's Good For The Game <visual candy> Fixes #65800 Fixes #68461 Changelog cl refactor: Refactored... well a lot really. Map views, anything to do with planes, multiz, a shit ton of rendering stuff. Basically if you see anything off visually report it admin: VV a mob, and hit View/Edit Planes in the dropdown to steal their view, and modify it as you like. You can do the same to yourself using the Edit/Debug Planes verb /cl
This commit is contained in:
@@ -61,7 +61,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
var/list/favorite_outfits = list()
|
||||
|
||||
/// A preview of the current character
|
||||
var/atom/movable/screen/character_preview_view/character_preview_view
|
||||
var/atom/movable/screen/map_view/char_preview/character_preview_view
|
||||
|
||||
/// A list of instantiated middleware
|
||||
var/list/datum/preference_middleware/middleware = list()
|
||||
@@ -121,19 +121,24 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
save_character() //let's save this new random character so it doesn't keep generating new ones.
|
||||
|
||||
/datum/preferences/ui_interact(mob/user, datum/tgui/ui)
|
||||
// If you leave and come back, re-register the character preview
|
||||
if (!isnull(character_preview_view) && !(character_preview_view in user.client?.screen))
|
||||
user.client?.register_map_obj(character_preview_view)
|
||||
// There used to be code here that readded the preview view if you "rejoined"
|
||||
// I'm making the assumption that ui close will be called whenever a user logs out, or loses a window
|
||||
// If this isn't the case, kill me and restore the code, thanks
|
||||
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
character_preview_view = create_character_preview_view(user)
|
||||
|
||||
ui = new(user, src, "PreferencesMenu")
|
||||
ui.set_autoupdate(FALSE)
|
||||
ui.open()
|
||||
|
||||
// HACK: Without this the character starts out really tiny because of some BYOND bug.
|
||||
// You can fix it by changing a preference, so let's just forcably update the body to emulate this.
|
||||
addtimer(CALLBACK(character_preview_view, /atom/movable/screen/character_preview_view/proc/update_body), 1 SECONDS)
|
||||
// Lemon from the future: this issue appears to replicate if the byond map (what we're relaying here)
|
||||
// Is shown while the client's mouse is on the screen. As soon as their mouse enters the main map, it's properly scaled
|
||||
// I hate this place
|
||||
addtimer(CALLBACK(character_preview_view, /atom/movable/screen/map_view/char_preview/proc/update_body), 1 SECONDS)
|
||||
|
||||
/datum/preferences/ui_state(mob/user)
|
||||
return GLOB.always_state
|
||||
@@ -146,13 +151,6 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
/datum/preferences/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
|
||||
if (isnull(character_preview_view))
|
||||
character_preview_view = create_character_preview_view(user)
|
||||
else if (character_preview_view.client != parent)
|
||||
// The client re-logged, and doing this when they log back in doesn't seem to properly
|
||||
// carry emissives.
|
||||
character_preview_view.register_to_client(parent)
|
||||
|
||||
if (tainted_character_profiles)
|
||||
data["character_profiles"] = create_character_profiles()
|
||||
tainted_character_profiles = FALSE
|
||||
@@ -291,9 +289,10 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
return TRUE
|
||||
|
||||
/datum/preferences/proc/create_character_preview_view(mob/user)
|
||||
character_preview_view = new(null, src, user.client)
|
||||
character_preview_view = new(null, src)
|
||||
character_preview_view.generate_view("character_preview_[REF(character_preview_view)]")
|
||||
character_preview_view.update_body()
|
||||
character_preview_view.register_to_client(user.client)
|
||||
character_preview_view.display_to(user)
|
||||
|
||||
return character_preview_view
|
||||
|
||||
@@ -333,62 +332,34 @@ GLOBAL_LIST_EMPTY(preferences_datums)
|
||||
value_cache -= preference.type
|
||||
preference.apply_to_client(parent, read_preference(preference.type))
|
||||
|
||||
// This is necessary because you can open the set preferences menu before
|
||||
// the atoms SS is done loading.
|
||||
INITIALIZE_IMMEDIATE(/atom/movable/screen/character_preview_view)
|
||||
|
||||
/// A preview of a character for use in the preferences menu
|
||||
/atom/movable/screen/character_preview_view
|
||||
/atom/movable/screen/map_view/char_preview
|
||||
name = "character_preview"
|
||||
del_on_map_removal = FALSE
|
||||
layer = GAME_PLANE
|
||||
plane = GAME_PLANE
|
||||
|
||||
/// The body that is displayed
|
||||
var/mob/living/carbon/human/dummy/body
|
||||
|
||||
/// The preferences this refers to
|
||||
var/datum/preferences/preferences
|
||||
|
||||
var/list/plane_masters = list()
|
||||
|
||||
/// The client that is watching this view
|
||||
var/client/client
|
||||
|
||||
/atom/movable/screen/character_preview_view/Initialize(mapload, datum/preferences/preferences, client/client)
|
||||
/atom/movable/screen/map_view/char_preview/Initialize(mapload, datum/preferences/preferences)
|
||||
. = ..()
|
||||
|
||||
assigned_map = "character_preview_[REF(src)]"
|
||||
set_position(1, 1)
|
||||
|
||||
src.preferences = preferences
|
||||
|
||||
/atom/movable/screen/character_preview_view/Destroy()
|
||||
/atom/movable/screen/map_view/char_preview/Destroy()
|
||||
QDEL_NULL(body)
|
||||
|
||||
for (var/plane_master in plane_masters)
|
||||
client?.screen -= plane_master
|
||||
qdel(plane_master)
|
||||
|
||||
client?.clear_map(assigned_map)
|
||||
|
||||
preferences?.character_preview_view = null
|
||||
|
||||
client = null
|
||||
plane_masters = null
|
||||
preferences = null
|
||||
|
||||
return ..()
|
||||
|
||||
/// Updates the currently displayed body
|
||||
/atom/movable/screen/character_preview_view/proc/update_body()
|
||||
/atom/movable/screen/map_view/char_preview/proc/update_body()
|
||||
if (isnull(body))
|
||||
create_body()
|
||||
else
|
||||
body.wipe_state()
|
||||
appearance = preferences.render_new_preview_appearance(body)
|
||||
|
||||
/atom/movable/screen/character_preview_view/proc/create_body()
|
||||
/atom/movable/screen/map_view/char_preview/proc/create_body()
|
||||
QDEL_NULL(body)
|
||||
|
||||
body = new
|
||||
@@ -396,24 +367,6 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/character_preview_view)
|
||||
// Without this, it doesn't show up in the menu
|
||||
body.appearance_flags &= ~KEEP_TOGETHER
|
||||
|
||||
/// Registers the relevant map objects to a client
|
||||
/atom/movable/screen/character_preview_view/proc/register_to_client(client/client)
|
||||
QDEL_LIST(plane_masters)
|
||||
|
||||
src.client = client
|
||||
|
||||
if (!client)
|
||||
return
|
||||
|
||||
for (var/plane_master_type in subtypesof(/atom/movable/screen/plane_master) - /atom/movable/screen/plane_master/blackness)
|
||||
var/atom/movable/screen/plane_master/plane_master = new plane_master_type()
|
||||
plane_master.screen_loc = "[assigned_map]:CENTER"
|
||||
client?.screen |= plane_master
|
||||
|
||||
plane_masters += plane_master
|
||||
|
||||
client?.register_map_obj(src)
|
||||
|
||||
/datum/preferences/proc/create_character_profiles()
|
||||
var/list/profiles = list()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user