This commit is contained in:
aozhiwei 2022-12-28 14:38:34 +08:00
parent b31f6cdd24
commit 2a8cbcc140
3 changed files with 7 additions and 11 deletions

View File

@ -2341,20 +2341,16 @@ void Human::OnLand()
} }
#ifdef MAP3D #ifdef MAP3D
{ {
a8::Vec3 center; glm::vec3 center = GetPos().ToGlmVec3();
center.x = GetPos().x / 10; room->map_instance->Scale(center);
center.z = GetPos().y / 10; glm::vec3 point;
a8::Vec3 point;
bool ok = room->map_instance->FindNearestPoint(center, 2, point); bool ok = room->map_instance->FindNearestPoint(center, 2, point);
if (!ok) { if (!ok) {
abort(); abort();
} }
Position new_pos; room->map_instance->UnScale(point);
new_pos.x = point.x * 10;
new_pos.y = point.y;
new_pos.z = point.z * 10;
Global::Instance()->verify_set_pos = 1; Global::Instance()->verify_set_pos = 1;
SetPos(new_pos); GetMutablePos().FromGlmVec3(point);
Global::Instance()->verify_set_pos = 0; Global::Instance()->verify_set_pos = 0;
#ifdef DEBUG #ifdef DEBUG
a8::XPrintf("OnLoad ok:%d pos:%f,%f,%f\n", a8::XPrintf("OnLoad ok:%d pos:%f,%f,%f\n",

View File

@ -534,7 +534,7 @@ bool MapInstance::Raycast(int layer, const glm::vec3& start, const glm::vec3& en
return true; return true;
} }
bool MapInstance::FindNearestPoint(const a8::Vec3& center, float radius, a8::Vec3& nearest_pt) bool MapInstance::FindNearestPoint(const glm::vec3& center, float radius, glm::vec3& nearest_pt)
{ {
dtPolyRef startRef = INVALID_NAVMESH_POLYREF; dtPolyRef startRef = INVALID_NAVMESH_POLYREF;

View File

@ -35,7 +35,7 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
glm::vec3& random_pt); glm::vec3& random_pt);
bool Raycast(int layer, const glm::vec3& start, const glm::vec3& end, bool Raycast(int layer, const glm::vec3& start, const glm::vec3& end,
glm::vec3& hit_point, bool& hit_result); glm::vec3& hit_point, bool& hit_result);
bool FindNearestPoint(const a8::Vec3& center, float radius, a8::Vec3& nearestPt); bool FindNearestPoint(const glm::vec3& center, float radius, glm::vec3& nearestPt);
bool GetPosHeight(const Position& pos, float& out_height); bool GetPosHeight(const Position& pos, float& out_height);
void Scale(glm::vec3& v); void Scale(glm::vec3& v);
void UnScale(glm::vec3& v); void UnScale(glm::vec3& v);