This commit is contained in:
aozhiwei 2022-12-14 14:38:45 +08:00
parent 0a22db99d6
commit 879ae26490
2 changed files with 49 additions and 0 deletions

View File

@ -25,6 +25,46 @@ a8::Vec2 Position::CalcDir2D(const Position& target_pos)
return target_pos.ToVec2() - 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::FromGlmVec2Ex(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;

View File

@ -76,6 +76,15 @@ struct Position
float Distance2D2(const Position& pos);
float ManhattanDistance2D(const Position& target_pos);
a8::Vec2 CalcDir2D(const Position& target_pos);
void FromVec2(const a8::Vec2 v);
void FromVec2Ex(const a8::Vec2 v);
void FromVec3(const a8::Vec3 v);
void FromGlmVec2(const glm::vec2 v);
void FromGlmVec2Ex(const glm::vec2 v);
void FromGlmVec3(const glm::vec3 v);
a8::Vec2 ToVec2() const;
a8::Vec3 ToVec3() const;
glm::vec2 ToGlmVec2() const;