113 lines
1.6 KiB
C++
113 lines
1.6 KiB
C++
#include "precompile.h"
|
|
|
|
#include <math.h>
|
|
|
|
#include "metamgr.h"
|
|
#include "human.h"
|
|
|
|
float Position::Distance2D(a8::Vec2 pos)
|
|
{
|
|
return pos.Distance(ToVec2());
|
|
}
|
|
|
|
float Position::ManhattanDistance2D(const Position& target_pos)
|
|
{
|
|
return ToVec2().ManhattanDistance(target_pos.ToVec2());
|
|
}
|
|
|
|
a8::Vec2 Position::CalcDir2D(const Position& target_pos)
|
|
{
|
|
return a8::Vec2(target_pos.x, target_pos.z) - a8::Vec2(x, z);
|
|
}
|
|
|
|
a8::Vec2 Position::CalcDir2DEx(const a8::Vec2& target_pos)
|
|
{
|
|
return target_pos - ToVec2();
|
|
}
|
|
|
|
a8::Vec2 Position::CalcDirGlm2DEx(const glm::vec2& target_pos)
|
|
{
|
|
return a8::Vec2(target_pos.x, target_pos.y) - ToVec2();
|
|
}
|
|
|
|
void Position::FromVec2(const a8::Vec2 v)
|
|
{
|
|
x = v.x;
|
|
y = v.y;
|
|
}
|
|
|
|
void Position::FromVec2Ex(const a8::Vec2 v)
|
|
{
|
|
x = v.x;
|
|
y = v.y;
|
|
z = 0;
|
|
}
|
|
|
|
void Position::FromVec3(const a8::Vec3 v)
|
|
{
|
|
x = v.x;
|
|
y = v.y;
|
|
z = v.z;
|
|
}
|
|
|
|
void Position::FromGlmVec2(const glm::vec2 v)
|
|
{
|
|
x = v.x;
|
|
y = v.y;
|
|
}
|
|
|
|
void Position::FromGlmVec2Ex(const glm::vec2 v)
|
|
{
|
|
x = v.x;
|
|
y = v.y;
|
|
z = 0;
|
|
}
|
|
|
|
void Position::FromGlmVec3(const glm::vec3 v)
|
|
{
|
|
x = v.x;
|
|
y = v.y;
|
|
z = v.z;
|
|
}
|
|
|
|
a8::Vec2 Position::ToVec2() const
|
|
{
|
|
a8::Vec2 v2;
|
|
v2.x = x;
|
|
v2.y = z;
|
|
return v2;
|
|
}
|
|
|
|
a8::Vec3 Position::ToVec3() const
|
|
{
|
|
a8::Vec3 v;
|
|
v.x = x;
|
|
v.y = y;
|
|
v.z = z;
|
|
return v;
|
|
}
|
|
|
|
glm::vec2 Position::ToGlmVec2() const
|
|
{
|
|
glm::vec2 v;
|
|
v.x = x;
|
|
v.y = y;
|
|
return v;
|
|
}
|
|
|
|
glm::vec3 Position::ToGlmVec3() const
|
|
{
|
|
glm::vec3 v;
|
|
v.x = x;
|
|
v.y = y;
|
|
v.z = z;
|
|
return v;
|
|
}
|
|
|
|
const Position& Position::AddVec2(const a8::Vec2& v)
|
|
{
|
|
x += v.x;
|
|
z += v.y;
|
|
return *this;
|
|
}
|