mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2025-01-31 10:40:33 +00:00
Fix incorrect texture mapping vectors for slopes
This commit is contained in:
parent
8309d8f634
commit
09730bff73
1 changed files with 21 additions and 14 deletions
|
@ -1624,7 +1624,7 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t
|
||||||
double lxscale, lyscale;
|
double lxscale, lyscale;
|
||||||
double xscale, yscale;
|
double xscale, yscale;
|
||||||
FVector3 p, m, n;
|
FVector3 p, m, n;
|
||||||
DAngle ang;
|
double ang, planeang, cosine, sine;
|
||||||
double zeroheight;
|
double zeroheight;
|
||||||
|
|
||||||
if (alpha <= 0)
|
if (alpha <= 0)
|
||||||
|
@ -1640,37 +1640,44 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t
|
||||||
|
|
||||||
pviewx = xs_ToFixed(32 - ds_xbits, pl->xform.xOffs * pl->xform.xScale);
|
pviewx = xs_ToFixed(32 - ds_xbits, pl->xform.xOffs * pl->xform.xScale);
|
||||||
pviewy = xs_ToFixed(32 - ds_ybits, pl->xform.yOffs * pl->xform.yScale);
|
pviewy = xs_ToFixed(32 - ds_ybits, pl->xform.yOffs * pl->xform.yScale);
|
||||||
|
planeang = (pl->xform.Angle + pl->xform.baseAngle).Radians();
|
||||||
|
|
||||||
// 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 = DAngle(270.) - ViewAngle;
|
ang = M_PI*3/2 - ViewAngle.Radians();
|
||||||
p[0] = ViewPos.X * ang.Cos() - ViewPos.Y * ang.Sin();
|
cosine = cos(ang), sine = sin(ang);
|
||||||
p[2] = ViewPos.X * ang.Sin() + ViewPos.Y * ang.Cos();
|
p[0] = ViewPos.X * cosine - ViewPos.Y * sine;
|
||||||
|
p[2] = ViewPos.X * sine + ViewPos.Y * cosine;
|
||||||
p[1] = pl->height.ZatPoint(0.0, 0.0) - ViewPos.Z;
|
p[1] = pl->height.ZatPoint(0.0, 0.0) - ViewPos.Z;
|
||||||
|
|
||||||
// m is the v direction vector in view space
|
// m is the v direction vector in view space
|
||||||
ang = DAngle(180.) - ViewAngle;
|
ang = ang - M_PI / 2 - planeang;
|
||||||
m[0] = yscale * cos(ang.Radians());
|
cosine = cos(ang), sine = sin(ang);
|
||||||
m[2] = yscale * sin(ang.Radians());
|
m[0] = yscale * cosine;
|
||||||
|
m[2] = yscale * sine;
|
||||||
// m[1] = pl->height.ZatPointF (0, iyscale) - pl->height.ZatPointF (0,0));
|
// m[1] = pl->height.ZatPointF (0, iyscale) - pl->height.ZatPointF (0,0));
|
||||||
// VectorScale2 (m, 64.f/VectorLength(m));
|
// VectorScale2 (m, 64.f/VectorLength(m));
|
||||||
|
|
||||||
// n is the u direction vector in view space
|
// n is the u direction vector in view space
|
||||||
ang += 90;
|
#if 0
|
||||||
n[0] = -xscale * cos(ang.Radians());
|
//let's use the sin/cosine we already know instead of computing new ones
|
||||||
n[2] = -xscale * sin(ang.Radians());
|
ang += M_PI/2
|
||||||
|
n[0] = -xscale * cos(ang);
|
||||||
|
n[2] = -xscale * sin(ang);
|
||||||
|
#else
|
||||||
|
n[0] = xscale * sine;
|
||||||
|
n[2] = -xscale * cosine;
|
||||||
|
#endif
|
||||||
// n[1] = pl->height.ZatPointF (ixscale, 0) - pl->height.ZatPointF (0,0));
|
// n[1] = pl->height.ZatPointF (ixscale, 0) - pl->height.ZatPointF (0,0));
|
||||||
// VectorScale2 (n, 64.f/VectorLength(n));
|
// VectorScale2 (n, 64.f/VectorLength(n));
|
||||||
|
|
||||||
// This code keeps the texture coordinates constant across the x,y plane no matter
|
// This code keeps the texture coordinates constant across the x,y plane no matter
|
||||||
// how much you slope the surface. Use the commented-out code above instead to keep
|
// how much you slope the surface. Use the commented-out code above instead to keep
|
||||||
// the textures a constant size across the surface's plane instead.
|
// the textures a constant size across the surface's plane instead.
|
||||||
ang = pl->xform.Angle + pl->xform.baseAngle;
|
cosine = cos(planeang), sine = sin(planeang);
|
||||||
double cosine = cos(ang.Radians()), sine = sin(ang.Radians());
|
|
||||||
m[1] = pl->height.ZatPoint(ViewPos.X + yscale * sine, ViewPos.Y + yscale * cosine) - zeroheight;
|
m[1] = pl->height.ZatPoint(ViewPos.X + yscale * sine, ViewPos.Y + yscale * cosine) - zeroheight;
|
||||||
ang += 90;
|
n[1] = pl->height.ZatPoint(ViewPos.X - xscale * cosine, ViewPos.Y + xscale * sine) - zeroheight;
|
||||||
n[1] = pl->height.ZatPoint(ViewPos.X + xscale * sine, ViewPos.Y + xscale * cosine) - zeroheight;
|
|
||||||
|
|
||||||
plane_su = p ^ m;
|
plane_su = p ^ m;
|
||||||
plane_sv = p ^ n;
|
plane_sv = p ^ n;
|
||||||
|
|
Loading…
Reference in a new issue