summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/physics_body_2d.cpp3
-rw-r--r--scene/3d/voxel_light_baker.cpp2
-rw-r--r--scene/resources/resource_format_text.cpp27
-rw-r--r--scene/resources/resource_format_text.h9
-rw-r--r--scene/resources/texture.cpp23
-rw-r--r--scene/resources/texture.h6
6 files changed, 42 insertions, 28 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 44b81dc0cc..ce80bc508e 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -1309,9 +1309,6 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
motion = motion.slide(n);
lv = lv.slide(n);
}
-
- if (p_stop_on_slope)
- break;
}
if (!found_collision) {
diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp
index 91b3ea6ca0..42c2318701 100644
--- a/scene/3d/voxel_light_baker.cpp
+++ b/scene/3d/voxel_light_baker.cpp
@@ -2208,7 +2208,7 @@ PoolVector<int> VoxelLightBaker::create_gi_probe_data() {
}
{
- uint16_t alpha = CLAMP(uint32_t(bake_cells[i].alpha * 65535.0), 0, 65535);
+ uint16_t alpha = MAX(uint32_t(bake_cells[i].alpha * 65535.0), 65535);
uint16_t level = bake_cells[i].level;
w32[ofs++] = (uint32_t(level) << 16) | uint32_t(alpha);
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index e838d4a685..9ef6b9b474 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -1408,7 +1408,20 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant,
if (pi.usage & PROPERTY_USAGE_STORAGE) {
Variant v = res->get(I->get().name);
- _find_resources(v);
+
+ if (pi.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) {
+ 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);
+ }
}
I = I->next();
@@ -1600,7 +1613,17 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
if (PE->get().usage & PROPERTY_USAGE_STORAGE) {
String name = PE->get().name;
- Variant value = res->get(name);
+ Variant value;
+ if (PE->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) {
+ NonPersistentKey npk;
+ npk.base = res;
+ npk.property = name;
+ if (non_persistent_map.has(npk)) {
+ value = non_persistent_map[npk];
+ }
+ } else {
+ value = res->get(name);
+ }
Variant default_value = ClassDB::class_get_default_property_value(res->get_class(), name);
if (default_value.get_type() != Variant::NIL && bool(Variant::evaluate(Variant::OP_EQUAL, value, default_value))) {
diff --git a/scene/resources/resource_format_text.h b/scene/resources/resource_format_text.h
index 526f7760d2..8d78ab33b0 100644
--- a/scene/resources/resource_format_text.h
+++ b/scene/resources/resource_format_text.h
@@ -155,6 +155,15 @@ class ResourceFormatSaverTextInstance {
bool bundle_resources;
bool skip_editor;
FileAccess *f;
+
+ struct NonPersistentKey { //for resource properties generated on the fly
+ RES base;
+ StringName property;
+ 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;
+
Set<RES> resource_set;
List<RES> saved_resources;
Map<RES, int> external_resources;
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 85c22f7bf9..e8cc160acf 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -157,7 +157,7 @@ bool ImageTexture::_get(const StringName &p_name, Variant &r_ret) const {
void ImageTexture::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic,sRGB,Mirrored Repeat"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image"));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "size", PROPERTY_HINT_NONE, ""));
}
@@ -178,12 +178,6 @@ void ImageTexture::_reload_hook(const RID &p_hook) {
_change_notify();
}
-bool ImageTexture::keep_images_cached = false;
-
-void ImageTexture::set_keep_images_cached(bool p_enable) {
- keep_images_cached = p_enable;
-}
-
void ImageTexture::create(int p_width, int p_height, Image::Format p_format, uint32_t p_flags) {
flags = p_flags;
@@ -205,9 +199,7 @@ void ImageTexture::create_from_image(const Ref<Image> &p_image, uint32_t p_flags
VisualServer::get_singleton()->texture_set_data(texture, p_image);
_change_notify();
- if (keep_images_cached) {
- image_cache = p_image;
- }
+ image_stored = true;
}
void ImageTexture::set_flags(uint32_t p_flags) {
@@ -255,10 +247,7 @@ void ImageTexture::set_data(const Ref<Image> &p_image) {
_change_notify();
alpha_cache.unref();
-
- if (keep_images_cached) {
- image_cache = p_image;
- }
+ image_stored = true;
}
void ImageTexture::_resource_path_changed() {
@@ -268,10 +257,10 @@ void ImageTexture::_resource_path_changed() {
Ref<Image> ImageTexture::get_data() const {
- if (image_cache.is_valid()) {
- return image_cache;
- } else {
+ if (image_stored) {
return VisualServer::get_singleton()->texture_get_data(texture);
+ } else {
+ return Ref<Image>();
}
}
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index bfea0f9300..dc3a3e0c74 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -111,7 +111,7 @@ private:
Size2 size_override;
float lossy_storage_quality;
mutable Ref<BitMap> alpha_cache;
- Ref<Image> image_cache;
+ bool image_stored;
protected:
virtual void reload_from_file();
@@ -126,11 +126,7 @@ protected:
void _set_data(Dictionary p_data);
- static bool keep_images_cached;
-
public:
- static void set_keep_images_cached(bool p_enable);
-
void create(int p_width, int p_height, Image::Format p_format, uint32_t p_flags = FLAGS_DEFAULT);
void create_from_image(const Ref<Image> &p_image, uint32_t p_flags = FLAGS_DEFAULT);