From 5955d8e31d951c1773e31d927815370f8884fd2c Mon Sep 17 00:00:00 2001 From: MalorMorfin Date: Fri, 6 Dec 2024 03:07:50 +1000 Subject: [PATCH 1/6] Port parallax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Портировал основное для работы чуть фикшеного параллакса --- code/_onclick/hud/parallax.dm | 213 ++++++++++++++------------ code/modules/client/client_defines.dm | 8 +- code/modules/client/client_procs.dm | 3 + 3 files changed, 124 insertions(+), 100 deletions(-) diff --git a/code/_onclick/hud/parallax.dm b/code/_onclick/hud/parallax.dm index 5a1eaf9f4da..b184d23a1c1 100644 --- a/code/_onclick/hud/parallax.dm +++ b/code/_onclick/hud/parallax.dm @@ -4,6 +4,9 @@ var/client/C = screenmob.client if (!apply_parallax_pref(viewmob)) //don't want shit computers to crash when specing someone with insane parallax, so use the viewer's pref return + if(isnull(C.parallax_rock)) + C.parallax_rock = new(null, src) + C.screen |= C.parallax_rock if(!length(C.parallax_layers_cached)) C.parallax_layers_cached = list() @@ -19,7 +22,7 @@ if (length(C.parallax_layers) > C.parallax_layers_max) C.parallax_layers.len = C.parallax_layers_max - C.screen |= (C.parallax_layers) + C.parallax_rock.vis_contents = C.parallax_layers var/atom/movable/screen/plane_master/PM = screenmob.hud_used.plane_masters["[PLANE_SPACE]"] if(screenmob != mymob) C.screen -= locate(/atom/movable/screen/plane_master/parallax_white) in C.screen @@ -48,15 +51,19 @@ var/mob/screenmob = viewmob || mymob var/client/C = screenmob.client if(C.prefs) - var/pref = C.prefs.parallax - if (isnull(pref)) - pref = PARALLAX_HIGH - switch(C.prefs.parallax) + var/parallax_selection = C?.prefs.parallax || PARALLAX_HIGH + + switch(parallax_selection) if (PARALLAX_INSANE) C.parallax_throttle = FALSE C.parallax_layers_max = 5 return TRUE + if(PARALLAX_HIGH) + C.parallax_throttle = PARALLAX_DELAY_DEFAULT + C.parallax_layers_max = 4 + return TRUE + if (PARALLAX_MED) C.parallax_throttle = PARALLAX_DELAY_MED C.parallax_layers_max = 3 @@ -70,11 +77,6 @@ if (PARALLAX_DISABLE) return FALSE - //This is high parallax. - C.parallax_throttle = PARALLAX_DELAY_DEFAULT - C.parallax_layers_max = 4 - return TRUE - /datum/hud/proc/update_parallax_pref(mob/viewmob) if(is_ground_level(viewmob.z)) return @@ -83,83 +85,65 @@ update_parallax(viewmob) // This sets which way the current shuttle is moving (returns true if the shuttle has stopped moving so the caller can append their animation) -/datum/hud/proc/set_parallax_movedir(new_parallax_movedir, skip_windups, mob/viewmob) +/datum/hud/proc/set_parallax_movedir(new_parallax_movedir = NONE, skip_windups, mob/viewmob) . = FALSE var/mob/screenmob = viewmob || mymob var/client/C = screenmob.client if(new_parallax_movedir == C.parallax_movedir) return - var/animatedir = new_parallax_movedir - if(new_parallax_movedir == FALSE) - var/animate_time = 0 - for(var/thing in C.parallax_layers) - var/atom/movable/screen/parallax_layer/L = thing - L.icon_state = initial(L.icon_state) - L.update_o(C.view) - var/T = PARALLAX_LOOP_TIME / L.speed - if (T > animate_time) - animate_time = T - C.dont_animate_parallax = world.time + min(animate_time, PARALLAX_LOOP_TIME) - animatedir = C.parallax_movedir - - var/matrix/newtransform - switch(animatedir) + + var/animation_dir = new_parallax_movedir || C.parallax_movedir + var/matrix/new_transform + switch(animation_dir) if(NORTH) - newtransform = matrix(1, 0, 0, 0, 1, 480) + new_transform = matrix(1, 0, 0, 0, 1, 480) if(SOUTH) - newtransform = matrix(1, 0, 0, 0, 1,-480) + new_transform = matrix(1, 0, 0, 0, 1,-480) if(EAST) - newtransform = matrix(1, 0, 480, 0, 1, 0) + new_transform = matrix(1, 0, 480, 0, 1, 0) if(WEST) - newtransform = matrix(1, 0,-480, 0, 1, 0) - - var/shortesttimer - if(!skip_windups) - for(var/thing in C.parallax_layers) - var/atom/movable/screen/parallax_layer/L = thing - - var/T = PARALLAX_LOOP_TIME / L.speed - if (isnull(shortesttimer)) - shortesttimer = T - if (T < shortesttimer) - shortesttimer = T - L.transform = newtransform - animate(L, transform = matrix(), time = T, easing = QUAD_EASING | (new_parallax_movedir ? EASE_IN : EASE_OUT), flags = ANIMATION_END_NOW) - if (new_parallax_movedir) - L.transform = newtransform - animate(transform = matrix(), time = T) //queue up another animate so lag doesn't create a shutter + new_transform = matrix(1, 0,-480, 0, 1, 0) + + var/longest_timer = 0 + for(var/key in C.parallax_animate_timers) + deltimer(C.parallax_animate_timers[key]) + C.parallax_animate_timers = list() + for(var/atom/movable/screen/parallax_layer/layer as anything in C.parallax_layers) + var/scaled_time = PARALLAX_LOOP_TIME / layer.speed + if(new_parallax_movedir == NONE) // If we're stopping, we need to stop on the same dime, yeah? + scaled_time = PARALLAX_LOOP_TIME + longest_timer = max(longest_timer, scaled_time) + + if(skip_windups) + update_parallax_motionblur(C, layer, new_parallax_movedir, new_transform) + continue - C.parallax_movedir = new_parallax_movedir - if (C.parallax_animate_timer) - deltimer(C.parallax_animate_timer) - var/datum/callback/CB = CALLBACK(src, PROC_REF(update_parallax_motionblur), C, animatedir, new_parallax_movedir, newtransform) - if(skip_windups || !shortesttimer) //shorttest timer can be null/0 if we don't have any parallax layers (ie the pref is off) - CB.Invoke() - else - C.parallax_animate_timer = addtimer(CB, min(shortesttimer, PARALLAX_LOOP_TIME), TIMER_CLIENT_TIME|TIMER_STOPPABLE) + layer.transform = new_transform + animate(layer, transform = matrix(), time = scaled_time, easing = QUAD_EASING | (new_parallax_movedir ? EASE_IN : EASE_OUT)) + if (new_parallax_movedir == NONE) + continue + //queue up another animate so lag doesn't create a shutter + animate(transform = new_transform, time = 0) + animate(transform = matrix(), time = scaled_time / 2) + C.parallax_animate_timers[layer] = addtimer(CALLBACK(src, PROC_REF(update_parallax_motionblur), C, layer, new_parallax_movedir, new_transform), scaled_time, TIMER_CLIENT_TIME|TIMER_STOPPABLE) + C.dont_animate_parallax = world.time + min(longest_timer, PARALLAX_LOOP_TIME) + C.parallax_movedir = new_parallax_movedir -/datum/hud/proc/update_parallax_motionblur(client/C, animatedir, new_parallax_movedir, matrix/newtransform) +/datum/hud/proc/update_parallax_motionblur(client/C, atom/movable/screen/parallax_layer/layer, new_parallax_movedir, matrix/new_transform) if(!C) return - C.parallax_animate_timer = FALSE - for(var/thing in C.parallax_layers) - var/atom/movable/screen/parallax_layer/L = thing - if (!new_parallax_movedir) - animate(L) - continue - - var/newstate = initial(L.icon_state) - var/T = PARALLAX_LOOP_TIME / L.speed - - if (newstate in icon_states(L.icon)) - L.icon_state = newstate - L.update_o(C.view) - - L.transform = newtransform - - animate(L, transform = matrix(), time = T, loop = -1, flags = ANIMATION_END_NOW) - animate(transform = matrix(), time = T) + C.parallax_animate_timers -= layer + + // If we are moving in a direction, we used the QUAD_EASING function with EASE_IN + // This means our position function is x^2. This is always LESS then the linear we're using here + // But if we just used the same time delay, our rate of change would mismatch. f'(1) = 2x for quad easing, rather then the 1 we get for linear + // (This is because of how derivatives work right?) + // Because of this, while our actual rate of change from before was PARALLAX_LOOP_TIME, our perceived rate of change was PARALLAX_LOOP_TIME / 2 (lower == faster). + // Let's account for that here + var/scaled_time = (PARALLAX_LOOP_TIME / layer.speed) / 2 + animate(layer, transform = new_transform, time = 0, loop = -1, flags = ANIMATION_END_NOW) + animate(transform = matrix(), time = scaled_time) /datum/hud/proc/update_parallax(mob/viewmob) var/mob/screenmob = viewmob || mymob @@ -167,19 +151,16 @@ var/turf/posobj = get_turf(C.eye) if(!posobj) return - var/area/areaobj = posobj.loc + var/area/areaobj = posobj.loc // Update the movement direction of the parallax if necessary (for shuttles) set_parallax_movedir(areaobj.parallax_movedir, FALSE, screenmob) - var/force + var/force = FALSE if(!C.previous_turf || (C.previous_turf.z != posobj.z)) C.previous_turf = posobj force = TRUE - if (!force && world.time < C.last_parallax_shift+C.parallax_throttle) - return - //Doing it this way prevents parallax layers from "jumping" when you change Z-Levels. var/offset_x = posobj.x - C.previous_turf.x var/offset_y = posobj.y - C.previous_turf.y @@ -187,33 +168,54 @@ if(!offset_x && !offset_y && !force) return - var/last_delay = world.time - C.last_parallax_shift - last_delay = min(last_delay, C.parallax_throttle) + var/glide_rate = round(world.icon_size / screenmob.glide_size * world.tick_lag, world.tick_lag) C.previous_turf = posobj - C.last_parallax_shift = world.time - for(var/atom/movable/screen/parallax_layer/parallax_layer as anything in C.parallax_layers) - parallax_layer.update_status(screenmob) - if (parallax_layer.view_sized != C.view) - parallax_layer.update_o(C.view) + var/largest_change = max(abs(offset_x), abs(offset_y)) + var/max_allowed_dist = (glide_rate / world.tick_lag) + 1 + // If we aren't already moving/don't allow parallax, have made some movement, and that movement was smaller then our "glide" size, animate + var/run_parralax = (C.do_parallax_animations && glide_rate && !areaobj.parallax_movedir && C.dont_animate_parallax <= world.time && largest_change <= max_allowed_dist) + for(var/atom/movable/screen/parallax_layer/parallax_layer as anything in C.parallax_layers) + var/our_speed = parallax_layer.speed + var/change_x + var/change_y + var/old_x = parallax_layer.offset_x + var/old_y = parallax_layer.offset_y if(parallax_layer.absolute) - parallax_layer.offset_x = -(posobj.x - SSparallax.planet_x_offset) * parallax_layer.speed - parallax_layer.offset_y = -(posobj.y - SSparallax.planet_y_offset) * parallax_layer.speed + // We use change here so the typically large absolute objects (just lavaland for now) don't jitter so much + change_x = (posobj.x - SSparallax.planet_x_offset) * our_speed + old_x + change_y = (posobj.y - SSparallax.planet_y_offset) * our_speed + old_y else - parallax_layer.offset_x -= offset_x * parallax_layer.speed - parallax_layer.offset_y -= offset_y * parallax_layer.speed + change_x = offset_x * our_speed + change_y = offset_y * our_speed - if(parallax_layer.offset_x > 240) + // This is how we tile parralax sprites + // It doesn't use change because we really don't want to animate this + if(old_x - change_x > 240) parallax_layer.offset_x -= 480 - if(parallax_layer.offset_x < -240) + parallax_layer.pixel_w = parallax_layer.offset_x + else if(old_x - change_x < -240) parallax_layer.offset_x += 480 - if(parallax_layer.offset_y > 240) + parallax_layer.pixel_w = parallax_layer.offset_x + if(old_y - change_y > 240) parallax_layer.offset_y -= 480 - if(parallax_layer.offset_y < -240) + parallax_layer.pixel_z = parallax_layer.offset_y + else if(old_y - change_y < -240) parallax_layer.offset_y += 480 + parallax_layer.pixel_z = parallax_layer.offset_y + + parallax_layer.offset_x -= change_x + parallax_layer.offset_y -= change_y + // Now that we have our offsets, let's do our positioning + // We're going to use an animate to "glide" that last movement out, so it looks nicer + // Don't do any animates if we're not actually moving enough distance yeah? thanks lad + if(run_parralax && (largest_change * our_speed > 1)) + animate(parallax_layer, pixel_w = round(parallax_layer.offset_x, 1), pixel_z = round(parallax_layer.offset_y, 1), time = glide_rate) + else + parallax_layer.pixel_w = round(parallax_layer.offset_x, 1) + parallax_layer.pixel_z = round(parallax_layer.offset_y, 1) - parallax_layer.screen_loc = "CENTER-7:[round(parallax_layer.offset_x,1)],CENTER-7:[round(parallax_layer.offset_y,1)]" /atom/movable/proc/update_parallax_contents() for(var/mob/client_mob as anything in client_mobs_in_contents) @@ -225,6 +227,15 @@ var/area/areaobj = get_area(client.eye) hud_used.set_parallax_movedir(areaobj.parallax_movedir, TRUE) +// Root object for parallax, all parallax layers are drawn onto this +INITIALIZE_IMMEDIATE(/atom/movable/screen/parallax_home) +/atom/movable/screen/parallax_home + icon = null + blend_mode = BLEND_ADD + plane = PLANE_SPACE_PARALLAX + screen_loc = "CENTER-7,CENTER-7" + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + /atom/movable/screen/parallax_layer icon = 'icons/effects/parallax.dmi' var/speed = 1 @@ -232,9 +243,9 @@ var/offset_y = 0 var/view_sized var/absolute = FALSE + appearance_flags = APPEARANCE_UI | KEEP_TOGETHER blend_mode = BLEND_ADD plane = PLANE_SPACE_PARALLAX - screen_loc = "CENTER-7,CENTER-7" mouse_opacity = MOUSE_OPACITY_TRANSPARENT @@ -248,20 +259,24 @@ if (!view) view = world.view + var/static/parallax_scaler = world.icon_size / 480 + + // Turn the view size into a grid of correctly scaled overlays var/list/viewscales = getviewsize(view) - var/countx = CEILING((viewscales[1] * 0.5) / (480 / world.icon_size), 1) + 1 - var/county = CEILING((viewscales[2] * 0.5) / (480 / world.icon_size), 1) + 1 + // This could be half the size but we need to provide space for parallax movement on mob movement, and movement on scroll from shuttles, so like this instead + var/countx = (CEILING((viewscales[1] / 2) * parallax_scaler, 1) + 1) + var/county = (CEILING((viewscales[2] / 2) * parallax_scaler, 1) + 1) var/list/new_overlays = new for(var/x in -countx to countx) for(var/y in -county to county) if(x == 0 && y == 0) continue var/mutable_appearance/texture_overlay = mutable_appearance(icon, icon_state) - texture_overlay.transform = matrix(1, 0, x*480, 0, 1, y*480) + texture_overlay.pixel_w += 480 * x + texture_overlay.pixel_z += 480 * y new_overlays += texture_overlay cut_overlays() add_overlay(new_overlays) - view_sized = view /atom/movable/screen/parallax_layer/proc/update_status(mob/M) return diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm index afb2c3381cb..305c69730c3 100644 --- a/code/modules/client/client_defines.dm +++ b/code/modules/client/client_defines.dm @@ -100,6 +100,7 @@ var/list/parallax_layers var/list/parallax_layers_cached + var/atom/movable/screen/parallax_home/parallax_rock var/atom/movable/movingmob var/turf/previous_turf ///world.time of when we can state animate()ing parallax again @@ -110,7 +111,10 @@ var/parallax_throttle = 0 var/parallax_movedir = 0 var/parallax_layers_max = 4 - var/parallax_animate_timer + /// Timers for the area directional animation, one for each layer + var/list/parallax_animate_timers + + var/do_parallax_animations = TRUE var/datum/db_query/clan_info @@ -139,3 +143,5 @@ /// The direction we WANT to move, based off our keybinds /// Will be udpated to be the actual direction later on var/intended_direction = NONE + + diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index a188beb687f..c795f977f0b 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -420,6 +420,9 @@ QDEL_LIST_ASSOC_VAL(char_render_holders) SSping.currentrun -= src QDEL_NULL(tooltips) + QDEL_NULL(parallax_rock) + QDEL_LIST(parallax_layers_cached) + parallax_layers = null Master.UpdateTickRate() SSambience.ambience_listening_clients -= src ..() //Even though we're going to be hard deleted there are still some things like signals that want to know the destroy is happening From eb4b4ed988c6aa480fe879ceb2f16eaa2ab919fd Mon Sep 17 00:00:00 2001 From: MalorMorfin Date: Fri, 6 Dec 2024 03:45:46 +1000 Subject: [PATCH 2/6] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BB=D0=B0=D0=BA=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/modules/mob/dead/observer/observer.dm | 3 --- code/modules/shuttle/on_move.dm | 2 -- 2 files changed, 5 deletions(-) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index ec4b8235c5f..4c498312334 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -306,7 +306,6 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER) set_glide_size(glide_size_override) if(newloc) abstract_move(newloc) - update_parallax_contents() else abstract_move(get_turf(src)) //Get out of closets and such as a ghost if((direct & NORTH) && y < world.maxy) @@ -432,8 +431,6 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER) return abstract_move(pick(get_area_turfs(A))) - update_parallax_contents() - /mob/dead/observer/verb/follow_ghost() set category = "Ghost" diff --git a/code/modules/shuttle/on_move.dm b/code/modules/shuttle/on_move.dm index e2e48ad8d80..315189f1cc9 100644 --- a/code/modules/shuttle/on_move.dm +++ b/code/modules/shuttle/on_move.dm @@ -117,8 +117,6 @@ All ShuttleMove procs go here if(rotation) shuttleRotate(rotation) - update_parallax_contents() - return TRUE /atom/movable/proc/lateShuttleMove(turf/oldT, list/movement_force, move_dir) From 3e84f4573c47c24fb383628e8130a83ee967033e Mon Sep 17 00:00:00 2001 From: MalorMorfin Date: Fri, 6 Dec 2024 04:20:49 +1000 Subject: [PATCH 3/6] clean var MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit почистил лишние... --- code/__DEFINES/preferences.dm | 4 ---- code/_onclick/hud/parallax.dm | 9 ++++----- code/modules/client/client_defines.dm | 5 ----- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/code/__DEFINES/preferences.dm b/code/__DEFINES/preferences.dm index b9943fbb4ff..76746e3d27a 100644 --- a/code/__DEFINES/preferences.dm +++ b/code/__DEFINES/preferences.dm @@ -92,10 +92,6 @@ #define PARALLAX_LOW 2 #define PARALLAX_DISABLE 3 //this option must be the highest number -#define PARALLAX_DELAY_DEFAULT world.tick_lag -#define PARALLAX_DELAY_MED 1 -#define PARALLAX_DELAY_LOW 2 - #define PIXEL_SCALING_AUTO 0 #define PIXEL_SCALING_1X 1 #define PIXEL_SCALING_1_2X 1.5 diff --git a/code/_onclick/hud/parallax.dm b/code/_onclick/hud/parallax.dm index b184d23a1c1..d0e248c5b4a 100644 --- a/code/_onclick/hud/parallax.dm +++ b/code/_onclick/hud/parallax.dm @@ -55,22 +55,22 @@ switch(parallax_selection) if (PARALLAX_INSANE) - C.parallax_throttle = FALSE + C.do_parallax_animations = TRUE C.parallax_layers_max = 5 return TRUE if(PARALLAX_HIGH) - C.parallax_throttle = PARALLAX_DELAY_DEFAULT + C.do_parallax_animations = TRUE C.parallax_layers_max = 4 return TRUE if (PARALLAX_MED) - C.parallax_throttle = PARALLAX_DELAY_MED + C.do_parallax_animations = TRUE C.parallax_layers_max = 3 return TRUE if (PARALLAX_LOW) - C.parallax_throttle = PARALLAX_DELAY_LOW + C.do_parallax_animations = FALSE C.parallax_layers_max = 1 return TRUE @@ -216,7 +216,6 @@ parallax_layer.pixel_w = round(parallax_layer.offset_x, 1) parallax_layer.pixel_z = round(parallax_layer.offset_y, 1) - /atom/movable/proc/update_parallax_contents() for(var/mob/client_mob as anything in client_mobs_in_contents) if(length(client_mob?.client?.parallax_layers) && client_mob.hud_used) diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm index 305c69730c3..a39f0e1138d 100644 --- a/code/modules/client/client_defines.dm +++ b/code/modules/client/client_defines.dm @@ -106,9 +106,6 @@ ///world.time of when we can state animate()ing parallax again var/dont_animate_parallax ///world.time of last parallax update - var/last_parallax_shift - ///ds between parallax updates - var/parallax_throttle = 0 var/parallax_movedir = 0 var/parallax_layers_max = 4 /// Timers for the area directional animation, one for each layer @@ -143,5 +140,3 @@ /// The direction we WANT to move, based off our keybinds /// Will be udpated to be the actual direction later on var/intended_direction = NONE - - From 05416725e4b3c8612740ca510929db4b4c4386b1 Mon Sep 17 00:00:00 2001 From: MalorMorfin Date: Sat, 7 Dec 2024 01:48:05 +1000 Subject: [PATCH 4/6] /2 is *0.5 now --- code/_onclick/hud/parallax.dm | 8 ++++---- code/modules/client/client_defines.dm | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/code/_onclick/hud/parallax.dm b/code/_onclick/hud/parallax.dm index d0e248c5b4a..a9b43ee783b 100644 --- a/code/_onclick/hud/parallax.dm +++ b/code/_onclick/hud/parallax.dm @@ -124,7 +124,7 @@ continue //queue up another animate so lag doesn't create a shutter animate(transform = new_transform, time = 0) - animate(transform = matrix(), time = scaled_time / 2) + animate(transform = matrix(), time = scaled_time * 0.5) C.parallax_animate_timers[layer] = addtimer(CALLBACK(src, PROC_REF(update_parallax_motionblur), C, layer, new_parallax_movedir, new_transform), scaled_time, TIMER_CLIENT_TIME|TIMER_STOPPABLE) C.dont_animate_parallax = world.time + min(longest_timer, PARALLAX_LOOP_TIME) @@ -141,7 +141,7 @@ // (This is because of how derivatives work right?) // Because of this, while our actual rate of change from before was PARALLAX_LOOP_TIME, our perceived rate of change was PARALLAX_LOOP_TIME / 2 (lower == faster). // Let's account for that here - var/scaled_time = (PARALLAX_LOOP_TIME / layer.speed) / 2 + var/scaled_time = (PARALLAX_LOOP_TIME / layer.speed) * 0.5 animate(layer, transform = new_transform, time = 0, loop = -1, flags = ANIMATION_END_NOW) animate(transform = matrix(), time = scaled_time) @@ -263,8 +263,8 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/parallax_home) // Turn the view size into a grid of correctly scaled overlays var/list/viewscales = getviewsize(view) // This could be half the size but we need to provide space for parallax movement on mob movement, and movement on scroll from shuttles, so like this instead - var/countx = (CEILING((viewscales[1] / 2) * parallax_scaler, 1) + 1) - var/county = (CEILING((viewscales[2] / 2) * parallax_scaler, 1) + 1) + var/countx = (CEILING((viewscales[1] * 0.5) * parallax_scaler, 1) + 1) + var/county = (CEILING((viewscales[2] * 0.5) * parallax_scaler, 1) + 1) var/list/new_overlays = new for(var/x in -countx to countx) for(var/y in -county to county) diff --git a/code/modules/client/client_defines.dm b/code/modules/client/client_defines.dm index a39f0e1138d..3a4e25b1664 100644 --- a/code/modules/client/client_defines.dm +++ b/code/modules/client/client_defines.dm @@ -105,12 +105,12 @@ var/turf/previous_turf ///world.time of when we can state animate()ing parallax again var/dont_animate_parallax - ///world.time of last parallax update var/parallax_movedir = 0 var/parallax_layers_max = 4 /// Timers for the area directional animation, one for each layer var/list/parallax_animate_timers - + /// Do we want to do parallax animations at all? + /// Exists to prevent laptop fires var/do_parallax_animations = TRUE var/datum/db_query/clan_info From 20a2054822ac756c48098b774b42ca75062ca34b Mon Sep 17 00:00:00 2001 From: MalorMorfin Date: Sat, 7 Dec 2024 20:26:55 +1000 Subject: [PATCH 5/6] review fix --- code/_onclick/hud/parallax.dm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/code/_onclick/hud/parallax.dm b/code/_onclick/hud/parallax.dm index a9b43ee783b..ac54e4f48cc 100644 --- a/code/_onclick/hud/parallax.dm +++ b/code/_onclick/hud/parallax.dm @@ -35,11 +35,10 @@ 0, 0, 0, 0 ) - /datum/hud/proc/remove_parallax(mob/viewmob) var/mob/screenmob = viewmob || mymob var/client/C = screenmob.client - C.screen -= (C.parallax_layers_cached) + C.screen -= (C.parallax_rock) var/atom/movable/screen/plane_master/PM = screenmob.hud_used.plane_masters["[PLANE_SPACE]"] if(screenmob != mymob) C.screen -= locate(/atom/movable/screen/plane_master/parallax_white) in C.screen @@ -237,16 +236,15 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/parallax_home) /atom/movable/screen/parallax_layer icon = 'icons/effects/parallax.dmi' + appearance_flags = APPEARANCE_UI | KEEP_TOGETHER + blend_mode = BLEND_ADD + plane = PLANE_SPACE_PARALLAX + mouse_opacity = MOUSE_OPACITY_TRANSPARENT var/speed = 1 var/offset_x = 0 var/offset_y = 0 var/view_sized var/absolute = FALSE - appearance_flags = APPEARANCE_UI | KEEP_TOGETHER - blend_mode = BLEND_ADD - plane = PLANE_SPACE_PARALLAX - mouse_opacity = MOUSE_OPACITY_TRANSPARENT - /atom/movable/screen/parallax_layer/Initialize(mapload, datum/hud/hud_owner, view) . = ..() From 27ddd8e8cb24c329ae6048906593af80445d9865 Mon Sep 17 00:00:00 2001 From: MalorMorfin Date: Mon, 9 Dec 2024 02:42:47 +1000 Subject: [PATCH 6/6] Planet don't move in shuttle --- code/_onclick/hud/parallax.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/_onclick/hud/parallax.dm b/code/_onclick/hud/parallax.dm index ac54e4f48cc..581e8df8b26 100644 --- a/code/_onclick/hud/parallax.dm +++ b/code/_onclick/hud/parallax.dm @@ -113,6 +113,9 @@ scaled_time = PARALLAX_LOOP_TIME longest_timer = max(longest_timer, scaled_time) + if(layer.absolute) + break + if(skip_windups) update_parallax_motionblur(C, layer, new_parallax_movedir, new_transform) continue