This commit is contained in:
aozhiwei 2023-10-26 16:54:27 +08:00
parent 01eb86ae3e
commit b43d0183c2

View File

@ -3596,9 +3596,39 @@ void Creature::ActivateTargetValidPos()
}
if (found) {
glm::vec3 start = found_pos;
glm::vec3 end = context_pos.ToGlmVec3();
glm::vec3 hit_point;
room->map_instance->Scale(start);
room->map_instance->Scale(end);
int same_polys_flags = 0;
std::vector<dtPolyRef> spec_polys;
bool hit_result = false;
bool ret = room->map_instance->RaycastEx(start, end, hit_point, hit_result, same_polys_flags, spec_polys, 0);
if (ret) {
room->map_instance->UnScale(hit_point);
target_valid_pos = hit_point;
}
} else {
glm::vec3 start = GetPos().ToGlmVec3();
glm::vec3 end = context_pos.ToGlmVec3();
glm::vec3 hit_point;
room->map_instance->Scale(start);
room->map_instance->Scale(end);
int same_polys_flags = 0;
std::vector<dtPolyRef> spec_polys;
bool hit_result = false;
bool ret = room->map_instance->RaycastEx(start, end, hit_point, hit_result, same_polys_flags, spec_polys, 0);
if (ret) {
room->map_instance->UnScale(hit_point);
target_valid_pos = hit_point;
}
}
}
target_valid_pos_activated = true;