From 539b269d019271a55b078efb4acdf33acb9e5521 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sat, 28 Sep 2024 13:53:21 -0600 Subject: [PATCH] Better CVector3f::Cross; link CVector3f/CModVectorElement Thanks @1superchip for the help --- config/GM8E01_00/symbols.txt | 2 +- configure.py | 4 ++-- include/Kyoto/Math/CVector3f.hpp | 18 +++++++++--------- src/Kyoto/Math/CVector3f.cpp | 2 +- src/Kyoto/Particles/CModVectorElement.cpp | 5 ++--- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index 667df2ea..da4638c0 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -26512,7 +26512,7 @@ lbl_805AE630 = .sdata2:0x805AE630; // type:object size:0x4 data:float lbl_805AE634 = .sdata2:0x805AE634; // type:object size:0x4 data:float lbl_805AE638 = .sdata2:0x805AE638; // type:object size:0x4 data:float lbl_805AE63C = .sdata2:0x805AE63C; // type:object size:0x4 data:float -lbl_805AE640 = .sdata2:0x805AE640; // type:object size:0x8 data:float +lbl_805AE640 = .sdata2:0x805AE640; // type:object size:0x4 data:float lbl_805AE648 = .sdata2:0x805AE648; // type:object size:0x4 data:float lbl_805AE64C = .sdata2:0x805AE64C; // type:object size:0x4 data:float lbl_805AE650 = .sdata2:0x805AE650; // type:object size:0x4 data:float diff --git a/configure.py b/configure.py index 7aded54b..7dd882ef 100755 --- a/configure.py +++ b/configure.py @@ -919,7 +919,7 @@ def Rel(lib_name, objects): Object(Matching, "Kyoto/Math/CVector2f.cpp"), Object(Matching, "Kyoto/Math/CVector2i.cpp"), Object(Matching, "Kyoto/Math/CVector3d.cpp"), - Object(NonMatching, "Kyoto/Math/CVector3f.cpp"), + Object(Matching, "Kyoto/Math/CVector3f.cpp"), Object(Matching, "Kyoto/Math/CVector3i.cpp"), Object(NonMatching, "Kyoto/Math/RMathUtils.cpp"), Object(Matching, "Kyoto/CCrc32.cpp"), @@ -931,7 +931,7 @@ def Rel(lib_name, objects): Object(Matching, "Kyoto/Particles/CColorElement.cpp"), Object(NonMatching, "Kyoto/Particles/CElementGen.cpp"), Object(Matching, "Kyoto/Particles/CIntElement.cpp"), - Object(NonMatching, "Kyoto/Particles/CModVectorElement.cpp"), + Object(Matching, "Kyoto/Particles/CModVectorElement.cpp"), Object(NonMatching, "Kyoto/Particles/CParticleDataFactory.cpp"), Object(Matching, "Kyoto/Particles/CParticleGen.cpp"), Object(Matching, "Kyoto/Particles/CParticleGlobals.cpp"), diff --git a/include/Kyoto/Math/CVector3f.hpp b/include/Kyoto/Math/CVector3f.hpp index 97e2868d..a02ec7cf 100644 --- a/include/Kyoto/Math/CVector3f.hpp +++ b/include/Kyoto/Math/CVector3f.hpp @@ -24,9 +24,9 @@ class CVector3f { CVector3f(CInputStream& in); void PutTo(COutputStream& out) const; - float GetX() const { return mX; } - float GetY() const { return mY; } - float GetZ() const { return mZ; } + const float GetX() const { return mX; } + const float GetY() const { return mY; } + const float GetZ() const { return mZ; } void SetX(float x) { mX = x; } void SetY(float y) { mY = y; } @@ -55,12 +55,12 @@ class CVector3f { } inline float MagSquared() const { return GetX() * GetX() + GetY() * GetY() + GetZ() * GetZ(); } static CVector3f Cross(const CVector3f& lhs, const CVector3f& rhs) { - const float lX = lhs.mX; - const float lY = lhs.mY; - const float lZ = lhs.mZ; - const float rX = rhs.mX; - const float rY = rhs.mY; - const float rZ = rhs.mZ; + const float lX = lhs.GetX(); + const float lY = lhs.GetY(); + const float lZ = lhs.GetZ(); + const float rX = rhs.GetX(); + const float rY = rhs.GetY(); + const float rZ = rhs.GetZ(); float z = lX * rY - rX * lY; float y = lZ * rX - rZ * lX; float x = lY * rZ - rY * lZ; diff --git a/src/Kyoto/Math/CVector3f.cpp b/src/Kyoto/Math/CVector3f.cpp index 4b456f83..bbf8e7c8 100644 --- a/src/Kyoto/Math/CVector3f.cpp +++ b/src/Kyoto/Math/CVector3f.cpp @@ -71,7 +71,7 @@ bool CVector3f::IsNotInf() const { return true; } -bool CVector3f::IsMagnitudeSafe() const { return IsNotInf() && MagSquared() >= 9.999999e-29f; } +bool CVector3f::IsMagnitudeSafe() const { return IsNotInf() && MagSquared() >= 9.9999995e-29f; } bool CVector3f::CanBeNormalized() const { int x = __HI(mX); diff --git a/src/Kyoto/Particles/CModVectorElement.cpp b/src/Kyoto/Particles/CModVectorElement.cpp index c0acc3ee..e37c777c 100644 --- a/src/Kyoto/Particles/CModVectorElement.cpp +++ b/src/Kyoto/Particles/CModVectorElement.cpp @@ -285,11 +285,10 @@ bool CMVESwirl::GetValue(int frame, CVector3f& pVel, CVector3f& pPos) const { xc_filterGain->GetValue(frame, c); x10_tangentialVelocity->GetValue(frame, d); - // CVector3f cross = ; - pVel = c * ( + pVel = ( b * CVector3f::Dot(b, pVel) + d * CVector3f::Cross(b, posToHelix) - ) + (1.f - c) * pVel; + ) * c + (1.f - c) * pVel; return false; }