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();
GlmHelper::Normalize(dir);
dir.y = 0;
while (distance > 10) {
}
if (distance > 600 || distance < 10) {
} else {
glm::vec3 center = context_pos.ToGlmVec3();
bool found = false;
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);
glm::vec3 point;
bool ok = room->map_instance->FindConnectableNearestPoint(center, 0.3f, point);
bool ok = room->map_instance->FindConnectableNearestPoint(center, 0.3f, found_pos);
if (ok) {
room->map_instance->UnScale(point);
target_valid_pos = point;
} else {
room->map_instance->UnScale(found_pos);
found = true;
break;
}
move_len += 10;
}
}
}