Skip to content

Commit

Permalink
Merge pull request #167 from limbonaut/dont-use-fast-collisions-in-op…
Browse files Browse the repository at this point in the history
…en-shapes

Don't use `CollisionGenerationMethod.Fast` in open shapes
  • Loading branch information
mphe authored Jun 21, 2024
2 parents 4d7de90 + 43c6e8c commit 355778e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions addons/rmsmartshape/shapes/shape.gd
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum ORIENTATION { COLINEAR, CLOCKWISE, C_CLOCKWISE }

enum CollisionGenerationMethod {
## Uses the shape curve to generate a collision polygon. Usually this method is accurate enough.
## For open shapes, a precise method will be used instead, as the fast method is not suitable.
Fast,
## Uses the edge generation algorithm to create an accurate collision representation that
## exactly matches the shape's visuals.
Expand Down Expand Up @@ -913,11 +914,10 @@ func bake_collision() -> void:

var generated_points: PackedVector2Array

match collision_generation_method:
CollisionGenerationMethod.Fast:
generated_points = _generate_collision_points_fast()
CollisionGenerationMethod.Precise:
generated_points = _generate_collision_points_precise()
if collision_generation_method == CollisionGenerationMethod.Fast and is_shape_closed():
generated_points = _generate_collision_points_fast()
else:
generated_points = _generate_collision_points_precise()

var xform := _collision_polygon_node.get_global_transform().affine_inverse() * get_global_transform()
_collision_polygon_node.polygon = xform * generated_points
Expand Down

0 comments on commit 355778e

Please sign in to comment.