mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-22 08:01:06 +00:00
Lighting fixes (#1886)
changes: Fixes directional lights not obeying Face-Direction. LIGHT_SEMI now works properly when a light is facing NORTH or SOUTH. Fixes #1884
This commit is contained in:
@@ -252,6 +252,7 @@
|
|||||||
#define POLAR_TO_CART_X(R,T) ((R) * cos(T))
|
#define POLAR_TO_CART_X(R,T) ((R) * cos(T))
|
||||||
#define POLAR_TO_CART_Y(R,T) ((R) * sin(T))
|
#define POLAR_TO_CART_Y(R,T) ((R) * sin(T))
|
||||||
#define PSEUDO_WEDGE(A_X,A_Y,B_X,B_Y) ((A_X)*(B_Y) - (A_Y)*(B_X))
|
#define PSEUDO_WEDGE(A_X,A_Y,B_X,B_Y) ((A_X)*(B_Y) - (A_Y)*(B_X))
|
||||||
|
#define MINMAX(NUM) ((NUM) < 0 ? -round(-(NUM)) : round(NUM))
|
||||||
|
|
||||||
/datum/light_source/proc/update_angle()
|
/datum/light_source/proc/update_angle()
|
||||||
var/turf/T = get_turf(top_atom)
|
var/turf/T = get_turf(top_atom)
|
||||||
@@ -268,10 +269,14 @@
|
|||||||
test_x_offset = cached_origin_x
|
test_x_offset = cached_origin_x
|
||||||
cached_origin_y = T.y
|
cached_origin_y = T.y
|
||||||
test_y_offset = cached_origin_y
|
test_y_offset = cached_origin_y
|
||||||
old_direction = top_atom.dir
|
|
||||||
|
if (istype(top_atom, /mob) && top_atom:facing_dir)
|
||||||
|
old_direction = top_atom:facing_dir
|
||||||
|
else
|
||||||
|
old_direction = top_atom.dir
|
||||||
|
|
||||||
var/angle = light_angle / 2
|
var/angle = light_angle / 2
|
||||||
switch (top_atom.dir)
|
switch (old_direction)
|
||||||
if (NORTH)
|
if (NORTH)
|
||||||
limit_a_t = angle + 90
|
limit_a_t = angle + 90
|
||||||
limit_b_t = -(angle) + 90
|
limit_b_t = -(angle) + 90
|
||||||
@@ -298,9 +303,13 @@
|
|||||||
|
|
||||||
// Convert our angle + range into a vector.
|
// Convert our angle + range into a vector.
|
||||||
limit_a_x = POLAR_TO_CART_X(light_range + 10, limit_a_t)
|
limit_a_x = POLAR_TO_CART_X(light_range + 10, limit_a_t)
|
||||||
|
limit_a_x = MINMAX(limit_a_x)
|
||||||
limit_a_y = POLAR_TO_CART_Y(light_range + 10, limit_a_t) // 10 is an arbitrary number, yes.
|
limit_a_y = POLAR_TO_CART_Y(light_range + 10, limit_a_t) // 10 is an arbitrary number, yes.
|
||||||
|
limit_a_y = MINMAX(limit_a_y)
|
||||||
limit_b_x = POLAR_TO_CART_X(light_range + 10, limit_b_t)
|
limit_b_x = POLAR_TO_CART_X(light_range + 10, limit_b_t)
|
||||||
|
limit_b_x = MINMAX(limit_b_x)
|
||||||
limit_b_y = POLAR_TO_CART_Y(light_range + 10, limit_b_t)
|
limit_b_y = POLAR_TO_CART_Y(light_range + 10, limit_b_t)
|
||||||
|
limit_b_y = MINMAX(limit_b_y)
|
||||||
// This won't change unless the origin or dir changes, might as well do it here.
|
// This won't change unless the origin or dir changes, might as well do it here.
|
||||||
targ_sign = PSEUDO_WEDGE(limit_a_x, limit_a_y, limit_b_x, limit_b_y) > 0
|
targ_sign = PSEUDO_WEDGE(limit_a_x, limit_a_y, limit_b_x, limit_b_y) > 0
|
||||||
|
|
||||||
@@ -314,15 +323,12 @@
|
|||||||
var/tb = PSEUDO_WEDGE(test_x, test_y, limit_b_x, limit_b_y)
|
var/tb = PSEUDO_WEDGE(test_x, test_y, limit_b_x, limit_b_y)
|
||||||
|
|
||||||
// if the signs of both at and tb are NOT the same, the point is NOT within the cone.
|
// if the signs of both at and tb are NOT the same, the point is NOT within the cone.
|
||||||
if ((at > 0) != targ_sign)
|
return (((at > 0) != targ_sign) || ((tb > 0) != targ_sign))
|
||||||
return TRUE
|
|
||||||
|
|
||||||
if ((tb > 0) != targ_sign)
|
|
||||||
return TRUE
|
|
||||||
|
|
||||||
#undef POLAR_TO_CART_X
|
#undef POLAR_TO_CART_X
|
||||||
#undef POLAR_TO_CART_Y
|
#undef POLAR_TO_CART_Y
|
||||||
#undef PSEUDO_WEDGE
|
#undef PSEUDO_WEDGE
|
||||||
|
#undef MINMAX
|
||||||
|
|
||||||
// This is the define used to calculate falloff.
|
// This is the define used to calculate falloff.
|
||||||
#define LUM_FALLOFF(C, T) (1 - CLAMP01(sqrt((C.x - T.x) ** 2 + (C.y - T.y) ** 2 + LIGHTING_HEIGHT) / max(1, light_range)))
|
#define LUM_FALLOFF(C, T) (1 - CLAMP01(sqrt((C.x - T.x) ** 2 + (C.y - T.y) ** 2 + LIGHTING_HEIGHT) / max(1, light_range)))
|
||||||
|
|||||||
Reference in New Issue
Block a user