Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TileSet: Transform rotated navigation (sub)-polygons individually. #92955

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions scene/resources/2d/tile_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6489,18 +6489,16 @@ Ref<NavigationPolygon> TileData::get_navigation_polygon(int p_layer_id, bool p_f
PackedVector2Array new_points = get_transformed_vertices(layer_tile_data.navigation_polygon->get_vertices(), p_flip_h, p_flip_v, p_transpose);
libklein marked this conversation as resolved.
Show resolved Hide resolved
transformed_polygon->set_vertices(new_points);

int num_polygons = layer_tile_data.navigation_polygon->get_polygon_count();
for (int i = 0; i < num_polygons; ++i) {
transformed_polygon->add_polygon(layer_tile_data.navigation_polygon->get_polygon(i));
}

for (int i = 0; i < layer_tile_data.navigation_polygon->get_outline_count(); i++) {
PackedVector2Array new_outline = get_transformed_vertices(layer_tile_data.navigation_polygon->get_outline(i), p_flip_h, p_flip_v, p_transpose);
transformed_polygon->add_outline(new_outline);
}

PackedInt32Array indices;
indices.resize(new_points.size());
int *w = indices.ptrw();
for (int i = 0; i < new_points.size(); i++) {
w[i] = i;
}
transformed_polygon->add_polygon(indices);
layer_tile_data.transformed_navigation_polygon[key] = transformed_polygon;
return transformed_polygon;
} else {
Expand Down
Loading