This commit is contained in:
aozhiwei 2023-05-14 16:45:12 +08:00
parent 9228c805ae
commit 6dacb8c500
3 changed files with 12 additions and 0 deletions

View File

@ -2567,12 +2567,18 @@ void Creature::OnLand()
room->map_instance->Scale(center); room->map_instance->Scale(center);
glm::vec3 point; glm::vec3 point;
bool ok = false; bool ok = false;
#if 1
center = GetPos().ToGlmVec3();
room->map_instance->Scale(center);
ok = room->map_instance->FindOnLandPoint(center, point);
#else
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
ok = room->map_instance->FindNearestPoint(center, 1.0f + 10 * i, point); ok = room->map_instance->FindNearestPoint(center, 1.0f + 10 * i, point);
if (ok) { if (ok) {
break; break;
} }
} }
#endif
#if 1 #if 1
if (point.y < 1.2) { if (point.y < 1.2) {
point.y = 3.0f; point.y = 3.0f;

View File

@ -1110,3 +1110,8 @@ bool MapInstance::GetNearestGrass(const glm::vec3& center, glm::vec3& out_pt)
} }
return false; return false;
} }
bool MapInstance::FindOnLandPoint(const glm::vec3& center, glm::vec3& nearest_pt)
{
}

View File

@ -48,6 +48,7 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
int& same_polys_flags, std::vector<dtPolyRef>& spec_polys, int& same_polys_flags, std::vector<dtPolyRef>& spec_polys,
unsigned short exclude_flags); unsigned short exclude_flags);
bool FindNearestPoint(const glm::vec3& center, float radius, glm::vec3& nearestPt); bool FindNearestPoint(const glm::vec3& center, float radius, glm::vec3& nearestPt);
bool FindOnLandPoint(const glm::vec3& center, glm::vec3& nearest_pt);
bool GetPosHeight(const Position& pos, float& out_height); bool GetPosHeight(const Position& pos, float& out_height);
dtPoly* GetPoly(glm::vec3 pos, int& poly_idx); dtPoly* GetPoly(glm::vec3 pos, int& poly_idx);
void Scale(glm::vec3& v); void Scale(glm::vec3& v);