2019-06-24 14:57:54 +00:00
|
|
|
#include "common.h"
|
2020-04-17 13:31:11 +00:00
|
|
|
|
2020-03-28 14:47:52 +00:00
|
|
|
#include "Ped.h"
|
2019-06-24 14:57:54 +00:00
|
|
|
#include "PedPlacement.h"
|
|
|
|
#include "World.h"
|
|
|
|
|
2020-07-27 13:04:05 +00:00
|
|
|
// --MIAMI: Done
|
|
|
|
bool
|
2019-06-24 14:57:54 +00:00
|
|
|
CPedPlacement::FindZCoorForPed(CVector* pos)
|
|
|
|
{
|
|
|
|
float zForPed;
|
|
|
|
float startZ = pos->z - 100.0f;
|
|
|
|
float foundColZ = -100.0f;
|
|
|
|
float foundColZ2 = -100.0f;
|
|
|
|
CColPoint foundCol;
|
|
|
|
CEntity* foundEnt;
|
|
|
|
|
|
|
|
CVector vec(
|
|
|
|
pos->x,
|
|
|
|
pos->y,
|
|
|
|
pos->z + 1.0f
|
|
|
|
);
|
|
|
|
|
2019-06-30 10:53:39 +00:00
|
|
|
if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, nil))
|
2019-06-24 14:57:54 +00:00
|
|
|
foundColZ = foundCol.point.z;
|
|
|
|
|
|
|
|
// Adjust coords and do a second test
|
|
|
|
vec.x += 0.1f;
|
|
|
|
vec.y += 0.1f;
|
|
|
|
|
2019-06-30 10:53:39 +00:00
|
|
|
if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, nil))
|
2019-06-24 14:57:54 +00:00
|
|
|
foundColZ2 = foundCol.point.z;
|
|
|
|
|
2020-04-19 16:34:08 +00:00
|
|
|
zForPed = Max(foundColZ, foundColZ2);
|
2019-06-24 14:57:54 +00:00
|
|
|
|
2020-07-27 13:04:05 +00:00
|
|
|
if (zForPed > -99.0f) {
|
2020-03-07 19:22:43 +00:00
|
|
|
pos->z = FEET_OFFSET + zForPed;
|
2020-07-27 13:04:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2019-06-24 14:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-07-18 02:26:46 +00:00
|
|
|
CEntity*
|
2020-05-05 01:45:18 +00:00
|
|
|
CPedPlacement::IsPositionClearOfCars(Const CVector *pos)
|
2019-07-18 02:26:46 +00:00
|
|
|
{
|
2019-07-31 15:54:18 +00:00
|
|
|
return CWorld::TestSphereAgainstWorld(*pos, 0.25f, nil, true, true, false, false, false, false);
|
2019-07-18 02:26:46 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 23:56:13 +00:00
|
|
|
bool
|
2020-05-08 20:29:43 +00:00
|
|
|
CPedPlacement::IsPositionClearForPed(const CVector& pos, float radius, int total, CEntity** entities)
|
2020-02-17 23:56:13 +00:00
|
|
|
{
|
|
|
|
int16 count;
|
2020-05-08 20:29:43 +00:00
|
|
|
if (radius == -1.0f)
|
|
|
|
radius = 0.75f;
|
|
|
|
if (total == -1)
|
|
|
|
total = 2;
|
|
|
|
CWorld::FindObjectsKindaColliding(pos, radius, true, &count, total, entities, false, true, true, false, false);
|
2020-02-17 23:56:13 +00:00
|
|
|
return count == 0;
|
|
|
|
}
|