From daed13485ef47d9c8992e53e1a976fba237fca50 Mon Sep 17 00:00:00 2001 From: Fire-Head Date: Wed, 15 Apr 2020 08:03:53 +0300 Subject: CWeapon done, ps2 cheats fix --- src/math/Vector.h | 7 +++++++ src/math/Vector2D.h | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/math') diff --git a/src/math/Vector.h b/src/math/Vector.h index 6f544ada..9b732610 100644 --- a/src/math/Vector.h +++ b/src/math/Vector.h @@ -46,6 +46,13 @@ public: y *= invsqrt; z *= invsqrt; } + + void Normalise2D(void) { + float sq = MagnitudeSqr2D(); + float invsqrt = RecipSqrt(sq); + x *= invsqrt; + y *= invsqrt; + } const CVector &operator+=(CVector const &right) { x += right.x; diff --git a/src/math/Vector2D.h b/src/math/Vector2D.h index 1e4d698f..705ad763 100644 --- a/src/math/Vector2D.h +++ b/src/math/Vector2D.h @@ -13,13 +13,14 @@ public: void Normalise(void){ float sq = MagnitudeSqr(); - if(sq > 0.0f){ + //if(sq > 0.0f){ float invsqrt = RecipSqrt(sq); x *= invsqrt; y *= invsqrt; - }else - x = 1.0f; + //}else + // x = 1.0f; } + const CVector2D &operator+=(CVector2D const &right) { x += right.x; y += right.y; -- cgit v1.2.3 From 6ef7924e0122155c390698bdd66e9757f4da5fa0 Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 17 Apr 2020 15:15:42 +0200 Subject: implemented CVector2D::NormaliseSafe for SkidMarks --- src/math/Vector2D.h | 12 +++++++----- src/math/math.cpp | 13 +++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'src/math') diff --git a/src/math/Vector2D.h b/src/math/Vector2D.h index 705ad763..0885a5d2 100644 --- a/src/math/Vector2D.h +++ b/src/math/Vector2D.h @@ -11,16 +11,18 @@ public: float Magnitude(void) const { return Sqrt(x*x + y*y); } float MagnitudeSqr(void) const { return x*x + y*y; } - void Normalise(void){ + void Normalise(void); + + void NormaliseSafe(void) { float sq = MagnitudeSqr(); - //if(sq > 0.0f){ + if(sq > 0.0f){ float invsqrt = RecipSqrt(sq); x *= invsqrt; y *= invsqrt; - //}else - // x = 1.0f; + }else + y = 1.0f; } - + const CVector2D &operator+=(CVector2D const &right) { x += right.x; y += right.y; diff --git a/src/math/math.cpp b/src/math/math.cpp index 4f74fac9..04fab797 100644 --- a/src/math/math.cpp +++ b/src/math/math.cpp @@ -4,6 +4,19 @@ // TODO: move more stuff into here +void +CVector2D::Normalise(void) +{ + float sq = MagnitudeSqr(); + assert(sq != 0.0f); // just be safe here + //if(sq > 0.0f){ + float invsqrt = RecipSqrt(sq); + x *= invsqrt; + y *= invsqrt; + //}else + // x = 1.0f; +} + void CMatrix::SetRotate(float xAngle, float yAngle, float zAngle) { -- cgit v1.2.3 From 599164006a9e7eb7328fc194c9bae1acbb2c887d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 17 Apr 2020 16:31:11 +0300 Subject: Remove patches --- src/math/math.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/math') diff --git a/src/math/math.cpp b/src/math/math.cpp index 4f74fac9..e11d048c 100644 --- a/src/math/math.cpp +++ b/src/math/math.cpp @@ -1,5 +1,5 @@ #include "common.h" -#include "patcher.h" + #include "Quaternion.h" // TODO: move more stuff into here @@ -191,8 +191,3 @@ CQuaternion::Get(RwMatrix *matrix) matrix->up.z = y_2z + w_2x; matrix->at.z = 1.0f - (x_2x + y_2y); } - -STARTPATCHES - InjectHook(0x4BA1C0, &CQuaternion::Slerp, PATCH_JUMP); - InjectHook(0x4BA0D0, &CQuaternion::Get, PATCH_JUMP); -ENDPATCHES -- cgit v1.2.3 From 370c4e48cd87122e8d38f1a72f6b8f62ff7b9c96 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Sun, 19 Apr 2020 18:34:08 +0200 Subject: Try to build with mingw --- src/math/Vector.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/math') diff --git a/src/math/Vector.h b/src/math/Vector.h index 269ffc88..44e646e9 100644 --- a/src/math/Vector.h +++ b/src/math/Vector.h @@ -9,6 +9,11 @@ public: #ifdef RWCORE_H CVector(const RwV3d &v) : x(v.x), y(v.y), z(v.z) {} + RwV3d toRwV3d(void) const { + RwV3d vecRw = { this->x, this->y, this->z }; + return vecRw; + } + operator RwV3d (void) const { RwV3d vecRw = { this->x, this->y, this->z }; return vecRw; -- cgit v1.2.3 From f03b4eec4c37eab75a5bd639279cfcc615105b01 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 23 Apr 2020 22:25:18 +0200 Subject: implemented skinned peds, no cutscene hands yet --- src/math/Quaternion.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/math') diff --git a/src/math/Quaternion.h b/src/math/Quaternion.h index fb37dc10..1d04bdff 100644 --- a/src/math/Quaternion.h +++ b/src/math/Quaternion.h @@ -10,6 +10,18 @@ public: float Magnitude(void) const { return Sqrt(x*x + y*y + z*z + w*w); } float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; } + void Normalise(void) { + float sq = MagnitudeSqr(); + if(sq == 0.0f) + w = 1.0f; + else{ + float invsqrt = RecipSqrt(sq); + x *= invsqrt; + y *= invsqrt; + z *= invsqrt; + w *= invsqrt; + } + } const CQuaternion &operator+=(CQuaternion const &right) { x += right.x; -- cgit v1.2.3