mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 11:56:49 +01:00
Backported from godot4: Fix NavigationAgent3D debug path duplicated points
Fixes duplicated points in NavigationAgent3D debug path.
- smix8
0b8798a995
This commit is contained in:
parent
24d7260169
commit
568b2541b8
@ -177,7 +177,7 @@ void NavigationAgent::_bind_methods() {
|
|||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_enabled"), "set_debug_enabled", "get_debug_enabled");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_enabled"), "set_debug_enabled", "get_debug_enabled");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_use_custom"), "set_debug_use_custom", "get_debug_use_custom");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_use_custom"), "set_debug_use_custom", "get_debug_use_custom");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_path_custom_color"), "set_debug_path_custom_color", "get_debug_path_custom_color");
|
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "debug_path_custom_color"), "set_debug_path_custom_color", "get_debug_path_custom_color");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "debug_path_custom_point_size", PROPERTY_HINT_RANGE, "1,50,1,suffix:px"), "set_debug_path_custom_point_size", "get_debug_path_custom_point_size");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "debug_path_custom_point_size", PROPERTY_HINT_RANGE, "0,50,0.01,or_greater,suffix:px"), "set_debug_path_custom_point_size", "get_debug_path_custom_point_size");
|
||||||
#endif // DEBUG_ENABLED
|
#endif // DEBUG_ENABLED
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("path_changed"));
|
ADD_SIGNAL(MethodInfo("path_changed"));
|
||||||
@ -932,7 +932,8 @@ Color NavigationAgent::get_debug_path_custom_color() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void NavigationAgent::set_debug_path_custom_point_size(float p_point_size) {
|
void NavigationAgent::set_debug_path_custom_point_size(float p_point_size) {
|
||||||
debug_path_custom_point_size = p_point_size;
|
debug_path_custom_point_size = MAX(0.0, p_point_size);
|
||||||
|
;
|
||||||
debug_path_dirty = true;
|
debug_path_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -998,28 +999,30 @@ void NavigationAgent::_update_debug_path() {
|
|||||||
debug_path_mesh->surface_set_material(0, debug_agent_path_line_material);
|
debug_path_mesh->surface_set_material(0, debug_agent_path_line_material);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<Vector3> debug_path_points_vertex_array;
|
if (debug_path_custom_point_size > 0.0) {
|
||||||
|
Vector<Vector3> debug_path_points_vertex_array;
|
||||||
|
|
||||||
for (int i = 0; i < navigation_path.size(); i++) {
|
for (int i = 0; i < navigation_path.size(); i++) {
|
||||||
debug_path_points_vertex_array.push_back(navigation_path[i]);
|
debug_path_points_vertex_array.push_back(navigation_path[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array debug_path_points_mesh_array;
|
Array debug_path_points_mesh_array;
|
||||||
debug_path_points_mesh_array.resize(Mesh::ARRAY_MAX);
|
debug_path_points_mesh_array.resize(Mesh::ARRAY_MAX);
|
||||||
debug_path_points_mesh_array[Mesh::ARRAY_VERTEX] = debug_path_lines_vertex_array;
|
debug_path_points_mesh_array[Mesh::ARRAY_VERTEX] = debug_path_points_vertex_array;
|
||||||
|
|
||||||
debug_path_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_POINTS, debug_path_points_mesh_array);
|
debug_path_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_POINTS, debug_path_points_mesh_array);
|
||||||
|
|
||||||
Ref<SpatialMaterial> debug_agent_path_point_material = NavigationServer::get_singleton()->get_debug_navigation_agent_path_point_material();
|
Ref<SpatialMaterial> debug_agent_path_point_material = NavigationServer::get_singleton()->get_debug_navigation_agent_path_point_material();
|
||||||
if (debug_use_custom) {
|
if (debug_use_custom) {
|
||||||
if (!debug_agent_path_point_custom_material.is_valid()) {
|
if (!debug_agent_path_point_custom_material.is_valid()) {
|
||||||
debug_agent_path_point_custom_material = debug_agent_path_point_material->duplicate();
|
debug_agent_path_point_custom_material = debug_agent_path_point_material->duplicate();
|
||||||
|
}
|
||||||
|
debug_agent_path_point_custom_material->set_albedo(debug_path_custom_color);
|
||||||
|
debug_agent_path_point_custom_material->set_point_size(debug_path_custom_point_size);
|
||||||
|
debug_path_mesh->surface_set_material(1, debug_agent_path_point_custom_material);
|
||||||
|
} else {
|
||||||
|
debug_path_mesh->surface_set_material(1, debug_agent_path_point_material);
|
||||||
}
|
}
|
||||||
debug_agent_path_point_custom_material->set_albedo(debug_path_custom_color);
|
|
||||||
debug_agent_path_point_custom_material->set_point_size(debug_path_custom_point_size);
|
|
||||||
debug_path_mesh->surface_set_material(1, debug_agent_path_point_custom_material);
|
|
||||||
} else {
|
|
||||||
debug_path_mesh->surface_set_material(1, debug_agent_path_point_material);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RS::get_singleton()->instance_set_base(debug_path_instance, debug_path_mesh->get_rid());
|
RS::get_singleton()->instance_set_base(debug_path_instance, debug_path_mesh->get_rid());
|
||||||
|
Loading…
Reference in New Issue
Block a user