Icon smooth refactor (#52864)

bitflag list construct added: an associative list of bitflags for cheap and quick element comparison between two lists using the same system.

    canSmoothWith list turned into a bitflag list.

    smoothing_groups list added to substitute the type path list.

    smoothing procs turned into atom procs, refactored and optimized a bit.

    smooth directions redefined in order to fit in 8 bits for a future smoothing system

    some variable names changed, foreseeing a second smoothing system

    SMOOTH_OBJ flag added, for things that need to scan turfs for smoothing. The old locate() optimization has the risk of returning false negatives by finding a child and returning null while there might be one of the wanted type as well, as it doesn't match the type exactly.

    SMOOTH_TRUE and SMOOTH_MORE condensed into SMOOTH_CORNERS. The old behavior can be replicated using smoothing groups without loss.

    Does very minor code cleanup.

    Processing-wise didn't find a noticeable difference. The system loses on init a bit by setting the bitflag_lists, and by scanning whole turf contents for object smoothing (increasing accuracy), and gains by making less checks per target to smooth, through the same bitflag_lists.

    Memory-wise there should be a small improvement, given that on the old system we had 63512 canSmoothWith lists (a few typelists, most unique), and on this new system canSmoothWith + smoothing_groups are both bitflag_lists from the same pool, totaling 46 in number.

Could be tested a bit to see if I missed any icons not properly smoothing.
This commit is contained in:
Rohesie
2020-08-13 14:03:49 +12:00
committed by GitHub
parent 951e41efa0
commit b0726e032b
37 changed files with 572 additions and 352 deletions
+1 -1
View File
@@ -105,7 +105,7 @@
icon = 'icons/turf/floors/carpet.dmi'
icon_state = "carpet"
floor_tile = /obj/item/stack/tile/carpet
smoothing_flags = SMOOTH_TRUE
smoothing_flags = SMOOTH_CORNERS
canSmoothWith = null
bullet_bounce_sound = null
tiled_dirt = FALSE
@@ -87,8 +87,9 @@
name = "pod window"
icon = 'icons/obj/smooth_structures/pod_window.dmi'
icon_state = "smooth"
smoothing_flags = SMOOTH_MORE
canSmoothWith = list(/turf/closed/wall/mineral/titanium/survival, /obj/machinery/door/airlock/survival_pod, /obj/structure/window/shuttle/survival_pod)
smoothing_flags = SMOOTH_CORNERS
smoothing_groups = list(SMOOTH_GROUP_SHUTTLE_PARTS, SMOOTH_GROUP_SURVIVAL_TIANIUM_POD)
canSmoothWith = list(SMOOTH_GROUP_SURVIVAL_TIANIUM_POD)
/obj/structure/window/shuttle/survival_pod/spawner/north
dir = NORTH
@@ -519,7 +519,7 @@ Difficulty: Hard
icon_state = "wall"
light_range = MINIMUM_USEFUL_LIGHT_RANGE
duration = 100
smoothing_flags = SMOOTH_TRUE
smoothing_flags = SMOOTH_CORNERS
/obj/effect/temp_visual/hierophant/wall/Initialize(mapload, new_caster)
. = ..()
@@ -304,7 +304,7 @@ While using this makes the system rely on OnFire, it still gives options for tim
icon = 'icons/turf/walls/hierophant_wall_temp.dmi'
icon_state = "wall"
duration = 50
smoothing_flags = SMOOTH_TRUE
smoothing_flags = SMOOTH_CORNERS
layer = BELOW_MOB_LAYER
color = rgb(255,0,0)
light_range = MINIMUM_USEFUL_LIGHT_RANGE
@@ -14,11 +14,11 @@
icon = 'icons/effects/spacevines.dmi'
icon_state = "flower_bud"
layer = SPACEVINE_MOB_LAYER
opacity = 0
canSmoothWith = list()
opacity = FALSE
canSmoothWith = null
smoothing_flags = NONE
/// The amount of time it takes to create a venus human trap, in deciseconds
var/growth_time = 1200
/// The amount of time it takes to create a venus human trap.
var/growth_time = 120 SECONDS
/obj/structure/alien/resin/flower_bud_enemy/Initialize()
. = ..()
@@ -198,7 +198,8 @@ GLOBAL_VAR_INIT(hhmysteryRoomNumber, 1337)
name = "hotel wall"
desc = "A wall designed to protect the security of the hotel's guests."
icon_state = "hotelwall"
canSmoothWith = list(/turf/closed/indestructible/hotelwall)
smoothing_groups = list(SMOOTH_GROUP_CLOSED_TURFS, SMOOTH_GROUP_HOTEL_WALLS)
canSmoothWith = list(SMOOTH_GROUP_HOTEL_WALLS)
explosion_block = INFINITY
/turf/open/indestructible/hotelwood