summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSpartan322 <Megacake1234@gmail.com>2024-10-14 02:57:59 -0400
committerSpartan322 <Megacake1234@gmail.com>2024-10-14 02:57:59 -0400
commit22d604c80d9ffd7ad72b06458a2e8e72ee5737e3 (patch)
tree176614fa17d6a68691b5f27f8e5f7d9b4dd17729 /core
parent83d65738b06986e5aa0943cae01e357133e04a75 (diff)
parent92e51fca7247c932f95a1662aefc28aca96e8de6 (diff)
downloadredot-engine-22d604c80d9ffd7ad72b06458a2e8e72ee5737e3.tar.gz
Merge commit godotengine@92e51fca7247c932f95a1662aefc28aca96e8de6
Diffstat (limited to 'core')
-rw-r--r--core/config/project_settings.cpp18
-rw-r--r--core/math/geometry_2d.cpp12
2 files changed, 13 insertions, 17 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp
index 876f5ae515..26ec56c8b0 100644
--- a/core/config/project_settings.cpp
+++ b/core/config/project_settings.cpp
@@ -1169,22 +1169,16 @@ bool ProjectSettings::is_project_loaded() const {
}
bool ProjectSettings::_property_can_revert(const StringName &p_name) const {
- if (!props.has(p_name)) {
- return false;
- }
-
- return props[p_name].initial != props[p_name].variant;
+ return props.has(p_name);
}
bool ProjectSettings::_property_get_revert(const StringName &p_name, Variant &r_property) const {
- if (!props.has(p_name)) {
- return false;
+ const RBMap<StringName, ProjectSettings::VariantContainer>::Element *value = props.find(p_name);
+ if (value) {
+ r_property = value->value().initial.duplicate();
+ return true;
}
-
- // Duplicate so that if value is array or dictionary, changing the setting will not change the stored initial value.
- r_property = props[p_name].initial.duplicate();
-
- return true;
+ return false;
}
void ProjectSettings::set_setting(const String &p_setting, const Variant &p_value) {
diff --git a/core/math/geometry_2d.cpp b/core/math/geometry_2d.cpp
index 68e236df3d..2812ebbe51 100644
--- a/core/math/geometry_2d.cpp
+++ b/core/math/geometry_2d.cpp
@@ -37,7 +37,8 @@
#define STB_RECT_PACK_IMPLEMENTATION
#include "thirdparty/misc/stb_rect_pack.h"
-#define PRECISION 5 // Based on CMP_EPSILON.
+const int clipper_precision = 5; // Based on CMP_EPSILON.
+const double clipper_scale = Math::pow(10.0, clipper_precision);
Vector<Vector<Vector2>> Geometry2D::decompose_polygon_in_convex(const Vector<Point2> &polygon) {
Vector<Vector<Vector2>> decomp;
@@ -226,7 +227,7 @@ Vector<Vector<Point2>> Geometry2D::_polypaths_do_operation(PolyBooleanOperation
path_b[i] = PointD(p_polypath_b[i].x, p_polypath_b[i].y);
}
- ClipperD clp(PRECISION); // Scale points up internally to attain the desired precision.
+ ClipperD clp(clipper_precision); // Scale points up internally to attain the desired precision.
clp.PreserveCollinear(false); // Remove redundant vertices.
if (is_a_open) {
clp.AddOpenSubject({ path_a });
@@ -300,9 +301,10 @@ Vector<Vector<Point2>> Geometry2D::_polypath_offset(const Vector<Point2> &p_poly
}
// Inflate/deflate.
- PathsD paths = InflatePaths({ polypath }, p_delta, jt, et, 2.0, PRECISION, 0.0);
- // Here the miter_limit = 2.0 and arc_tolerance = 0.0 are Clipper2 defaults,
- // and the PRECISION is used to scale points up internally, to attain the desired precision.
+ PathsD paths = InflatePaths({ polypath }, p_delta, jt, et, 2.0, clipper_precision, 0.25 * clipper_scale);
+ // Here the points are scaled up internally and
+ // the arc_tolerance is scaled accordingly
+ // to attain the desired precision.
Vector<Vector<Point2>> polypaths;
for (PathsD::size_type i = 0; i < paths.size(); ++i) {