Skip to content

Commit 89917cb

Browse files
authored
Update UnityResolve.hpp
1 parent a0e0008 commit 89917cb

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

UnityResolve.hpp

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#if WINDOWS_MODE || LINUX_MODE
99
#include <format>
10+
#include <numbers>
1011
#include <ranges>
1112
#include <regex>
1213
#endif
@@ -571,7 +572,7 @@ class UnityResolve final {
571572
[](void* ptr, std::vector<Assembly*>& v) {
572573
if (ptr == nullptr) return;
573574

574-
Assembly* assembly = new Assembly{ .address = ptr };
575+
auto assembly = new Assembly{ .address = ptr };
575576
void* image;
576577
try {
577578
image = Invoke<void*>("mono_assembly_get_image", ptr);
@@ -852,7 +853,7 @@ class UnityResolve final {
852853
}
853854

854855
auto ToVectors(Vector3* m_pForward, Vector3* m_pRight, Vector3* m_pUp) const -> void {
855-
constexpr auto m_fDeg2Rad = static_cast<float>(3.1415926) / 180.F;
856+
constexpr auto m_fDeg2Rad = std::numbers::pi_v<float> / 180.F;
856857

857858
const auto m_fSinX = sinf(x * m_fDeg2Rad);
858859
const auto m_fCosX = cosf(x * m_fDeg2Rad);
@@ -1107,7 +1108,7 @@ class UnityResolve final {
11071108
}
11081109

11091110
auto Euler(float m_fX, float m_fY, float m_fZ) -> Quaternion {
1110-
constexpr auto m_fDeg2Rad = static_cast<float>(3.1415926) / 180.F;
1111+
constexpr auto m_fDeg2Rad = std::numbers::pi_v<float> / 180.F;
11111112

11121113
m_fX = m_fX * m_fDeg2Rad * 0.5F;
11131114
m_fY = m_fY * m_fDeg2Rad * 0.5F;
@@ -1138,12 +1139,12 @@ class UnityResolve final {
11381139
const auto m_fDist = (x * x) + (y * y) + (z * z) + (w * w);
11391140

11401141
if (const auto m_fTest = x * w - y * z; m_fTest > 0.4995F * m_fDist) {
1141-
m_vEuler.x = static_cast<float>(3.1415926) * 0.5F;
1142+
m_vEuler.x = std::numbers::pi_v<float> * 0.5F;
11421143
m_vEuler.y = 2.F * atan2f(y, x);
11431144
m_vEuler.z = 0.F;
11441145
}
11451146
else if (m_fTest < -0.4995F * m_fDist) {
1146-
m_vEuler.x = static_cast<float>(3.1415926) * -0.5F;
1147+
m_vEuler.x = std::numbers::pi_v<float> * -0.5F;
11471148
m_vEuler.y = -2.F * atan2f(y, x);
11481149
m_vEuler.z = 0.F;
11491150
}
@@ -1153,7 +1154,7 @@ class UnityResolve final {
11531154
m_vEuler.z = atan2f(2.F * w * z + 2.F * x * y, 1.F - 2.F * (z * z + x * x));
11541155
}
11551156

1156-
constexpr auto m_fRad2Deg = 180.F / static_cast<float>(3.1415926);
1157+
constexpr auto m_fRad2Deg = 180.F / std::numbers::pi_v<float>;
11571158
m_vEuler.x *= m_fRad2Deg;
11581159
m_vEuler.y *= m_fRad2Deg;
11591160
m_vEuler.z *= m_fRad2Deg;
@@ -1808,7 +1809,7 @@ class UnityResolve final {
18081809
}*bounds{ nullptr };
18091810

18101811
std::uintptr_t max_length{ 0 };
1811-
__declspec(align(8)) T** vector {};
1812+
T** vector {};
18121813

18131814
auto GetData() -> uintptr_t { return reinterpret_cast<uintptr_t>(&vector); }
18141815

@@ -2261,22 +2262,17 @@ class UnityResolve final {
22612262
auto GetPosition() -> Vector3 {
22622263
static Method* method;
22632264

2264-
if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get<Method>(mode_ == Mode::Mono ? "get_position_Injected" : "get_position");
2265-
if (mode_ == Mode::Mono && method) {
2266-
const Vector3 vec3{};
2267-
method->Invoke<void>(this, &vec3);
2268-
return vec3;
2269-
}
2270-
if (method) return method->Invoke<Vector3>(this);
2271-
return {};
2265+
if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get<Method>("get_position_Injected");
2266+
const Vector3 vec3{};
2267+
method->Invoke<void>(this, &vec3);
2268+
return vec3;
22722269
}
22732270

22742271
auto SetPosition(const Vector3& position) -> void {
22752272
static Method* method;
22762273

2277-
if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get<Method>(mode_ == Mode::Mono ? "set_position_Injected" : "set_position");
2278-
if (mode_ == Mode::Mono && method) return method->Invoke<void>(this, &position);
2279-
if (method) return method->Invoke<void>(this, position);
2274+
if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get<Method>("set_position_Injected");
2275+
return method->Invoke<void>(this, &position);
22802276
}
22812277

22822278
auto GetRight() -> Vector3 {
@@ -2390,14 +2386,10 @@ class UnityResolve final {
23902386
auto GetLocalScale() -> Vector3 {
23912387
static Method* method;
23922388

2393-
if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get<Method>(mode_ == Mode::Mono ? "get_localScale_Injected" : "get_localScale");
2394-
if (mode_ == Mode::Mono && method) {
2395-
const Vector3 vec3{};
2396-
method->Invoke<void>(this, &vec3);
2397-
return vec3;
2398-
}
2399-
if (method) return method->Invoke<Vector3>(this);
2400-
return {};
2389+
if (!method) method = Get("UnityEngine.CoreModule.dll")->Get("Transform")->Get<Method>("get_localScale_Injected");
2390+
const Vector3 vec3{};
2391+
method->Invoke<void>(this, &vec3);
2392+
return vec3;
24012393
}
24022394

24032395
auto SetLocalScale(const Vector3& position) -> void {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy