Godot Version
v4.3 dev4
Question
I’m making a drawing physics line mechanic like in Crayon Physics.
I’m using Geometry2D.offset_polyline() to generate collision polygon from mouse input.
Problem is when I draw looping shape it returns 2 polygon which is outer one and inner hole,
since CollisionPolygon2D doesn’t support holes i need to somehow merge it into single polygon.
my current shape generation code
func update_shape(line: PackedVector2Array) -> void:
var polygons := Geometry2D.offset_polyline(line, line_size, Geometry2D.JOIN_ROUND)
polygon = polygons[0]
queue_redraw()
set_collision_polygon(polygon)
center_of_mass = calculate_center(polygon)
mass = polygon.size() as float * weight_mult
which results
https://i.imgur.com/IA0f7yO.mp4
Any ideas?