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.
This commit is contained in:
RedEnchilada 2015-05-22 22:07:07 -05:00
parent 3f8e7b1739
commit 89319b1c2a
15 changed files with 42 additions and 62 deletions

View file

@ -441,7 +441,6 @@ extern const char *compdate, *comptime, *comprevision;
/// Kalaron/Eternity Engine slope code (SRB2CB ported) /// Kalaron/Eternity Engine slope code (SRB2CB ported)
/// Depends on NEED_FIXED_VECTORS? for a few functions. /// Depends on NEED_FIXED_VECTORS? for a few functions.
/// However, uses own vector types for math.
#define ESLOPE #define ESLOPE
/// Fixed and float point types /// Fixed and float point types

View file

@ -119,7 +119,7 @@ fixed_t FixedHypot(fixed_t x, fixed_t y)
return FixedMul(ax, yx1); // |x|*((1 + (x/y)^2)^1/2) 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) vector2_t *FV2_Load(vector2_t *vec, fixed_t x, fixed_t y)
{ {

View file

@ -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 typedef struct
{ {

View file

@ -24,7 +24,7 @@
// SoM created 05/18/09 // SoM created 05/18/09
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if 0 // GET THIS SHEIT OUTTA HEEEEEEEEEEEEEEEEEEEEEEERE
#include "doomdef.h" #include "doomdef.h"
#include "m_vector.h" #include "m_vector.h"
#include "r_main.h" #include "r_main.h"
@ -1156,3 +1156,4 @@ void FV_Normalf(const v3float_t *a_triangle, v3float_t *a_normal)
// EOF // EOF
#endif // #ifdef ESLOPE #endif // #ifdef ESLOPE
#endif

View file

@ -28,7 +28,7 @@
#ifndef M_VECTOR_H__ #ifndef M_VECTOR_H__
#define M_VECTOR_H__ #define M_VECTOR_H__
#ifdef ESLOPE #if 0 //#ifdef ESLOPE
#include "m_fixed.h" #include "m_fixed.h"
#include "tables.h" #include "tables.h"

View file

@ -2116,7 +2116,7 @@ void P_XYMovement(mobj_t *mo)
boolean moved; boolean moved;
#ifdef ESLOPE #ifdef ESLOPE
pslope_t *oldslope = NULL; pslope_t *oldslope = NULL;
v3fixed_t slopemom; vector3_t slopemom;
fixed_t predictedz = 0; fixed_t predictedz = 0;
#endif #endif
@ -2829,7 +2829,7 @@ static boolean P_ZMovement(mobj_t *mo)
|| (mo->z + mo->height >= mo->ceilingz && mo->eflags & MFE_VERTICALFLIP)) || (mo->z + mo->height >= mo->ceilingz && mo->eflags & MFE_VERTICALFLIP))
&& !(mo->flags & MF_NOCLIPHEIGHT)) && !(mo->flags & MF_NOCLIPHEIGHT))
{ {
v3fixed_t mom; vector3_t mom;
mom.x = mo->momx; mom.x = mo->momx;
mom.y = mo->momy; mom.y = mo->momy;
mom.z = mo->momz; mom.z = mo->momz;

View file

@ -79,7 +79,7 @@ void P_RunDynamicSlopes(void) {
} }
if (slope->zdelta != FixedDiv(zdelta, slope->extent)) { 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); slope->zangle = R_PointToAngle2(0, 0, slope->extent, -zdelta);
P_CalculateSlopeNormal(slope); P_CalculateSlopeNormal(slope);
} }
@ -91,20 +91,20 @@ void P_RunDynamicSlopes(void) {
// //
// Alocates and fill the contents of a slope structure. // 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) const fixed_t zdelta, boolean dynamic)
{ {
pslope_t *ret = Z_Malloc(sizeof(pslope_t), PU_LEVEL, NULL); pslope_t *ret = Z_Malloc(sizeof(pslope_t), PU_LEVEL, NULL);
memset(ret, 0, sizeof(*ret)); memset(ret, 0, sizeof(*ret));
ret->of.x = FIXED_TO_FLOAT(ret->o.x = o->x); ret->o.x = o->x;
ret->of.y = FIXED_TO_FLOAT(ret->o.y = o->y); ret->o.y = o->y;
ret->of.z = FIXED_TO_FLOAT(ret->o.z = o->z); ret->o.z = o->z;
ret->df.x = FIXED_TO_FLOAT(ret->d.x = d->x); ret->d.x = d->x;
ret->df.y = FIXED_TO_FLOAT(ret->d.y = d->y); ret->d.y = d->y;
ret->zdeltaf = FIXED_TO_FLOAT(ret->zdelta = zdelta); ret->zdelta = zdelta;
if (dynamic) { // Add to the dynamic slopes list if (dynamic) { // Add to the dynamic slopes list
ret->next = dynslopes; ret->next = dynslopes;
@ -170,8 +170,8 @@ void P_SpawnSlope_Line(int linenum)
line_t *line = lines + linenum; line_t *line = lines + linenum;
INT16 special = line->special; INT16 special = line->special;
pslope_t *fslope = NULL, *cslope = NULL; pslope_t *fslope = NULL, *cslope = NULL;
v3fixed_t origin, point; vector3_t origin, point;
v2fixed_t direction; vector2_t direction;
fixed_t nx, ny, dz, extent; fixed_t nx, ny, dz, extent;
boolean frontfloor = (special == 386 || special == 388 || special == 393); 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); return slope->o.z + FixedMul(dist, slope->zdelta);
} }
#ifdef SPRINGCLEAN
// //
// P_GetZAtf // 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; float dist = (x - slope->of.x) * slope->df.x + (y - slope->of.y) * slope->df.y;
return slope->of.z + (dist * slope->zdeltaf); return slope->of.z + (dist * slope->zdeltaf);
} }
#endif
// 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;
}
// //
// P_QuantizeMomentumToSlope // P_QuantizeMomentumToSlope
// //
// When given a vector, rotates it and aligns it to a slope // 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.x = -slope->d.y;
axis.y = slope->d.x; axis.y = slope->d.x;
axis.z = 0; 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 // Double the pre-rotation Z, then halve the post-rotation Z. This reduces the
// vertical launch given from slopes while increasing the horizontal launch // vertical launch given from slopes while increasing the horizontal launch
// given. Good for SRB2's gravity and horizontal speeds. // given. Good for SRB2's gravity and horizontal speeds.
v3fixed_t slopemom; vector3_t slopemom;
slopemom.x = mo->momx; slopemom.x = mo->momx;
slopemom.y = mo->momy; slopemom.y = mo->momy;
slopemom.z = mo->momz*2; slopemom.z = mo->momz*2;
@ -838,7 +828,7 @@ void P_SlopeLaunch(mobj_t *mo)
// Function to help handle landing on slopes // Function to help handle landing on slopes
void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope)
{ {
v3fixed_t mom; vector3_t mom;
mom.x = thing->momx; mom.x = thing->momx;
mom.y = thing->momy; mom.y = thing->momy;
mom.z = thing->momz*2; mom.z = thing->momz*2;

View file

@ -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); 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 // 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_SlopeLaunch(mobj_t *mo);
void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope); void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope);
void P_ButteredSlope(mobj_t *mo); void P_ButteredSlope(mobj_t *mo);

