mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-03 01:19:38 +01:00
Simplifications to NavigationAgent and NavigationAgent2D.
This commit is contained in:
parent
268c27458a
commit
11d47d8fdc
@ -611,7 +611,7 @@ Vector2 NavigationAgent2D::get_target_position() const {
|
|||||||
Vector2 NavigationAgent2D::get_next_position() {
|
Vector2 NavigationAgent2D::get_next_position() {
|
||||||
update_navigation();
|
update_navigation();
|
||||||
|
|
||||||
const Vector<Vector2> &navigation_path = navigation_result->get_path();
|
const Vector<Vector2> navigation_path = navigation_result->get_path();
|
||||||
if (navigation_path.size() == 0) {
|
if (navigation_path.size() == 0) {
|
||||||
ERR_FAIL_COND_V(agent_parent == nullptr, Vector2());
|
ERR_FAIL_COND_V(agent_parent == nullptr, Vector2());
|
||||||
return agent_parent->get_global_transform().get_origin();
|
return agent_parent->get_global_transform().get_origin();
|
||||||
@ -649,7 +649,7 @@ bool NavigationAgent2D::is_navigation_finished() {
|
|||||||
Vector2 NavigationAgent2D::get_final_position() {
|
Vector2 NavigationAgent2D::get_final_position() {
|
||||||
update_navigation();
|
update_navigation();
|
||||||
|
|
||||||
const Vector<Vector2> &navigation_path = navigation_result->get_path();
|
const Vector<Vector2> navigation_path = navigation_result->get_path();
|
||||||
if (navigation_path.size() == 0) {
|
if (navigation_path.size() == 0) {
|
||||||
return Vector2();
|
return Vector2();
|
||||||
}
|
}
|
||||||
@ -687,6 +687,7 @@ void NavigationAgent2D::update_navigation() {
|
|||||||
if (agent_parent == nullptr) {
|
if (agent_parent == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!agent_parent->is_inside_tree()) {
|
if (!agent_parent->is_inside_tree()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -708,7 +709,7 @@ void NavigationAgent2D::update_navigation() {
|
|||||||
} else {
|
} else {
|
||||||
// Check if too far from the navigation path
|
// Check if too far from the navigation path
|
||||||
if (nav_path_index > 0) {
|
if (nav_path_index > 0) {
|
||||||
const Vector<Vector2> &navigation_path = navigation_result->get_path();
|
const Vector<Vector2> navigation_path = navigation_result->get_path();
|
||||||
|
|
||||||
Vector2 segment[2];
|
Vector2 segment[2];
|
||||||
segment[0] = navigation_path[nav_path_index - 1];
|
segment[0] = navigation_path[nav_path_index - 1];
|
||||||
@ -727,13 +728,7 @@ void NavigationAgent2D::update_navigation() {
|
|||||||
navigation_query->set_navigation_layers(navigation_layers);
|
navigation_query->set_navigation_layers(navigation_layers);
|
||||||
navigation_query->set_metadata_flags(path_metadata_flags);
|
navigation_query->set_metadata_flags(path_metadata_flags);
|
||||||
|
|
||||||
if (map_override.is_valid()) {
|
navigation_query->set_map(get_navigation_map());
|
||||||
navigation_query->set_map(map_override);
|
|
||||||
} else if (navigation != nullptr) {
|
|
||||||
navigation_query->set_map(navigation->get_rid());
|
|
||||||
} else {
|
|
||||||
navigation_query->set_map(agent_parent->get_world_2d()->get_navigation_map());
|
|
||||||
}
|
|
||||||
|
|
||||||
Navigation2DServer::get_singleton()->query_path(navigation_query, navigation_result);
|
Navigation2DServer::get_singleton()->query_path(navigation_query, navigation_result);
|
||||||
|
|
||||||
@ -753,10 +748,10 @@ void NavigationAgent2D::update_navigation() {
|
|||||||
// Check if we can advance the navigation path
|
// Check if we can advance the navigation path
|
||||||
if (navigation_finished == false) {
|
if (navigation_finished == false) {
|
||||||
// Advances to the next far away position.
|
// Advances to the next far away position.
|
||||||
const Vector<Vector2> &navigation_path = navigation_result->get_path();
|
const Vector<Vector2> navigation_path = navigation_result->get_path();
|
||||||
const Vector<int32_t> &navigation_path_types = navigation_result->get_path_types();
|
const Vector<int32_t> navigation_path_types = navigation_result->get_path_types();
|
||||||
const Array &navigation_path_rids = navigation_result->get_path_rids();
|
const Array navigation_path_rids = navigation_result->get_path_rids();
|
||||||
const Vector<uint64_t> &navigation_path_owners = navigation_result->get_path_owner_ids();
|
const Vector<uint64_t> navigation_path_owners = navigation_result->get_path_owner_ids();
|
||||||
|
|
||||||
while (origin.distance_to(navigation_path[nav_path_index]) < path_desired_distance) {
|
while (origin.distance_to(navigation_path[nav_path_index]) < path_desired_distance) {
|
||||||
Dictionary details;
|
Dictionary details;
|
||||||
@ -924,7 +919,7 @@ void NavigationAgent2D::_update_debug_path() {
|
|||||||
RenderingServer::get_singleton()->canvas_item_set_parent(debug_path_instance, agent_parent->get_canvas());
|
RenderingServer::get_singleton()->canvas_item_set_parent(debug_path_instance, agent_parent->get_canvas());
|
||||||
RenderingServer::get_singleton()->canvas_item_set_visible(debug_path_instance, agent_parent->is_visible_in_tree());
|
RenderingServer::get_singleton()->canvas_item_set_visible(debug_path_instance, agent_parent->is_visible_in_tree());
|
||||||
|
|
||||||
const Vector<Vector2> &navigation_path = navigation_result->get_path();
|
const Vector<Vector2> navigation_path = navigation_result->get_path();
|
||||||
|
|
||||||
if (navigation_path.size() <= 1) {
|
if (navigation_path.size() <= 1) {
|
||||||
return;
|
return;
|
||||||
|
@ -590,7 +590,7 @@ Vector3 NavigationAgent::get_target_position() const {
|
|||||||
Vector3 NavigationAgent::get_next_position() {
|
Vector3 NavigationAgent::get_next_position() {
|
||||||
update_navigation();
|
update_navigation();
|
||||||
|
|
||||||
const Vector<Vector3> &navigation_path = navigation_result->get_path();
|
const Vector<Vector3> navigation_path = navigation_result->get_path();
|
||||||
if (navigation_path.size() == 0) {
|
if (navigation_path.size() == 0) {
|
||||||
ERR_FAIL_COND_V_MSG(agent_parent == nullptr, Vector3(), "The agent has no parent.");
|
ERR_FAIL_COND_V_MSG(agent_parent == nullptr, Vector3(), "The agent has no parent.");
|
||||||
return agent_parent->get_global_transform().origin;
|
return agent_parent->get_global_transform().origin;
|
||||||
@ -628,7 +628,7 @@ bool NavigationAgent::is_navigation_finished() {
|
|||||||
Vector3 NavigationAgent::get_final_position() {
|
Vector3 NavigationAgent::get_final_position() {
|
||||||
update_navigation();
|
update_navigation();
|
||||||
|
|
||||||
const Vector<Vector3> &navigation_path = navigation_result->get_path();
|
const Vector<Vector3> navigation_path = navigation_result->get_path();
|
||||||
|
|
||||||
if (navigation_path.size() == 0) {
|
if (navigation_path.size() == 0) {
|
||||||
return Vector3();
|
return Vector3();
|
||||||
@ -699,7 +699,7 @@ void NavigationAgent::update_navigation() {
|
|||||||
} else {
|
} else {
|
||||||
// Check if too far from the navigation path
|
// Check if too far from the navigation path
|
||||||
if (nav_path_index > 0) {
|
if (nav_path_index > 0) {
|
||||||
const Vector<Vector3> &navigation_path = navigation_result->get_path();
|
const Vector<Vector3> navigation_path = navigation_result->get_path();
|
||||||
|
|
||||||
Vector3 segment[2];
|
Vector3 segment[2];
|
||||||
segment[0] = navigation_path[nav_path_index - 1];
|
segment[0] = navigation_path[nav_path_index - 1];
|
||||||
@ -740,10 +740,10 @@ void NavigationAgent::update_navigation() {
|
|||||||
// Check if we can advance the navigation path
|
// Check if we can advance the navigation path
|
||||||
if (navigation_finished == false) {
|
if (navigation_finished == false) {
|
||||||
// Advances to the next far away position.
|
// Advances to the next far away position.
|
||||||
const Vector<Vector3> &navigation_path = navigation_result->get_path();
|
const Vector<Vector3> navigation_path = navigation_result->get_path();
|
||||||
const Vector<int32_t> &navigation_path_types = navigation_result->get_path_types();
|
const Vector<int32_t> navigation_path_types = navigation_result->get_path_types();
|
||||||
const Array &navigation_path_rids = navigation_result->get_path_rids();
|
const Array navigation_path_rids = navigation_result->get_path_rids();
|
||||||
const Vector<uint64_t> &navigation_path_owners = navigation_result->get_path_owner_ids();
|
const Vector<uint64_t> navigation_path_owners = navigation_result->get_path_owner_ids();
|
||||||
|
|
||||||
while (origin.distance_to(navigation_path[nav_path_index] - Vector3(0, path_height_offset, 0)) < path_desired_distance) {
|
while (origin.distance_to(navigation_path[nav_path_index] - Vector3(0, path_height_offset, 0)) < path_desired_distance) {
|
||||||
Dictionary details;
|
Dictionary details;
|
||||||
@ -969,7 +969,7 @@ void NavigationAgent::_update_debug_path() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Vector<Vector3> &navigation_path = navigation_result->get_path();
|
const Vector<Vector3> navigation_path = navigation_result->get_path();
|
||||||
|
|
||||||
if (navigation_path.size() <= 1) {
|
if (navigation_path.size() <= 1) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user