godot_heightmap_plugin icon indicating copy to clipboard operation
godot_heightmap_plugin copied to clipboard

Godot never saves the terrain resource after it was modified by a not-undoable action

Open Zylann opened this issue 6 years ago • 3 comments

After investigating #100, I basically found that if I use the resize tool, generator or importer, and then save the scene right after that, it won't save the terrain data. i.e the scene saving process does not call the plugin's resource saver. It won't even show a star (*) next to the scene tab, supposed to show it was modified.

It looks like it will only save it if you perform an undoable action to it, like painting height or textures.

I already emit the changed signal on HTerrainData each time changes are done to terrain maps, but this appears to have no particular effect. I wonder what I'm missing here, or if it's a Godot bug/flaw?

Zylann avatar Sep 24 '19 18:09 Zylann

Looks like calling property_list_changed_notify() makes the resource saved, but it doesn't make the * appear in the scene tab. So it still doesn't warn you if you close the scene or the editor...

But if it did, it would overlap with the original intent of that property, which is to update the inspector when the property list changes, i.e if you undo a change causing the inspector to change, it would leave the scene modified even if that undo changed the scene back to its non-changed state.

Zylann avatar Sep 24 '19 19:09 Zylann

Worked around in 2d2a8d760527e4e301707de28171e415139c095a Downside is, if you still use Ctrl+Z just after the non-undoable action, your scene might revert back to "non modified" and the terrain won't be saved.

To close this issue:

  • Either something should be exposed in Godot to handle this situation,
  • Or full-terrain changes should be made undoable (possible, but requires some work using cache files)

Zylann avatar Sep 24 '19 20:09 Zylann

This no longer applies to using the generator, which is now fully undoable. But it persists in other areas where undo isn't implemented:

  • Import
  • Resize
  • Globalmap baking
  • Removal of detail layer

Zylann avatar Mar 26 '20 21:03 Zylann