This commit is contained in:
aozhiwei 2023-10-26 16:35:05 +08:00
parent 4432132f23
commit 7cee55b4ca

View File

@ -3569,18 +3569,29 @@ void Creature::ActivateTargetValidPos()
if (target_valid_pos_activated) { if (target_valid_pos_activated) {
target_valid_pos = GetPos().ToGlmVec3(); target_valid_pos = GetPos().ToGlmVec3();
float distance = GetPos().Distance2D2(context_pos); float distance = GetPos().Distance2D2(context_pos);
if (distance > 600 || distance < 10) { if (GlmHelper::IsEqual2D(GetPos().ToGlmVec3(), context_pos.ToGlmVec3()) ||
distance > 600) {
} else { } else {
glm::vec3 center = context_pos.ToGlmVec3(); distance = std::min(600.0f, distance);
room->map_instance->Scale(center); glm::vec3 dir = GetPos().ToGlmVec3() - context_pos.ToGlmVec3();
GlmHelper::Normalize(dir);
dir.y = 0;
while (distance > 10) {
}
if (distance > 600 || distance < 10) {
glm::vec3 point;
bool ok = room->map_instance->FindConnectableNearestPoint(center, 0.3f, point);
if (ok) {
room->map_instance->UnScale(point);
target_valid_pos = point;
} else { } else {
glm::vec3 center = context_pos.ToGlmVec3();
room->map_instance->Scale(center);
glm::vec3 point;
bool ok = room->map_instance->FindConnectableNearestPoint(center, 0.3f, point);
if (ok) {
room->map_instance->UnScale(point);
target_valid_pos = point;
} else {
}
} }
} }
target_valid_pos_activated = true; target_valid_pos_activated = true;