Trouble adding points to ConvexPolygonShape3D in script

Godot Version

4.3.stable

Question

I have trouble adding points to a ConvexPolygonShape3D in a script using the points property of the ConvexPolygonShape3D object. It seems to only works if I build the entire PackedVector3Array myself before giving to the Shape3D. Instead of working with the property itself.

Exemples:

var shape: ConvexPolygonShape3D = ConvexPolygonShape3D.new()
var array: Array[Vector3] = [Vector3.ZERO, Vector3.ONE] # some array (not empty)
shape.points.append_array(PackedVector3Array(array))
print(shape.points)

This code print [] (empty array) but PackedVector3Array(array) is not empty.
I don’t understand why.


var shape: ConvexPolygonShape3D = ConvexPolygonShape3D.new()
var array: Array[Vector3] = [Vector3.ZERO, Vector3.ONE] # some array (not empty)
var packed_array = PackedVector3Array(array)
shape.points = packed_array
print(shape.points)

This code works, it print [(0, 0, 0), (1, 1, 1)]


var shape: ConvexPolygonShape3D = ConvexPolygonShape3D.new()
var array: Array[Vector3] = [Vector3.ZERO, Vector3.ONE] # some array (not empty)
var packed_array = PackedVector3Array(array)
shape.points = packed_array
shape.points.append(Vector3.FORWARD)
print(shape.points)

This code still print [(0, 0, 0), (1, 1, 1)] … ignoring the append, it’s the same with append_array.

I also tried using resize because i fought that i had to manually grow the array. It seems that the only way to actually edit the points of a ConvexPolygonShape3D is to reassign the property using the setter (set_points or points =).

I don’t understand this behavior, is this expected ? if so why ?