summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorsmix8 <52464204+smix8@users.noreply.github.com>2022-12-06 23:32:11 +0100
committersmix8 <52464204+smix8@users.noreply.github.com>2023-01-26 18:19:03 +0100
commitbf1571979cd3cd90b2b5c4581b2947450aa4cd9d (patch)
treec47b8ff57f6fb444e9f4c57d259f6fdcad7f218e /scene
parenta3a42159e31db27f8ae7c1ecad6a9ed417cb05de (diff)
Rename Navigation uses of 'location' to 'position'
Contrary to the entire rest of the engine NavigationAgent's and NavigationLinks decided to deal with locations instead of positions.
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/navigation_agent_2d.cpp32
-rw-r--r--scene/2d/navigation_agent_2d.h10
-rw-r--r--scene/2d/navigation_link_2d.cpp78
-rw-r--r--scene/2d/navigation_link_2d.h17
-rw-r--r--scene/3d/navigation_agent_3d.cpp32
-rw-r--r--scene/3d/navigation_agent_3d.h10
-rw-r--r--scene/3d/navigation_link_3d.cpp98
-rw-r--r--scene/3d/navigation_link_3d.h17
8 files changed, 178 insertions, 116 deletions
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp
index 6b842e6e6b..907fb7e6a9 100644
--- a/scene/2d/navigation_agent_2d.cpp
+++ b/scene/2d/navigation_agent_2d.cpp
@@ -76,10 +76,10 @@ void NavigationAgent2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_navigation_map", "navigation_map"), &NavigationAgent2D::set_navigation_map);
ClassDB::bind_method(D_METHOD("get_navigation_map"), &NavigationAgent2D::get_navigation_map);
- ClassDB::bind_method(D_METHOD("set_target_location", "location"), &NavigationAgent2D::set_target_location);
- ClassDB::bind_method(D_METHOD("get_target_location"), &NavigationAgent2D::get_target_location);
+ ClassDB::bind_method(D_METHOD("set_target_position", "position"), &NavigationAgent2D::set_target_position);
+ ClassDB::bind_method(D_METHOD("get_target_position"), &NavigationAgent2D::get_target_position);
- ClassDB::bind_method(D_METHOD("get_next_location"), &NavigationAgent2D::get_next_location);
+ ClassDB::bind_method(D_METHOD("get_next_path_position"), &NavigationAgent2D::get_next_path_position);
ClassDB::bind_method(D_METHOD("distance_to_target"), &NavigationAgent2D::distance_to_target);
ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &NavigationAgent2D::set_velocity);
ClassDB::bind_method(D_METHOD("get_current_navigation_result"), &NavigationAgent2D::get_current_navigation_result);
@@ -88,12 +88,12 @@ void NavigationAgent2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_target_reached"), &NavigationAgent2D::is_target_reached);
ClassDB::bind_method(D_METHOD("is_target_reachable"), &NavigationAgent2D::is_target_reachable);
ClassDB::bind_method(D_METHOD("is_navigation_finished"), &NavigationAgent2D::is_navigation_finished);
- ClassDB::bind_method(D_METHOD("get_final_location"), &NavigationAgent2D::get_final_location);
+ ClassDB::bind_method(D_METHOD("get_final_position"), &NavigationAgent2D::get_final_position);
ClassDB::bind_method(D_METHOD("_avoidance_done", "new_velocity"), &NavigationAgent2D::_avoidance_done);
ADD_GROUP("Pathfinding", "");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "target_location", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_target_location", "get_target_location");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "target_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_target_position", "get_target_position");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_desired_distance", PROPERTY_HINT_RANGE, "0.1,1000,0.01,suffix:px"), "set_path_desired_distance", "get_path_desired_distance");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,1000,0.01,suffix:px"), "set_target_desired_distance", "get_target_desired_distance");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_max_distance", PROPERTY_HINT_RANGE, "10,1000,1,suffix:px"), "set_path_max_distance", "get_path_max_distance");
@@ -328,17 +328,17 @@ real_t NavigationAgent2D::get_path_max_distance() {
return path_max_distance;
}
-void NavigationAgent2D::set_target_location(Vector2 p_location) {
- target_location = p_location;
+void NavigationAgent2D::set_target_position(Vector2 p_position) {
+ target_position = p_position;
target_position_submitted = true;
_request_repath();
}
-Vector2 NavigationAgent2D::get_target_location() const {
- return target_location;
+Vector2 NavigationAgent2D::get_target_position() const {
+ return target_position;
}
-Vector2 NavigationAgent2D::get_next_location() {
+Vector2 NavigationAgent2D::get_next_path_position() {
update_navigation();
const Vector<Vector2> &navigation_path = navigation_result->get_path();
@@ -352,7 +352,7 @@ Vector2 NavigationAgent2D::get_next_location() {
real_t NavigationAgent2D::distance_to_target() const {
ERR_FAIL_COND_V_MSG(agent_parent == nullptr, 0.0, "The agent has no parent.");
- return agent_parent->get_global_position().distance_to(target_location);
+ return agent_parent->get_global_position().distance_to(target_position);
}
bool NavigationAgent2D::is_target_reached() const {
@@ -360,7 +360,7 @@ bool NavigationAgent2D::is_target_reached() const {
}
bool NavigationAgent2D::is_target_reachable() {
- return target_desired_distance >= get_final_location().distance_to(target_location);
+ return target_desired_distance >= get_final_position().distance_to(target_position);
}
bool NavigationAgent2D::is_navigation_finished() {
@@ -368,7 +368,7 @@ bool NavigationAgent2D::is_navigation_finished() {
return navigation_finished;
}
-Vector2 NavigationAgent2D::get_final_location() {
+Vector2 NavigationAgent2D::get_final_position() {
update_navigation();
const Vector<Vector2> &navigation_path = navigation_result->get_path();
@@ -450,7 +450,7 @@ void NavigationAgent2D::update_navigation() {
if (reload_path) {
navigation_query->set_start_position(origin);
- navigation_query->set_target_position(target_location);
+ navigation_query->set_target_position(target_position);
navigation_query->set_navigation_layers(navigation_layers);
navigation_query->set_metadata_flags(path_metadata_flags);
@@ -472,7 +472,7 @@ void NavigationAgent2D::update_navigation() {
// Check if we can advance the navigation path
if (navigation_finished == false) {
- // Advances to the next far away location.
+ // Advances to the next far away position.
const Vector<Vector2> &navigation_path = navigation_result->get_path();
const Vector<int32_t> &navigation_path_types = navigation_result->get_path_types();
const TypedArray<RID> &navigation_path_rids = navigation_result->get_path_rids();
@@ -482,7 +482,7 @@ void NavigationAgent2D::update_navigation() {
Dictionary details;
const Vector2 waypoint = navigation_path[navigation_path_index];
- details[SNAME("location")] = waypoint;
+ details[SNAME("position")] = waypoint;
int waypoint_type = -1;
if (path_metadata_flags.has_flag(NavigationPathQueryParameters2D::PathMetadataFlags::PATH_METADATA_INCLUDE_TYPES)) {
diff --git a/scene/2d/navigation_agent_2d.h b/scene/2d/navigation_agent_2d.h
index 190a2fcbda..9787bb1bdb 100644
--- a/scene/2d/navigation_agent_2d.h
+++ b/scene/2d/navigation_agent_2d.h
@@ -60,7 +60,7 @@ class NavigationAgent2D : public Node {
real_t path_max_distance = 100.0;
- Vector2 target_location;
+ Vector2 target_position;
bool target_position_submitted = false;
Ref<NavigationPathQueryParameters2D> navigation_query;
Ref<NavigationPathQueryResult2D> navigation_result;
@@ -143,10 +143,10 @@ public:
void set_path_max_distance(real_t p_pmd);
real_t get_path_max_distance();
- void set_target_location(Vector2 p_location);
- Vector2 get_target_location() const;
+ void set_target_position(Vector2 p_position);
+ Vector2 get_target_position() const;
- Vector2 get_next_location();
+ Vector2 get_next_path_position();
Ref<NavigationPathQueryResult2D> get_current_navigation_result() const {
return navigation_result;
@@ -162,7 +162,7 @@ public:
bool is_target_reached() const;
bool is_target_reachable();
bool is_navigation_finished();
- Vector2 get_final_location();
+ Vector2 get_final_position();
void set_velocity(Vector2 p_velocity);
void _avoidance_done(Vector3 p_new_velocity);
diff --git a/scene/2d/navigation_link_2d.cpp b/scene/2d/navigation_link_2d.cpp
index 9ef0ba617e..65bf178cc5 100644
--- a/scene/2d/navigation_link_2d.cpp
+++ b/scene/2d/navigation_link_2d.cpp
@@ -48,11 +48,11 @@ void NavigationLink2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationLink2D::set_navigation_layer_value);
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationLink2D::get_navigation_layer_value);
- ClassDB::bind_method(D_METHOD("set_start_location", "location"), &NavigationLink2D::set_start_location);
- ClassDB::bind_method(D_METHOD("get_start_location"), &NavigationLink2D::get_start_location);
+ ClassDB::bind_method(D_METHOD("set_start_position", "position"), &NavigationLink2D::set_start_position);
+ ClassDB::bind_method(D_METHOD("get_start_position"), &NavigationLink2D::get_start_position);
- ClassDB::bind_method(D_METHOD("set_end_location", "location"), &NavigationLink2D::set_end_location);
- ClassDB::bind_method(D_METHOD("get_end_location"), &NavigationLink2D::get_end_location);
+ ClassDB::bind_method(D_METHOD("set_end_position", "position"), &NavigationLink2D::set_end_position);
+ ClassDB::bind_method(D_METHOD("get_end_position"), &NavigationLink2D::get_end_position);
ClassDB::bind_method(D_METHOD("set_enter_cost", "enter_cost"), &NavigationLink2D::set_enter_cost);
ClassDB::bind_method(D_METHOD("get_enter_cost"), &NavigationLink2D::get_enter_cost);
@@ -63,12 +63,38 @@ void NavigationLink2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bidirectional"), "set_bidirectional", "is_bidirectional");
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_2D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "start_location"), "set_start_location", "get_start_location");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "end_location"), "set_end_location", "get_end_location");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "start_position"), "set_start_position", "get_start_position");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "end_position"), "set_end_position", "get_end_position");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "enter_cost"), "set_enter_cost", "get_enter_cost");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "travel_cost"), "set_travel_cost", "get_travel_cost");
}
+#ifndef DISABLE_DEPRECATED
+bool NavigationLink2D::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == "start_location") {
+ set_start_position(p_value);
+ return true;
+ }
+ if (p_name == "end_location") {
+ set_end_position(p_value);
+ return true;
+ }
+ return false;
+}
+
+bool NavigationLink2D::_get(const StringName &p_name, Variant &r_ret) const {
+ if (p_name == "start_location") {
+ r_ret = get_start_position();
+ return true;
+ }
+ if (p_name == "end_location") {
+ r_ret = get_end_position();
+ return true;
+ }
+ return false;
+}
+#endif // DISABLE_DEPRECATED
+
void NavigationLink2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -77,15 +103,15 @@ void NavigationLink2D::_notification(int p_what) {
// Update global positions for the link.
Transform2D gt = get_global_transform();
- NavigationServer2D::get_singleton()->link_set_start_location(link, gt.xform(start_location));
- NavigationServer2D::get_singleton()->link_set_end_location(link, gt.xform(end_location));
+ NavigationServer2D::get_singleton()->link_set_start_position(link, gt.xform(start_position));
+ NavigationServer2D::get_singleton()->link_set_end_position(link, gt.xform(end_position));
}
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
// Update global positions for the link.
Transform2D gt = get_global_transform();
- NavigationServer2D::get_singleton()->link_set_start_location(link, gt.xform(start_location));
- NavigationServer2D::get_singleton()->link_set_end_location(link, gt.xform(end_location));
+ NavigationServer2D::get_singleton()->link_set_start_position(link, gt.xform(start_position));
+ NavigationServer2D::get_singleton()->link_set_end_position(link, gt.xform(end_position));
} break;
case NOTIFICATION_EXIT_TREE: {
NavigationServer2D::get_singleton()->link_set_map(link, RID());
@@ -102,9 +128,9 @@ void NavigationLink2D::_notification(int p_what) {
real_t radius = NavigationServer2D::get_singleton()->map_get_link_connection_radius(get_world_2d()->get_navigation_map());
- draw_line(get_start_location(), get_end_location(), color);
- draw_arc(get_start_location(), radius, 0, Math_TAU, 10, color);
- draw_arc(get_end_location(), radius, 0, Math_TAU, 10, color);
+ draw_line(get_start_position(), get_end_position(), color);
+ draw_arc(get_start_position(), radius, 0, Math_TAU, 10, color);
+ draw_arc(get_end_position(), radius, 0, Math_TAU, 10, color);
}
#endif // DEBUG_ENABLED
} break;
@@ -119,14 +145,14 @@ Rect2 NavigationLink2D::_edit_get_rect() const {
real_t radius = NavigationServer2D::get_singleton()->map_get_link_connection_radius(get_world_2d()->get_navigation_map());
- Rect2 rect(get_start_location(), Size2());
- rect.expand_to(get_end_location());
+ Rect2 rect(get_start_position(), Size2());
+ rect.expand_to(get_end_position());
rect.grow_by(radius);
return rect;
}
bool NavigationLink2D::_edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const {
- Point2 segment[2] = { get_start_location(), get_end_location() };
+ Point2 segment[2] = { get_start_position(), get_end_position() };
Vector2 closest_point = Geometry2D::get_closest_point_to_segment(p_point, segment);
return p_point.distance_to(closest_point) < p_tolerance;
@@ -199,19 +225,19 @@ bool NavigationLink2D::get_navigation_layer_value(int p_layer_number) const {
return get_navigation_layers() & (1 << (p_layer_number - 1));
}
-void NavigationLink2D::set_start_location(Vector2 p_location) {
- if (start_location.is_equal_approx(p_location)) {
+void NavigationLink2D::set_start_position(Vector2 p_position) {
+ if (start_position.is_equal_approx(p_position)) {
return;
}
- start_location = p_location;
+ start_position = p_position;
if (!is_inside_tree()) {
return;
}
Transform2D gt = get_global_transform();
- NavigationServer2D::get_singleton()->link_set_start_location(link, gt.xform(start_location));
+ NavigationServer2D::get_singleton()->link_set_start_position(link, gt.xform(start_position));
update_configuration_warnings();
@@ -222,19 +248,19 @@ void NavigationLink2D::set_start_location(Vector2 p_location) {
#endif // DEBUG_ENABLED
}
-void NavigationLink2D::set_end_location(Vector2 p_location) {
- if (end_location.is_equal_approx(p_location)) {
+void NavigationLink2D::set_end_position(Vector2 p_position) {
+ if (end_position.is_equal_approx(p_position)) {
return;
}
- end_location = p_location;
+ end_position = p_position;
if (!is_inside_tree()) {
return;
}
Transform2D gt = get_global_transform();
- NavigationServer2D::get_singleton()->link_set_end_location(link, gt.xform(end_location));
+ NavigationServer2D::get_singleton()->link_set_end_position(link, gt.xform(end_position));
update_configuration_warnings();
@@ -270,8 +296,8 @@ void NavigationLink2D::set_travel_cost(real_t p_travel_cost) {
PackedStringArray NavigationLink2D::get_configuration_warnings() const {
PackedStringArray warnings = Node::get_configuration_warnings();
- if (start_location.is_equal_approx(end_location)) {
- warnings.push_back(RTR("NavigationLink2D start location should be different than the end location to be useful."));
+ if (start_position.is_equal_approx(end_position)) {
+ warnings.push_back(RTR("NavigationLink2D start position should be different than the end position to be useful."));
}
return warnings;
diff --git a/scene/2d/navigation_link_2d.h b/scene/2d/navigation_link_2d.h
index e14ee5adb9..5bf2a72358 100644
--- a/scene/2d/navigation_link_2d.h
+++ b/scene/2d/navigation_link_2d.h
@@ -40,8 +40,8 @@ class NavigationLink2D : public Node2D {
RID link;
bool bidirectional = true;
uint32_t navigation_layers = 1;
- Vector2 end_location;
- Vector2 start_location;
+ Vector2 end_position;
+ Vector2 start_position;
real_t enter_cost = 0.0;
real_t travel_cost = 1.0;
@@ -49,6 +49,11 @@ protected:
static void _bind_methods();
void _notification(int p_what);
+#ifndef DISABLE_DEPRECATED
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+#endif // DISABLE_DEPRECATED
+
public:
#ifdef TOOLS_ENABLED
virtual Rect2 _edit_get_rect() const override;
@@ -67,11 +72,11 @@ public:
void set_navigation_layer_value(int p_layer_number, bool p_value);
bool get_navigation_layer_value(int p_layer_number) const;
- void set_start_location(Vector2 p_location);
- Vector2 get_start_location() const { return start_location; }
+ void set_start_position(Vector2 p_position);
+ Vector2 get_start_position() const { return start_position; }
- void set_end_location(Vector2 p_location);
- Vector2 get_end_location() const { return end_location; }
+ void set_end_position(Vector2 p_position);
+ Vector2 get_end_position() const { return end_position; }
void set_enter_cost(real_t p_enter_cost);
real_t get_enter_cost() const { return enter_cost; }
diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp
index 0034bf78b9..fe7ddcb06e 100644
--- a/scene/3d/navigation_agent_3d.cpp
+++ b/scene/3d/navigation_agent_3d.cpp
@@ -80,10 +80,10 @@ void NavigationAgent3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_navigation_map", "navigation_map"), &NavigationAgent3D::set_navigation_map);
ClassDB::bind_method(D_METHOD("get_navigation_map"), &NavigationAgent3D::get_navigation_map);
- ClassDB::bind_method(D_METHOD("set_target_location", "location"), &NavigationAgent3D::set_target_location);
- ClassDB::bind_method(D_METHOD("get_target_location"), &NavigationAgent3D::get_target_location);
+ ClassDB::bind_method(D_METHOD("set_target_position", "position"), &NavigationAgent3D::set_target_position);
+ ClassDB::bind_method(D_METHOD("get_target_position"), &NavigationAgent3D::get_target_position);
- ClassDB::bind_method(D_METHOD("get_next_location"), &NavigationAgent3D::get_next_location);
+ ClassDB::bind_method(D_METHOD("get_next_path_position"), &NavigationAgent3D::get_next_path_position);
ClassDB::bind_method(D_METHOD("distance_to_target"), &NavigationAgent3D::distance_to_target);
ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &NavigationAgent3D::set_velocity);
ClassDB::bind_method(D_METHOD("get_current_navigation_result"), &NavigationAgent3D::get_current_navigation_result);
@@ -92,12 +92,12 @@ void NavigationAgent3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_target_reached"), &NavigationAgent3D::is_target_reached);
ClassDB::bind_method(D_METHOD("is_target_reachable"), &NavigationAgent3D::is_target_reachable);
ClassDB::bind_method(D_METHOD("is_navigation_finished"), &NavigationAgent3D::is_navigation_finished);
- ClassDB::bind_method(D_METHOD("get_final_location"), &NavigationAgent3D::get_final_location);
+ ClassDB::bind_method(D_METHOD("get_final_position"), &NavigationAgent3D::get_final_position);
ClassDB::bind_method(D_METHOD("_avoidance_done", "new_velocity"), &NavigationAgent3D::_avoidance_done);
ADD_GROUP("Pathfinding", "");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "target_location", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_target_location", "get_target_location");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "target_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_target_position", "get_target_position");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "path_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01,suffix:m"), "set_path_desired_distance", "get_path_desired_distance");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "target_desired_distance", PROPERTY_HINT_RANGE, "0.1,100,0.01,suffix:m"), "set_target_desired_distance", "get_target_desired_distance");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "agent_height_offset", PROPERTY_HINT_RANGE, "-100.0,100,0.01,suffix:m"), "set_agent_height_offset", "get_agent_height_offset");
@@ -344,17 +344,17 @@ real_t NavigationAgent3D::get_path_max_distance() {
return path_max_distance;
}
-void NavigationAgent3D::set_target_location(Vector3 p_location) {
- target_location = p_location;
+void NavigationAgent3D::set_target_position(Vector3 p_position) {
+ target_position = p_position;
target_position_submitted = true;
_request_repath();
}
-Vector3 NavigationAgent3D::get_target_location() const {
- return target_location;
+Vector3 NavigationAgent3D::get_target_position() const {
+ return target_position;
}
-Vector3 NavigationAgent3D::get_next_location() {
+Vector3 NavigationAgent3D::get_next_path_position() {
update_navigation();
const Vector<Vector3> &navigation_path = navigation_result->get_path();
@@ -368,7 +368,7 @@ Vector3 NavigationAgent3D::get_next_location() {
real_t NavigationAgent3D::distance_to_target() const {
ERR_FAIL_COND_V_MSG(agent_parent == nullptr, 0.0, "The agent has no parent.");
- return agent_parent->get_global_transform().origin.distance_to(target_location);
+ return agent_parent->get_global_transform().origin.distance_to(target_position);
}
bool NavigationAgent3D::is_target_reached() const {
@@ -376,7 +376,7 @@ bool NavigationAgent3D::is_target_reached() const {
}
bool NavigationAgent3D::is_target_reachable() {
- return target_desired_distance >= get_final_location().distance_to(target_location);
+ return target_desired_distance >= get_final_position().distance_to(target_position);
}
bool NavigationAgent3D::is_navigation_finished() {
@@ -384,7 +384,7 @@ bool NavigationAgent3D::is_navigation_finished() {
return navigation_finished;
}
-Vector3 NavigationAgent3D::get_final_location() {
+Vector3 NavigationAgent3D::get_final_position() {
update_navigation();
const Vector<Vector3> &navigation_path = navigation_result->get_path();
@@ -467,7 +467,7 @@ void NavigationAgent3D::update_navigation() {
if (reload_path) {
navigation_query->set_start_position(origin);
- navigation_query->set_target_position(target_location);
+ navigation_query->set_target_position(target_position);
navigation_query->set_navigation_layers(navigation_layers);
navigation_query->set_metadata_flags(path_metadata_flags);
@@ -489,7 +489,7 @@ void NavigationAgent3D::update_navigation() {
// Check if we can advance the navigation path
if (navigation_finished == false) {
- // Advances to the next far away location.
+ // Advances to the next far away position.
const Vector<Vector3> &navigation_path = navigation_result->get_path();
const Vector<int32_t> &navigation_path_types = navigation_result->get_path_types();
const TypedArray<RID> &navigation_path_rids = navigation_result->get_path_rids();
@@ -499,7 +499,7 @@ void NavigationAgent3D::update_navigation() {
Dictionary details;
const Vector3 waypoint = navigation_path[navigation_path_index];
- details[SNAME("location")] = waypoint;
+ details[SNAME("position")] = waypoint;
int waypoint_type = -1;
if (path_metadata_flags.has_flag(NavigationPathQueryParameters3D::PathMetadataFlags::PATH_METADATA_INCLUDE_TYPES)) {
diff --git a/scene/3d/navigation_agent_3d.h b/scene/3d/navigation_agent_3d.h
index 91be068392..12f83ce6a8 100644
--- a/scene/3d/navigation_agent_3d.h
+++ b/scene/3d/navigation_agent_3d.h
@@ -62,7 +62,7 @@ class NavigationAgent3D : public Node {
real_t path_max_distance = 3.0;
- Vector3 target_location;
+ Vector3 target_position;
bool target_position_submitted = false;
Ref<NavigationPathQueryParameters3D> navigation_query;
Ref<NavigationPathQueryResult3D> navigation_result;
@@ -155,10 +155,10 @@ public:
void set_path_max_distance(real_t p_pmd);
real_t get_path_max_distance();
- void set_target_location(Vector3 p_location);
- Vector3 get_target_location() const;
+ void set_target_position(Vector3 p_position);
+ Vector3 get_target_position() const;
- Vector3 get_next_location();
+ Vector3 get_next_path_position();
Ref<NavigationPathQueryResult3D> get_current_navigation_result() const {
return navigation_result;
@@ -174,7 +174,7 @@ public:
bool is_target_reached() const;
bool is_target_reachable();
bool is_navigation_finished();
- Vector3 get_final_location();
+ Vector3 get_final_position();
void set_velocity(Vector3 p_velocity);
void _avoidance_done(Vector3 p_new_velocity);
diff --git a/scene/3d/navigation_link_3d.cpp b/scene/3d/navigation_link_3d.cpp
index e058ef62d0..f47fcfaf51 100644
--- a/scene/3d/navigation_link_3d.cpp
+++ b/scene/3d/navigation_link_3d.cpp
@@ -70,10 +70,10 @@ void NavigationLink3D::_update_debug_mesh() {
Vector<Vector3> lines;
// Draw line between the points.
- lines.push_back(start_location);
- lines.push_back(end_location);
+ lines.push_back(start_position);
+ lines.push_back(end_position);
- // Draw start location search radius
+ // Draw start position search radius
for (int i = 0; i < 30; i++) {
// Create a circle
const float ra = Math::deg_to_rad((float)(i * 12));
@@ -84,21 +84,21 @@ void NavigationLink3D::_update_debug_mesh() {
// Draw axis-aligned circle
switch (up_axis) {
case Vector3::AXIS_X:
- lines.append(start_location + Vector3(0, a.x, a.y));
- lines.append(start_location + Vector3(0, b.x, b.y));
+ lines.append(start_position + Vector3(0, a.x, a.y));
+ lines.append(start_position + Vector3(0, b.x, b.y));
break;
case Vector3::AXIS_Y:
- lines.append(start_location + Vector3(a.x, 0, a.y));
- lines.append(start_location + Vector3(b.x, 0, b.y));
+ lines.append(start_position + Vector3(a.x, 0, a.y));
+ lines.append(start_position + Vector3(b.x, 0, b.y));
break;
case Vector3::AXIS_Z:
- lines.append(start_location + Vector3(a.x, a.y, 0));
- lines.append(start_location + Vector3(b.x, b.y, 0));
+ lines.append(start_position + Vector3(a.x, a.y, 0));
+ lines.append(start_position + Vector3(b.x, b.y, 0));
break;
}
}
- // Draw end location search radius
+ // Draw end position search radius
for (int i = 0; i < 30; i++) {
// Create a circle
const float ra = Math::deg_to_rad((float)(i * 12));
@@ -109,16 +109,16 @@ void NavigationLink3D::_update_debug_mesh() {
// Draw axis-aligned circle
switch (up_axis) {
case Vector3::AXIS_X:
- lines.append(end_location + Vector3(0, a.x, a.y));
- lines.append(end_location + Vector3(0, b.x, b.y));
+ lines.append(end_position + Vector3(0, a.x, a.y));
+ lines.append(end_position + Vector3(0, b.x, b.y));
break;
case Vector3::AXIS_Y:
- lines.append(end_location + Vector3(a.x, 0, a.y));
- lines.append(end_location + Vector3(b.x, 0, b.y));
+ lines.append(end_position + Vector3(a.x, 0, a.y));
+ lines.append(end_position + Vector3(b.x, 0, b.y));
break;
case Vector3::AXIS_Z:
- lines.append(end_location + Vector3(a.x, a.y, 0));
- lines.append(end_location + Vector3(b.x, b.y, 0));
+ lines.append(end_position + Vector3(a.x, a.y, 0));
+ lines.append(end_position + Vector3(b.x, b.y, 0));
break;
}
}
@@ -157,11 +157,11 @@ void NavigationLink3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_navigation_layer_value", "layer_number", "value"), &NavigationLink3D::set_navigation_layer_value);
ClassDB::bind_method(D_METHOD("get_navigation_layer_value", "layer_number"), &NavigationLink3D::get_navigation_layer_value);
- ClassDB::bind_method(D_METHOD("set_start_location", "location"), &NavigationLink3D::set_start_location);
- ClassDB::bind_method(D_METHOD("get_start_location"), &NavigationLink3D::get_start_location);
+ ClassDB::bind_method(D_METHOD("set_start_position", "position"), &NavigationLink3D::set_start_position);
+ ClassDB::bind_method(D_METHOD("get_start_position"), &NavigationLink3D::get_start_position);
- ClassDB::bind_method(D_METHOD("set_end_location", "location"), &NavigationLink3D::set_end_location);
- ClassDB::bind_method(D_METHOD("get_end_location"), &NavigationLink3D::get_end_location);
+ ClassDB::bind_method(D_METHOD("set_end_position", "position"), &NavigationLink3D::set_end_position);
+ ClassDB::bind_method(D_METHOD("get_end_position"), &NavigationLink3D::get_end_position);
ClassDB::bind_method(D_METHOD("set_enter_cost", "enter_cost"), &NavigationLink3D::set_enter_cost);
ClassDB::bind_method(D_METHOD("get_enter_cost"), &NavigationLink3D::get_enter_cost);
@@ -172,12 +172,38 @@ void NavigationLink3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bidirectional"), "set_bidirectional", "is_bidirectional");
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_layers", PROPERTY_HINT_LAYERS_3D_NAVIGATION), "set_navigation_layers", "get_navigation_layers");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "start_location"), "set_start_location", "get_start_location");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "end_location"), "set_end_location", "get_end_location");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "start_position"), "set_start_position", "get_start_position");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "end_position"), "set_end_position", "get_end_position");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "enter_cost"), "set_enter_cost", "get_enter_cost");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "travel_cost"), "set_travel_cost", "get_travel_cost");
}
+#ifndef DISABLE_DEPRECATED
+bool NavigationLink3D::_set(const StringName &p_name, const Variant &p_value) {
+ if (p_name == "start_location") {
+ set_start_position(p_value);
+ return true;
+ }
+ if (p_name == "end_location") {
+ set_end_position(p_value);
+ return true;
+ }
+ return false;
+}
+
+bool NavigationLink3D::_get(const StringName &p_name, Variant &r_ret) const {
+ if (p_name == "start_location") {
+ r_ret = get_start_position();
+ return true;
+ }
+ if (p_name == "end_location") {
+ r_ret = get_end_position();
+ return true;
+ }
+ return false;
+}
+#endif // DISABLE_DEPRECATED
+
void NavigationLink3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -186,8 +212,8 @@ void NavigationLink3D::_notification(int p_what) {
// Update global positions for the link.
Transform3D gt = get_global_transform();
- NavigationServer3D::get_singleton()->link_set_start_location(link, gt.xform(start_location));
- NavigationServer3D::get_singleton()->link_set_end_location(link, gt.xform(end_location));
+ NavigationServer3D::get_singleton()->link_set_start_position(link, gt.xform(start_position));
+ NavigationServer3D::get_singleton()->link_set_end_position(link, gt.xform(end_position));
}
#ifdef DEBUG_ENABLED
@@ -197,8 +223,8 @@ void NavigationLink3D::_notification(int p_what) {
case NOTIFICATION_TRANSFORM_CHANGED: {
// Update global positions for the link.
Transform3D gt = get_global_transform();
- NavigationServer3D::get_singleton()->link_set_start_location(link, gt.xform(start_location));
- NavigationServer3D::get_singleton()->link_set_end_location(link, gt.xform(end_location));
+ NavigationServer3D::get_singleton()->link_set_start_position(link, gt.xform(start_position));
+ NavigationServer3D::get_singleton()->link_set_end_position(link, gt.xform(end_position));
#ifdef DEBUG_ENABLED
if (is_inside_tree() && debug_instance.is_valid()) {
@@ -316,19 +342,19 @@ bool NavigationLink3D::get_navigation_layer_value(int p_layer_number) const {
return get_navigation_layers() & (1 << (p_layer_number - 1));
}
-void NavigationLink3D::set_start_location(Vector3 p_location) {
- if (start_location.is_equal_approx(p_location)) {
+void NavigationLink3D::set_start_position(Vector3 p_position) {
+ if (start_position.is_equal_approx(p_position)) {
return;
}
- start_location = p_location;
+ start_position = p_position;
if (!is_inside_tree()) {
return;
}
Transform3D gt = get_global_transform();
- NavigationServer3D::get_singleton()->link_set_start_location(link, gt.xform(start_location));
+ NavigationServer3D::get_singleton()->link_set_start_position(link, gt.xform(start_position));
#ifdef DEBUG_ENABLED
_update_debug_mesh();
@@ -338,19 +364,19 @@ void NavigationLink3D::set_start_location(Vector3 p_location) {
update_configuration_warnings();
}
-void NavigationLink3D::set_end_location(Vector3 p_location) {
- if (end_location.is_equal_approx(p_location)) {
+void NavigationLink3D::set_end_position(Vector3 p_position) {
+ if (end_position.is_equal_approx(p_position)) {
return;
}
- end_location = p_location;
+ end_position = p_position;
if (!is_inside_tree()) {
return;
}
Transform3D gt = get_global_transform();
- NavigationServer3D::get_singleton()->link_set_end_location(link, gt.xform(end_location));
+ NavigationServer3D::get_singleton()->link_set_end_position(link, gt.xform(end_position));
#ifdef DEBUG_ENABLED
_update_debug_mesh();
@@ -385,8 +411,8 @@ void NavigationLink3D::set_travel_cost(real_t p_travel_cost) {
PackedStringArray NavigationLink3D::get_configuration_warnings() const {
PackedStringArray warnings = Node::get_configuration_warnings();
- if (start_location.is_equal_approx(end_location)) {
- warnings.push_back(RTR("NavigationLink3D start location should be different than the end location to be useful."));
+ if (start_position.is_equal_approx(end_position)) {
+ warnings.push_back(RTR("NavigationLink3D start position should be different than the end position to be useful."));
}
return warnings;
diff --git a/scene/3d/navigation_link_3d.h b/scene/3d/navigation_link_3d.h
index 175c5cdd5d..5c9ec36189 100644
--- a/scene/3d/navigation_link_3d.h
+++ b/scene/3d/navigation_link_3d.h
@@ -40,8 +40,8 @@ class NavigationLink3D : public Node3D {
RID link;
bool bidirectional = true;
uint32_t navigation_layers = 1;
- Vector3 end_location;
- Vector3 start_location;
+ Vector3 end_position;
+ Vector3 start_position;
real_t enter_cost = 0.0;
real_t travel_cost = 1.0;
@@ -56,6 +56,11 @@ protected:
static void _bind_methods();
void _notification(int p_what);
+#ifndef DISABLE_DEPRECATED
+ bool _set(const StringName &p_name, const Variant &p_value);
+ bool _get(const StringName &p_name, Variant &r_ret) const;
+#endif // DISABLE_DEPRECATED
+
public:
NavigationLink3D();
~NavigationLink3D();
@@ -72,11 +77,11 @@ public:
void set_navigation_layer_value(int p_layer_number, bool p_value);
bool get_navigation_layer_value(int p_layer_number) const;
- void set_start_location(Vector3 p_location);
- Vector3 get_start_location() const { return start_location; }
+ void set_start_position(Vector3 p_position);
+ Vector3 get_start_position() const { return start_position; }
- void set_end_location(Vector3 p_location);
- Vector3 get_end_location() const { return end_location; }
+ void set_end_position(Vector3 p_position);
+ Vector3 get_end_position() const { return end_position; }
void set_enter_cost(real_t p_enter_cost);
real_t get_enter_cost() const { return enter_cost; }