Skip to content

Commit

Permalink
Fix to allow TextureArrays to be serialised.
Browse files Browse the repository at this point in the history
  • Loading branch information
SaracenOne committed Feb 16, 2021
1 parent a1222e4 commit 2ba3561
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
11 changes: 7 additions & 4 deletions core/io/resource_format_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1674,14 +1674,17 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant

Variant value = res->get(E->get().name);
if (E->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) {
NonPersistentKey npk;
npk.base = res;
npk.property = E->get().name;
non_persistent_map[npk] = value;

RES sres = value;
if (sres.is_valid()) {
NonPersistentKey npk;
npk.base = res;
npk.property = E->get().name;
non_persistent_map[npk] = sres;
resource_set.insert(sres);
saved_resources.push_back(sres);
} else {
_find_resources(value);
}
} else {
_find_resources(value);
Expand Down
2 changes: 1 addition & 1 deletion core/io/resource_format_binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ResourceFormatSaverBinaryInstance {
bool operator<(const NonPersistentKey &p_key) const { return base == p_key.base ? property < p_key.property : base < p_key.base; }
};

Map<NonPersistentKey, RES> non_persistent_map;
Map<NonPersistentKey, Variant> non_persistent_map;
Map<StringName, int> string_map;
Vector<StringName> strings;

Expand Down
11 changes: 7 additions & 4 deletions scene/resources/resource_format_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1416,14 +1416,17 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant,
Variant v = res->get(I->get().name);

if (pi.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) {
NonPersistentKey npk;
npk.base = res;
npk.property = pi.name;
non_persistent_map[npk] = v;

RES sres = v;
if (sres.is_valid()) {
NonPersistentKey npk;
npk.base = res;
npk.property = pi.name;
non_persistent_map[npk] = sres;
resource_set.insert(sres);
saved_resources.push_back(sres);
} else {
_find_resources(v);
}
} else {
_find_resources(v);
Expand Down
2 changes: 1 addition & 1 deletion scene/resources/resource_format_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class ResourceFormatSaverTextInstance {
bool operator<(const NonPersistentKey &p_key) const { return base == p_key.base ? property < p_key.property : base < p_key.base; }
};

Map<NonPersistentKey, RES> non_persistent_map;
Map<NonPersistentKey, Variant> non_persistent_map;

Set<RES> resource_set;
List<RES> saved_resources;
Expand Down
2 changes: 1 addition & 1 deletion scene/resources/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2515,7 +2515,7 @@ void TextureLayered::_bind_methods() {
ClassDB::bind_method(D_METHOD("_get_data"), &TextureLayered::_get_data);

ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter"), "set_flags", "get_flags");
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_data", "_get_data");
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT), "_set_data", "_get_data");

BIND_ENUM_CONSTANT(FLAG_MIPMAPS);
BIND_ENUM_CONSTANT(FLAG_REPEAT);
Expand Down

0 comments on commit 2ba3561

Please sign in to comment.