Skip to content

Commit

Permalink
Three player rendering fixes (#4068)
Browse files Browse the repository at this point in the history
* Resize human_face.dmi from 32x48 to 32x32

* Fix spin dancing breaking the dancer's transform (shrinking giants)

* Fix layer issue with Floran / Pod People hair

* dumbass

* fix integration test runtime

* Fix bad crop which was breaking long hairstyles

* midway

* Improve bad icon check and resize some moth icons

* remove testing check

* Documentation

* Turn off delayed height filters in the preferences window

* wow I can't read
  • Loading branch information
Sorenon authored Nov 6, 2024
1 parent d997d2e commit 141abee
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 10 deletions.
7 changes: 5 additions & 2 deletions code/game/machinery/dance_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,11 @@
M.lying_fix()

/mob/living/proc/lying_fix()
animate(src, transform = null, time = 1, loop = 0)
lying_prev = 0
//MONKESTATION EDIT START : Fixes this breaking the mob's size
// animate(src, transform = null, time = 1, loop = 0) - original
// lying_prev = 0 - original
rebuild_transform()
//MONKESTATION EDIT END

/obj/machinery/jukebox/proc/dance_over()
for(var/mob/living/L in rangers)
Expand Down
6 changes: 6 additions & 0 deletions code/modules/mob/living/carbon/human/dummy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ INITIALIZE_IMMEDIATE(/mob/living/carbon/human/dummy)
harvest_organs()
return ..()

/*
MONKESTATION EDIT START
This causes a problem with tall players as some of their overlays will go outside of the 32x32 range which the mob's icon is restricted to
// To speed up the preference menu, we apply 1 filter to the entire mob
/mob/living/carbon/human/dummy/regenerate_icons()
. = ..()
Expand All @@ -35,6 +38,9 @@ INITIALIZE_IMMEDIATE(/mob/living/carbon/human/dummy)
/mob/living/carbon/human/dummy/apply_height_offsets(image/appearance, upper_torso)
return
MONKESTATION EDIT END
*/

///Let's extract our dummies organs and limbs for storage, to reduce the cache missed that spamming a dummy cause
/mob/living/carbon/human/dummy/proc/harvest_organs()
for(var/slot in list(ORGAN_SLOT_BRAIN, ORGAN_SLOT_HEART, ORGAN_SLOT_LUNGS, ORGAN_SLOT_APPENDIX, \
Expand Down
23 changes: 19 additions & 4 deletions code/modules/mob/living/carbon/human/human_update_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -914,10 +914,25 @@ generate/load female uniform sprites matching all previously decided variables
* Applies a filter to an appearance according to mob height
*/
/mob/living/carbon/human/proc/apply_height_filters(image/appearance, only_apply_in_prefs = FALSE)
var/static/icon/cut_torso_mask = icon('icons/effects/cut.dmi', "Cut1")
var/static/icon/cut_legs_mask = icon('icons/effects/cut.dmi', "Cut2")
var/static/icon/lenghten_torso_mask = icon('icons/effects/cut.dmi', "Cut3")
var/static/icon/lenghten_legs_mask = icon('icons/effects/cut.dmi', "Cut4")
//MONKESTATION EDIT START : Pick a displacement mask depending on the height of the icon, 32x48 icons are used for features which would otherwise get clipped when tall players use them
var/dims = get_icon_dimensions(appearance.icon)
var/icon_width = dims["width"]
var/icon_height = dims["height"]

var/mask_icon = 'icons/effects/cut.dmi'
if(icon_width != 0 && icon_height != 0)
if(icon_width != 32)
throw EXCEPTION("Bad dimensions ([icon_width]x[icon_height]) for icon '[appearance.icon]'")
if(icon_height == 48)
mask_icon = 'monkestation/icons/effects/cut_32x48.dmi'
else if(icon_height != 32)
throw EXCEPTION("Bad dimensions ([icon_width]x[icon_height]) for icon '[appearance.icon]'")

var/icon/cut_torso_mask = icon(mask_icon, "Cut1")
var/icon/cut_legs_mask = icon(mask_icon, "Cut2")
var/icon/lenghten_torso_mask = icon(mask_icon, "Cut3")
var/icon/lenghten_legs_mask = icon(mask_icon, "Cut4")
//MONKESTATION EDIT END

appearance.remove_filter(list(
"Cut_Torso",
Expand Down
3 changes: 2 additions & 1 deletion code/modules/surgery/organs/external/_external_organs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@

///Podperson bodypart overlay, with special coloring functionality to render the flowers in the inverse color
/datum/bodypart_overlay/mutant/pod_hair
layers = EXTERNAL_FRONT|EXTERNAL_ADJACENT
// layers = EXTERNAL_FRONT|EXTERNAL_ADJACENT monkestation edit - original
layers = EXTERNAL_FRONT
feature_key = "pod_hair"

///This layer will be colored differently than the rest of the organ. So we can get differently colored flowers or something
Expand Down
Binary file modified icons/mob/species/moth/moth_antennae.dmi
Binary file not shown.
Binary file modified icons/mob/species/moth/moth_markings.dmi
Binary file not shown.
7 changes: 4 additions & 3 deletions monkestation/code/modules/cybernetics/elements/dancing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@
final_pixel_y += living_target.body_position_pixel_y_offset
animate(target, pixel_y = final_pixel_y, time = 0.5 SECONDS)

/datum/dance/head_spin/trigger_dance(mob/living/target)
/datum/dance/head_spin/trigger_dance(mob/living/target, start=TRUE)
ADD_TRAIT(target, TRAIT_IMMOBILIZED, type)
animate(target, transform = matrix(180, MATRIX_ROTATE), time = 1, loop = 0)
var/matrix/initial_matrix = matrix(target.transform)
if(start)
animate(target, transform = initial_matrix * matrix(180, MATRIX_ROTATE), time = 1, loop = 0)
for (var/i in 1 to 60)
if (!target)
return
Expand Down Expand Up @@ -177,7 +178,7 @@
target.lying_fix()

/datum/dance/head_spin/proc/restart_dance(mob/target)
INVOKE_ASYNC(src, PROC_REF(trigger_dance), target)
INVOKE_ASYNC(src, PROC_REF(trigger_dance), target, FALSE)

/datum/dance/head_spin/end_dance(mob/target)
continues = FALSE
Expand Down
41 changes: 41 additions & 0 deletions monkestation/code/modules/mob/living/living_update_icons.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Used to restore the mob's transform when it is in an undefined state
* If the mob's transform is not messed up just use update_transform()
*/
/mob/living/proc/rebuild_transform()
var/matrix/ntransform = matrix()

/**
* pixel x/y/w/z all discard values after the decimal separator.
* That, coupled with the rendered interpolation, may make the
* icons look awfuller than they already are, or not, whatever.
* The solution to this nit is translating the missing decimals.
* also flooring increases the distance from 0 for negative numbers.
*/
var/abs_pixel_y_offset = 0

if(lying_angle && rotate_on_lying)
ntransform.Turn(lying_angle)

if(current_size != RESIZE_DEFAULT_SIZE)
ntransform.Scale(current_size)

//Update final_pixel_y so our mob doesn't go out of the southern bounds of the tile when standing
if(!lying_angle || !rotate_on_lying) //But not if the mob has been rotated.
//Make sure the body position y offset is also updated
body_position_pixel_y_offset = get_pixel_y_offset_standing(current_size)
abs_pixel_y_offset = abs(body_position_pixel_y_offset)
var/new_translate = (abs_pixel_y_offset - round(abs_pixel_y_offset)) * SIGN(body_position_pixel_y_offset)
if(new_translate)
ntransform.Translate(0, new_translate)

//Update the height of the maptext according to the size of the mob so they don't overlap.
var/old_maptext_offset = body_maptext_height_offset
body_maptext_height_offset = initial(maptext_height) * (current_size - 1) * 0.5
maptext_height += body_maptext_height_offset - old_maptext_offset

var/pixel_y = base_pixel_y + body_position_pixel_y_offset

SEND_SIGNAL(src, COMSIG_PAUSE_FLOATING_ANIM, 0.3 SECONDS)
animate(src, transform = ntransform, time = 0, pixel_y = pixel_y, dir = dir, easing = NONE)
SEND_SIGNAL(src, COMSIG_LIVING_POST_UPDATE_TRANSFORM, TRUE, lying_angle, TRUE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/datum/bodypart_overlay/mutant/pod_hair/get_overlay(layer, obj/item/bodypart/limb)
layer = -HAIR_LAYER
var/mutable_appearance/MA = mutable_appearance(layer = layer)
for(var/image_layer in list(-BODY_ADJ_LAYER, -BODY_FRONT_LAYER))
var/mutable_appearance/returned = get_image(image_layer, limb)
color_image(returned, image_layer, limb)
MA.overlays += returned
return MA

/datum/bodypart_overlay/mutant/pod_hair/get_image(image_layer, obj/item/bodypart/limb)
if(!sprite_datum)
CRASH("Trying to call get_image() on [type] while it didn't have a sprite_datum. This shouldn't happen, report it as soon as possible.")

var/list/icon_state_builder = list()
icon_state_builder += "m" //Male is default because sprite accessories are so ancient they predate the concept of not hardcoding gender
icon_state_builder += feature_key
icon_state_builder += get_base_icon_state()
icon_state_builder += mutant_bodyparts_layertext(image_layer)

var/icon = sprite_datum.icon
var/finished_icon_state = icon_state_builder.Join("_")

if(image_layer == -BODY_ADJ_LAYER && istype(limb, /obj/item/bodypart/head/floran))
icon = 'monkestation/icons/mob/species/floran/floran_hair.dmi'
finished_icon_state = get_base_icon_state()

var/mutable_appearance/appearance = mutable_appearance(icon, finished_icon_state, layer = -HAIR_LAYER)

if(sprite_datum.center)
center_image(appearance, sprite_datum.dimension_x, sprite_datum.dimension_y)

return appearance
Binary file added monkestation/icons/effects/cut_32x48.dmi
Binary file not shown.
Binary file not shown.
Binary file modified monkestation/icons/mob/species/tundramoths/moth_antennae.dmi
Binary file not shown.
Binary file modified monkestation/icons/mob/species/tundramoths/moth_markings.dmi
Binary file not shown.
2 changes: 2 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -7378,6 +7378,7 @@
#include "monkestation\code\modules\mob\living\init_signals.dm"
#include "monkestation\code\modules\mob\living\living_defines.dm"
#include "monkestation\code\modules\mob\living\living_movement.dm"
#include "monkestation\code\modules\mob\living\living_update_icons.dm"
#include "monkestation\code\modules\mob\living\status_procs.dm"
#include "monkestation\code\modules\mob\living\basic\animatronic.dm"
#include "monkestation\code\modules\mob\living\basic\bots\medbot\medbot.dm"
Expand Down Expand Up @@ -8025,6 +8026,7 @@
#include "monkestation\code\modules\surgery\bodyparts\teratoma_bodyparts.dm"
#include "monkestation\code\modules\surgery\organs\augments.dm"
#include "monkestation\code\modules\surgery\organs\autosurgeon.dm"
#include "monkestation\code\modules\surgery\organs\external\_external_organs.dm"
#include "monkestation\code\modules\surgery\organs\external\anime.dm"
#include "monkestation\code\modules\surgery\organs\external\ethereal_accessories.dm"
#include "monkestation\code\modules\surgery\organs\external\floran_accessories.dm"
Expand Down

0 comments on commit 141abee

Please sign in to comment.