summaryrefslogtreecommitdiff
path: root/scene/resources/texture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/texture.cpp')
-rw-r--r--scene/resources/texture.cpp126
1 files changed, 47 insertions, 79 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index b5754caa6a..2106619a6b 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -40,19 +40,15 @@
#include "servers/camera/camera_feed.h"
int Texture2D::get_width() const {
- int ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_width, ret)) {
- return ret;
- }
- return 0;
+ int ret = 0;
+ GDVIRTUAL_REQUIRED_CALL(_get_width, ret);
+ return ret;
}
int Texture2D::get_height() const {
- int ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_height, ret)) {
- return ret;
- }
- return 0;
+ int ret = 0;
+ GDVIRTUAL_REQUIRED_CALL(_get_height, ret);
+ return ret;
}
Size2 Texture2D::get_size() const {
@@ -1092,57 +1088,44 @@ TypedArray<Image> Texture3D::_get_datai() const {
}
Image::Format Texture3D::get_format() const {
- Image::Format ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_format, ret)) {
- return ret;
- }
- return Image::FORMAT_MAX;
+ Image::Format ret = Image::FORMAT_MAX;
+ GDVIRTUAL_REQUIRED_CALL(_get_format, ret);
+ return ret;
}
int Texture3D::get_width() const {
- int ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_width, ret)) {
- return ret;
- }
- return 0;
+ int ret = 0;
+ GDVIRTUAL_REQUIRED_CALL(_get_width, ret);
+ return ret;
}
int Texture3D::get_height() const {
- int ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_height, ret)) {
- return ret;
- }
- return 0;
+ int ret = 0;
+ GDVIRTUAL_REQUIRED_CALL(_get_height, ret);
+ return ret;
}
int Texture3D::get_depth() const {
- int ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_depth, ret)) {
- return ret;
- }
-
- return 0;
+ int ret = 0;
+ GDVIRTUAL_REQUIRED_CALL(_get_depth, ret);
+ return ret;
}
bool Texture3D::has_mipmaps() const {
- bool ret;
- if (GDVIRTUAL_REQUIRED_CALL(_has_mipmaps, ret)) {
- return ret;
- }
- return false;
+ bool ret = false;
+ GDVIRTUAL_REQUIRED_CALL(_has_mipmaps, ret);
+ return ret;
}
Vector<Ref<Image>> Texture3D::get_data() const {
TypedArray<Image> ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_data, ret)) {
- Vector<Ref<Image>> data;
- data.resize(ret.size());
- for (int i = 0; i < data.size(); i++) {
- data.write[i] = ret[i];
- }
- return data;
+ GDVIRTUAL_REQUIRED_CALL(_get_data, ret);
+ Vector<Ref<Image>> data;
+ data.resize(ret.size());
+ for (int i = 0; i < data.size(); i++) {
+ data.write[i] = ret[i];
}
- return Vector<Ref<Image>>();
+ return data;
}
void Texture3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_format"), &Texture3D::get_format);
@@ -2859,60 +2842,45 @@ AnimatedTexture::~AnimatedTexture() {
///////////////////////////////
Image::Format TextureLayered::get_format() const {
- Image::Format ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_format, ret)) {
- return ret;
- }
- return Image::FORMAT_MAX;
+ Image::Format ret = Image::FORMAT_MAX;
+ GDVIRTUAL_REQUIRED_CALL(_get_format, ret);
+ return ret;
}
TextureLayered::LayeredType TextureLayered::get_layered_type() const {
- uint32_t ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_layered_type, ret)) {
- return (LayeredType)ret;
- }
- return LAYERED_TYPE_2D_ARRAY;
+ uint32_t ret = LAYERED_TYPE_2D_ARRAY;
+ GDVIRTUAL_REQUIRED_CALL(_get_layered_type, ret);
+ return (LayeredType)ret;
}
int TextureLayered::get_width() const {
- int ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_width, ret)) {
- return ret;
- }
- return 0;
+ int ret = 0;
+ GDVIRTUAL_REQUIRED_CALL(_get_width, ret);
+ return ret;
}
int TextureLayered::get_height() const {
- int ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_height, ret)) {
- return ret;
- }
- return 0;
+ int ret = 0;
+ GDVIRTUAL_REQUIRED_CALL(_get_height, ret);
+ return ret;
}
int TextureLayered::get_layers() const {
- int ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_layers, ret)) {
- return ret;
- }
-
- return 0;
+ int ret = 0;
+ GDVIRTUAL_REQUIRED_CALL(_get_layers, ret);
+ return ret;
}
bool TextureLayered::has_mipmaps() const {
- bool ret;
- if (GDVIRTUAL_REQUIRED_CALL(_has_mipmaps, ret)) {
- return ret;
- }
- return false;
+ bool ret = false;
+ GDVIRTUAL_REQUIRED_CALL(_has_mipmaps, ret);
+ return ret;
}
Ref<Image> TextureLayered::get_layer_data(int p_layer) const {
Ref<Image> ret;
- if (GDVIRTUAL_REQUIRED_CALL(_get_layer_data, p_layer, ret)) {
- return ret;
- }
- return Ref<Image>();
+ GDVIRTUAL_REQUIRED_CALL(_get_layer_data, p_layer, ret);
+ return ret;
}
void TextureLayered::_bind_methods() {