New math wrappers

from miami
This commit is contained in:
eray orçunus 2020-07-23 00:31:06 +03:00
parent 98dd771d6c
commit 7e32c603fc
5 changed files with 11 additions and 9 deletions

View File

@ -108,7 +108,7 @@ public:
if (angle >= TWOPI) if (angle >= TWOPI)
angle -= TWOPI; angle -= TWOPI;
return (int)floorf(angle / DEGTORAD(45.0f)); return (int)Floor(angle / DEGTORAD(45.0f));
} }
// Unlike usual string comparison functions, these don't care about greater or lesser // Unlike usual string comparison functions, these don't care about greater or lesser

View File

@ -746,8 +746,8 @@ void CRadar::DrawRadarMap()
DrawRadarMask(); DrawRadarMask();
// top left ist (0, 0) // top left ist (0, 0)
int x = floorf((vec2DRadarOrigin.x - RADAR_MIN_X) / RADAR_TILE_SIZE); int x = Floor((vec2DRadarOrigin.x - RADAR_MIN_X) / RADAR_TILE_SIZE);
int y = ceilf((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - RADAR_MIN_Y) / RADAR_TILE_SIZE); int y = Ceil((RADAR_NUM_TILES - 1) - (vec2DRadarOrigin.y - RADAR_MIN_Y) / RADAR_TILE_SIZE);
StreamRadarSections(x, y); StreamRadarSections(x, y);
RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEFOGENABLE, (void*)FALSE);
@ -1251,7 +1251,7 @@ void CRadar::Shutdown()
void CRadar::StreamRadarSections(const CVector &posn) void CRadar::StreamRadarSections(const CVector &posn)
{ {
StreamRadarSections(floorf((2000.0f + posn.x) / 500.0f), ceilf(7.0f - (2000.0f + posn.y) / 500.0f)); StreamRadarSections(Floor((2000.0f + posn.x) / 500.0f), Ceil(7.0f - (2000.0f + posn.y) / 500.0f));
} }
void CRadar::StreamRadarSections(int32 x, int32 y) void CRadar::StreamRadarSections(int32 x, int32 y)

View File

@ -15,3 +15,5 @@ inline float Sqrt(float x) { return sqrtf(x); }
inline float RecipSqrt(float x, float y) { return x/Sqrt(y); } inline float RecipSqrt(float x, float y) { return x/Sqrt(y); }
inline float RecipSqrt(float x) { return RecipSqrt(1.0f, x); } inline float RecipSqrt(float x) { return RecipSqrt(1.0f, x); }
inline float Pow(float x, float y) { return powf(x, y); } inline float Pow(float x, float y) { return powf(x, y); }
inline float Floor(float x) { return floorf(x); }
inline float Ceil(float x) { return ceilf(x); }

View File

@ -9349,7 +9349,7 @@ CPed::ProcessControl(void)
m_collidingEntityWhileFleeing = collidingEnt; m_collidingEntityWhileFleeing = collidingEnt;
m_collidingEntityWhileFleeing->RegisterReference((CEntity **) &m_collidingEntityWhileFleeing); m_collidingEntityWhileFleeing->RegisterReference((CEntity **) &m_collidingEntityWhileFleeing);
uint8 currentDir = floorf((PI + m_fRotationCur) / DEGTORAD(45.0f)); uint8 currentDir = Floor((PI + m_fRotationCur) / DEGTORAD(45.0f));
uint8 nextDir; uint8 nextDir;
ThePaths.FindNextNodeWandering(PATH_PED, GetPosition(), &m_pLastPathNode, &m_pNextPathNode, currentDir, &nextDir); ThePaths.FindNextNodeWandering(PATH_PED, GetPosition(), &m_pLastPathNode, &m_pNextPathNode, currentDir, &nextDir);

View File

@ -857,9 +857,9 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL
// prestep x1 and x2 to next integer y // prestep x1 and x2 to next integer y
deltaA = CalcNewDelta(&poly[a1], &poly[a2]); deltaA = CalcNewDelta(&poly[a1], &poly[a2]);
xA = deltaA * (ceilf(poly[a1].y) - poly[a1].y) + poly[a1].x; xA = deltaA * (Ceil(poly[a1].y) - poly[a1].y) + poly[a1].x;
deltaB = CalcNewDelta(&poly[b1], &poly[b2]); deltaB = CalcNewDelta(&poly[b1], &poly[b2]);
xB = deltaB * (ceilf(poly[b1].y) - poly[b1].y) + poly[b1].x; xB = deltaB * (Ceil(poly[b1].y) - poly[b1].y) + poly[b1].x;
if(y != yend){ if(y != yend){
if(deltaB < 0.0f && (int)xB < xstart) if(deltaB < 0.0f && (int)xB < xstart)
@ -904,7 +904,7 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL
xstart = poly[b1].x; xstart = poly[b1].x;
}while(y == (int)poly[b2].y); }while(y == (int)poly[b2].y);
deltaB = CalcNewDelta(&poly[b1], &poly[b2]); deltaB = CalcNewDelta(&poly[b1], &poly[b2]);
xB = deltaB * (ceilf(poly[b1].y) - poly[b1].y) + poly[b1].x; xB = deltaB * (Ceil(poly[b1].y) - poly[b1].y) + poly[b1].x;
if(deltaB < 0.0f && (int)xB < xstart) if(deltaB < 0.0f && (int)xB < xstart)
xstart = xB; xstart = xB;
} }
@ -940,7 +940,7 @@ CRenderer::ScanSectorPoly(RwV2d *poly, int32 numVertices, void (*scanfunc)(CPtrL
xend = poly[a1].x; xend = poly[a1].x;
}while(y == (int)poly[a2].y); }while(y == (int)poly[a2].y);
deltaA = CalcNewDelta(&poly[a1], &poly[a2]); deltaA = CalcNewDelta(&poly[a1], &poly[a2]);
xA = deltaA * (ceilf(poly[a1].y) - poly[a1].y) + poly[a1].x; xA = deltaA * (Ceil(poly[a1].y) - poly[a1].y) + poly[a1].x;
if(deltaA >= 0.0f && (int)xA > xend) if(deltaA >= 0.0f && (int)xA > xend)
xend = xA; xend = xA;
} }