From 986466de671ee898455a96c061912efc2ecf5392 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 1 Sep 2022 20:19:05 +1000 Subject: [PATCH] - Commence updating `gi->DrawAutomapPlayer()` for floatification, beginning with Duke's `CSTAT_SPRITE_ALIGNMENT_FACING` code. --- source/core/automap.cpp | 12 ++++++------ source/core/automap.h | 2 +- source/games/duke/src/game_misc.cpp | 27 ++++++++++----------------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/source/core/automap.cpp b/source/core/automap.cpp index 3536fae56..4d760c5cf 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -404,8 +404,8 @@ static void drawredlines(const DVector2& cpos, const double sine, const double c if (ShowRedLine(wallnum(&wal), i)) { - auto v1 = OutAutomapVector(wal.pos - cpos, sine, cosine, xydim, gZoom); - auto v2 = OutAutomapVector(wal.point2Wall()->pos - cpos, sine, cosine, xydim, gZoom); + auto v1 = OutAutomapVector(wal.pos - cpos, sine, cosine, gZoom, xydim); + auto v2 = OutAutomapVector(wal.point2Wall()->pos - cpos, sine, cosine, gZoom, xydim); drawlinergb(v1.X, v1.Y, v2.X, v2.Y, RedLineColor()); } } @@ -432,8 +432,8 @@ static void drawwhitelines(const DVector2& cpos, const double sine, const double if (isSWALL() && !gFullMap && !show2dwall[wallnum(&wal)]) continue; - auto v1 = OutAutomapVector(wal.pos - cpos, sine, cosine, xydim, gZoom); - auto v2 = OutAutomapVector(wal.point2Wall()->pos - cpos, sine, cosine, xydim, gZoom); + auto v1 = OutAutomapVector(wal.pos - cpos, sine, cosine, gZoom, xydim); + auto v2 = OutAutomapVector(wal.point2Wall()->pos - cpos, sine, cosine, gZoom, xydim); drawlinergb(v1.X, v1.Y, v2.X, v2.Y, WhiteLineColor()); } } @@ -532,7 +532,7 @@ static void renderDrawMapView(const DVector2& cpos, const double sine, const dou vertices.Resize(mesh->vertices.Size()); for (unsigned j = 0; j < mesh->vertices.Size(); j++) { - auto v = OutAutomapVector(DVector2(mesh->vertices[j].X - cpos.X, -mesh->vertices[j].Y - cpos.Y), sine, cosine, xydim, gZoom); + auto v = OutAutomapVector(DVector2(mesh->vertices[j].X - cpos.X, -mesh->vertices[j].Y - cpos.Y), sine, cosine, gZoom, xydim); vertices[j] = { float(v.X), float(v.Y), mesh->texcoords[j].X, mesh->texcoords[j].Y }; } @@ -558,7 +558,7 @@ static void renderDrawMapView(const DVector2& cpos, const double sine, const dou for (unsigned j = 0; j < 4; j++) { - auto v = OutAutomapVector(pp[j] - cpos, sine, cosine, xydim, gZoom); + auto v = OutAutomapVector(pp[j] - cpos, sine, cosine, gZoom, xydim); vertices[j] = { float(v.X), float(v.Y), j == 1 || j == 2 ? 1.f : 0.f, j == 2 || j == 3 ? 1.f : 0.f }; } int shade; diff --git a/source/core/automap.h b/source/core/automap.h index bd6d78c91..2835abe20 100644 --- a/source/core/automap.h +++ b/source/core/automap.h @@ -25,7 +25,7 @@ inline void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, PalEntry drawlinergb(x1 / 4096., y1 / 4096., x2 / 4096., y2 / 4096., p); } -inline DVector2 OutAutomapVector(const DVector2& pos, const double sine, const double cosine, const DVector2& xydim, const double zoom = 1.) +inline DVector2 OutAutomapVector(const DVector2& pos, const double sine, const double cosine, const double zoom = 1., const DVector2& xydim = { 0, 0 }) { return pos.Rotated(cosine, sine).Rotated90CW() * zoom + xydim; } diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index f04d72405..75de66d8d 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -387,6 +387,8 @@ ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize) bool GameInterface::DrawAutomapPlayer(int mx, int my, int cposx, int cposy, const double czoom, const DAngle cang, double const smoothratio) { + DVector2 v1, v2, v3, v4; + DAngle an; int i, j, k, l, x1, y1, x2, y2, x3, y3, x4, y4, ox, oy, xoff, yoff; int dax, day, cosang, sinang, xspan, yspan, sprx, spry; int xrepeat, yrepeat, tilenum; @@ -416,27 +418,18 @@ bool GameInterface::DrawAutomapPlayer(int mx, int my, int cposx, int cposy, cons sprx = act->int_pos().X; spry = act->int_pos().Y; + auto xydim = DVector2(twod->GetWidth() * 0.5, twod->GetHeight() * 0.5); + if ((act->spr.cstat & CSTAT_SPRITE_BLOCK_ALL) != 0) switch (act->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) { case CSTAT_SPRITE_ALIGNMENT_FACING: - //break; + an = -cang; + v1 = OutAutomapVector(DVector2(sprx - cposx, spry - cposy) * inttoworld, an.Sin(), an.Cos(), czoom / 1024.); + v2 = OutAutomapVector(act->spr.angle.ToVector() * 8., an.Sin(), an.Cos(), czoom / 1024.); - ox = sprx - cposx; - oy = spry - cposy; - x1 = DMulScale(ox, xvect, -oy, yvect, 16); - y1 = DMulScale(oy, xvect, ox, yvect, 16); - - ox = bcos(act->int_ang(), -7); - oy = bsin(act->int_ang(), -7); - x2 = DMulScale(ox, xvect, -oy, yvect, 16); - y2 = DMulScale(oy, xvect, ox, yvect, 16); - - x3 = x2; - y3 = y2; - - drawlinergb(x1 - x2 + xdim, y1 - y3 + ydim, x1 + x2 + xdim, y1 + y3 + ydim, col); - drawlinergb(x1 - y2 + xdim, y1 + x3 + ydim, x1 + x2 + xdim, y1 + y3 + ydim, col); - drawlinergb(x1 + y2 + xdim, y1 - x3 + ydim, x1 + x2 + xdim, y1 + y3 + ydim, col); + drawlinergb(v1.X - v2.X + xydim.X, v1.Y - v2.Y + xydim.Y, v1.X + v2.X + xydim.X, v1.Y + v2.Y + xydim.Y, col); + drawlinergb(v1.X - v2.Y + xydim.X, v1.Y + v2.X + xydim.Y, v1.X + v2.X + xydim.X, v1.Y + v2.Y + xydim.Y, col); + drawlinergb(v1.X + v2.Y + xydim.X, v1.Y - v2.X + xydim.Y, v1.X + v2.X + xydim.X, v1.Y + v2.Y + xydim.Y, col); break; case CSTAT_SPRITE_ALIGNMENT_WALL: