49 lines
1005 B
C++
49 lines
1005 B
C++
#include "precompile.h"
|
|
|
|
#include <math.h>
|
|
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
|
|
#include "human.h"
|
|
#include "glmhelper.h"
|
|
|
|
float Position::Distance2D2(const Position& pos) const
|
|
{
|
|
glm::vec2 v1 = glm::vec2(GetX(), GetZ());
|
|
glm::vec2 v2 = glm::vec2(pos.GetX(), pos.GetZ());
|
|
return glm::length(v2 - v1);
|
|
}
|
|
|
|
float Position::Distance2D2(const glm::vec3& pos) const
|
|
{
|
|
glm::vec2 v1 = glm::vec2(GetX(), GetZ());
|
|
glm::vec2 v2 = glm::vec2(pos.x, pos.z);
|
|
return glm::length(v2 - v1);
|
|
}
|
|
|
|
float Position::ManhattanDistance2D(const Position& target_pos) const
|
|
{
|
|
float distance = std::fabs(GetX() - target_pos.GetX()) + std::fabs(GetZ() - target_pos.GetZ());
|
|
return distance;
|
|
}
|
|
|
|
glm::vec3 Position::CalcDir(const Position& target_pos) const
|
|
{
|
|
return target_pos.loc_ - loc_;
|
|
}
|
|
|
|
float Position::DistanceGlmVec3(const glm::vec3& v) const
|
|
{
|
|
return GlmHelper::Norm(v - ToGlmVec3());
|
|
}
|
|
|
|
namespace a8
|
|
{
|
|
|
|
bool GtOrEqZero(float val)
|
|
{
|
|
return val > 0.000001f;
|
|
}
|
|
|
|
}
|