From 89319b1c2a27c4a2fee5dca9caae1ebc12866e37 Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Fri, 22 May 2015 22:07:07 -0500 Subject: [PATCH] Dummy out m_vector and use m_fixed's functions instead These functions were already here before, and I /swear/ the slope physics became slightly less glitchy after switching to them... Only issue is the slope plane mapping code hasn't been properly converted yet, so they don't render properly for now. --- src/doomdef.h | 1 - src/m_fixed.c | 2 +- src/m_fixed.h | 2 +- src/m_vector.c | 3 ++- src/m_vector.h | 2 +- src/p_mobj.c | 4 ++-- src/p_slopes.c | 44 +++++++++++++++++--------------------------- src/p_slopes.h | 7 +------ src/p_user.c | 4 ++-- src/r_defs.h | 15 +++------------ src/r_draw.c | 2 +- src/r_draw.h | 5 ++++- src/r_plane.c | 9 +++++---- src/tables.c | 2 +- src/tables.h | 2 +- 15 files changed, 42 insertions(+), 62 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index c150b46b9..bfa5ee0ce 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -441,7 +441,6 @@ extern const char *compdate, *comptime, *comprevision; /// Kalaron/Eternity Engine slope code (SRB2CB ported) /// Depends on NEED_FIXED_VECTORS? for a few functions. -/// However, uses own vector types for math. #define ESLOPE /// Fixed and float point types diff --git a/src/m_fixed.c b/src/m_fixed.c index 25a25a966..739265aa2 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -119,7 +119,7 @@ fixed_t FixedHypot(fixed_t x, fixed_t y) return FixedMul(ax, yx1); // |x|*((1 + (x/y)^2)^1/2) } -#ifdef NEED_FIXED_VECTOR +#if 1 //#ifdef NEED_FIXED_VECTOR vector2_t *FV2_Load(vector2_t *vec, fixed_t x, fixed_t y) { diff --git a/src/m_fixed.h b/src/m_fixed.h index 92b992632..53962269b 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -358,7 +358,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x) } -#ifdef NEED_FIXED_VECTOR +#if 1//#ifdef NEED_FIXED_VECTOR typedef struct { diff --git a/src/m_vector.c b/src/m_vector.c index 96ed7cae0..b417fd980 100644 --- a/src/m_vector.c +++ b/src/m_vector.c @@ -24,7 +24,7 @@ // SoM created 05/18/09 // //----------------------------------------------------------------------------- - +#if 0 // GET THIS SHEIT OUTTA HEEEEEEEEEEEEEEEEEEEEEEERE #include "doomdef.h" #include "m_vector.h" #include "r_main.h" @@ -1156,3 +1156,4 @@ void FV_Normalf(const v3float_t *a_triangle, v3float_t *a_normal) // EOF #endif // #ifdef ESLOPE +#endif diff --git a/src/m_vector.h b/src/m_vector.h index 37d30c746..a2be3a7de 100644 --- a/src/m_vector.h +++ b/src/m_vector.h @@ -28,7 +28,7 @@ #ifndef M_VECTOR_H__ #define M_VECTOR_H__ -#ifdef ESLOPE +#if 0 //#ifdef ESLOPE #include "m_fixed.h" #include "tables.h" diff --git a/src/p_mobj.c b/src/p_mobj.c index 7a3ee0bbd..270220f82 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2116,7 +2116,7 @@ void P_XYMovement(mobj_t *mo) boolean moved; #ifdef ESLOPE pslope_t *oldslope = NULL; - v3fixed_t slopemom; + vector3_t slopemom; fixed_t predictedz = 0; #endif @@ -2829,7 +2829,7 @@ static boolean P_ZMovement(mobj_t *mo) || (mo->z + mo->height >= mo->ceilingz && mo->eflags & MFE_VERTICALFLIP)) && !(mo->flags & MF_NOCLIPHEIGHT)) { - v3fixed_t mom; + vector3_t mom; mom.x = mo->momx; mom.y = mo->momy; mom.z = mo->momz; diff --git a/src/p_slopes.c b/src/p_slopes.c index a4f334caf..a1bfb01c3 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -79,7 +79,7 @@ void P_RunDynamicSlopes(void) { } if (slope->zdelta != FixedDiv(zdelta, slope->extent)) { - slope->zdeltaf = FIXED_TO_FLOAT(slope->zdelta = FixedDiv(zdelta, slope->extent)); + slope->zdelta = FixedDiv(zdelta, slope->extent); slope->zangle = R_PointToAngle2(0, 0, slope->extent, -zdelta); P_CalculateSlopeNormal(slope); } @@ -91,20 +91,20 @@ void P_RunDynamicSlopes(void) { // // Alocates and fill the contents of a slope structure. // -static pslope_t *P_MakeSlope(const v3fixed_t *o, const v2fixed_t *d, +static pslope_t *P_MakeSlope(const vector3_t *o, const vector2_t *d, const fixed_t zdelta, boolean dynamic) { pslope_t *ret = Z_Malloc(sizeof(pslope_t), PU_LEVEL, NULL); memset(ret, 0, sizeof(*ret)); - ret->of.x = FIXED_TO_FLOAT(ret->o.x = o->x); - ret->of.y = FIXED_TO_FLOAT(ret->o.y = o->y); - ret->of.z = FIXED_TO_FLOAT(ret->o.z = o->z); + ret->o.x = o->x; + ret->o.y = o->y; + ret->o.z = o->z; - ret->df.x = FIXED_TO_FLOAT(ret->d.x = d->x); - ret->df.y = FIXED_TO_FLOAT(ret->d.y = d->y); + ret->d.x = d->x; + ret->d.y = d->y; - ret->zdeltaf = FIXED_TO_FLOAT(ret->zdelta = zdelta); + ret->zdelta = zdelta; if (dynamic) { // Add to the dynamic slopes list ret->next = dynslopes; @@ -170,8 +170,8 @@ void P_SpawnSlope_Line(int linenum) line_t *line = lines + linenum; INT16 special = line->special; pslope_t *fslope = NULL, *cslope = NULL; - v3fixed_t origin, point; - v2fixed_t direction; + vector3_t origin, point; + vector2_t direction; fixed_t nx, ny, dz, extent; boolean frontfloor = (special == 386 || special == 388 || special == 393); @@ -772,7 +772,7 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y) return slope->o.z + FixedMul(dist, slope->zdelta); } - +#ifdef SPRINGCLEAN // // P_GetZAtf // @@ -786,30 +786,20 @@ float P_GetZAtf(pslope_t *slope, float x, float y) float dist = (x - slope->of.x) * slope->df.x + (y - slope->of.y) * slope->df.y; return slope->of.z + (dist * slope->zdeltaf); } - -// Unused? -Red -// P_DistFromPlanef -// -float P_DistFromPlanef(const v3float_t *point, const v3float_t *pori, - const v3float_t *pnormal) -{ - return (point->x - pori->x) * pnormal->x + - (point->y - pori->y) * pnormal->y + - (point->z - pori->z) * pnormal->z; -} +#endif // // P_QuantizeMomentumToSlope // // When given a vector, rotates it and aligns it to a slope -void P_QuantizeMomentumToSlope(v3fixed_t *momentum, pslope_t *slope) +void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) { - v3fixed_t axis; + vector3_t axis; axis.x = -slope->d.y; axis.y = slope->d.x; axis.z = 0; - M_VecRotate(momentum, &axis, slope->zangle); + FV3_Rotate(momentum, &axis, slope->zangle >> ANGLETOFINESHIFT); } // @@ -821,7 +811,7 @@ void P_SlopeLaunch(mobj_t *mo) // Double the pre-rotation Z, then halve the post-rotation Z. This reduces the // vertical launch given from slopes while increasing the horizontal launch // given. Good for SRB2's gravity and horizontal speeds. - v3fixed_t slopemom; + vector3_t slopemom; slopemom.x = mo->momx; slopemom.y = mo->momy; slopemom.z = mo->momz*2; @@ -838,7 +828,7 @@ void P_SlopeLaunch(mobj_t *mo) // Function to help handle landing on slopes void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) { - v3fixed_t mom; + vector3_t mom; mom.x = thing->momx; mom.y = thing->momy; mom.z = thing->momz*2; diff --git a/src/p_slopes.h b/src/p_slopes.h index 4281d5796..916690fe7 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -71,13 +71,8 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y); float P_GetZAtf(pslope_t *slope, float x, float y); -// Unused? -Red -// Returns the distance of the given point from the given origin and normal. -float P_DistFromPlanef(const v3float_t *point, const v3float_t *pori, - const v3float_t *pnormal); - // Lots of physics-based bullshit -void P_QuantizeMomentumToSlope(v3fixed_t *momentum, pslope_t *slope); +void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope); void P_SlopeLaunch(mobj_t *mo); void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope); void P_ButteredSlope(mobj_t *mo); diff --git a/src/p_user.c b/src/p_user.c index b389985b6..115c79638 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1790,7 +1790,7 @@ static void P_CheckBouncySectors(player_t *player) fixed_t oldy; fixed_t oldz; #ifdef ESLOPE - v3fixed_t momentum; + vector3_t momentum; #endif oldx = player->mo->x; @@ -4519,7 +4519,7 @@ static void P_3dMovement(player_t *player) boolean analogmove = false; fixed_t oldMagnitude, newMagnitude; #ifdef ESLOPE - v3fixed_t totalthrust; + vector3_t totalthrust; totalthrust.x = totalthrust.y = 0; // I forget if this is needed totalthrust.z = FRACUNIT*P_MobjFlip(player->mo)/3; // A bit of extra push-back on slopes diff --git a/src/r_defs.h b/src/r_defs.h index 27e4b9170..9f35af7e5 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -236,30 +236,21 @@ typedef struct secplane_t // Kalaron Slopes #ifdef ESLOPE -#include "m_vector.h" - typedef struct pslope_s { // --- Information used in clipping/projection --- // Origin vector for the plane - // NOTE: All similarly named entries in this struct do the same thing, - // differing with just 'f' in the name for float: - // o = of, d = df, zdelta = zdeltaf; the only difference is that one's fixed, - // and the one with the 'f' is floating point, for easier reference elsewhere in the code - v3fixed_t o; - v3float_t of; + vector3_t o; // 2-Dimentional vector (x, y) normalized. Used to determine distance from // the origin in 2d mapspace. (Basically a thrust of FRACUNIT in xydirection angle) - v2fixed_t d; - v2float_t df; + vector2_t d; // The rate at which z changes based on distance from the origin plane. fixed_t zdelta; - float zdeltaf; // The normal of the slope; will always point upward, and thus be inverted on ceilings. I think it's only needed for physics? -Red - v3fixed_t normal; + vector3_t normal; // For comparing when a slope should be rendered fixed_t lowz; diff --git a/src/r_draw.c b/src/r_draw.c index e63aa5a2b..f25ecfa04 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -105,7 +105,7 @@ UINT8 *ds_transmap; // one of the translucency tables #ifdef ESLOPE pslope_t *ds_slope; // Current slope being used -v3float_t ds_su, ds_sv, ds_sz; // Vectors for... stuff? +FVector ds_su, ds_sv, ds_sz; // Vectors for... stuff? float focallengthf, zeroheight; #endif diff --git a/src/r_draw.h b/src/r_draw.h index 1116e1c25..b29791cc4 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -61,8 +61,11 @@ extern UINT8 *ds_source; // start of a 64*64 tile image extern UINT8 *ds_transmap; #ifdef ESLOPE +///TODO: either convert ds_su, etc to FPU or declare a floating-point vector type somewhere +#include "hardware/hw_defs.h" + pslope_t *ds_slope; // Current slope being used -v3float_t ds_su, ds_sv, ds_sz; // Vectors for... stuff? +FVector ds_su, ds_sv, ds_sz; // Vectors for... stuff? float focallengthf, zeroheight; #endif diff --git a/src/r_plane.c b/src/r_plane.c index b0768539b..839f2fa38 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -941,7 +941,7 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->slope) { // Potentially override other stuff for now cus we're mean. :< But draw a slope plane! // I copied ZDoom's code and adapted it to SRB2... -Red - v3float_t p, m, n; + FVector p, m, n; angle_t ang; //double zeroheight; @@ -972,9 +972,10 @@ void R_DrawSinglePlane(visplane_t *pl) m.y = FIXED_TO_FLOAT(P_GetZAt(pl->slope, viewx + FINESINE(ang), viewy + FINECOSINE(ang))) - zeroheight; n.y = FIXED_TO_FLOAT(P_GetZAt(pl->slope, viewx + FINECOSINE(ang), viewy - FINESINE(ang))) - zeroheight; - M_CrossProduct3f(&ds_su, &p, &m); - M_CrossProduct3f(&ds_sv, &p, &n); - M_CrossProduct3f(&ds_sz, &m, &n); + ///TODO: slope FPU conversion stuff + //M_CrossProduct3f(&ds_su, &p, &m); + //M_CrossProduct3f(&ds_sv, &p, &n); + //M_CrossProduct3f(&ds_sz, &m, &n); ds_su.z *= focallengthf; ds_sv.z *= focallengthf; diff --git a/src/tables.c b/src/tables.c index fa71effef..3ee2685c8 100644 --- a/src/tables.c +++ b/src/tables.c @@ -2226,7 +2226,7 @@ angle_t tantoangle[2049] = }; -#ifdef NEED_FIXED_VECTOR +#if 1 //#ifdef NEED_FIXED_VECTOR static angle_t fineacon[65536*2] = { ANGLE_MAX, 2143707442, 2142143280, 2140943052, 2139931208, 2139039753, 2138233813, 2137492672, 2136802831, 2136154917, 2135542102, 2134959233, 2134402306, 2133868139, 2133354148, 2132858208, diff --git a/src/tables.h b/src/tables.h index 219d668b9..b1de1a428 100644 --- a/src/tables.h +++ b/src/tables.h @@ -97,7 +97,7 @@ FUNCMATH angle_t FixedAngle(fixed_t fa); FUNCMATH angle_t FixedAngleC(fixed_t fa, fixed_t factor); -#ifdef NEED_FIXED_VECTOR +#if 1 //#ifdef NEED_FIXED_VECTOR /// The FixedAcos function FUNCMATH angle_t FixedAcos(fixed_t x);