summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2022-02-19 23:54:00 +0100
committerGitHub <noreply@github.com>2022-02-19 23:54:00 +0100
commit499eec13a3660f6f05a6212be97ea164fd98b519 (patch)
tree7f17672b0c830f0de370d8330db00fb50ad25330
parent18a2c0bf7d232fa621b05b955ed8799ef5cbaa47 (diff)
parent31d723c4ce7c0299f2964751dc2f3beaeedb89f8 (diff)
Merge pull request #57163 from winterpixelgames/feature/allow-disable-atlas-texture-alpha-trim
Allow disabling the alpha trim on texture atlas creation.
-rw-r--r--editor/import/resource_importer_texture_atlas.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp
index d2a9fe2538..cd481e009e 100644
--- a/editor/import/resource_importer_texture_atlas.cpp
+++ b/editor/import/resource_importer_texture_atlas.cpp
@@ -75,6 +75,7 @@ void ResourceImporterTextureAtlas::get_import_options(const String &p_path, List
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "atlas_file", PROPERTY_HINT_SAVE_FILE, "*.png"), ""));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "import_mode", PROPERTY_HINT_ENUM, "Region,Mesh2D"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "crop_to_region"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "trim_alpha_border_from_region"), true));
}
String ResourceImporterTextureAtlas::get_option_group_file() const {
@@ -210,14 +211,18 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
pack_data.is_cropped = options["crop_to_region"];
int mode = options["import_mode"];
+ bool trim_alpha_border_from_region = options["trim_alpha_border_from_region"];
if (mode == IMPORT_MODE_REGION) {
pack_data.is_mesh = false;
EditorAtlasPacker::Chart chart;
- //clip a region from the image
- Rect2 used_rect = image->get_used_rect();
+ Rect2 used_rect = Rect2(Vector2(), image->get_size());
+ if (trim_alpha_border_from_region) {
+ // Clip a region from the image.
+ used_rect = image->get_used_rect();
+ }
pack_data.region = used_rect;
chart.vertices.push_back(used_rect.position);