godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Automatically delete glTF binary data file when deleting a glTF file #8015

Open Yiannis128 opened 1 year ago

Yiannis128 commented 1 year ago

Describe the project you are working on

A 3D game with a lot of models imported using GLTF format

Describe the problem or limitation you are having in your project

Deleting a GLTF file does not delete the bin data.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Delete GLTF bin related file when deleting the GLTF file.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

When a GLTF file with an associated binary is deleted, the binary is also deleted.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It can be worked by an editor plugin, but it will be used often.

Is there a reason why this should be core and not an add-on in the asset library?

It is part of the GLTF implementation. Quality of life.

Calinou commented 1 year ago

I don't think the Godot editor should ever remove additional source assets if you decide to remove one of the files. For instance, removing a OBJ file shouldn't automatically remove the MTL file (or vice versa).

This is different for imported resources within .godot/ which could be cleaned up automatically, but source assets shouldn't be tampered by Godot without asking the user.

Yiannis128 commented 1 year ago

I don't think the Godot editor should ever remove additional source assets if you decide to remove one of the files. For instance, removing a OBJ file shouldn't automatically remove the MTL file (or vice versa).

This is different for imported resources within .godot/ which could be cleaned up automatically, but source assets shouldn't be tampered by Godot without asking the user.

Don't GLTF separate files have a main GLTF which is a pointer, and a bin which is the model data (along with textures). So that bin is only used for the GLTF asset, it isn't shared to my knowledge. I think it would be worth having it as an option at least in the import settings.

fire commented 1 year ago

Do you think the texture files should be deleted too?

.bin and gltf are linked

Yiannis128 commented 1 year ago

Textures no because they aren't deleted for everything else. But a texture can be used in multiple assets. The .bin and glTF files cannot exist separately.

fire commented 1 year ago

Also in the gltf spec any arbitrary list of binary blobs can be listed, we should delete all of them right?

Yiannis128 commented 1 year ago

Yes, assuming that they're not used by multiple assets (which to my knowledge I haven't seen it done before).

This would make the project files much neater and decrease file sizes. Currently, there's no way to delete the .bin files and check if it will break anything.

fire commented 1 year ago

Previously there was a feature for dependent file imports, but I don't know where it went.

It's definitely possible to get the list of paths in the gltf json from the GLTFState.

It's currently feature freeze but I'm ok with what was discussed here for after the freeze.

Calinou has some disagreement, and yes I do think objs should delete the mtls too.

Yiannis128 commented 1 year ago

Previously there was a feature for dependent file imports, but I don't know where it went.

It's definitely possible to get the list of paths in the gltf json from the GLTFState.

It's currently feature freeze but I'm ok with what was discussed here for after the freeze.

Calinou has some disagreement, and yes I do think objs should delete the mtls too.

If there are disagreements, could it be implemented as an option in Editor settings? In bigger projects, it will help massively with reducing file size.