mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2025-06-17 23:07:26 +08:00
refactor: improvement load_3d_ground_at_coords (#2654)
This commit is contained in:
parent
f07a6e0506
commit
b0e528d7cd
@ -193,45 +193,35 @@ namespace big::entity
|
|||||||
|
|
||||||
bool load_ground_at_3dcoord(Vector3& location)
|
bool load_ground_at_3dcoord(Vector3& location)
|
||||||
{
|
{
|
||||||
float groundZ;
|
constexpr float max_ground_check = 1000.f;
|
||||||
bool done = false;
|
constexpr int max_attempts = 300;
|
||||||
|
float ground_z = location.z;
|
||||||
|
int current_attempts = 0;
|
||||||
|
bool found_ground;
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++)
|
do {
|
||||||
|
found_ground = MISC::GET_GROUND_Z_FOR_3D_COORD(location.x, location.y, max_ground_check, &ground_z, FALSE, FALSE);
|
||||||
|
STREAMING::REQUEST_COLLISION_AT_COORD(location.x, location.y, location.z);
|
||||||
|
|
||||||
|
if (current_attempts % 10 == 0)
|
||||||
{
|
{
|
||||||
for (int z = 0; z < 1000; z += 25)
|
location.z += 25.f;
|
||||||
{
|
}
|
||||||
float ground_iteration = static_cast<float>(z);
|
|
||||||
// Only request a collision after the first try failed because the location might already be loaded on first attempt.
|
++current_attempts;
|
||||||
if (i >= 1 && (z % 100 == 0))
|
|
||||||
{
|
|
||||||
STREAMING::REQUEST_COLLISION_AT_COORD(location.x, location.y, ground_iteration);
|
|
||||||
script::get_current()->yield();
|
script::get_current()->yield();
|
||||||
}
|
} while (!found_ground && current_attempts < max_attempts);
|
||||||
|
|
||||||
if (MISC::GET_GROUND_Z_FOR_3D_COORD(location.x, location.y, ground_iteration, &groundZ, false, false))
|
if (!found_ground)
|
||||||
{
|
{
|
||||||
location.z = groundZ + 1.f;
|
|
||||||
done = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float height;
|
|
||||||
if (done && WATER::GET_WATER_HEIGHT(location.x, location.y, location.z, &height))
|
|
||||||
{
|
|
||||||
location.z = height + 1.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (done)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
location.z = 1000.f;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location.z = ground_z + 1.f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
double distance_to_middle_of_screen(const rage::fvector2& screen_pos)
|
double distance_to_middle_of_screen(const rage::fvector2& screen_pos)
|
||||||
{
|
{
|
||||||
double cumulative_distance{};
|
double cumulative_distance{};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user