- pass a floating point view position to the bunch drawer

This commit is contained in:
Christoph Oelckers 2022-09-16 19:13:06 +02:00
parent 16f61800ef
commit bbf77c908b
3 changed files with 15 additions and 14 deletions

View file

@ -53,15 +53,15 @@
// //
//========================================================================== //==========================================================================
void BunchDrawer::Init(HWDrawInfo *_di, Clipper* c, vec2_t& view, angle_t a1, angle_t a2) void BunchDrawer::Init(HWDrawInfo *_di, Clipper* c, const DVector2& view, angle_t a1, angle_t a2)
{ {
ang1 = a1; ang1 = a1;
ang2 = a2; ang2 = a2;
angrange = ang2 - ang1; angrange = ang2 - ang1;
di = _di; di = _di;
clipper = c; clipper = c;
viewx = view.X * (1/ 16.f); viewx = view.X;
viewy = view.Y * -(1/ 16.f); viewy = view.Y;
viewz = (float)di->Viewpoint.Pos.Z; viewz = (float)di->Viewpoint.Pos.Z;
StartScene(); StartScene();
@ -72,7 +72,9 @@ void BunchDrawer::Init(HWDrawInfo *_di, Clipper* c, vec2_t& view, angle_t a1, an
for (auto& w : wall) for (auto& w : wall)
{ {
// Precalculate the clip angles to avoid doing this repeatedly during level traversal. // Precalculate the clip angles to avoid doing this repeatedly during level traversal.
auto vv = w.wall_int_pos() - view; DVector2 vv;
vv.X = w.pos.X - view.X;
vv.Y = w.pos.Y + view.Y; // beware of different coordinate systems!
w.clipangle = RAD2BAM(atan2(vv.Y, vv.X)); w.clipangle = RAD2BAM(atan2(vv.Y, vv.X));
} }
memset(sectionstartang.Data(), -1, sectionstartang.Size() * sizeof(sectionstartang[0])); memset(sectionstartang.Data(), -1, sectionstartang.Size() * sizeof(sectionstartang[0]));

View file

@ -59,7 +59,7 @@ private:
void ProcessSection(int sectnum, bool portal); void ProcessSection(int sectnum, bool portal);
public: public:
void Init(HWDrawInfo* _di, Clipper* c, vec2_t& view, angle_t a1, angle_t a2); void Init(HWDrawInfo* _di, Clipper* c, const DVector2& view, angle_t a1, angle_t a2);
void RenderScene(const int* viewsectors, unsigned sectcount, bool portal); void RenderScene(const int* viewsectors, unsigned sectcount, bool portal);
const BitArray& GotSector() const { return gotsector; } const BitArray& GotSector() const { return gotsector; }
}; };

View file

@ -380,19 +380,18 @@ void HWDrawInfo::CreateScene(bool portal)
ingeo = false; ingeo = false;
geoofs = { 0,0 }; geoofs = { 0,0 };
vec2_t view = { int(vp.Pos.X * 16), int(vp.Pos.Y * -16) };
if(!portal) mClipper->SetVisibleRange(vp.RotAngle, a1); if(!portal) mClipper->SetVisibleRange(vp.RotAngle, a1);
if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, view, vp.RotAngle - a1, vp.RotAngle + a1); if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, vp.Pos, vp.RotAngle - a1, vp.RotAngle + a1);
else mDrawer.Init(this, mClipper, view, 0, 0); else mDrawer.Init(this, mClipper, vp.Pos, 0, 0);
if (vp.SectNums) if (vp.SectNums)
mDrawer.RenderScene(vp.SectNums, vp.SectCount, portal); mDrawer.RenderScene(vp.SectNums, vp.SectCount, portal);
else else
mDrawer.RenderScene(&vp.SectCount, 1, portal); mDrawer.RenderScene(&vp.SectCount, 1, portal);
SetupSprite.Clock(); SetupSprite.Clock();
gi->processSprites(tsprites, view.X, view.Y, vp.Pos.Z * -256, DAngle::fromBam(vp.RotAngle), vp.TicFrac); // vp is in render space, so we must convert back.
gi->processSprites(tsprites, vp.Pos.X * 16, vp.Pos.Y * -16, vp.Pos.Z * -256, DAngle::fromBam(vp.RotAngle), vp.TicFrac);
DispatchSprites(); DispatchSprites();
SetupSprite.Unclock(); SetupSprite.Unclock();
@ -420,8 +419,8 @@ void HWDrawInfo::CreateScene(bool portal)
if (eff.geosector[i] == drawsectp) drawsectp = eff.geosectorwarp[i]; if (eff.geosector[i] == drawsectp) drawsectp = eff.geosectorwarp[i];
} }
if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, view, vp.RotAngle - a1, vp.RotAngle + a1); if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, vp.Pos, vp.RotAngle - a1, vp.RotAngle + a1);
else mDrawer.Init(this, mClipper, view, 0, 0); else mDrawer.Init(this, mClipper, vp.Pos, 0, 0);
int drawsect = sectnum(drawsectp); int drawsect = sectnum(drawsectp);
mDrawer.RenderScene(&drawsect, 1, false); mDrawer.RenderScene(&drawsect, 1, false);
@ -452,8 +451,8 @@ void HWDrawInfo::CreateScene(bool portal)
if (eff.geosector[i] == orgdrawsectp) drawsectp = eff.geosectorwarp2[i]; if (eff.geosector[i] == orgdrawsectp) drawsectp = eff.geosectorwarp2[i];
} }
if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, view, vp.RotAngle - a1, vp.RotAngle + a1); if (a1 != 0xffffffff) mDrawer.Init(this, mClipper, vp.Pos, vp.RotAngle - a1, vp.RotAngle + a1);
else mDrawer.Init(this, mClipper, view, 0, 0); else mDrawer.Init(this, mClipper, vp.Pos, 0, 0);
drawsect = sectnum(drawsectp); drawsect = sectnum(drawsectp);
mDrawer.RenderScene(&drawsect, 1, false); mDrawer.RenderScene(&drawsect, 1, false);