Godot Version
4.3 – Double float precision
Question
Good morning! I have been scratching my head for about 3 weeks on this one, I’ve searched the forums and scoured youtube and the godot docs for any insights or solutions and I’m just stuck.
I am literally just trying to merge some polygons, I’ve isolated a scene here with the bare bones of this issue: two Polygon2D nodes:
I’ve tried many ways of setting this up, but in this case, both nodes’ transforms are at origin position, I used the editor to manually draw these shapes such that they overlap each other. See the code and output below (forgive the mess, at least it’s small) :
CODE:
final_poly = Polygon2D.new()
final_poly.texture = DIRT_TEXTURE
var p1:Polygon2D = $Polygontestsquare
var p2:Polygon2D = $Polygontestsquare2
print(p1.polygon)
print(p2.polygon)
var temp:PackedVector2Array
temp= Geometry2D.merge_polygons(p2.polygon,p1.polygon)
print(temp)
OUTPUT:
[(256, 64), (384, 64), (384, 128), (352, 96), (296, 96), (256, 128), (216, 120), (216, 72)]
[(304, 112), (296, 72), (312, 56), (336, 56), (352, 72), (344, 112), (352, 136), (336, 256), (312, 256), (296, 136)]
[(0, 0)]
It doesn’t matter if I use merge, intersect, clip, anything, nor does it matter if I assign the array as above, append, or append_array. I either get an empty array, or an array with 1 (or 2 in the case of clip) of (0,0).
Am I doing something obviously wrong here or is it possible that using a godot build that has double float precision enabled might be breaking the Geometry2D class? I just would think that even if I’m doing something wrong, I would have at some point returned a value other than , nothing.