diff --git a/Core/GameEngine/Include/GameClient/ParticleSys.h b/Core/GameEngine/Include/GameClient/ParticleSys.h index ee69d5415b0..3412aa63ba4 100644 --- a/Core/GameEngine/Include/GameClient/ParticleSys.h +++ b/Core/GameEngine/Include/GameClient/ParticleSys.h @@ -763,11 +763,10 @@ class ParticleSystemManager : public SubsystemInterface, ParticleSystemTemplate *newTemplate( const AsciiString &name ); /// given a template, instantiate a particle system -#if RETAIL_COMPATIBLE_CRC + // TheSuperHackers @bugfix Okladnoj 03/08/2026 Must stay virtual with retail compatibility disabled too, + // because ParticleSystemManagerDummy now loads the particle system templates in both modes and therefore + // has to block the creation of particle systems by overriding this function. virtual ParticleSystem *createParticleSystem( const ParticleSystemTemplate *sysTemplate, Bool createSlaves = TRUE ); -#else - ParticleSystem* createParticleSystem(const ParticleSystemTemplate* sysTemplate, Bool createSlaves = TRUE); -#endif /** given a template, instantiate a particle system. if attachTo is not null, attach the particle system to the given object. diff --git a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp index b5170cc840a..8db761f7b60 100644 --- a/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp +++ b/Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp @@ -2070,7 +2070,7 @@ UnsignedInt PathfindCell::costToGoal( PathfindCell *goal ) Int dy = m_info->m_pos.y - goal->getYIndex(); #define NO_REAL_DIST #ifdef REAL_DIST - Int cost = COST_ORTHOGONAL*WWMath::Sqrt(dx*dx + dy*dy); + Int cost = COST_ORTHOGONAL*WWMath::Sqrt((float)(dx*dx + dy*dy)); #else if (dx<0) dx = -dx; if (dy<0) dy = -dy; @@ -2096,7 +2096,7 @@ UnsignedInt PathfindCell::costToHierGoal( PathfindCell *goal ) } Int dx = m_info->m_pos.x - goal->getXIndex(); Int dy = m_info->m_pos.y - goal->getYIndex(); - Int cost = REAL_TO_INT_FLOOR(COST_ORTHOGONAL*WWMath::Sqrt(dx*dx + dy*dy) + 0.5f); + Int cost = REAL_TO_INT_FLOOR(COST_ORTHOGONAL*WWMath::Sqrt((float)(dx*dx + dy*dy)) + 0.5f); return cost; } @@ -6444,7 +6444,7 @@ Int Pathfinder::examineNeighboringCells(PathfindCell *parentCell, PathfindCell * } else { dx = newCellCoord.x - goalCell->getXIndex(); dy = newCellCoord.y - goalCell->getYIndex(); - costRemaining = COST_ORTHOGONAL*WWMath::Sqrt(dx*dx + dy*dy); + costRemaining = COST_ORTHOGONAL*WWMath::Sqrt((float)(dx*dx + dy*dy)); costRemaining -= attackDistance/2; if (costRemaining<0) costRemaining=0; diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/CameraShakeSystem.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/CameraShakeSystem.cpp index 1fd0679cbe7..7c5192ecc37 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/CameraShakeSystem.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/CameraShakeSystem.cpp @@ -160,7 +160,7 @@ void CameraShakeSystemClass::CameraShakerClass::Compute_Rotations(const Vector3 ** omega(t) = start_omega + (end_omega - start_omega) * t ** phi = random(0..start_omega) */ - float intensity = Intensity * (1.0f - WWMath::Sqrt_Legacy(len2) / Radius) * (1.0f - ElapsedTime / Duration); + float intensity = Intensity * (1.0f - WWMath::Sqrt(len2) / Radius) * (1.0f - ElapsedTime / Duration); for (int i=0; i<3; i++) { float omega = Omega[i] + (END_OMEGA - Omega[i]) * ElapsedTime; (*set_angles)[i] += AXIS_ROTATION[i] * intensity * WWMath::Sinf_Legacy(omega * ElapsedTime + Phi[i]); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DMouse.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DMouse.cpp index c30c4cd0a18..6651f54ff47 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DMouse.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DMouse.cpp @@ -567,7 +567,7 @@ void W3DMouse::draw() { offset = TheInGameUI->getScrollAmount(); offset.normalize(); - Real theta = atan2(-offset.y, offset.x); + Real theta = WWMath::Atan2(-offset.y, offset.x); theta -= (Real)WWMATH_HALF_PI; tm.Rotate_Z(theta); } diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp index 6cb1bcac357..ef30417eb14 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp @@ -2779,7 +2779,7 @@ void W3DView::rotateCameraTowardPosition(const Coord3D *pLoc, Int milliseconds, Vector2 dir(pLoc->x-curPos.x, pLoc->y-curPos.y); const Real dirLength = dir.Length(); if (dirLength<0.1f) return; - Real angle = WWMath::Acos_Legacy(dir.X/dirLength); + Real angle = WWMath::Acos(dir.X/dirLength); if (dir.Y<0.0f) { angle = -angle; } @@ -2922,7 +2922,7 @@ void W3DView::cameraModLookToward(Coord3D *pLoc) Vector2 dir(pLoc->x-result.x, pLoc->y-result.y); const Real dirLength = dir.Length(); if (dirLength<0.1f) continue; - Real angle = WWMath::Acos_Legacy(dir.X/dirLength); + Real angle = WWMath::Acos(dir.X/dirLength); if (dir.Y<0.0f) { angle = -angle; } @@ -3003,7 +3003,7 @@ void W3DView::cameraModFinalLookToward(Coord3D *pLoc) Vector2 dir(pLoc->x-result.x, pLoc->y-result.y); const Real dirLength = dir.Length(); if (dirLength<0.1f) continue; - Real angle = WWMath::Acos_Legacy(dir.X/dirLength); + Real angle = WWMath::Acos(dir.X/dirLength); if (dir.Y<0.0f) { angle = -angle; } @@ -3184,7 +3184,7 @@ void W3DView::setupWaypointPath(Bool orient) m_mcwpInfo.waySegLength[i] = dirLength; m_mcwpInfo.totalDistance += m_mcwpInfo.waySegLength[i]; if (orient && dirLength >= 0.1f) { - angle = WWMath::Acos_Legacy(dir.X/dirLength); + angle = WWMath::Acos(dir.X/dirLength); if (dir.Y<0.0f) { angle = -angle; } @@ -3260,7 +3260,7 @@ static Real makeQuadraticS(Real t) tPrime = 0.5 * (2*t*2*t); } else { tPrime = (t-0.5)*2; - tPrime = WWMath::Sqrt_Legacy(tPrime); + tPrime = WWMath::Sqrt(tPrime); tPrime = 0.5 + 0.5*(tPrime); } return tPrime*0.5 + t*0.5; @@ -3294,7 +3294,7 @@ void W3DView::rotateCameraOneFrame() const Real dirLength = dir.Length(); if (dirLength>=0.1f) { - Real angle = WWMath::Acos_Legacy(dir.X/dirLength); + Real angle = WWMath::Acos(dir.X/dirLength); if (dir.Y<0.0f) { angle = -angle; } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp b/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp index dde6e35f8c4..5a78a5f1273 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp @@ -450,7 +450,7 @@ void PolygonClass::Compute_Plane() ay /= (double)NumVerts; az /= (double)NumVerts; - double len = WWMath::Sqrt_Legacy(nx*nx + ny*ny + nz*nz); + double len = WWMath::Sqrt((float)(nx*nx + ny*ny + nz*nz)); nx /= len; ny /= len; nz /= len; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp b/Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp index 3e8745abc1e..0d8de7c376f 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp @@ -960,8 +960,8 @@ bool TexProjectClass::Compute_Perspective_Projection float tan_hfov2 = WWMath::Fabsf_Legacy(box.Extent.X / (box.Center.Z + box.Extent.Z)); float tan_vfov2 = WWMath::Fabsf_Legacy(box.Extent.Y / (box.Center.Z + box.Extent.Z)); - float hfov = 2.0f * WWMath::Atan_Legacy(tan_hfov2); - float vfov = 2.0f * WWMath::Atan_Legacy(tan_vfov2); + float hfov = 2.0f * WWMath::Atan(tan_hfov2); + float vfov = 2.0f * WWMath::Atan(tan_vfov2); /* ** Plug in the results. diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.cpp b/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.cpp index 17aefcc701c..3805659b907 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.cpp @@ -213,7 +213,7 @@ SoundPseudo3DClass::Update_Pseudo_Pan () // // Calculate a normalized pan from 0 (hard left) to 1.0F (hard right) // - float angle = WWMath::Atan2_Legacy (rel_sound_pos.Y, rel_sound_pos.X); + float angle = WWMath::Atan2 (rel_sound_pos.Y, rel_sound_pos.X); float pan = -WWMath::Fast_Sin (angle); pan = (pan / 2.0F) + 0.5F; diff --git a/Core/Libraries/Source/WWVegas/WWLib/Point.h b/Core/Libraries/Source/WWVegas/WWLib/Point.h index bde3fbf100b..3c74f9f39ee 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/Point.h +++ b/Core/Libraries/Source/WWVegas/WWLib/Point.h @@ -36,7 +36,7 @@ #pragma once -#include "wwmath.h" +#include "WWMath/wwmath.h" template class TRect; diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmathline.cpp b/Core/Libraries/Source/WWVegas/WWMath/colmathline.cpp index 43be3a73a99..726adee7e86 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmathline.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/colmathline.cpp @@ -253,7 +253,7 @@ bool CollisionMath::Collide(const LineSegClass & line,const SphereClass & sphere if (disc < 0.0f) { return false; } else { - float d = WWMath::Sqrt_Legacy(disc); + float d = WWMath::Sqrt(disc); float frac = (clen - d) / line.Get_Length(); if (frac<0.0f) frac = (clen + d) / line.Get_Length(); diff --git a/Core/Libraries/Source/WWVegas/WWMath/euler.cpp b/Core/Libraries/Source/WWVegas/WWMath/euler.cpp index 9685ec39705..15d27779e84 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/euler.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/euler.cpp @@ -180,35 +180,35 @@ void EulerAnglesClass::From_Matrix(const Matrix3D & M, int order) _euler_unpack_order(order,i,j,k,h,n,s,f); if (s == EULER_REPEAT_YES) { - double sy = WWMath::Sqrt(M[i][j]*M[i][j] + M[i][k]*M[i][k]); + float sy = WWMath::Sqrt(M[i][j]*M[i][j] + M[i][k]*M[i][k]); if (sy > 16*FLT_EPSILON) { - Angle[0] = WWMath::Atan2_Legacy(M[i][j],M[i][k]); - Angle[1] = WWMath::Atan2_Legacy(sy,M[i][i]); - Angle[2] = WWMath::Atan2_Legacy(M[j][i],-M[k][i]); + Angle[0] = WWMath::Atan2(M[i][j],M[i][k]); + Angle[1] = WWMath::Atan2(sy,M[i][i]); + Angle[2] = WWMath::Atan2(M[j][i],-M[k][i]); } else { - Angle[0] = WWMath::Atan2_Legacy(-M[j][k],M[j][j]); - Angle[1] = WWMath::Atan2_Legacy(sy,M[i][i]); + Angle[0] = WWMath::Atan2(-M[j][k],M[j][j]); + Angle[1] = WWMath::Atan2(sy,M[i][i]); Angle[2] = 0.0; } } else { - double cy = WWMath::Sqrt(M[i][i]*M[i][i] + M[j][i]*M[j][i]); + float cy = WWMath::Sqrt(M[i][i]*M[i][i] + M[j][i]*M[j][i]); if (cy > 16*FLT_EPSILON) { - Angle[0] = WWMath::Atan2_Legacy(M[k][j],M[k][k]); - Angle[1] = WWMath::Atan2_Legacy(-M[k][i],cy); - Angle[2] = WWMath::Atan2_Legacy(M[j][i],M[i][i]); + Angle[0] = WWMath::Atan2(M[k][j],M[k][k]); + Angle[1] = WWMath::Atan2(-M[k][i],cy); + Angle[2] = WWMath::Atan2(M[j][i],M[i][i]); } else { - Angle[0] = WWMath::Atan2_Legacy(-M[j][k],M[j][j]); - Angle[1] = WWMath::Atan2_Legacy(-M[k][i],cy); + Angle[0] = WWMath::Atan2(-M[j][k],M[j][j]); + Angle[1] = WWMath::Atan2(-M[k][i],cy); Angle[2] = 0; } } diff --git a/Core/Libraries/Source/WWVegas/WWMath/matrix3.h b/Core/Libraries/Source/WWVegas/WWMath/matrix3.h index 004923f700f..379053fb5e9 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/matrix3.h +++ b/Core/Libraries/Source/WWVegas/WWMath/matrix3.h @@ -589,7 +589,7 @@ WWINLINE Matrix3x3& Matrix3x3::operator /= (float d) WWINLINE float Matrix3x3::Get_X_Rotation() const { Vector3 v = (*this) * Vector3(0.0,1.0,0.0); - return WWMath::Atan2_Legacy(v[2], v[1]); + return WWMath::Atan2(v[2], v[1]); } /*********************************************************************************************** @@ -607,7 +607,7 @@ WWINLINE float Matrix3x3::Get_X_Rotation() const WWINLINE float Matrix3x3::Get_Y_Rotation() const { Vector3 v = (*this) * Vector3(0.0,0.0,1.0); - return WWMath::Atan2_Legacy(v[0],v[2]); + return WWMath::Atan2(v[0],v[2]); } /*********************************************************************************************** @@ -625,7 +625,7 @@ WWINLINE float Matrix3x3::Get_Y_Rotation() const WWINLINE float Matrix3x3::Get_Z_Rotation() const { Vector3 v = (*this) * Vector3(1.0,0.0,0.0); - return WWMath::Atan2_Legacy(v[1],v[0]); + return WWMath::Atan2(v[1],v[0]); } WWINLINE Vector3 Matrix3x3::Get_X_Vector() const diff --git a/Core/Libraries/Source/WWVegas/WWMath/matrix3d.cpp b/Core/Libraries/Source/WWVegas/WWMath/matrix3d.cpp index 1bb6b74abeb..72e52a5891b 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/matrix3d.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/matrix3d.cpp @@ -248,7 +248,7 @@ void Matrix3D::Set_Rotation(const Quaternion & q) *=============================================================================================*/ float Matrix3D::Get_X_Rotation() const { - return WWMath::Atan2_Legacy(Row[2][1], Row[1][1]); + return WWMath::Atan2(Row[2][1], Row[1][1]); } @@ -266,7 +266,7 @@ float Matrix3D::Get_X_Rotation() const *=============================================================================================*/ float Matrix3D::Get_Y_Rotation() const { - return WWMath::Atan2_Legacy(Row[0][2], Row[2][2]); + return WWMath::Atan2(Row[0][2], Row[2][2]); } @@ -284,7 +284,7 @@ float Matrix3D::Get_Y_Rotation() const *=============================================================================================*/ float Matrix3D::Get_Z_Rotation() const { - return WWMath::Atan2_Legacy(Row[1][0], Row[0][0]); + return WWMath::Atan2(Row[1][0], Row[0][0]); } @@ -372,7 +372,7 @@ void Matrix3D::Look_At_Dir(const Vector3 &pos, const Vector3 &dir, float roll) float dz = dir.Z; // length of projection onto XY plane - float len2 = (float)WWMath::Sqrt_Legacy(dx*dx + dy*dy); + float len2 = (float)WWMath::Sqrt(dx*dx + dy*dy); // pitch sinp = dz; diff --git a/Core/Libraries/Source/WWVegas/WWMath/quat.cpp b/Core/Libraries/Source/WWVegas/WWMath/quat.cpp index cc119ac72d6..31d6a47b1c3 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/quat.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/quat.cpp @@ -200,7 +200,7 @@ Quaternion Trackball(float x0, float y0, float x1, float y1, float sphsize) // Avoid problems with out of control values if (t > 1.0f) t = 1.0f; if (t < -1.0f) t = -1.0f; - phi = 2.0f * WWMath::Asin_Legacy(t); + phi = 2.0f * WWMath::Asin(t); return Axis_To_Quat(a, phi); } @@ -324,7 +324,7 @@ void __cdecl Fast_Slerp(Quaternion& res, const Quaternion & p,const Quaternion & // ---------------------------------------------------------------------------- // normal slerp! // else { -// theta = WWMath::Acos_Legacy(cos_t); +// theta = WWMath::Acos(cos_t); // sin_t = WWMath::Sinf_Legacy(theta); // oo_sin_t = 1.0 / sin_t; // beta = WWMath::Sinf_Legacy(theta - alpha*theta) * oo_sin_t; @@ -512,7 +512,7 @@ void Slerp(Quaternion& res, const Quaternion & p,const Quaternion & q,float alph } else { // normal slerp! - theta = WWMath::Acos_Legacy(cos_t); + theta = WWMath::Acos(cos_t); float sin_t = WWMath::Sinf_Legacy(theta); oo_sin_t = 1.0f / sin_t; beta = WWMath::Sinf_Legacy(theta - alpha*theta) * oo_sin_t; @@ -567,7 +567,7 @@ void Slerp_Setup(const Quaternion & p,const Quaternion & q,SlerpInfoStruct * sle } else { slerpinfo->Linear = false; - slerpinfo->Theta = WWMath::Acos_Legacy(cos_t); + slerpinfo->Theta = WWMath::Acos(cos_t); slerpinfo->SinT = WWMath::Sinf_Legacy(slerpinfo->Theta); } @@ -868,10 +868,10 @@ float project_to_sphere(float r, float x, float y) { const float SQRT2 = 1.41421356f; float t, z; - float d = WWMath::Sqrt_Legacy(x * x + y * y); + float d = WWMath::Sqrt(x * x + y * y); if (d < r * (SQRT2/(2.0f))) // inside sphere - z = WWMath::Sqrt_Legacy(r * r - d * d); + z = WWMath::Sqrt(r * r - d * d); else { // on hyperbola t = r / SQRT2; z = t * t / d; diff --git a/Core/Libraries/Source/WWVegas/WWMath/quat.h b/Core/Libraries/Source/WWVegas/WWMath/quat.h index 805225a8c86..a1c6d36f75d 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/quat.h +++ b/Core/Libraries/Source/WWVegas/WWMath/quat.h @@ -87,7 +87,7 @@ class Quaternion WWINLINE float Length2() const { return (X*X + Y*Y + Z*Z + W*W); } // Magnitude of the quaternion - WWINLINE float Length() const { return WWMath::Sqrt_Legacy(Length2()); } + WWINLINE float Length() const { return WWMath::Sqrt(Length2()); } // Make the quaternion unit length void Normalize(); diff --git a/Core/Libraries/Source/WWVegas/WWMath/vector2.h b/Core/Libraries/Source/WWVegas/WWMath/vector2.h index a7d110e58d2..2fe734cee66 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vector2.h +++ b/Core/Libraries/Source/WWVegas/WWMath/vector2.h @@ -356,7 +356,7 @@ WWINLINE Vector2 Normalize(const Vector2 & vec) *========================================================================*/ WWINLINE float Vector2::Length() const { - return (float)WWMath::Sqrt_Legacy(Length2()); + return (float)WWMath::Sqrt(Length2()); } /************************************************************************** @@ -638,7 +638,7 @@ WWINLINE float Distance(float x1, float y1, float x2, float y2) float x_diff = x1 - x2; float y_diff = y1 - y2; - return (WWMath::Sqrt_Legacy((x_diff * x_diff) + (y_diff * y_diff))); + return (WWMath::Sqrt((x_diff * x_diff) + (y_diff * y_diff))); } diff --git a/Core/Libraries/Source/WWVegas/WWMath/vector3.h b/Core/Libraries/Source/WWVegas/WWMath/vector3.h index 3e058579cba..f558c340813 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vector3.h +++ b/Core/Libraries/Source/WWVegas/WWMath/vector3.h @@ -452,7 +452,7 @@ WWINLINE Vector3 Normalize(const Vector3 & vec) *========================================================================*/ WWINLINE float Vector3::Length() const { - return WWMath::Sqrt_Legacy(Length2()); + return WWMath::Sqrt(Length2()); } /************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WWMath/vector4.h b/Core/Libraries/Source/WWVegas/WWMath/vector4.h index 18764bebad3..21601bc4f25 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vector4.h +++ b/Core/Libraries/Source/WWVegas/WWMath/vector4.h @@ -303,7 +303,7 @@ WWINLINE Vector4 Normalize(const Vector4 & vec) *========================================================================*/ WWINLINE float Vector4::Length() const { - return WWMath::Sqrt_Legacy(Length2()); + return WWMath::Sqrt(Length2()); } /************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WWMath/vehiclecurve.cpp b/Core/Libraries/Source/WWVegas/WWMath/vehiclecurve.cpp index cb52599cb09..cd6ba177417 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vehiclecurve.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/vehiclecurve.cpp @@ -102,8 +102,8 @@ Find_Tangent // Determine the offset angle (from the line between the point and center) // where the 2 tangent points lie. // - float angle_offset = WWMath::Acos_Legacy (radius / dist); - float base_angle = WWMath::Atan2_Legacy (delta_x, -delta_y); + float angle_offset = WWMath::Acos (radius / dist); + float base_angle = WWMath::Atan2 (delta_x, -delta_y); base_angle = WWMath::Wrap (base_angle, 0, DEG_TO_RADF (360)); // @@ -185,10 +185,10 @@ Find_Turn_Arc // the point halfway between the angles formed by the (prev-curr) and // (next-curr) vectors. // - float angle1 = ::WWMath::Atan2_Legacy ((prev_pt.Y - curr_pt.Y), prev_pt.X - curr_pt.X); + float angle1 = ::WWMath::Atan2 ((prev_pt.Y - curr_pt.Y), prev_pt.X - curr_pt.X); angle1 = WWMath::Wrap (angle1, 0, DEG_TO_RADF (360)); - float angle2 = ::WWMath::Atan2_Legacy ((next_pt.Y - curr_pt.Y), next_pt.X - curr_pt.X); + float angle2 = ::WWMath::Atan2 ((next_pt.Y - curr_pt.Y), next_pt.X - curr_pt.X); angle2 = WWMath::Wrap (angle2, 0, DEG_TO_RADF (360)); float avg_angle = (angle1 + angle2) * 0.5F; @@ -252,7 +252,7 @@ Find_Tangents // // Find the angle where the current position lies on the turn arc // - (*point_angle) = ::WWMath::Atan2_Legacy (curr_pt.X - arc_center.X, -(curr_pt.Y - arc_center.Y)); + (*point_angle) = ::WWMath::Atan2 (curr_pt.X - arc_center.X, -(curr_pt.Y - arc_center.Y)); (*point_angle) = WWMath::Wrap ((*point_angle), 0, DEG_TO_RADF (360)); // diff --git a/Core/Libraries/Source/WWVegas/WWMath/wwmath.h b/Core/Libraries/Source/WWVegas/WWMath/wwmath.h index c83cfaa8eff..f2dffb98883 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/wwmath.h +++ b/Core/Libraries/Source/WWVegas/WWMath/wwmath.h @@ -52,12 +52,12 @@ #define WWMATH_EPSILON 0.0001f #define WWMATH_EPSILON2 WWMATH_EPSILON * WWMATH_EPSILON #define WWMATH_HALF_PI 1.570796327f -#define WWMATH_PI 3.141592654f -#define WWMATH_TWO_PI 6.283185308f +#define WWMATH_PI 3.141592654f +#define WWMATH_TWO_PI 6.283185308f #define WWMATH_FLOAT_MAX (FLT_MAX) #define WWMATH_FLOAT_MIN (FLT_MIN) -#define WWMATH_SQRT2 1.414213562f -#define WWMATH_SQRT3 1.732050808f +#define WWMATH_SQRT2 1.414213562f +#define WWMATH_SQRT3 1.732050808f #define WWMATH_OOSQRT2 0.707106781f #define WWMATH_OOSQRT3 0.577350269f @@ -99,16 +99,14 @@ class WWMath // Initialization and Shutdown. Other math sub-systems which require initialization and // shutdown processing will be handled in these functions -static void Init(); -static void Shutdown(); +static void Init(); +static void Shutdown(); static WWINLINE double Pow(double x, double y); static WWINLINE float Powf(float x, float y); static WWINLINE double Sqr(float x); -static WWINLINE float Sqrt_Legacy(float val); static WWINLINE float Sqrt(float x); - static WWINLINE float Sqrt(int x); - static WWINLINE double Sqrt(double x); +static WWINLINE double Sqrt(double x); static WWINLINE float Sqrtf(float x); static WWINLINE float Inv_Sqrt_Legacy(float a); static WWINLINE double Inv_Sqrt(double x); @@ -116,21 +114,17 @@ static WWINLINE float Inv_Sqrtf(float x); static WWINLINE float Fast_Acos(float val); static WWINLINE float Fast_Asin(float val); -static WWINLINE float Acos_Legacy(float val); static WWINLINE float Acos(float x); - static WWINLINE double Acos(double x); +static WWINLINE double Acos(double x); static WWINLINE float Acosf(float x); -static WWINLINE float Asin_Legacy(float val); static WWINLINE float Asin(float x); - static WWINLINE double Asin(double x); +static WWINLINE double Asin(double x); static WWINLINE float Asinf(float x); -static WWINLINE float Atan_Legacy(float x); static WWINLINE float Atan(float x); - static WWINLINE double Atan(double x); +static WWINLINE double Atan(double x); static WWINLINE float Atanf(float x); -static WWINLINE float Atan2_Legacy(float x, float y); static WWINLINE float Atan2(float x, float y); - static WWINLINE double Atan2(double x, double y); +static WWINLINE double Atan2(double x, double y); static WWINLINE float Atan2f(float x, float y); static WWINLINE float Fast_Cos(float val); @@ -138,18 +132,18 @@ static WWINLINE float Fast_Inv_Cos(float val); static WWINLINE float Fast_Sin(float val); static WWINLINE float Fast_Inv_Sin(float val); static WWINLINE float Cos(float val); - static WWINLINE double Cos(double val); +static WWINLINE double Cos(double val); static WWINLINE float Cosf(float val); static WWINLINE float Cosf_Legacy(float val); // Prevent automatic compiler promotion of float arguments to double-precision variants. - // Single-precision math in GameMath (gm_*f) is guaranteed to be cross-platform bit-identical, - // whereas double-precision math (gm_*) can diverge by 1 ULP due to FPU precision differences (x87 vs NEON). - static WWINLINE float Sin(float val); - static WWINLINE double Sin(double val); +// Single-precision math in GameMath (gm_*f) is guaranteed to be cross-platform bit-identical, +// whereas double-precision math (gm_*) can diverge by 1 ULP due to FPU precision differences (x87 vs NEON). +static WWINLINE float Sin(float val); +static WWINLINE double Sin(double val); static WWINLINE float Sinf(float val); static WWINLINE float Sinf_Legacy(float val); static WWINLINE float Tan(float x); - static WWINLINE double Tan(double x); +static WWINLINE double Tan(double x); static WWINLINE float Tanf(float x); static WWINLINE double Cosh(double x); @@ -160,7 +154,7 @@ static WWINLINE double Tanh(double x); static WWINLINE float Tanhf(float x); static WWINLINE float Fabs(float x); - static WWINLINE double Fabs(double x); +static WWINLINE double Fabs(double x); static WWINLINE float Fabsf(float x); static WWINLINE float Fabsf_Legacy(float val); @@ -178,45 +172,45 @@ static WWINLINE float Log10f(float x); static WWINLINE double Log(double x); static WWINLINE float Logf(float x); -static WWINLINE bool Fast_Is_Float_Positive(const float & val); -static WWINLINE bool Is_Power_Of_2(const unsigned int val); +static WWINLINE bool Fast_Is_Float_Positive(const float & val); +static WWINLINE bool Is_Power_Of_2(const unsigned int val); -static float Random_Float(); +static float Random_Float(); -static WWINLINE float Random_Float(float min,float max); -static WWINLINE float Clamp(float val, float min = 0.0f, float max = 1.0f); +static WWINLINE float Random_Float(float min,float max); +static WWINLINE float Clamp(float val, float min = 0.0f, float max = 1.0f); static WWINLINE double Clamp(double val, double min = 0.0f, double max = 1.0f); -static WWINLINE int Clamp_Int(int val, int min_val, int max_val); -static WWINLINE float Wrap(float val, float min = 0.0f, float max = 1.0f); +static WWINLINE int Clamp_Int(int val, int min_val, int max_val); +static WWINLINE float Wrap(float val, float min = 0.0f, float max = 1.0f); static WWINLINE double Wrap(double val, double min = 0.0f, double max = 1.0f); -static WWINLINE float Min(float a, float b); -static WWINLINE float Max(float a, float b); +static WWINLINE float Min(float a, float b); +static WWINLINE float Max(float a, float b); // Linearly interpolates between a and b using parameter t in [0, 1]. // t = 0 returns a, t = 1 returns b, values in between return a proportionate blend. -static WWINLINE float Lerp(float a, float b, float t); +static WWINLINE float Lerp(float a, float b, float t); static WWINLINE double Lerp(double a, double b, float t); // Computes the interpolation parameter t such that v = Lerp(a, b, t). // Returns where v lies between a and b as a ratio, typically in [0, 1]. -static WWINLINE float Inverse_Lerp(float a, float b, float v); +static WWINLINE float Inverse_Lerp(float a, float b, float v); static WWINLINE double Inverse_Lerp(double a, double b, float v); -static WWINLINE bool Is_Valid_Float(float x); -static WWINLINE bool Is_Valid_Double(double x); +static WWINLINE bool Is_Valid_Float(float x); +static WWINLINE bool Is_Valid_Double(double x); -static WWINLINE int Float_To_Int_Chop(float f); -static WWINLINE int Float_To_Int_Floor(float f); -static WWINLINE long Float_To_Long(float f); -static WWINLINE long Float_To_Long(double f); -static WWINLINE int Float_As_Int(const float f) { return *((int*)&f); } -static WWINLINE unsigned char Unit_Float_To_Byte(float f) { return (unsigned char)(f*255.0f); } -static WWINLINE float Byte_To_Unit_Float(unsigned char byte) { return ((float)byte) / 255.0f; } +static WWINLINE int Float_To_Int_Chop(float f); +static WWINLINE int Float_To_Int_Floor(float f); +static WWINLINE long Float_To_Long(float f); +static WWINLINE long Float_To_Long(double f); +static WWINLINE int Float_As_Int(const float f) { return *((int*)&f); } +static WWINLINE unsigned char Unit_Float_To_Byte(float f) { return (unsigned char)(f*255.0f); } +static WWINLINE float Byte_To_Unit_Float(unsigned char byte) { return ((float)byte) / 255.0f; } -static WWINLINE float Normalize_Angle(float angle); // Normalizes the angle to the range -PI..PI +static WWINLINE float Normalize_Angle(float angle); // Normalizes the angle to the range -PI..PI -static WWINLINE float Div_Safe(float dividend, float divisor, float fallback = 0.0f); -static WWINLINE double Div_Safe(double dividend, double divisor, double fallback = 0.0); +static WWINLINE float Div_Safe(float dividend, float divisor, float fallback = 0.0f); +static WWINLINE double Div_Safe(double dividend, double divisor, double fallback = 0.0); }; @@ -247,40 +241,12 @@ WWINLINE float WWMath::Powf(float x, float y) #endif } -WWINLINE float WWMath::Sqrt_Legacy(float val) -{ -#if USE_DETERMINISTIC_MATH - return gm_sqrtf(val); - -#elif defined(_MSC_VER) && defined(_M_IX86) - float retval; - __asm { - fld [val] - fsqrt - fstp [retval] - } - return retval; - -#else - return (float)sqrt((double)val); -#endif -} - WWINLINE float WWMath::Sqrt(float x) { #if USE_DETERMINISTIC_MATH return gm_sqrtf(x); #else - return (float)Sqrt((double)x); -#endif -} - -WWINLINE float WWMath::Sqrt(int x) -{ -#if USE_DETERMINISTIC_MATH - return gm_sqrtf((float)x); -#else - return (float)Sqrt((double)x); + return sqrtf(x); #endif } @@ -376,7 +342,7 @@ WWINLINE float WWMath::Fast_Acos(float val) { // Near -1 and +1, the table becomes too inaccurate if (Fabsf_Legacy(val) > 0.975f) { - return Acos_Legacy(val); + return Acos(val); } val*=float(ARC_TABLE_SIZE/2); @@ -400,7 +366,7 @@ WWINLINE float WWMath::Fast_Asin(float val) { // Near -1 and +1, the table becomes too inaccurate if (Fabsf_Legacy(val) > 0.975f) { - return Asin_Legacy(val); + return Asin(val); } val*=float(ARC_TABLE_SIZE/2); @@ -420,15 +386,6 @@ WWINLINE float WWMath::Fast_Asin(float val) return (1.0f - frac) * _FastAsinTable[idx0] + frac * _FastAsinTable[idx1]; } -WWINLINE float WWMath::Acos_Legacy(float val) -{ -#if USE_DETERMINISTIC_MATH - return gm_acosf(val); -#else - return (float)acos((double)val); -#endif -} - WWINLINE float WWMath::Acos(float x) { #if USE_DETERMINISTIC_MATH @@ -456,15 +413,6 @@ WWINLINE float WWMath::Acosf(float x) #endif } -WWINLINE float WWMath::Asin_Legacy(float val) -{ -#if USE_DETERMINISTIC_MATH - return gm_asinf(val); -#else - return (float)asin((double)val); -#endif -} - WWINLINE float WWMath::Asin(float x) { #if USE_DETERMINISTIC_MATH @@ -491,15 +439,6 @@ WWINLINE float WWMath::Asinf(float x) #endif } -WWINLINE float WWMath::Atan_Legacy(float x) -{ -#if USE_DETERMINISTIC_MATH - return gm_atanf(x); -#else - return (float)atan((double)x); -#endif -} - WWINLINE float WWMath::Atan(float x) { #if USE_DETERMINISTIC_MATH @@ -527,15 +466,6 @@ WWINLINE float WWMath::Atanf(float x) #endif } -WWINLINE float WWMath::Atan2_Legacy(float x, float y) -{ -#if USE_DETERMINISTIC_MATH - return gm_atan2f(x, y); -#else - return (float)atan2((double)x, (double)y); -#endif -} - WWINLINE float WWMath::Atan2(float x, float y) { #if USE_DETERMINISTIC_MATH diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DRoadBuffer.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DRoadBuffer.cpp index c4c855f9eae..a4f1125b659 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DRoadBuffer.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DRoadBuffer.cpp @@ -2872,7 +2872,7 @@ void W3DRoadBuffer::insertCurveSegmentAt(Int ndx1, Int ndx2) line1.Set(Vector3(pr1->X, pr1->Y, 0), Vector3(pr2->X, pr2->Y, 0)); line2.Set(Vector3(pr3->X, pr3->Y, 0), Vector3(pr4->X, pr4->Y, 0)); } - Real angle = WWMath::Acos_Legacy(curSin); + Real angle = WWMath::Acos(curSin); Real count = angle / (PI/6.0f); // number of 30 degree steps. if (count<0.9 || m_roads[ndx1].m_pt1.isAngled) { miter(ndx1, ndx2); diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp index 572ecdcccb0..376495b2aac 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp @@ -769,13 +769,13 @@ void CameraClass::Get_Clip_Planes(float & znear,float & zfar) const float CameraClass::Get_Horizontal_FOV() const { float width = ViewPlane.Max.X - ViewPlane.Min.X; - return 2*WWMath::Atan2_Legacy(width,2.0); + return 2*WWMath::Atan2(width,2.0f); } float CameraClass::Get_Vertical_FOV() const { float height = ViewPlane.Max.Y - ViewPlane.Min.Y; - return 2*WWMath::Atan2_Legacy(height,2.0); + return 2*WWMath::Atan2(height,2.0f); } float CameraClass::Get_Aspect_Ratio() const diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp index 36dcc993df6..6a592fc5da8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp @@ -1675,6 +1675,10 @@ WeaponTemplate *WeaponStore::newWeaponTemplate(AsciiString name) wt->m_name = name; wt->m_nameKey = TheNameKeyGenerator->nameToKey( name ); +#if USE_DETERMINISTIC_MATH + // TheSuperHackers @bugfix Okladnoj 31/07/2026 Guard under USE_DETERMINISTIC_MATH so retail CRC is + // preserved: forcing this flag changes weapon behaviour and desyncs the retail 1.04 replays. It is + // only needed for cross-platform determinism, where retail compatibility is already abandoned. if (strcmp(name.str(), "SupW_AuroraFuelBombWeapon") == 0) { // Note: m_dieOnDetonate is set to true to fix the Alpha Aurora second explosion inconsistency when targeting structures. @@ -1685,6 +1689,7 @@ WeaponTemplate *WeaponStore::newWeaponTemplate(AsciiString name) wt->m_dieOnDetonate = TRUE; DEBUG_LOG(("WeaponStore::newWeaponTemplate() - forcing MissileCallsOnDie for %s", name.str())); } +#endif m_weaponTemplateVector.push_back(wt); m_weaponTemplateHashMap[wt->m_nameKey] = wt; diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DRoadBuffer.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DRoadBuffer.cpp index 76fe703e725..15c3d347d76 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DRoadBuffer.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DRoadBuffer.cpp @@ -2896,7 +2896,7 @@ void W3DRoadBuffer::insertCurveSegmentAt(Int ndx1, Int ndx2) line1.Set(Vector3(pr1->X, pr1->Y, 0), Vector3(pr2->X, pr2->Y, 0)); line2.Set(Vector3(pr3->X, pr3->Y, 0), Vector3(pr4->X, pr4->Y, 0)); } - Real angle = WWMath::Acos_Legacy(curSin); + Real angle = WWMath::Acos(curSin); Real count = angle / (PI/6.0f); // number of 30 degree steps. if (count<0.9 || m_roads[ndx1].m_pt1.isAngled) { miter(ndx1, ndx2); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp index 3144c5114c3..4cc1f37aaab 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp @@ -769,13 +769,13 @@ void CameraClass::Get_Clip_Planes(float & znear,float & zfar) const float CameraClass::Get_Horizontal_FOV() const { float width = ViewPlane.Max.X - ViewPlane.Min.X; - return 2*WWMath::Atan2_Legacy(width,2.0); + return 2*WWMath::Atan2(width,2.0f); } float CameraClass::Get_Vertical_FOV() const { float height = ViewPlane.Max.Y - ViewPlane.Min.Y; - return 2*WWMath::Atan2_Legacy(height,2.0); + return 2*WWMath::Atan2(height,2.0f); } float CameraClass::Get_Aspect_Ratio() const