Skip to content

Tweak editor atlas import error texture #69173

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Nov 25, 2022

This uses a smaller, pixel-perfect design for the error texture, which reduces editor binary size by about 25 KB. Export templates do not contain this image, so their binary size is not affected by this change.

This image is rarely ever shown in the editor, so it doesn't need to look pretty. Reducing binary size is likely more important here. Replacing it with an actual editor scale-independent SVG would be the best solution, but I don't know how this could be done.

These warnings are caused by GIMP's XPM exporter, I'm not sure how to fix the output file so it doesn't cause them:

Error: editor/import/atlas_import_failed.xpm:3:1: error: ISO C++ forbids converting a string constant to 'char*' [-Werror=write-strings]
    3 | "128 64 3 1",
      | ^~~~~~~~~~~~

Preview

2× nearest-neighbor scaling is used here.

Before After
image image

Source file for the new image: atlas_import_failed.xcf.zip

The font used is Kenney Pixels (licensed under CC0).

This uses a smaller, pixel-perfect design for the error texture, which
reduces editor binary size by about 25 KB. Export templates do not contain
this image, so their binary size is not affected by this change.
@Calinou Calinou requested a review from a team as a code owner November 25, 2022 16:55
@Calinou Calinou added this to the 4.0 milestone Nov 25, 2022
@Calinou Calinou added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Nov 25, 2022
@akien-mga
Copy link
Member

Is there any good reason to use XPM over a PNG or SVG here?

@Calinou
Copy link
Member Author

Calinou commented Nov 25, 2022

Is there any good reason to use XPM over a PNG or SVG here?

As the code says:

Error ResourceImporterTextureAtlas::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
/* If this happens, it's because the atlas_file field was not filled, so just import a broken texture */
//use an xpm because it's size independent, the editor images are vector and size dependent
//it's a simple hack
Ref<Image> broken = memnew(Image((const char **)atlas_import_failed_xpm));
ResourceSaver::save(ImageTexture::create_from_image(broken), p_save_path + ".tex");
return OK;
}

If we can find a way to import a SVG independently of editor scale, I suppose we could get rid of this hack.

@YuriSizov YuriSizov modified the milestones: 4.0, 4.1 Feb 10, 2023
@YuriSizov YuriSizov modified the milestones: 4.1, 4.2 Jun 14, 2023
@AThousandShips AThousandShips modified the milestones: 4.2, 4.3 Oct 27, 2023
@akien-mga akien-mga modified the milestones: 4.3, 4.x Jun 28, 2024
@aaronfranke
Copy link
Member

@Calinou SVGTexture was added in Godot 4.5: #105655

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherrypick:3.x Considered for cherry-picking into a future 3.x release enhancement topic:editor topic:import
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants