Allow setting negative WorldBoundaryShape2D.distance through the editor

This commit is contained in:
kleonc
2023-05-19 13:28:50 +02:00
parent 01453ab7f3
commit 77b8e0fcb7
5 changed files with 25 additions and 19 deletions

View File

@@ -155,7 +155,8 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
Ref<WorldBoundaryShape2D> world_boundary = node->get_shape();
if (idx == 0) {
world_boundary->set_distance(p_point.length());
Vector2 normal = world_boundary->get_normal();
world_boundary->set_distance(p_point.dot(normal) / normal.length_squared());
} else {
world_boundary->set_normal(p_point.normalized());
}