From 38e444124ae148969b3bdc41f3524a6ded36b24f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 15 May 2023 11:15:17 +0800 Subject: [PATCH] 1 --- server/gameserver/mapinstance.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/server/gameserver/mapinstance.cc b/server/gameserver/mapinstance.cc index 077b9dca..e7b7b9fc 100644 --- a/server/gameserver/mapinstance.cc +++ b/server/gameserver/mapinstance.cc @@ -1134,6 +1134,12 @@ void MapInstance::AdjustOnLandPoint(glm::vec3& point) if (dtStatusFailed(status) || poly_count <= 0) { return; } + + glm::vec3 orig; + glm::vec3 dir; + glm::vec2 bary_position; + float distance; + for (int i = 0; i < poly_count; ++i) { unsigned int slat = 0; unsigned int it = 0; @@ -1152,6 +1158,20 @@ void MapInstance::AdjustOnLandPoint(glm::vec3& point) const float* va = &tile->verts[poly->verts[0]*3]; const float* vb = &tile->verts[poly->verts[ii-1]*3]; const float* vc = &tile->verts[poly->verts[ii]*3]; + + glm::vec3 v0 = glm::vec3(va[0], va[1], va[2]); + glm::vec3 v1 = glm::vec3(vb[0], vb[1], vb[2]); + glm::vec3 v2 = glm::vec3(vc[0], vc[1], vc[2]); + bool hit = glm::intersectRayTriangle + (orig, + dir, + v0, + v1, + v2, + bary_position, + distance + ); + } } }