GridMap physics not rebuilding after MeshLibrary.set_item_shapes() — is there a proper API?

haii everyone,

I’m working on an EditorPlugin that modifies GridMap collision shapes by calling MeshLibrary.set_item_shapes() on each item. The shapes are written correctly to the resource, and I can see them in the MeshLibrary preview.

However, the GridMap’s physics bodies do not update in the editor or at runtime unless I manually force a refresh by toggling any property in the Inspector — for example, changing Center X or Center Y, or temporarily setting mesh_library = null and reassigning it.

Here’s what I’ve tried so far:

  • gridmap.notify_property_list_changed()
  • gridmap.update_internal_physics() — this method does not exist in Godot 4.7
  • Setting gridmap.mesh_library = null then reassigning it — this works, but it’s clearly a hack

I’ve also noticed that this behavior is consistent — it’s not intermittent. The physics only updates when I manually “touch” a property.

I suspect there’s an internal method in the C++ source (something like _rebuild_physics_bodies() or _update_physics_server()) that gets called when an Inspector property is toggled. However, set_item_shapes() doesn’t trigger this.

I’m using Godot 4.7.stable. Does anyone know the proper API to force a GridMap to rebuild its physics bodies after modifying its MeshLibrary? Developer Godot atau kontributor core yang paham source code C+±nya pasti langsung tau jawabannya — mereka yang nulis kode recreate_octant_data() atau apapun nama internalnya.

Thanks in advance!