From 879ae26490a2ae7969328d8d52df057fb6ab9133 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 14 Dec 2022 14:38:45 +0800 Subject: [PATCH] 1 --- server/gameserver/types.cc | 40 ++++++++++++++++++++++++++++++++++++++ server/gameserver/types.h | 9 +++++++++ 2 files changed, 49 insertions(+) diff --git a/server/gameserver/types.cc b/server/gameserver/types.cc index 2e59f9c0..6f5c7ef9 100644 --- a/server/gameserver/types.cc +++ b/server/gameserver/types.cc @@ -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; diff --git a/server/gameserver/types.h b/server/gameserver/types.h index 80cbd51b..d88e215a 100644 --- a/server/gameserver/types.h +++ b/server/gameserver/types.h @@ -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;