Skip to content

Commit 5b74a56

Browse files
committed
Check for duplicate extremum collision vertices
1 parent 17dd87c commit 5b74a56

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

addons/rmsmartshape/shapes/point_array.gd

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ var _vertex_cache := PackedVector2Array()
4545
var _curve := Curve2D.new()
4646
var _curve_no_control_points := Curve2D.new()
4747
var _tesselation_cache := PackedVector2Array()
48-
var _tesselation_distinct_cache := PackedVector2Array()
4948
var _tess_vertex_mapping := SS2D_TesselationVertexMapping.new()
5049

5150
## Gets called when points were modified.
@@ -608,22 +607,6 @@ func get_tessellated_points() -> PackedVector2Array:
608607
return _tesselation_cache
609608

610609

611-
## Returns a PackedVector2Array with all distinct points
612-
func get_tessellated_distinct_points() -> PackedVector2Array:
613-
_tesselation_distinct_cache = []
614-
615-
_update_cache()
616-
617-
## Force update if first use of distinct cache
618-
var _tesselation_cache_size: int = _tesselation_cache.size()
619-
var _tesselation_distinct_cache_size: int = _tesselation_distinct_cache.size()
620-
621-
if _tesselation_distinct_cache_size - 1 < _tesselation_cache_size:
622-
_tesselation_distinct_cache = _tesselation_cache.slice(0, _tesselation_cache_size - 1)
623-
624-
return _tesselation_distinct_cache
625-
626-
627610
func set_tessellation_stages(value: int) -> void:
628611
tessellation_stages = value
629612
_changed()
@@ -678,9 +661,7 @@ func _update_cache() -> void:
678661
if _tesselation_cache.size() >= 2:
679662
_tesselation_cache[0] = _curve.get_point_position(0)
680663
_tesselation_cache[-1] = _curve.get_point_position(_curve.get_point_count() - 1)
681-
682-
_tesselation_distinct_cache = _tesselation_cache.slice(0, _tesselation_cache.size() - 1)
683-
664+
684665
_tess_vertex_mapping.build(_tesselation_cache, _vertex_cache)
685666

686667
_point_cache_dirty = false

addons/rmsmartshape/shapes/shape.gd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ func _generate_collision_points_precise() -> PackedVector2Array:
901901

902902

903903
func _generate_collision_points_fast() -> PackedVector2Array:
904-
return _points.get_tessellated_distinct_points()
904+
return _points.get_tessellated_points()
905905

906906

907907
func bake_collision() -> void:
@@ -919,6 +919,9 @@ func bake_collision() -> void:
919919
else:
920920
generated_points = _generate_collision_points_precise()
921921

922+
if generated_points.size() > 1 and generated_points[0] == generated_points[-1]:
923+
generated_points = generated_points.slice(0, -1)
924+
922925
var xform := _collision_polygon_node.get_global_transform().affine_inverse() * get_global_transform()
923926
_collision_polygon_node.polygon = xform * generated_points
924927

0 commit comments

Comments
 (0)