I am loading a flat mesh from a file, deforming it and using the deformed mesh in my scene. The problem is that the saved ArrayMesh (.res) is being deformed despite me not calling for the file to be overwritten. Does anyone know how I can avoid this?
Important note: All of this is happening in tool scripts so that I can use the editor to my advantage during development of the project.
TLDR; setting the cache mode to CACHE_MODE_IGNORE fixed the problem.
I think I figured it out – if it turns out that I am wrong, I will update this thread since I will definitely know before it times out. Sorry for answering my own question (again). Hopefully this can help someone in the future.
I made the following change to the line where I load the mesh:
# previous
var mesh: LeafPetalSurface = load("res://meshes/LeafPetalMesh.res")
# current
var mesh: LeafPetalSurface = ResourceLoader.load("res://meshes/LeafPetalMesh.res", "", ResourceLoader.CacheMode.CACHE_MODE_IGNORE )
Ignoring the cache isn’t intended to produce a duplicate, it often (maybe always) does because it will read from disk instead of the faster in-memory cache.
Using .duplicate() sounds like it’s exactly what you want, and explictly telling Godot that you want a duplicate so you can freely modify a separate clone of the resource. It should also be slightly faster as it won’t read from disk over and over again.