summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-11-10 08:28:08 +0100
committerGitHub <noreply@github.com>2020-11-10 08:28:08 +0100
commit8e056ba2034caa9f69d242eb97eff54ce3760813 (patch)
tree4fa6ebf28401601e03b0ce2b387f60c32b771fb5 /core
parentefc4d217d61f592a16ebab30731ff9f595dee2cf (diff)
parent0f249f5c0aa2c3a89848f03f155b76e834e4c32a (diff)
Merge pull request #43417 from akien-mga/variant-default-constructors-docs
Variant: Sync docs with new constructors, fixes to #43403
Diffstat (limited to 'core')
-rw-r--r--core/math/color.h15
-rw-r--r--core/math/color_names.inc10
-rw-r--r--core/math/transform.cpp7
-rw-r--r--core/math/transform.h5
-rw-r--r--core/string/ustring.h2
-rw-r--r--core/variant/variant_construct.cpp17
6 files changed, 43 insertions, 13 deletions
diff --git a/core/math/color.h b/core/math/color.h
index 94502a79bf..a9be9e9035 100644
--- a/core/math/color.h
+++ b/core/math/color.h
@@ -209,9 +209,10 @@ struct Color {
_FORCE_INLINE_ Color() {}
/**
- * RGB / RGBA construct parameters. Alpha is optional, but defaults to 1.0
+ * RGBA construct parameters.
+ * Alpha is not optional as otherwise we can't bind the RGB version for scripting.
*/
- _FORCE_INLINE_ Color(float p_r, float p_g, float p_b, float p_a = 1.0) {
+ _FORCE_INLINE_ Color(float p_r, float p_g, float p_b, float p_a) {
r = p_r;
g = p_g;
b = p_b;
@@ -219,6 +220,16 @@ struct Color {
}
/**
+ * RGB construct parameters.
+ */
+ _FORCE_INLINE_ Color(float p_r, float p_g, float p_b) {
+ r = p_r;
+ g = p_g;
+ b = p_b;
+ a = 1.0;
+ }
+
+ /**
* Construct a Color from another Color, but with the specified alpha value.
*/
_FORCE_INLINE_ Color(const Color &p_c, float p_a) {
diff --git a/core/math/color_names.inc b/core/math/color_names.inc
index cbc821026e..523c7e3c59 100644
--- a/core/math/color_names.inc
+++ b/core/math/color_names.inc
@@ -61,9 +61,7 @@ static NamedColor named_colors[] = {
{ "gold", Color(1.00, 0.84, 0.00) },
{ "goldenrod", Color(0.85, 0.65, 0.13) },
{ "gray", Color(0.75, 0.75, 0.75) },
- { "webgray", Color(0.50, 0.50, 0.50) },
{ "green", Color(0.00, 1.00, 0.00) },
- { "webgreen", Color(0.00, 0.50, 0.00) },
{ "greenyellow", Color(0.68, 1.00, 0.18) },
{ "honeydew", Color(0.94, 1.00, 0.94) },
{ "hotpink", Color(1.00, 0.41, 0.71) },
@@ -93,7 +91,6 @@ static NamedColor named_colors[] = {
{ "linen", Color(0.98, 0.94, 0.90) },
{ "magenta", Color(1.00, 0.00, 1.00) },
{ "maroon", Color(0.69, 0.19, 0.38) },
- { "webmaroon", Color(0.50, 0.00, 0.00) },
{ "mediumaquamarine", Color(0.40, 0.80, 0.67) },
{ "mediumblue", Color(0.00, 0.00, 0.80) },
{ "mediumorchid", Color(0.73, 0.33, 0.83) },
@@ -126,7 +123,6 @@ static NamedColor named_colors[] = {
{ "plum", Color(0.87, 0.63, 0.87) },
{ "powderblue", Color(0.69, 0.88, 0.90) },
{ "purple", Color(0.63, 0.13, 0.94) },
- { "webpurple", Color(0.50, 0.00, 0.50) },
{ "rebeccapurple", Color(0.40, 0.20, 0.60) },
{ "red", Color(1.00, 0.00, 0.00) },
{ "rosybrown", Color(0.74, 0.56, 0.56) },
@@ -148,9 +144,13 @@ static NamedColor named_colors[] = {
{ "teal", Color(0.00, 0.50, 0.50) },
{ "thistle", Color(0.85, 0.75, 0.85) },
{ "tomato", Color(1.00, 0.39, 0.28) },
- { "turquoise", Color(0.25, 0.88, 0.82) },
{ "transparent", Color(1.00, 1.00, 1.00, 0.00) },
+ { "turquoise", Color(0.25, 0.88, 0.82) },
{ "violet", Color(0.93, 0.51, 0.93) },
+ { "webgray", Color(0.50, 0.50, 0.50) },
+ { "webgreen", Color(0.00, 0.50, 0.00) },
+ { "webmaroon", Color(0.50, 0.00, 0.00) },
+ { "webpurple", Color(0.50, 0.00, 0.50) },
{ "wheat", Color(0.96, 0.87, 0.70) },
{ "white", Color(1.00, 1.00, 1.00) },
{ "whitesmoke", Color(0.96, 0.96, 0.96) },
diff --git a/core/math/transform.cpp b/core/math/transform.cpp
index d36fd6a63d..733bb4d55e 100644
--- a/core/math/transform.cpp
+++ b/core/math/transform.cpp
@@ -200,6 +200,13 @@ Transform::Transform(const Basis &p_basis, const Vector3 &p_origin) :
origin(p_origin) {
}
+Transform::Transform(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z, const Vector3 &p_origin) :
+ origin(p_origin) {
+ basis.set_axis(0, p_x);
+ basis.set_axis(1, p_y);
+ basis.set_axis(2, p_z);
+}
+
Transform::Transform(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t ox, real_t oy, real_t oz) {
basis = Basis(xx, xy, xz, yx, yy, yz, zx, zy, zz);
origin = Vector3(ox, oy, oz);
diff --git a/core/math/transform.h b/core/math/transform.h
index 71847d36ac..c63dbcb989 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -106,9 +106,10 @@ public:
operator String() const;
- Transform(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t ox, real_t oy, real_t oz);
- Transform(const Basis &p_basis, const Vector3 &p_origin = Vector3());
Transform() {}
+ Transform(const Basis &p_basis, const Vector3 &p_origin = Vector3());
+ Transform(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z, const Vector3 &p_origin);
+ Transform(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t ox, real_t oy, real_t oz);
};
_FORCE_INLINE_ Vector3 Transform::xform(const Vector3 &p_vector) const {
diff --git a/core/string/ustring.h b/core/string/ustring.h
index 35475a2124..201b439b12 100644
--- a/core/string/ustring.h
+++ b/core/string/ustring.h
@@ -433,10 +433,10 @@ public:
/**
* The constructors must not depend on other overloads
*/
- /* String(char32_t p_char);*/
_FORCE_INLINE_ String() {}
_FORCE_INLINE_ String(const String &p_str) { _cowdata._ref(p_str._cowdata); }
+
String &operator=(const String &p_str) {
_cowdata._ref(p_str._cowdata);
return *this;
diff --git a/core/variant/variant_construct.cpp b/core/variant/variant_construct.cpp
index 5281265294..b777323e82 100644
--- a/core/variant/variant_construct.cpp
+++ b/core/variant/variant_construct.cpp
@@ -292,7 +292,7 @@ public:
}
static Variant::Type get_base_type() {
- return Variant::CALLABLE;
+ return Variant::SIGNAL;
}
};
@@ -569,10 +569,12 @@ void Variant::_register_variant_constructors() {
add_constructor<VariantConstructNoArgs<int64_t>>(sarray());
add_constructor<VariantConstructor<int64_t, int64_t>>(sarray("from"));
add_constructor<VariantConstructor<int64_t, double>>(sarray("from"));
+ add_constructor<VariantConstructor<int64_t, bool>>(sarray("from"));
add_constructor<VariantConstructNoArgs<double>>(sarray());
add_constructor<VariantConstructor<double, double>>(sarray("from"));
add_constructor<VariantConstructor<double, int64_t>>(sarray("from"));
+ add_constructor<VariantConstructor<double, bool>>(sarray("from"));
add_constructor<VariantConstructNoArgs<String>>(sarray());
add_constructor<VariantConstructor<String, String>>(sarray("from"));
@@ -613,13 +615,15 @@ void Variant::_register_variant_constructors() {
add_constructor<VariantConstructNoArgs<Transform2D>>(sarray());
add_constructor<VariantConstructor<Transform2D, Transform2D>>(sarray("from"));
- add_constructor<VariantConstructor<Transform2D, Vector2, Vector2, Vector2>>(sarray("x", "y", "origin"));
+ add_constructor<VariantConstructor<Transform2D, float, Vector2>>(sarray("rotation", "position"));
+ add_constructor<VariantConstructor<Transform2D, Vector2, Vector2, Vector2>>(sarray("x_axis", "y_axis", "origin"));
add_constructor<VariantConstructNoArgs<Plane>>(sarray());
add_constructor<VariantConstructor<Plane, Plane>>(sarray("from"));
add_constructor<VariantConstructor<Plane, Vector3, double>>(sarray("normal", "d"));
add_constructor<VariantConstructor<Plane, Vector3, Vector3>>(sarray("point", "normal"));
add_constructor<VariantConstructor<Plane, Vector3, Vector3, Vector3>>(sarray("point1", "point2", "point3"));
+ add_constructor<VariantConstructor<Plane, double, double, double, double>>(sarray("a", "b", "c", "d"));
add_constructor<VariantConstructNoArgs<Quat>>(sarray());
add_constructor<VariantConstructor<Quat, Quat>>(sarray("from"));
@@ -627,6 +631,7 @@ void Variant::_register_variant_constructors() {
add_constructor<VariantConstructor<Quat, Vector3>>(sarray("euler"));
add_constructor<VariantConstructor<Quat, Vector3, double>>(sarray("axis", "angle"));
add_constructor<VariantConstructor<Quat, Vector3, Vector3>>(sarray("arc_from", "arc_to"));
+ add_constructor<VariantConstructor<Quat, double, double, double, double>>(sarray("x", "y", "z", "w"));
add_constructor<VariantConstructNoArgs<::AABB>>(sarray());
add_constructor<VariantConstructor<::AABB, ::AABB>>(sarray("from"));
@@ -635,14 +640,20 @@ void Variant::_register_variant_constructors() {
add_constructor<VariantConstructNoArgs<Basis>>(sarray());
add_constructor<VariantConstructor<Basis, Basis>>(sarray("from"));
add_constructor<VariantConstructor<Basis, Quat>>(sarray("from"));
- add_constructor<VariantConstructor<Basis, Vector3, Vector3, Vector3>>(sarray("x", "y", "z"));
+ add_constructor<VariantConstructor<Basis, Vector3>>(sarray("euler"));
+ add_constructor<VariantConstructor<Basis, Vector3, double>>(sarray("axis", "phi"));
+ add_constructor<VariantConstructor<Basis, Vector3, Vector3, Vector3>>(sarray("x_axis", "y_axis", "z_axis"));
add_constructor<VariantConstructNoArgs<Transform>>(sarray());
add_constructor<VariantConstructor<Transform, Transform>>(sarray("from"));
add_constructor<VariantConstructor<Transform, Basis, Vector3>>(sarray("basis", "origin"));
+ add_constructor<VariantConstructor<Transform, Vector3, Vector3, Vector3, Vector3>>(sarray("x_axis", "y_axis", "z_axis", "origin"));
add_constructor<VariantConstructNoArgs<Color>>(sarray());
add_constructor<VariantConstructor<Color, Color>>(sarray("from"));
+ add_constructor<VariantConstructor<Color, Color, double>>(sarray("from", "alpha"));
+ add_constructor<VariantConstructor<Color, double, double, double>>(sarray("r", "g", "b"));
+ add_constructor<VariantConstructor<Color, double, double, double, double>>(sarray("r", "g", "b", "a"));
add_constructor<VariantConstructNoArgs<StringName>>(sarray());
add_constructor<VariantConstructor<StringName, StringName>>(sarray("from"));