This commit is contained in:
aozhiwei 2023-10-26 16:44:32 +08:00
parent 7cee55b4ca
commit d24b0201d6

View File

@ -3576,21 +3576,22 @@ void Creature::ActivateTargetValidPos()
glm::vec3 dir = GetPos().ToGlmVec3() - context_pos.ToGlmVec3(); glm::vec3 dir = GetPos().ToGlmVec3() - context_pos.ToGlmVec3();
GlmHelper::Normalize(dir); GlmHelper::Normalize(dir);
dir.y = 0; dir.y = 0;
while (distance > 10) {
} bool found = false;
if (distance > 600 || distance < 10) { glm::vec3 found_pos;
{
float move_len = 0;
while (move_len + 10 < distance) {
glm::vec3 center = context_pos.ToGlmVec3() + dir * move_len;
room->map_instance->Scale(center);
} else { bool ok = room->map_instance->FindConnectableNearestPoint(center, 0.3f, found_pos);
glm::vec3 center = context_pos.ToGlmVec3(); if (ok) {
room->map_instance->Scale(center); room->map_instance->UnScale(found_pos);
found = true;
glm::vec3 point; break;
bool ok = room->map_instance->FindConnectableNearestPoint(center, 0.3f, point); }
if (ok) { move_len += 10;
room->map_instance->UnScale(point);
target_valid_pos = point;
} else {
} }
} }
} }