Havok: Add hkVector4f::store

Fixes a matching issue in physCapsuleShape
This commit is contained in:
Léo Lam 2021-12-19 13:07:35 +01:00
parent b028cb3264
commit 9f6d37bb3c
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
3 changed files with 39 additions and 7 deletions

View File

@ -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,

Can't render this file because it is too large.

View File

@ -4,6 +4,11 @@
#include <Havok/Common/Base/Types/hkBaseDefs.h>
#include <Havok/Common/Base/Types/hkBaseTypes.h>
#ifdef __aarch64__
#include <arm_neon.h>
#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 <int N>
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 <int N>
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
}

View File

@ -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());
}
}