diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 83f4964bf93bd6d3f01bfc700fe944b6ce2c1d12..f8e2808a200837c133a8a4ebbc8438dc5aef38f7 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -2609,9 +2609,11 @@ static int slope_set(lua_State *L) slope->o.z = luaL_checkfixed(L, -1); else slope->o.z = 0; - slope->dorigin.x = FixedToDouble(slope->o.x); - slope->dorigin.y = FixedToDouble(slope->o.y); - slope->dorigin.z = FixedToDouble(slope->o.z); + DVector3_Load(&slope->dorigin, + FixedToDouble(slope->o.x), + FixedToDouble(slope->o.y), + FixedToDouble(slope->o.z) + ); lua_pop(L, 1); break; } diff --git a/src/m_vector.c b/src/m_vector.c index 546826c76d11c38f0801727222ea1a27a6a12bff..3132a869d458c83aac517ac609258b506b6395b8 100644 --- a/src/m_vector.c +++ b/src/m_vector.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 1999-2024 by Sonic Team Junior. +// Copyright (C) 2024 by Sonic Team Junior. // Copyright (C) 2009 by Stephen McGranahan. // // This program is free software distributed under the diff --git a/src/m_vector.h b/src/m_vector.h index abd23f1cf2d9cedd168282de63343d18141a1976..55669be037c9ce54ffd70bf3782225e913e1a1b4 100644 --- a/src/m_vector.h +++ b/src/m_vector.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 1999-2024 by Sonic Team Junior. +// Copyright (C) 2024 by Sonic Team Junior. // Copyright (C) 2009 by Stephen McGranahan. // // This program is free software distributed under the diff --git a/src/p_slopes.c b/src/p_slopes.c index a41a3343a9361fa5c051c71619b72b5be93c3f86..bcee0318189ba1e3bfde73c526f567f6f085f9bb 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2004 by Stephen McGranahan +// Copyright (C) 2009 by Stephen McGranahan. // Copyright (C) 2015-2023 by Sonic Team Junior. // // This program is free software distributed under the @@ -38,17 +38,17 @@ void P_CalculateSlopeNormal(pslope_t *slope) { static void CalculateVectors(pslope_t *slope, dvector3_t *dnormal) { double hyp = hypot(dnormal->x, dnormal->y); - if (fpclassify(hyp) == FP_ZERO) + + if (fpclassify(hyp) == FP_NORMAL) { - slope->dnormdir.x = slope->dnormdir.y = 0.0; - slope->dzdelta = 0.0; + slope->dnormdir.x = -dnormal->x / hyp; + slope->dnormdir.y = -dnormal->y / hyp; + slope->dzdelta = hyp / dnormal->z; } else { - slope->dnormdir.x = -(dnormal->x / hyp); - slope->dnormdir.y = -(dnormal->y / hyp); - - slope->dzdelta = hyp / dnormal->z; + slope->dnormdir.x = slope->dnormdir.y = 0.0; + slope->dzdelta = 0.0; } } diff --git a/src/p_slopes.h b/src/p_slopes.h index 78731c2a99d7e34b8be1957fad917f0a758d7004..1a7e604b284b60ec0ceff3aa27ca764b3391450f 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2004 by Stephen McGranahan +// Copyright (C) 2009 by Stephen McGranahan. // Copyright (C) 2015-2023 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/r_plane.c b/src/r_plane.c index f3536dbb207ac597b011388149d2fee6cd18eade..1295b63ba54889ff2e23e3eb4c69e0b3a5899d86 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -663,6 +663,7 @@ static void R_DrawSkyPlane(visplane_t *pl) // Returns the height of the sloped plane at (x, y) as a double static double R_GetSlopeZAt(const pslope_t *slope, fixed_t x, fixed_t y) { + // If you want to reimplement this using just the equation constants, use this instead: // (d + a*x + b*y) * -(1.0 / c) double px = FixedToDouble(x) - slope->dorigin.x; @@ -712,11 +713,11 @@ void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, return; } - // slope_v is the v direction vector in view space + // the v direction vector in view space slope_v.x = cos(ang); slope_v.z = sin(ang); - // slope_u is the u direction vector in view space + // the u direction vector in view space slope_u.x = sin(ang); slope_u.z = -cos(ang); @@ -754,11 +755,11 @@ void R_SetScaledSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t float xscale = FixedToFloat(xs); float yscale = FixedToFloat(ys); - // m is the v direction vector in view space + // the v direction vector in view space slope_v.x = yscale * cos(ang); slope_v.z = yscale * sin(ang); - // n is the u direction vector in view space + // the u direction vector in view space slope_u.x = xscale * sin(ang); slope_u.z = -xscale * cos(ang);