godotengine / godotengine/godot

Geometry2D.clip_polygons() Geometry2D.merge_polygons() returns [(0,0)]

Open
#87,153 10 comments 1 reaction 0 assignees View on GitHub
bug needs testing topic:core
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Tested on: 4.2,stable 4.2.1

### System information

windows 11 - Godot 4.2x

### Issue description

Maybe there is something I need to the packedVector2Arrays before passing them as arguments for clip_polygon() or merge_polygon() but there is no documentation about it.

### Steps to reproduce

- create a scene, add two polygon2D or collisionpolygon2D nodes, create polygons on the editor that overlap.
- on the root script:
```
func _ready():
var _poly1 = $CollisionPolygon2D
var _poly2 = $CollisionPolygon2D2
var _new_poly: Polygon2D = Polygon2D.new()
var clipped_poly: PackedVector2Array

var _poly1_vec2array = _poly1.polygon #you can use .get_polygon() result is the same
print(poly1_vec2array) # the polygons are assigned correctly
var _poly2_vec2array = _poly2.polygon
print(poly2_vec2array) # the polygons are assigned correctly

clipped_poly = Geometry2D.clip_polygons(poly1_vec2array,poly2_vec2array)

print_debug(clipped_poly) # returns a single point on PackedVector2Array = [(0,0]]

```

### Minimal reproduction project (MRP)

[Tests.zip](https://github.com/godotengine/godot/files/13929008/Tests.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the attached Tests.zip reproduction project and the Geometry2D.clip_polygons() and merge_polygons() entry points. Reproduce the overlapping Polygon2D and CollisionPolygon2D case, then determine the expected result for the supplied PackedVector2Array inputs; done means the incorrect [(0,0)] result is fixed or the required input behavior is documented.

Written by the indexing model from the issue text.

Assessment

Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.