From 2e8e5f99e71e439cd501f6d46addea87531c5fd5 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Fri, 30 Sep 2022 12:11:12 +1000 Subject: [PATCH] - Fix mixed X/Y pos subtraction in `spriteGetZOfSlopef()` and use a bit more of the backend. * Confirmed coordinate mix-up when reviewing commit `- added spriteGetZOfSlopeF for the backend`. --- source/core/gamefuncs.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index dab34788b..7a110c66c 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -380,9 +380,7 @@ inline int tspriteGetSlope(const tspritetype* spr) inline double spriteGetZOfSlopef(const spritetypebase* tspr, const DVector2& pos, int heinum) { if (heinum == 0) return tspr->pos.Z; - auto ang = tspr->angle; - double factor = -ang.Sin() * (pos.X - tspr->pos.Y) - ang.Cos() * (pos.X - tspr->pos.X); - return tspr->pos.Z + heinum * factor * (1. / SLOPEVAL_FACTOR); + return tspr->pos.Z + heinum * -tspr->angle.ToVector().dot(pos - tspr->pos.XY()) * (1. / SLOPEVAL_FACTOR); } //==========================================================================