Skip to content
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

Remove more occurrences of "stex" #58965

Merged
merged 1 commit into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/classes/CompressedTexture2D.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="CompressedTexture2D" inherits="Texture2D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A [code].stex[/code] texture.
A [code].ctex[/code] texture.
</brief_description>
<description>
A texture that is loaded from a [code].stex[/code] file.
A texture that is loaded from a [code].ctex[/code] file.
</description>
<tutorials>
</tutorials>
Expand All @@ -19,7 +19,7 @@
</methods>
<members>
<member name="load_path" type="String" setter="load" getter="get_load_path" default="&quot;&quot;">
The CompressedTexture's file path to a [code].stex[/code] file.
The CompressedTexture's file path to a [code].ctex[/code] file.
</member>
</members>
</class>
2 changes: 1 addition & 1 deletion doc/classes/ResourceFormatLoader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<description>
Godot loads resources in the editor or in exported games using ResourceFormatLoaders. They are queried automatically via the [ResourceLoader] singleton, or when a resource with internal dependencies is loaded. Each file type may load as a different resource type, so multiple ResourceFormatLoaders are registered in the engine.
Extending this class allows you to define your own loader. Be sure to respect the documented return types and values. You should give it a global class name with [code]class_name[/code] for it to be registered. Like built-in ResourceFormatLoaders, it will be called automatically when loading resources of its handled type(s). You may also implement a [ResourceFormatSaver].
[b]Note:[/b] You can also extend [EditorImportPlugin] if the resource type you need exists but Godot is unable to load its format. Choosing one way over another depends on if the format is suitable or not for the final exported game. For example, it's better to import [code].png[/code] textures as [code].stex[/code] ([CompressedTexture2D]) first, so they can be loaded with better efficiency on the graphics card.
[b]Note:[/b] You can also extend [EditorImportPlugin] if the resource type you need exists but Godot is unable to load its format. Choosing one way over another depends on if the format is suitable or not for the final exported game. For example, it's better to import [code].png[/code] textures as [code].ctex[/code] ([CompressedTexture2D]) first, so they can be loaded with better efficiency on the graphics card.
</description>
<tutorials>
</tutorials>
Expand Down
16 changes: 8 additions & 8 deletions editor/import/resource_importer_layered_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ void ResourceImporterLayeredTexture::get_recognized_extensions(List<String> *p_e
String ResourceImporterLayeredTexture::get_save_extension() const {
switch (mode) {
case MODE_CUBEMAP: {
return "scube";
return "ccube";
} break;
case MODE_2D_ARRAY: {
return "stexarray";
return "ctexarray";
} break;
case MODE_CUBEMAP_ARRAY: {
return "scubearray";
return "ccubearray";
} break;
case MODE_3D: {
return "stex3d";
return "ctex3d";
} break;
}

Expand Down Expand Up @@ -274,11 +274,11 @@ void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, cons
f->store_32(0);

for (int i = 0; i < p_images.size(); i++) {
ResourceImporterTexture::save_to_stex_format(f, p_images[i], ResourceImporterTexture::CompressMode(p_compress_mode), used_channels, p_vram_compression, p_lossy);
ResourceImporterTexture::save_to_ctex_format(f, p_images[i], ResourceImporterTexture::CompressMode(p_compress_mode), used_channels, p_vram_compression, p_lossy);
}

for (int i = 0; i < mipmap_images.size(); i++) {
ResourceImporterTexture::save_to_stex_format(f, mipmap_images[i], ResourceImporterTexture::CompressMode(p_compress_mode), used_channels, p_vram_compression, p_lossy);
ResourceImporterTexture::save_to_ctex_format(f, mipmap_images[i], ResourceImporterTexture::CompressMode(p_compress_mode), used_channels, p_vram_compression, p_lossy);
}

f->close();
Expand Down Expand Up @@ -393,7 +393,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
texture_import->bptc_ldr = bptc_ldr;
texture_import->mipmaps = mipmaps;
texture_import->used_channels = used_channels;
_check_compress_stex(texture_import);
_check_compress_ctex(texture_import);
if (r_metadata) {
Dictionary metadata;
metadata["vram_texture"] = compress_mode == COMPRESS_VRAM_COMPRESSED;
Expand Down Expand Up @@ -474,7 +474,7 @@ ResourceImporterLayeredTexture::ResourceImporterLayeredTexture() {
ResourceImporterLayeredTexture::~ResourceImporterLayeredTexture() {
}

void ResourceImporterLayeredTexture::_check_compress_stex(Ref<LayeredTextureImport> r_texture_import) {
void ResourceImporterLayeredTexture::_check_compress_ctex(Ref<LayeredTextureImport> r_texture_import) {
String extension = get_save_extension();
ERR_FAIL_NULL(r_texture_import->csource);
if (r_texture_import->compress_mode != COMPRESS_VRAM_COMPRESSED) {
Expand Down
2 changes: 1 addition & 1 deletion editor/import/resource_importer_layered_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ResourceImporterLayeredTexture : public ResourceImporter {
static ResourceImporterLayeredTexture *singleton;

public:
void _check_compress_stex(Ref<LayeredTextureImport> r_texture_import);
void _check_compress_ctex(Ref<LayeredTextureImport> r_texture_import);

static ResourceImporterLayeredTexture *get_singleton() { return singleton; }
virtual String get_importer_name() const override;
Expand Down
14 changes: 7 additions & 7 deletions editor/import/resource_importer_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void ResourceImporterTexture::get_import_options(const String &p_path, List<Impo
}
}

void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality) {
void ResourceImporterTexture::save_to_ctex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality) {
switch (p_compress_mode) {
case COMPRESS_LOSSLESS: {
bool lossless_force_png = ProjectSettings::get_singleton()->get("rendering/textures/lossless_compression/force_png") ||
Expand Down Expand Up @@ -317,7 +317,7 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
}
}

void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String &p_to_path, CompressMode p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_roughness, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel) {
void ResourceImporterTexture::_save_ctex(const Ref<Image> &p_image, const String &p_to_path, CompressMode p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_roughness, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel) {
FileAccess *f = FileAccess::open(p_to_path, FileAccess::WRITE);
ERR_FAIL_NULL(f);
f->store_8('G');
Expand Down Expand Up @@ -394,7 +394,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String

Image::UsedChannels used_channels = image->detect_used_channels(csource);

save_to_stex_format(f, image, p_compress_mode, used_channels, p_vram_compression, p_lossy_quality);
save_to_ctex_format(f, image, p_compress_mode, used_channels, p_vram_compression, p_lossy_quality);

memdelete(f);
}
Expand Down Expand Up @@ -540,19 +540,19 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
if (!bptc_ldr && can_s3tc && is_ldr) {
image_compress_mode = Image::COMPRESS_S3TC;
}
_save_stex(image, p_save_path + ".s3tc.ctex", compress_mode, lossy, image_compress_mode, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel);
_save_ctex(image, p_save_path + ".s3tc.ctex", compress_mode, lossy, image_compress_mode, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel);
r_platform_variants->push_back("s3tc");
formats_imported.push_back("s3tc");
}

if (ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2")) {
_save_stex(image, p_save_path + ".etc2.ctex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel);
_save_ctex(image, p_save_path + ".etc2.ctex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel);
r_platform_variants->push_back("etc2");
formats_imported.push_back("etc2");
}

if (ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc")) {
_save_stex(image, p_save_path + ".etc.ctex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel);
_save_ctex(image, p_save_path + ".etc.ctex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel);
r_platform_variants->push_back("etc");
formats_imported.push_back("etc");
}
Expand All @@ -562,7 +562,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
}
} else {
//import normally
_save_stex(image, p_save_path + ".ctex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel);
_save_ctex(image, p_save_path + ".ctex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel);
}

if (r_metadata) {
Expand Down
4 changes: 2 additions & 2 deletions editor/import/resource_importer_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ class ResourceImporterTexture : public ResourceImporter {
static ResourceImporterTexture *singleton;
static const char *compression_formats[];

void _save_stex(const Ref<Image> &p_image, const String &p_to_path, CompressMode p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel);
void _save_ctex(const Ref<Image> &p_image, const String &p_to_path, CompressMode p_compress_mode, float p_lossy_quality, Image::CompressMode p_vram_compression, bool p_mipmaps, bool p_streamable, bool p_detect_3d, bool p_detect_srgb, bool p_detect_normal, bool p_force_normal, bool p_srgb_friendly, bool p_force_po2_for_compressed, uint32_t p_limit_mipmap, const Ref<Image> &p_normal, Image::RoughnessChannel p_roughness_channel);

public:
static void save_to_stex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality);
static void save_to_ctex_format(FileAccess *f, const Ref<Image> &p_image, CompressMode p_compress_mode, Image::UsedChannels p_channels, Image::CompressMode p_compress_format, float p_lossy_quality);

static ResourceImporterTexture *get_singleton() { return singleton; }
virtual String get_importer_name() const override;
Expand Down
2 changes: 1 addition & 1 deletion editor/project_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ ProjectExportDialog::ProjectExportDialog() {
enc_ex_filters = memnew(LineEdit);
enc_ex_filters->connect("text_changed", callable_mp(this, &ProjectExportDialog::_enc_filters_changed));
sec_vb->add_margin_child(
TTR("Filters to exclude files/folders\n(comma-separated, e.g: *.stex, *.import, music/*)"),
TTR("Filters to exclude files/folders\n(comma-separated, e.g: *.ctex, *.import, music/*)"),
enc_ex_filters);

script_key = memnew(LineEdit);
Expand Down
76 changes: 38 additions & 38 deletions scene/resources/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,24 +435,24 @@ void CompressedTexture2D::set_path(const String &p_path, bool p_take_over) {
}

void CompressedTexture2D::_requested_3d(void *p_ud) {
CompressedTexture2D *st = (CompressedTexture2D *)p_ud;
Ref<CompressedTexture2D> stex(st);
CompressedTexture2D *ct = (CompressedTexture2D *)p_ud;
Ref<CompressedTexture2D> ctex(ct);
ERR_FAIL_COND(!request_3d_callback);
request_3d_callback(stex);
request_3d_callback(ctex);
}

void CompressedTexture2D::_requested_roughness(void *p_ud, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_roughness_channel) {
CompressedTexture2D *st = (CompressedTexture2D *)p_ud;
Ref<CompressedTexture2D> stex(st);
CompressedTexture2D *ct = (CompressedTexture2D *)p_ud;
Ref<CompressedTexture2D> ctex(ct);
ERR_FAIL_COND(!request_roughness_callback);
request_roughness_callback(stex, p_normal_path, p_roughness_channel);
request_roughness_callback(ctex, p_normal_path, p_roughness_channel);
}

void CompressedTexture2D::_requested_normal(void *p_ud) {
CompressedTexture2D *st = (CompressedTexture2D *)p_ud;
Ref<CompressedTexture2D> stex(st);
CompressedTexture2D *ct = (CompressedTexture2D *)p_ud;
Ref<CompressedTexture2D> ctex(ct);
ERR_FAIL_COND(!request_normal_callback);
request_normal_callback(stex);
request_normal_callback(ctex);
}

CompressedTexture2D::TextureFormatRequestCallback CompressedTexture2D::request_3d_callback = nullptr;
Expand All @@ -475,14 +475,14 @@ Error CompressedTexture2D::_load_data(const String &p_path, int &r_width, int &r
f->get_buffer(header, 4);
if (header[0] != 'G' || header[1] != 'S' || header[2] != 'T' || header[3] != '2') {
memdelete(f);
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Stream texture file is corrupt (Bad header).");
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Compressed texture file is corrupt (Bad header).");
}

uint32_t version = f->get_32();

if (version > FORMAT_VERSION) {
memdelete(f);
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Stream texture file is too new.");
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Compressed texture file is too new.");
}
r_width = f->get_32();
r_height = f->get_32();
Expand Down Expand Up @@ -866,11 +866,11 @@ Error CompressedTexture3D::_load_data(const String &p_path, Vector<Ref<Image>> &
f->get_buffer(header, 4);
ERR_FAIL_COND_V(header[0] != 'G' || header[1] != 'S' || header[2] != 'T' || header[3] != 'L', ERR_FILE_UNRECOGNIZED);

//stored as stream textures (used for lossless and lossy compression)
//stored as compressed textures (used for lossless and lossy compression)
uint32_t version = f->get_32();

if (version > FORMAT_VERSION) {
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Stream texture file is too new.");
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Compressed texture file is too new.");
}

r_depth = f->get_32(); //depth
Expand Down Expand Up @@ -1022,15 +1022,15 @@ RES ResourceFormatLoaderCompressedTexture3D::load(const String &p_path, const St
}

void ResourceFormatLoaderCompressedTexture3D::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("stex3d");
p_extensions->push_back("ctex3d");
}

bool ResourceFormatLoaderCompressedTexture3D::handles_type(const String &p_type) const {
return p_type == "CompressedTexture3D";
}

String ResourceFormatLoaderCompressedTexture3D::get_resource_type(const String &p_path) const {
if (p_path.get_extension().to_lower() == "stex3d") {
if (p_path.get_extension().to_lower() == "ctex3d") {
return "CompressedTexture3D";
}
return "";
Expand Down Expand Up @@ -2620,13 +2620,13 @@ Error CompressedTextureLayered::_load_data(const String &p_path, Vector<Ref<Imag
uint8_t header[4];
f->get_buffer(header, 4);
if (header[0] != 'G' || header[1] != 'S' || header[2] != 'T' || header[3] != 'L') {
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Stream texture layered file is corrupt (Bad header).");
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Compressed texture layered file is corrupt (Bad header).");
}

uint32_t version = f->get_32();

if (version > FORMAT_VERSION) {
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Stream texture file is too new.");
ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Compressed texture file is too new.");
}

uint32_t layer_count = f->get_32(); //layer count
Expand Down Expand Up @@ -2767,54 +2767,54 @@ CompressedTextureLayered::~CompressedTextureLayered() {
/////////////////////////////////////////////////

RES ResourceFormatLoaderCompressedTextureLayered::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
Ref<CompressedTextureLayered> st;
if (p_path.get_extension().to_lower() == "stexarray") {
Ref<CompressedTexture2DArray> s;
s.instantiate();
st = s;
} else if (p_path.get_extension().to_lower() == "scube") {
Ref<CompressedCubemap> s;
s.instantiate();
st = s;
} else if (p_path.get_extension().to_lower() == "scubearray") {
Ref<CompressedCubemapArray> s;
s.instantiate();
st = s;
Ref<CompressedTextureLayered> ct;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed some st's below so it doesn't compile.

if (p_path.get_extension().to_lower() == "ctexarray") {
Ref<CompressedTexture2DArray> c;
c.instantiate();
ct = c;
} else if (p_path.get_extension().to_lower() == "ccube") {
Ref<CompressedCubemap> c;
c.instantiate();
ct = c;
} else if (p_path.get_extension().to_lower() == "ccubearray") {
Ref<CompressedCubemapArray> c;
c.instantiate();
ct = c;
} else {
if (r_error) {
*r_error = ERR_FILE_UNRECOGNIZED;
}
return RES();
}
Error err = st->load(p_path);
Error err = ct->load(p_path);
if (r_error) {
*r_error = err;
}
if (err != OK) {
return RES();
}

return st;
return ct;
}

void ResourceFormatLoaderCompressedTextureLayered::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("stexarray");
p_extensions->push_back("scube");
p_extensions->push_back("scubearray");
p_extensions->push_back("ctexarray");
p_extensions->push_back("ccube");
p_extensions->push_back("ccubearray");
}

bool ResourceFormatLoaderCompressedTextureLayered::handles_type(const String &p_type) const {
return p_type == "CompressedTexture2DArray" || p_type == "CompressedCubemap" || p_type == "CompressedCubemapArray";
}

String ResourceFormatLoaderCompressedTextureLayered::get_resource_type(const String &p_path) const {
if (p_path.get_extension().to_lower() == "stexarray") {
if (p_path.get_extension().to_lower() == "ctexarray") {
return "CompressedTexture2DArray";
}
if (p_path.get_extension().to_lower() == "scube") {
if (p_path.get_extension().to_lower() == "ccube") {
return "CompressedCubemap";
}
if (p_path.get_extension().to_lower() == "scubearray") {
if (p_path.get_extension().to_lower() == "ccubearray") {
return "CompressedCubemapArray";
}
return "";
Expand Down