View file

@ -1790,7 +1790,7 @@ static void P_CheckBouncySectors(player_t *player)
fixed_t oldy; fixed_t oldy;
fixed_t oldz; fixed_t oldz;
#ifdef ESLOPE #ifdef ESLOPE
v3fixed_t momentum; vector3_t momentum;
#endif #endif
oldx = player->mo->x; oldx = player->mo->x;
@ -4519,7 +4519,7 @@ static void P_3dMovement(player_t *player)
boolean analogmove = false; boolean analogmove = false;
fixed_t oldMagnitude, newMagnitude; fixed_t oldMagnitude, newMagnitude;
#ifdef ESLOPE #ifdef ESLOPE
v3fixed_t totalthrust; vector3_t totalthrust;
totalthrust.x = totalthrust.y = 0; // I forget if this is needed 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 totalthrust.z = FRACUNIT*P_MobjFlip(player->mo)/3; // A bit of extra push-back on slopes

View file

@ -236,30 +236,21 @@ typedef struct secplane_t
// Kalaron Slopes // Kalaron Slopes
#ifdef ESLOPE #ifdef ESLOPE
#include "m_vector.h"
typedef struct pslope_s typedef struct pslope_s
{ {
// --- Information used in clipping/projection --- // --- Information used in clipping/projection ---
// Origin vector for the plane // Origin vector for the plane
// NOTE: All similarly named entries in this struct do the same thing, vector3_t o;
// 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;
// 2-Dimentional vector (x, y) normalized. Used to determine distance from // 2-Dimentional vector (x, y) normalized. Used to determine distance from
// the origin in 2d mapspace. (Basically a thrust of FRACUNIT in xydirection angle) // the origin in 2d mapspace. (Basically a thrust of FRACUNIT in xydirection angle)
v2fixed_t d; vector2_t d;
v2float_t df;
// The rate at which z changes based on distance from the origin plane. // The rate at which z changes based on distance from the origin plane.
fixed_t zdelta; 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 // 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 // For comparing when a slope should be rendered
fixed_t lowz; fixed_t lowz;

View file

@ -105,7 +105,7 @@ UINT8 *ds_transmap; // one of the translucency tables
#ifdef ESLOPE #ifdef ESLOPE
pslope_t *ds_slope; // Current slope being used 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; float focallengthf, zeroheight;
#endif #endif

View file

@ -61,8 +61,11 @@ extern UINT8 *ds_source; // start of a 64*64 tile image
extern UINT8 *ds_transmap; extern UINT8 *ds_transmap;
#ifdef ESLOPE #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 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; float focallengthf, zeroheight;
#endif #endif

View file

@ -941,7 +941,7 @@ void R_DrawSinglePlane(visplane_t *pl)
if (pl->slope) { if (pl->slope) {
// Potentially override other stuff for now cus we're mean. :< But draw a slope plane! // 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 // I copied ZDoom's code and adapted it to SRB2... -Red
v3float_t p, m, n; FVector p, m, n;
angle_t ang; angle_t ang;
//double zeroheight; //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; 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; n.y = FIXED_TO_FLOAT(P_GetZAt(pl->slope, viewx + FINECOSINE(ang), viewy - FINESINE(ang))) - zeroheight;
M_CrossProduct3f(&ds_su, &p, &m); ///TODO: slope FPU conversion stuff
M_CrossProduct3f(&ds_sv, &p, &n); //M_CrossProduct3f(&ds_su, &p, &m);
M_CrossProduct3f(&ds_sz, &m, &n); //M_CrossProduct3f(&ds_sv, &p, &n);
//M_CrossProduct3f(&ds_sz, &m, &n);
ds_su.z *= focallengthf; ds_su.z *= focallengthf;
ds_sv.z *= focallengthf; ds_sv.z *= focallengthf;

View file

@ -2226,7 +2226,7 @@ angle_t tantoangle[2049] =
}; };
#ifdef NEED_FIXED_VECTOR #if 1 //#ifdef NEED_FIXED_VECTOR
static angle_t fineacon[65536*2] = { static angle_t fineacon[65536*2] = {
ANGLE_MAX, 2143707442, 2142143280, 2140943052, 2139931208, 2139039753, 2138233813, 2137492672, 2136802831, 2136154917, 2135542102, 2134959233, 2134402306, 2133868139, 2133354148, 2132858208, ANGLE_MAX, 2143707442, 2142143280, 2140943052, 2139931208, 2139039753, 2138233813, 2137492672, 2136802831, 2136154917, 2135542102, 2134959233, 2134402306, 2133868139, 2133354148, 2132858208,

View file

@ -97,7 +97,7 @@ FUNCMATH angle_t FixedAngle(fixed_t fa);
FUNCMATH angle_t FixedAngleC(fixed_t fa, fixed_t factor); FUNCMATH angle_t FixedAngleC(fixed_t fa, fixed_t factor);
#ifdef NEED_FIXED_VECTOR #if 1 //#ifdef NEED_FIXED_VECTOR
/// The FixedAcos function /// The FixedAcos function
FUNCMATH angle_t FixedAcos(fixed_t x); FUNCMATH angle_t FixedAcos(fixed_t x);