Skip to content

Commit

Permalink
Prefer set_data when setting polygons and vertices.
Browse files Browse the repository at this point in the history
  • Loading branch information
libklein committed Aug 16, 2024
1 parent 2688859 commit d121458
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion modules/navigation/3d/nav_mesh_generator_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,6 @@ void NavMeshGenerator3D::generator_bake_from_source_geometry_data(Ref<Navigation
nav_polygons.push_back(nav_indices);
}
}
p_navigation_mesh->set_polygons(nav_polygons);

p_navigation_mesh->set_data(nav_vertices, nav_polygons);

Expand Down
11 changes: 7 additions & 4 deletions scene/resources/2d/tile_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6502,16 +6502,19 @@ Ref<NavigationPolygon> TileData::get_navigation_polygon(int p_layer_id, bool p_f
transformed_polygon.instantiate();

PackedVector2Array new_points = get_transformed_vertices(layer_tile_data.navigation_polygon->get_vertices(), p_flip_h, p_flip_v, p_transpose);
transformed_polygon->set_vertices(new_points);

transformed_polygon->set_polygons(layer_tile_data.navigation_polygon->get_polygons());
transformed_polygon->set_data(new_points, layer_tile_data.navigation_polygon->get_polygons());

const Vector<Vector<Vector2>> outlines = layer_tile_data.navigation_polygon->get_outlines();
int outline_count = outlines.size();

int outline_count = layer_tile_data.navigation_polygon->get_outline_count();
Vector<Vector<Vector2>> new_outlines;
new_outlines.resize(outline_count);

for (int i = 0; i < outline_count; i++) {
new_outlines.write[i] = get_transformed_vertices(layer_tile_data.navigation_polygon->get_outline(i), p_flip_h, p_flip_v, p_transpose);
new_outlines.write[i] = get_transformed_vertices(outlines[i], p_flip_h, p_flip_v, p_transpose);
}

transformed_polygon->set_outlines(new_outlines);

layer_tile_data.transformed_navigation_polygon[key] = transformed_polygon;
Expand Down
3 changes: 1 addition & 2 deletions scene/resources/3d/importer_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,8 +1101,7 @@ Ref<NavigationMesh> ImporterMesh::create_navigation_mesh() {

Ref<NavigationMesh> nm;
nm.instantiate();
nm->set_vertices(vertices);
nm->set_polygons(face_polygons);
nm->set_data(vertices, face_polygons);

return nm;
}
Expand Down

0 comments on commit d121458

Please sign in to comment.