mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-17 05:31:53 +00:00
Simplify skybox parallax code and add support for scaling for larger client.view sizes.
- Hooked up skybox to recalculate it's scaling when the view changes. - Added constant defines to clarify where the magic numbers are coming from.
This commit is contained in:
@@ -270,6 +270,7 @@
|
|||||||
|
|
||||||
#define WORLD_ICON_SIZE 32 //Needed for the R-UST port
|
#define WORLD_ICON_SIZE 32 //Needed for the R-UST port
|
||||||
#define PIXEL_MULTIPLIER WORLD_ICON_SIZE/32 //Needed for the R-UST port
|
#define PIXEL_MULTIPLIER WORLD_ICON_SIZE/32 //Needed for the R-UST port
|
||||||
|
#define MAX_CLIENT_VIEW 34 // Maximum effective value of client.view (According to DM references)
|
||||||
|
|
||||||
// Maploader bounds indices
|
// Maploader bounds indices
|
||||||
#define MAP_MINX 1
|
#define MAP_MINX 1
|
||||||
|
|||||||
@@ -1,19 +1,34 @@
|
|||||||
|
#define SKYBOX_PADDING 4 // How much larger we want the skybox image to be than client's screen (in turfs)
|
||||||
|
#define SKYBOX_PIXELS 736 // Size of skybox image in pixels
|
||||||
|
#define SKYBOX_TURFS (SKYBOX_PIXELS/WORLD_ICON_SIZE)
|
||||||
|
|
||||||
// Skybox screen object.
|
// Skybox screen object.
|
||||||
/obj/skybox
|
/obj/skybox
|
||||||
name = "skybox"
|
name = "skybox"
|
||||||
mouse_opacity = 0
|
mouse_opacity = 0
|
||||||
anchored = TRUE
|
anchored = TRUE
|
||||||
simulated = FALSE
|
simulated = FALSE
|
||||||
screen_loc = "CENTER:-352,CENTER:-352" // (736/2 - 32/2)
|
screen_loc = "CENTER,CENTER"
|
||||||
plane = SKYBOX_PLANE
|
plane = SKYBOX_PLANE
|
||||||
blend_mode = BLEND_MULTIPLY // You actually need to do it this way or you see it in occlusion.
|
blend_mode = BLEND_MULTIPLY // You actually need to do it this way or you see it in occlusion.
|
||||||
|
|
||||||
|
// Adjust transform property to scale for client's view var. We assume the skybox is 736x736 px
|
||||||
|
/obj/skybox/proc/scale_to_view(var/view)
|
||||||
|
var/matrix/M = matrix()
|
||||||
|
// Translate to center the icon over us!
|
||||||
|
M.Translate(-(SKYBOX_PIXELS - WORLD_ICON_SIZE) / 2)
|
||||||
|
// Scale appropriately based on view size. (7 results in scale of 1)
|
||||||
|
view = text2num(view) || 7 // Sanitize
|
||||||
|
M.Scale(((min(MAX_CLIENT_VIEW, view) + SKYBOX_PADDING) * 2 + 1) / SKYBOX_TURFS)
|
||||||
|
src.transform = M
|
||||||
|
|
||||||
/client
|
/client
|
||||||
var/obj/skybox/skybox
|
var/obj/skybox/skybox
|
||||||
|
|
||||||
/client/proc/update_skybox(rebuild)
|
/client/proc/update_skybox(rebuild)
|
||||||
if(!skybox)
|
if(!skybox)
|
||||||
skybox = new()
|
skybox = new()
|
||||||
|
skybox.scale_to_view(src.view)
|
||||||
screen += skybox
|
screen += skybox
|
||||||
rebuild = 1
|
rebuild = 1
|
||||||
|
|
||||||
@@ -23,7 +38,7 @@
|
|||||||
skybox.cut_overlays()
|
skybox.cut_overlays()
|
||||||
skybox.add_overlay(SSskybox.get_skybox(T.z))
|
skybox.add_overlay(SSskybox.get_skybox(T.z))
|
||||||
screen |= skybox
|
screen |= skybox
|
||||||
skybox.screen_loc = "CENTER:[-352 + (world.maxx>>1) - T.x],CENTER:[-352 + (world.maxy>>1) - T.y]"
|
skybox.screen_loc = "CENTER:[(world.maxx>>1) - T.x],CENTER:[(world.maxy>>1) - T.y]"
|
||||||
|
|
||||||
/mob/Login()
|
/mob/Login()
|
||||||
. = ..()
|
. = ..()
|
||||||
@@ -40,3 +55,13 @@
|
|||||||
. = ..()
|
. = ..()
|
||||||
if(. && client)
|
if(. && client)
|
||||||
client.update_skybox(old_z != get_z(src))
|
client.update_skybox(old_z != get_z(src))
|
||||||
|
|
||||||
|
/mob/set_viewsize()
|
||||||
|
. = ..()
|
||||||
|
if (. && client)
|
||||||
|
client.update_skybox()
|
||||||
|
client.skybox?.scale_to_view(client.view)
|
||||||
|
|
||||||
|
#undef SKYBOX_BORDER
|
||||||
|
#undef SKYBOX_PIXELS
|
||||||
|
#undef SKYBOX_TURFS
|
||||||
|
|||||||
Reference in New Issue
Block a user