mirror of
https://github.com/Relintai/texture_packer.git
synced 2024-11-12 10:15:16 +01:00
Added an ERR_FAIL_COND into TexturePacker::add_texture. Aléso fixed an issue from the previous few commits with variables in scope in TextureMerger.
This commit is contained in:
parent
5d28f6fc1e
commit
1e0da8f335
@ -72,7 +72,7 @@ Vector<Variant> TextureMerger::get_textures() {
|
|||||||
void TextureMerger::set_textures(const Vector<Variant> &textures) {
|
void TextureMerger::set_textures(const Vector<Variant> &textures) {
|
||||||
bool texture_removed = false;
|
bool texture_removed = false;
|
||||||
for (int i = 0; i < _textures.size(); ++i) {
|
for (int i = 0; i < _textures.size(); ++i) {
|
||||||
if (_packer->unref_texture(_textures[i])) {
|
if (_packer->unref_texture(_textures.get(i))) {
|
||||||
texture_removed = true;
|
texture_removed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ void TextureMerger::set_textures(const Vector<Variant> &textures) {
|
|||||||
_textures.resize(textures.size());
|
_textures.resize(textures.size());
|
||||||
|
|
||||||
for (int i = 0; i < textures.size(); i++) {
|
for (int i = 0; i < textures.size(); i++) {
|
||||||
Ref<Texture> texture = Ref<Texture>(textures[i]);
|
Ref<Texture> texture = Ref<Texture>(textures.get(i));
|
||||||
|
|
||||||
_textures.set(i, texture);
|
_textures.set(i, texture);
|
||||||
}
|
}
|
||||||
@ -91,10 +91,10 @@ void TextureMerger::set_textures(const Vector<Variant> &textures) {
|
|||||||
|
|
||||||
bool texture_added = false;
|
bool texture_added = false;
|
||||||
for (int i = 0; i < _textures.size(); ++i) {
|
for (int i = 0; i < _textures.size(); ++i) {
|
||||||
Ref<Texture> tex = _textures.get(i);
|
Ref<Texture> texture = _textures.get(i);
|
||||||
|
|
||||||
if (tex.is_valid() && !_packer->contains_texture(tex)) {
|
if (texture.is_valid() && !_packer->contains_texture(texture)) {
|
||||||
Ref<AtlasTexture> tex = _packer->add_texture(tex);
|
Ref<AtlasTexture> tex = _packer->add_texture(texture);
|
||||||
|
|
||||||
if (has_method("_texture_added"))
|
if (has_method("_texture_added"))
|
||||||
call("_texture_added", tex);
|
call("_texture_added", tex);
|
||||||
|
@ -36,6 +36,8 @@ void TexturePacker::set_margin(const int margin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ref<AtlasTexture> TexturePacker::add_texture(Ref<Texture> texture) {
|
Ref<AtlasTexture> TexturePacker::add_texture(Ref<Texture> texture) {
|
||||||
|
ERR_FAIL_COND_V(!texture.is_valid(), Ref<AtlasTexture>());
|
||||||
|
|
||||||
Ref<AtlasTexture> atlas_text = texture;
|
Ref<AtlasTexture> atlas_text = texture;
|
||||||
|
|
||||||
if (atlas_text.is_valid()) {
|
if (atlas_text.is_valid()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user