-
-
未解决 [求助]麻烦帮忙看看一个算法
-
发表于: 2020-2-29 15:15 2139
-
private:
Vector3 GetPosition(DWORD64 transform)
{
if (!transform) return Vector3{ 0.f, 0.f, 0.f };
struct Matrix34 { BYTE vec0[16]; BYTE vec1[16]; BYTE vec2[16]; };
const __m128 mulVec0 = { -2.000, 2.000, -2.000, 0.000 };
const __m128 mulVec1 = { 2.000, -2.000, -2.000, 0.000 };
const __m128 mulVec2 = { -2.000, -2.000, 2.000, 0.000 };
int Index = *(PINT)(transform + 0x40);
DWORD64 pTransformData = safe_read(transform + 0x38, DWORD64);
DWORD64 transformData[2];
safe_memcpy(&transformData, (PVOID)(pTransformData + 0x18), 16);
size_t sizeMatriciesBuf = 48 * Index + 48;
size_t sizeIndicesBuf = 4 * Index + 4;
int pIndicesBuf[100];
Matrix34 pMatriciesBuf[1000];
safe_memcpy(pMatriciesBuf, (PVOID)transformData[0], sizeMatriciesBuf);
safe_memcpy(pIndicesBuf, (PVOID)transformData[1], sizeIndicesBuf);
__m128 result = *(__m128*)((ULONGLONG)pMatriciesBuf + 0x30 * Index);
int transformIndex = *(int*)((ULONGLONG)pIndicesBuf + 0x4 * Index);
while (transformIndex >= 0)
{
Matrix34 matrix34 = *(Matrix34*)((ULONGLONG)pMatriciesBuf + 0x30 * transformIndex);
__m128 xxxx = _mm_castsi128_ps(_mm_shuffle_epi32(*(__m128i*)(&matrix34.vec1), 0x00));
__m128 yyyy = _mm_castsi128_ps(_mm_shuffle_epi32(*(__m128i*)(&matrix34.vec1), 0x55));
__m128 zwxy = _mm_castsi128_ps(_mm_shuffle_epi32(*(__m128i*)(&matrix34.vec1), 0x8E));
__m128 wzyw = _mm_castsi128_ps(_mm_shuffle_epi32(*(__m128i*)(&matrix34.vec1), 0xDB));
__m128 zzzz = _mm_castsi128_ps(_mm_shuffle_epi32(*(__m128i*)(&matrix34.vec1), 0xAA));
__m128 yxwy = _mm_castsi128_ps(_mm_shuffle_epi32(*(__m128i*)(&matrix34.vec1), 0x71));
__m128 tmp7 = _mm_mul_ps(*(__m128*)(&matrix34.vec2), result);
result = _mm_add_ps(
_mm_add_ps(
_mm_add_ps(
_mm_mul_ps(
_mm_sub_ps(
_mm_mul_ps(_mm_mul_ps(xxxx, mulVec1), zwxy),
_mm_mul_ps(_mm_mul_ps(yyyy, mulVec2), wzyw)),
_mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(tmp7), 0xAA))),
_mm_mul_ps(
_mm_sub_ps(
_mm_mul_ps(_mm_mul_ps(zzzz, mulVec2), wzyw),
_mm_mul_ps(_mm_mul_ps(xxxx, mulVec0), yxwy)),
_mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(tmp7), 0x55)))),
_mm_add_ps(
_mm_mul_ps(
_mm_sub_ps(
_mm_mul_ps(_mm_mul_ps(yyyy, mulVec0), yxwy),
_mm_mul_ps(_mm_mul_ps(zzzz, mulVec1), zwxy)),
_mm_castsi128_ps(_mm_shuffle_epi32(_mm_castps_si128(tmp7), 0x00))),
tmp7)), *(__m128*)(&matrix34.vec0));
transformIndex = *(int*)((ULONGLONG)pIndicesBuf + 0x4 * transformIndex);
}
return Vector3(result.m128_f32[0], result.m128_f32[1], result.m128_f32[2]);
}
//各位能帮忙讲讲这个算法是怎么实现的吗?
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!
赞赏
看原图
赞赏
雪币:
留言: