#clip_polyline_with_polygon() return nothing but (0, 0)
4 messages · Page 1 of 1 (latest)
Now, I wanted to draw the room_rect, but remove chunks of it for a door (where the red clip_rect is as you might have guessed). So I figured I'd try clip_polyline_with_polygon(), that's what it's for, right? But when I tried, absolutely nothing gets drawn anymore. When I try to print clip_polyline_with_polygon's output, I get [(0.0, 0.0), (0.0, 0.0)]. Any thoughts?
func _draw() -> void:
for room in player_ship.rooms:
var converted_room_pos : Vector2i = room.grid_position * tile_size
var converted_room_dims : Vector2i = room.dimensions * tile_size
var room_rect : PackedVector2Array = [
converted_room_pos,
converted_room_pos + Vector2i.RIGHT * converted_room_dims.x,
converted_room_pos + converted_room_dims,
converted_room_pos + Vector2i.DOWN * converted_room_dims.y,
converted_room_pos]
var clip_rect : PackedVector2Array = [
Vector2i(32, -4),
Vector2i(64, -4),
Vector2i(64, 4),
Vector2i(32, 4),
Vector2i(32, -4)]
var drawn_room : PackedVector2Array = Geometry2D.clip_polyline_with_polygon(room_rect, clip_rect)
draw_multiline(drawn_room, Color.BLACK, 2)
print(drawn_room)
#draw_polyline(room_rect, Color.GOLD, 2.0)
#draw_colored_polygon(clip_rect, Color.RED)
(Note the commented out lines near the bottom of the block of code)
clip_polyline_with_polygon() return nothing but (0, 0)