summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/io/image.cpp20
-rw-r--r--core/io/resource.cpp3
-rw-r--r--core/io/resource.h2
-rw-r--r--core/variant/array.cpp2
-rw-r--r--core/variant/dictionary.cpp2
-rw-r--r--core/variant/variant.cpp9
-rw-r--r--core/variant/variant.h3
7 files changed, 24 insertions, 17 deletions
diff --git a/core/io/image.cpp b/core/io/image.cpp
index 674af6b0a6..15d0182dfc 100644
--- a/core/io/image.cpp
+++ b/core/io/image.cpp
@@ -1930,8 +1930,7 @@ Error Image::generate_mipmaps(bool p_renormalize) {
}
Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, const Ref<Image> &p_normal_map) {
- Vector<double> normal_sat_vec; //summed area table
- double *normal_sat = nullptr; //summed area table for normal map
+ LocalVector<double> normal_sat_vec; //summed area table
int normal_w = 0, normal_h = 0;
ERR_FAIL_COND_V_MSG(p_normal_map.is_null() || p_normal_map->is_empty(), ERR_INVALID_PARAMETER, "Must provide a valid normal map for roughness mipmaps");
@@ -1945,8 +1944,7 @@ Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, con
normal_h = nm->get_height();
normal_sat_vec.resize(normal_w * normal_h * 3);
-
- normal_sat = normal_sat_vec.ptrw();
+ double *normal_sat = normal_sat_vec.ptr();
//create summed area table
@@ -2021,24 +2019,26 @@ Error Image::generate_mipmap_roughness(RoughnessChannel p_roughness_channel, con
avg[2] += normal_sat[tofs + 2];
}
- if (from_y > 0) {
+ if (from_y > 0 && to_x > 0) {
uint32_t tofs = ((from_y - 1) * normal_w + to_x) * 3;
avg[0] -= normal_sat[tofs + 0];
avg[1] -= normal_sat[tofs + 1];
avg[2] -= normal_sat[tofs + 2];
}
- if (from_x > 0) {
+ if (from_x > 0 && to_y > 0) {
uint32_t tofs = (to_y * normal_w + (from_x - 1)) * 3;
avg[0] -= normal_sat[tofs + 0];
avg[1] -= normal_sat[tofs + 1];
avg[2] -= normal_sat[tofs + 2];
}
- uint32_t tofs = (to_y * normal_w + to_x) * 3;
- avg[0] += normal_sat[tofs + 0];
- avg[1] += normal_sat[tofs + 1];
- avg[2] += normal_sat[tofs + 2];
+ if (to_y > 0 && to_x > 0) {
+ uint32_t tofs = (to_y * normal_w + to_x) * 3;
+ avg[0] += normal_sat[tofs + 0];
+ avg[1] += normal_sat[tofs + 1];
+ avg[2] += normal_sat[tofs + 2];
+ }
double div = double(size_x * size_y);
Vector3 vec(avg[0] / div, avg[1] / div, avg[2] / div);
diff --git a/core/io/resource.cpp b/core/io/resource.cpp
index 68cdeabac7..e0d42a274a 100644
--- a/core/io/resource.cpp
+++ b/core/io/resource.cpp
@@ -379,8 +379,8 @@ Node *Resource::get_local_scene() const {
}
void Resource::setup_local_to_scene() {
- // Can't use GDVIRTUAL in Resource, so this will have to be done with a signal
emit_signal(SNAME("setup_local_to_scene_requested"));
+ GDVIRTUAL_CALL(_setup_local_to_scene);
}
void Resource::reset_local_to_scene() {
@@ -460,6 +460,7 @@ void Resource::_bind_methods() {
get_rid_bind.return_val.type = Variant::RID;
::ClassDB::add_virtual_method(get_class_static(), get_rid_bind, true, Vector<String>(), true);
+ GDVIRTUAL_BIND(_setup_local_to_scene);
}
Resource::Resource() :
diff --git a/core/io/resource.h b/core/io/resource.h
index f848bdba99..a9b1a88f6b 100644
--- a/core/io/resource.h
+++ b/core/io/resource.h
@@ -33,6 +33,7 @@
#include "core/io/resource_uid.h"
#include "core/object/class_db.h"
+#include "core/object/gdvirtual.gen.inc"
#include "core/object/ref_counted.h"
#include "core/templates/safe_refcount.h"
#include "core/templates/self_list.h"
@@ -81,6 +82,7 @@ protected:
void _take_over_path(const String &p_path);
virtual void reset_local_to_scene();
+ GDVIRTUAL0(_setup_local_to_scene);
public:
static Node *(*_get_local_scene_func)(); //used by editor
diff --git a/core/variant/array.cpp b/core/variant/array.cpp
index 4c9ee68ab5..ab0315ae34 100644
--- a/core/variant/array.cpp
+++ b/core/variant/array.cpp
@@ -137,7 +137,7 @@ bool Array::recursive_equal(const Array &p_array, int recursion_count) const {
}
recursion_count++;
for (int i = 0; i < size; i++) {
- if (!a1[i].hash_compare(a2[i], recursion_count)) {
+ if (!a1[i].hash_compare(a2[i], recursion_count, false)) {
return false;
}
}
diff --git a/core/variant/dictionary.cpp b/core/variant/dictionary.cpp
index 2dda9fc1f8..141ce25fa6 100644
--- a/core/variant/dictionary.cpp
+++ b/core/variant/dictionary.cpp
@@ -210,7 +210,7 @@ bool Dictionary::recursive_equal(const Dictionary &p_dictionary, int recursion_c
recursion_count++;
for (const KeyValue<Variant, Variant> &this_E : _p->variant_map) {
HashMap<Variant, Variant, VariantHasher, StringLikeVariantComparator>::ConstIterator other_E(p_dictionary._p->variant_map.find(this_E.key));
- if (!other_E || !this_E.value.hash_compare(other_E->value, recursion_count)) {
+ if (!other_E || !this_E.value.hash_compare(other_E->value, recursion_count, false)) {
return false;
}
}
diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp
index 8a0289898d..63ea3274ce 100644
--- a/core/variant/variant.cpp
+++ b/core/variant/variant.cpp
@@ -3235,8 +3235,11 @@ uint32_t Variant::recursive_hash(int recursion_count) const {
return 0;
}
+#define hash_compare_scalar_base(p_lhs, p_rhs, semantic_comparison) \
+ (((p_lhs) == (p_rhs)) || (semantic_comparison && Math::is_nan(p_lhs) && Math::is_nan(p_rhs)))
+
#define hash_compare_scalar(p_lhs, p_rhs) \
- (((p_lhs) == (p_rhs)) || (Math::is_nan(p_lhs) && Math::is_nan(p_rhs)))
+ (hash_compare_scalar_base(p_lhs, p_rhs, true))
#define hash_compare_vector2(p_lhs, p_rhs) \
(hash_compare_scalar((p_lhs).x, (p_rhs).x) && \
@@ -3282,7 +3285,7 @@ uint32_t Variant::recursive_hash(int recursion_count) const {
\
return true
-bool Variant::hash_compare(const Variant &p_variant, int recursion_count) const {
+bool Variant::hash_compare(const Variant &p_variant, int recursion_count, bool semantic_comparison) const {
if (type != p_variant.type) {
return false;
}
@@ -3293,7 +3296,7 @@ bool Variant::hash_compare(const Variant &p_variant, int recursion_count) const
} break;
case FLOAT: {
- return hash_compare_scalar(_data._float, p_variant._data._float);
+ return hash_compare_scalar_base(_data._float, p_variant._data._float, semantic_comparison);
} break;
case STRING: {
diff --git a/core/variant/variant.h b/core/variant/variant.h
index 04c2fe2012..d698f85754 100644
--- a/core/variant/variant.h
+++ b/core/variant/variant.h
@@ -751,7 +751,8 @@ public:
uint32_t hash() const;
uint32_t recursive_hash(int recursion_count) const;
- bool hash_compare(const Variant &p_variant, int recursion_count = 0) const;
+ // By default, performs a semantic comparison. Otherwise, numeric/binary comparison (if appropriate).
+ bool hash_compare(const Variant &p_variant, int recursion_count = 0, bool semantic_comparison = true) const;
bool identity_compare(const Variant &p_variant) const;
bool booleanize() const;
String stringify(int recursion_count = 0) const;