From d77f09f2f053f32f0055f52256080409d78512e2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 1 Jan 2023 17:08:43 +0800 Subject: [PATCH] 1 --- server/gameserver/mapinstance.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/gameserver/mapinstance.cc b/server/gameserver/mapinstance.cc index 9dad8d24..e9c43f38 100644 --- a/server/gameserver/mapinstance.cc +++ b/server/gameserver/mapinstance.cc @@ -468,14 +468,14 @@ bool MapInstance::Raycast(int layer, const glm::vec3& start, const glm::vec3& en // Hit dtVlerp(hit_pos_, spos, epos, t); if (npolys > 0) { - a8::Vec2 dir(epos[0] - spos[0], epos[2] - spos[2]); - dir.Normalize(); + glm::vec3 dir(epos[0] - spos[0], epos[1] - spos[1], epos[2] - spos[2]); + GlmHelper::Normalize(dir); float hit_pos_copy[3]; dtVcopy(hit_pos_copy, hit_pos_); float h = 0; bool ok = false; - dir = dir / 10; + Scale(dir); for (int ii = npolys - 1; ii >= 0; --ii) { auto ret = navmesh_query_->getPolyHeight(polys_[ii], hit_pos_copy, &h); @@ -489,7 +489,7 @@ bool MapInstance::Raycast(int layer, const glm::vec3& start, const glm::vec3& en } else { for (int i = 0; i < 3; ++i) { hit_pos_copy[0] -= dir.x; - hit_pos_copy[2] -= dir.y; + hit_pos_copy[2] -= dir.z; for (int ii = npolys - 1; ii >= 0; --ii) { auto ret = navmesh_query_->getPolyHeight(polys_[ii], hit_pos_copy, &h); if (ret == DT_SUCCESS){ @@ -504,7 +504,7 @@ bool MapInstance::Raycast(int layer, const glm::vec3& start, const glm::vec3& en dtVcopy(hit_pos_copy, hit_pos_); for (int i = 0; i < 3; ++i) { hit_pos_copy[0] += dir.x; - hit_pos_copy[2] += dir.y; + hit_pos_copy[2] += dir.z; for (int ii = npolys - 1; ii >= 0; --ii) { auto ret = navmesh_query_->getPolyHeight(polys_[ii], hit_pos_copy, &h); if (ret == DT_SUCCESS){