Fix NavigationObstacle2D debug position
Fixes NavigationObstacle2D debug position.
This commit is contained in:
parent
60f3b7967c
commit
2512157294
|
@ -79,7 +79,7 @@ void NavigationObstacle2D::_notification(int p_what) {
|
||||||
previous_transform = get_global_transform();
|
previous_transform = get_global_transform();
|
||||||
// need to trigger map controlled agent assignment somehow for the fake_agent since obstacles use no callback like regular agents
|
// need to trigger map controlled agent assignment somehow for the fake_agent since obstacles use no callback like regular agents
|
||||||
NavigationServer2D::get_singleton()->obstacle_set_avoidance_enabled(obstacle, avoidance_enabled);
|
NavigationServer2D::get_singleton()->obstacle_set_avoidance_enabled(obstacle, avoidance_enabled);
|
||||||
_update_position(get_global_transform().get_origin());
|
_update_position(get_global_position());
|
||||||
set_physics_process_internal(true);
|
set_physics_process_internal(true);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ void NavigationObstacle2D::_notification(int p_what) {
|
||||||
|
|
||||||
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
|
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
|
||||||
if (is_inside_tree()) {
|
if (is_inside_tree()) {
|
||||||
_update_position(get_global_transform().get_origin());
|
_update_position(get_global_position());
|
||||||
|
|
||||||
if (velocity_submitted) {
|
if (velocity_submitted) {
|
||||||
velocity_submitted = false;
|
velocity_submitted = false;
|
||||||
|
@ -164,9 +164,9 @@ NavigationObstacle2D::~NavigationObstacle2D() {
|
||||||
void NavigationObstacle2D::set_vertices(const Vector<Vector2> &p_vertices) {
|
void NavigationObstacle2D::set_vertices(const Vector<Vector2> &p_vertices) {
|
||||||
vertices = p_vertices;
|
vertices = p_vertices;
|
||||||
NavigationServer2D::get_singleton()->obstacle_set_vertices(obstacle, vertices);
|
NavigationServer2D::get_singleton()->obstacle_set_vertices(obstacle, vertices);
|
||||||
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())) {
|
#ifdef DEBUG_ENABLED
|
||||||
queue_redraw();
|
queue_redraw();
|
||||||
}
|
#endif // DEBUG_ENABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationObstacle2D::set_navigation_map(RID p_navigation_map) {
|
void NavigationObstacle2D::set_navigation_map(RID p_navigation_map) {
|
||||||
|
@ -195,9 +195,9 @@ void NavigationObstacle2D::set_radius(real_t p_radius) {
|
||||||
radius = p_radius;
|
radius = p_radius;
|
||||||
|
|
||||||
NavigationServer2D::get_singleton()->obstacle_set_radius(obstacle, radius);
|
NavigationServer2D::get_singleton()->obstacle_set_radius(obstacle, radius);
|
||||||
if (is_inside_tree() && (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())) {
|
#ifdef DEBUG_ENABLED
|
||||||
queue_redraw();
|
queue_redraw();
|
||||||
}
|
#endif // DEBUG_ENABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationObstacle2D::set_avoidance_layers(uint32_t p_layers) {
|
void NavigationObstacle2D::set_avoidance_layers(uint32_t p_layers) {
|
||||||
|
@ -237,6 +237,9 @@ void NavigationObstacle2D::set_avoidance_enabled(bool p_enabled) {
|
||||||
|
|
||||||
avoidance_enabled = p_enabled;
|
avoidance_enabled = p_enabled;
|
||||||
NavigationServer2D::get_singleton()->obstacle_set_avoidance_enabled(obstacle, avoidance_enabled);
|
NavigationServer2D::get_singleton()->obstacle_set_avoidance_enabled(obstacle, avoidance_enabled);
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
queue_redraw();
|
||||||
|
#endif // DEBUG_ENABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavigationObstacle2D::get_avoidance_enabled() const {
|
bool NavigationObstacle2D::get_avoidance_enabled() const {
|
||||||
|
@ -255,13 +258,16 @@ void NavigationObstacle2D::_update_map(RID p_map) {
|
||||||
|
|
||||||
void NavigationObstacle2D::_update_position(const Vector2 p_position) {
|
void NavigationObstacle2D::_update_position(const Vector2 p_position) {
|
||||||
NavigationServer2D::get_singleton()->obstacle_set_position(obstacle, p_position);
|
NavigationServer2D::get_singleton()->obstacle_set_position(obstacle, p_position);
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
queue_redraw();
|
||||||
|
#endif // DEBUG_ENABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
void NavigationObstacle2D::_update_fake_agent_radius_debug() {
|
void NavigationObstacle2D::_update_fake_agent_radius_debug() {
|
||||||
if (radius > 0.0 && NavigationServer2D::get_singleton()->get_debug_navigation_avoidance_enable_obstacles_radius()) {
|
if (radius > 0.0 && NavigationServer2D::get_singleton()->get_debug_navigation_avoidance_enable_obstacles_radius()) {
|
||||||
Color debug_radius_color = NavigationServer2D::get_singleton()->get_debug_navigation_avoidance_obstacles_radius_color();
|
Color debug_radius_color = NavigationServer2D::get_singleton()->get_debug_navigation_avoidance_obstacles_radius_color();
|
||||||
draw_circle(get_global_transform().get_origin(), radius, debug_radius_color);
|
RS::get_singleton()->canvas_item_add_circle(get_canvas_item(), Vector2(), radius, debug_radius_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
Loading…
Reference in New Issue