-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.x] Convert TSCN files into binary .scn on export by default #51096
base: 3.x
Are you sure you want to change the base?
Conversation
The setting still needs to be respected. The only change here should be the introduction of compression, possibly to all types of resources, not just scenes. Well, I guess the extension can also be changed for scenes, if you are really pedantic about it, but it’s not necessary. Also, all PRs must be made against master first and foremost, unless there is a very special need to fix something in a 3.x branch. Changes can then be backported to 3.x anyway, either via a cherrypick (if compatible) or a dedicated PR (like this one). |
The plugin name
I will prepare separate PR for master, but I'm working on a huge project on 3.x where I can check this better and mentioned bugs related to 3.x, that's why I reveresed the priority. I don't see prepared test project for 4.0 so i'll have to make one. |
fee3125
to
75a1da4
Compare
If all kinds of resources are piped through it, possibly it can be renamed. Though this can be left for a master PR for compatibility reasons. |
Maybe I will leave it here and change in separate PR, but it looks like they are. At least this is the only place (*two places in one plugin) where |
@@ -1776,19 +1776,46 @@ void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, con | |||
if (!convert) { | |||
return; | |||
} | |||
String tmp_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpfile.res"); | |||
Error err = ResourceFormatLoaderText::convert_file_to_binary(p_path, tmp_path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is desired, I think compression should be added to this ResourceFormatLoaderText::convert_file_to_binary
method.
With your change, every converted scene has to be loaded and saved but the commit message for 2514338, which added ResourceFormatLoaderText::convert_file_to_binary
, mentions that "This method works by directly converting text to binary, so the scene does not need to be loaded and saved". There was probably a reason by @reduz to do it this way (I guess it's faster?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"This method works by directly converting text to binary, so the scene does not need to be loaded and saved" - internally it is loaded and after conversion saved as binary tmpfile.res
and then we are loading it with FileAccess::get_file_as_array()
. I'm not sure if it's a good approach to duplicate functionality instead of reusing ResourceSaver::save()
(which is used by editor when we save the scene or other resources).
A brief look at the design on export tscns to final project. Here are the trade-offs, and comments on the choices we can make when exporting.
|
Compressed binary should be the default. Even if the transfer is compressed by Steam etc, there's no reason the game should take up more space on disk (even after extracting a zip for instance). Especially with zstd reading compressed data (and decompressing it) is faster than reading not compressed data. Also, it would be really interesting if someone looked into using the zstd training mode to create a dictionary during export - that should significantly improve compression of these types of files. |
44722bd
to
96ffd83
Compare
Regarding compression - now it's respecting |
96ffd83
to
d26e633
Compare
Maybe you should add this note to the top comment. It is a backport of #33228. What else does this PR need to make it into 3.x? Compression is great, but I'm especially interested in binary everything on export by default. Thanks for the effort. |
71cb8d3
to
c58391c
Compare
Fixes godotengine/godot-docs#5131 (.tscn scenes are properly compiled into compressed .scn)
Possible fix for #42115