mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 15:22:20 +00:00
Slope planes work again. I hacked an alignment fix in too.
This commit is contained in:
parent
89319b1c2a
commit
3629a2141b
3 changed files with 44 additions and 24 deletions
|
@ -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
|
||||||
FVector ds_su, ds_sv, ds_sz; // Vectors for... stuff?
|
floatv3_t ds_su, ds_sv, ds_sz; // Vectors for... stuff?
|
||||||
float focallengthf, zeroheight;
|
float focallengthf, zeroheight;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,12 @@ 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
|
typedef struct {
|
||||||
#include "hardware/hw_defs.h"
|
float x, y, z;
|
||||||
|
} floatv3_t;
|
||||||
|
|
||||||
pslope_t *ds_slope; // Current slope being used
|
pslope_t *ds_slope; // Current slope being used
|
||||||
FVector ds_su, ds_sv, ds_sz; // Vectors for... stuff?
|
floatv3_t ds_su, ds_sv, ds_sz; // Vectors for... stuff?
|
||||||
float focallengthf, zeroheight;
|
float focallengthf, zeroheight;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -941,41 +941,60 @@ 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
|
||||||
FVector p, m, n;
|
floatv3_t p, m, n;
|
||||||
angle_t ang;
|
float ang;
|
||||||
//double zeroheight;
|
//double zeroheight;
|
||||||
|
float fudge;
|
||||||
|
|
||||||
double vx = FIXED_TO_FLOAT(viewx);
|
float vx = FIXED_TO_FLOAT(viewx);
|
||||||
double vy = FIXED_TO_FLOAT(viewy);
|
float vy = FIXED_TO_FLOAT(viewy);
|
||||||
double vz = FIXED_TO_FLOAT(viewz);
|
float vz = FIXED_TO_FLOAT(viewz);
|
||||||
|
|
||||||
zeroheight = FIXED_TO_FLOAT(P_GetZAt(pl->slope, viewx, viewy));
|
zeroheight = FIXED_TO_FLOAT(P_GetZAt(pl->slope, viewx, viewy));
|
||||||
|
|
||||||
|
#define ANG2RAD(angle) ((float)((angle)*M_PI)/ANGLE_180)
|
||||||
|
|
||||||
// p is the texture origin in view space
|
// p is the texture origin in view space
|
||||||
// Don't add in the offsets at this stage, because doing so can result in
|
// Don't add in the offsets at this stage, because doing so can result in
|
||||||
// errors if the flat is rotated.
|
// errors if the flat is rotated.
|
||||||
ang = (ANGLE_270 - viewangle)>>ANGLETOFINESHIFT;
|
ang = ANG2RAD(ANGLE_270 - viewangle);
|
||||||
p.x = vx * FIXED_TO_FLOAT(FINECOSINE(ang)) - vy * FIXED_TO_FLOAT(FINESINE(ang));
|
p.x = vx * cos(ang) - vy * sin(ang);
|
||||||
p.z = vx * FIXED_TO_FLOAT(FINESINE(ang)) + vy * FIXED_TO_FLOAT(FINECOSINE(ang));
|
p.z = vx * sin(ang) + vy * cos(ang);
|
||||||
p.y = FIXED_TO_FLOAT(P_GetZAt(pl->slope, 0, 0)) - vz;
|
p.y = FIXED_TO_FLOAT(P_GetZAt(pl->slope, 0, 0)) - vz;
|
||||||
|
|
||||||
// m is the v direction vector in view space
|
// m is the v direction vector in view space
|
||||||
ang = (ANGLE_180 - viewangle - pl->plangle) >> ANGLETOFINESHIFT;
|
ang = ANG2RAD(ANGLE_180 - viewangle - pl->plangle);
|
||||||
m.x = FIXED_TO_FLOAT(FINECOSINE(ang));
|
m.x = cos(ang);
|
||||||
m.z = FIXED_TO_FLOAT(FINESINE(ang));
|
m.z = sin(ang);
|
||||||
|
|
||||||
// n is the u direction vector in view space
|
// n is the u direction vector in view space
|
||||||
n.x = FIXED_TO_FLOAT(FINESINE(ang));
|
n.x = sin(ang);
|
||||||
n.z = -FIXED_TO_FLOAT(FINECOSINE(ang));
|
n.z = -cos(ang);
|
||||||
|
|
||||||
ang = pl->plangle>>ANGLETOFINESHIFT;
|
ang = ANG2RAD(pl->plangle);
|
||||||
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 + FLOAT_TO_FIXED(sin(ang)), viewy + FLOAT_TO_FIXED(cos(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 + FLOAT_TO_FIXED(cos(ang)), viewy - FLOAT_TO_FIXED(sin(ang)))) - zeroheight;
|
||||||
|
|
||||||
///TODO: slope FPU conversion stuff
|
// Okay, look, don't ask me why this works, but without this setup there's a disgusting-looking misalignment with the textures. -Red
|
||||||
//M_CrossProduct3f(&ds_su, &p, &m);
|
fudge = ((1<<nflatshiftup)+1.0f)/(1<<nflatshiftup);
|
||||||
//M_CrossProduct3f(&ds_sv, &p, &n);
|
|
||||||
//M_CrossProduct3f(&ds_sz, &m, &n);
|
m.x /= fudge;
|
||||||
|
m.y /= fudge;
|
||||||
|
m.z /= fudge;
|
||||||
|
|
||||||
|
n.x *= fudge;
|
||||||
|
n.y *= fudge;
|
||||||
|
n.z *= fudge;
|
||||||
|
|
||||||
|
// Eh. I tried making this stuff fixed-point and it exploded on me. Here's a macro for the only floating-point vector function I recall using.
|
||||||
|
#define CROSS(d, v1, v2) \
|
||||||
|
d.x = (v1.y * v2.z) - (v1.z * v2.y);\
|
||||||
|
d.y = (v1.z * v2.x) - (v1.x * v2.z);\
|
||||||
|
d.z = (v1.x * v2.y) - (v1.y * v2.x)
|
||||||
|
CROSS(ds_su, p, m);
|
||||||
|
CROSS(ds_sv, p, n);
|
||||||
|
CROSS(ds_sz, m, n);
|
||||||
|
#undef CROSS
|
||||||
|
|
||||||
ds_su.z *= focallengthf;
|
ds_su.z *= focallengthf;
|
||||||
ds_sv.z *= focallengthf;
|
ds_sv.z *= focallengthf;
|
||||||
|
|
Loading…
Reference in a new issue