diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 8e22c0e9..3e53f8c5 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -83582,7 +83582,7 @@ Address,Quality,Size,Name 0x0000007100fabcdc,O,000008,_ZNK4ksys4phys11CapsuleBody8getShapeEv 0x0000007100fabce4,U,000252, 0x0000007100fabde0,U,000160, -0x0000007100fabe80,m,000192,_ZN4ksys4phys11CapsuleBody14sub_7100FABE80EPN4sead7Vector3IfEES5_RK10hkVector4f +0x0000007100fabe80,O,000192,_ZN4ksys4phys11CapsuleBody14sub_7100FABE80EPN4sead7Vector3IfEES5_RK10hkVector4f 0x0000007100fabf40,U,000204, 0x0000007100fac00c,U,000092, 0x0000007100fac068,U,000008, diff --git a/lib/hkStubs/Havok/Common/Base/Math/Vector/hkVector4f.h b/lib/hkStubs/Havok/Common/Base/Math/Vector/hkVector4f.h index a6fbc982..e8a6039b 100644 --- a/lib/hkStubs/Havok/Common/Base/Math/Vector/hkVector4f.h +++ b/lib/hkStubs/Havok/Common/Base/Math/Vector/hkVector4f.h @@ -4,6 +4,11 @@ #include #include +#ifdef __aarch64__ +#include +#define HK_VECTOR4F_AARCH64_NEON +#endif + class hkVector4f { public: HK_DECLARE_CLASS_ALLOCATOR(hkVector4f) @@ -20,6 +25,10 @@ public: void sub_7100FABE80(const hkVector4f&, const hkVector4f&); + /// Store N floats to out. + template + void store(hkFloat32* out) const; + m128 v; }; @@ -40,3 +49,30 @@ inline void hkVector4f::set(hkFloat32 x, hkFloat32 y, hkFloat32 z, hkFloat32 w) inline void hkVector4f::setAll(hkReal x) { v = {x, x, x, x}; } + +template +inline void hkVector4f::store(hkFloat32* out) const { + static_assert(1 <= N && N <= 4, "invalid N"); +#ifdef HK_VECTOR4F_AARCH64_NEON + switch (N) { + case 1: + vst1q_lane_f32(out, v, 0); + break; + case 2: + vst1_f32(out, vget_low_f32(v)); + break; + case 3: + vst1_f32(out, vget_low_f32(v)); + vst1q_lane_f32(out + 2, v, 2); + break; + case 4: + vst1q_f32(out, v); + break; + default: + break; + } +#else + for (int i = 0; i < N; ++i) + p[i] = v[i]; +#endif +} diff --git a/src/KingSystem/Physics/RigidBody/Shape/physCapsuleShape.cpp b/src/KingSystem/Physics/RigidBody/Shape/physCapsuleShape.cpp index 42782577..05dc3bd9 100644 --- a/src/KingSystem/Physics/RigidBody/Shape/physCapsuleShape.cpp +++ b/src/KingSystem/Physics/RigidBody/Shape/physCapsuleShape.cpp @@ -102,16 +102,12 @@ void CapsuleBody::sub_7100FABE80(sead::Vector3f* veca, sead::Vector3f* vecb, if (veca != nullptr) { hkVector4 tmp; tmp.sub_7100FABE80(rb_vec, hkVector4(vertex_a.x, vertex_a.y, vertex_a.z)); - veca->x = tmp.v[0]; - veca->y = tmp.v[1]; - veca->z = tmp.v[2]; + tmp.store<3>(veca->e.data()); } if (vecb != nullptr) { hkVector4 tmp; tmp.sub_7100FABE80(rb_vec, hkVector4(vertex_b.x, vertex_b.y, vertex_b.z)); - vecb->x = tmp.v[0]; - vecb->y = tmp.v[1]; - vecb->z = tmp.v[2]; + tmp.store<3>(vecb->e.data()); } }