summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/doc_data.h2
-rw-r--r--core/io/logger.cpp2
-rw-r--r--core/math/basis.cpp12
-rw-r--r--core/math/basis.h2
-rw-r--r--core/math/color.h10
-rw-r--r--core/math/quat.cpp72
-rw-r--r--core/math/quat.h60
-rw-r--r--core/math/random_number_generator.cpp7
-rw-r--r--core/math/random_number_generator.h8
-rw-r--r--core/math/random_pcg.h7
-rw-r--r--core/math/vector2.cpp8
-rw-r--r--core/math/vector2.h26
-rw-r--r--core/math/vector3.cpp8
-rw-r--r--core/math/vector3.h52
-rw-r--r--core/object/script_language.h2
-rw-r--r--core/variant/variant_call.cpp24
16 files changed, 153 insertions, 149 deletions
diff --git a/core/doc_data.h b/core/doc_data.h
index bf016792ea..65b57d1381 100644
--- a/core/doc_data.h
+++ b/core/doc_data.h
@@ -89,7 +89,7 @@ public:
struct ConstantDoc {
String name;
String value;
- bool is_value_valid;
+ bool is_value_valid = false;
String enumeration;
String description;
bool operator<(const ConstantDoc &p_const) const {
diff --git a/core/io/logger.cpp b/core/io/logger.cpp
index 0e6a2e2c9f..f5cea00f28 100644
--- a/core/io/logger.cpp
+++ b/core/io/logger.cpp
@@ -152,7 +152,7 @@ void RotatedFileLogger::rotate_file() {
char timestamp[21];
OS::Date date = OS::get_singleton()->get_date();
OS::Time time = OS::get_singleton()->get_time();
- sprintf(timestamp, "_%04d-%02d-%02d_%02d-%02d-%02d", date.year, date.month, date.day, time.hour, time.min, time.sec);
+ sprintf(timestamp, "_%04d-%02d-%02d_%02d.%02d.%02d", date.year, date.month, date.day, time.hour, time.min, time.sec);
String backup_name = base_path.get_basename() + timestamp;
if (base_path.get_extension() != String()) {
diff --git a/core/math/basis.cpp b/core/math/basis.cpp
index c6030d9757..a64f29517d 100644
--- a/core/math/basis.cpp
+++ b/core/math/basis.cpp
@@ -1017,15 +1017,15 @@ void Basis::set_diagonal(const Vector3 &p_diag) {
elements[2][2] = p_diag.z;
}
-Basis Basis::slerp(const Basis &target, const real_t &t) const {
+Basis Basis::slerp(const Basis &p_to, const real_t &p_weight) const {
//consider scale
Quat from(*this);
- Quat to(target);
+ Quat to(p_to);
- Basis b(from.slerp(to, t));
- b.elements[0] *= Math::lerp(elements[0].length(), target.elements[0].length(), t);
- b.elements[1] *= Math::lerp(elements[1].length(), target.elements[1].length(), t);
- b.elements[2] *= Math::lerp(elements[2].length(), target.elements[2].length(), t);
+ Basis b(from.slerp(to, p_weight));
+ b.elements[0] *= Math::lerp(elements[0].length(), p_to.elements[0].length(), p_weight);
+ b.elements[1] *= Math::lerp(elements[1].length(), p_to.elements[1].length(), p_weight);
+ b.elements[2] *= Math::lerp(elements[2].length(), p_to.elements[2].length(), p_weight);
return b;
}
diff --git a/core/math/basis.h b/core/math/basis.h
index 2584f1ff48..4cb3d55200 100644
--- a/core/math/basis.h
+++ b/core/math/basis.h
@@ -170,7 +170,7 @@ public:
bool is_diagonal() const;
bool is_rotation() const;
- Basis slerp(const Basis &target, const real_t &t) const;
+ Basis slerp(const Basis &p_to, const real_t &p_weight) const;
void rotate_sh(real_t *p_values);
operator String() const;
diff --git a/core/math/color.h b/core/math/color.h
index a9be9e9035..b928ff8592 100644
--- a/core/math/color.h
+++ b/core/math/color.h
@@ -92,13 +92,13 @@ struct Color {
void invert();
Color inverted() const;
- _FORCE_INLINE_ Color lerp(const Color &p_b, float p_t) const {
+ _FORCE_INLINE_ Color lerp(const Color &p_to, float p_weight) const {
Color res = *this;
- res.r += (p_t * (p_b.r - r));
- res.g += (p_t * (p_b.g - g));
- res.b += (p_t * (p_b.b - b));
- res.a += (p_t * (p_b.a - a));
+ res.r += (p_weight * (p_to.r - r));
+ res.g += (p_weight * (p_to.g - g));
+ res.b += (p_weight * (p_to.b - b));
+ res.a += (p_weight * (p_to.a - a));
return res;
}
diff --git a/core/math/quat.cpp b/core/math/quat.cpp
index b6a017dd41..fc2d71c377 100644
--- a/core/math/quat.cpp
+++ b/core/math/quat.cpp
@@ -106,16 +106,16 @@ Vector3 Quat::get_euler_yxz() const {
return m.get_euler_yxz();
}
-void Quat::operator*=(const Quat &q) {
- set(w * q.x + x * q.w + y * q.z - z * q.y,
- w * q.y + y * q.w + z * q.x - x * q.z,
- w * q.z + z * q.w + x * q.y - y * q.x,
- w * q.w - x * q.x - y * q.y - z * q.z);
+void Quat::operator*=(const Quat &p_q) {
+ set(w * p_q.x + x * p_q.w + y * p_q.z - z * p_q.y,
+ w * p_q.y + y * p_q.w + z * p_q.x - x * p_q.z,
+ w * p_q.z + z * p_q.w + x * p_q.y - y * p_q.x,
+ w * p_q.w - x * p_q.x - y * p_q.y - z * p_q.z);
}
-Quat Quat::operator*(const Quat &q) const {
+Quat Quat::operator*(const Quat &p_q) const {
Quat r = *this;
- r *= q;
+ r *= p_q;
return r;
}
@@ -146,29 +146,29 @@ Quat Quat::inverse() const {
return Quat(-x, -y, -z, w);
}
-Quat Quat::slerp(const Quat &q, const real_t &t) const {
+Quat Quat::slerp(const Quat &p_to, const real_t &p_weight) const {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The start quaternion must be normalized.");
- ERR_FAIL_COND_V_MSG(!q.is_normalized(), Quat(), "The end quaternion must be normalized.");
+ ERR_FAIL_COND_V_MSG(!p_to.is_normalized(), Quat(), "The end quaternion must be normalized.");
#endif
Quat to1;
real_t omega, cosom, sinom, scale0, scale1;
// calc cosine
- cosom = dot(q);
+ cosom = dot(p_to);
// adjust signs (if necessary)
if (cosom < 0.0) {
cosom = -cosom;
- to1.x = -q.x;
- to1.y = -q.y;
- to1.z = -q.z;
- to1.w = -q.w;
+ to1.x = -p_to.x;
+ to1.y = -p_to.y;
+ to1.z = -p_to.z;
+ to1.w = -p_to.w;
} else {
- to1.x = q.x;
- to1.y = q.y;
- to1.z = q.z;
- to1.w = q.w;
+ to1.x = p_to.x;
+ to1.y = p_to.y;
+ to1.z = p_to.z;
+ to1.w = p_to.w;
}
// calculate coefficients
@@ -177,13 +177,13 @@ Quat Quat::slerp(const Quat &q, const real_t &t) const {
// standard case (slerp)
omega = Math::acos(cosom);
sinom = Math::sin(omega);
- scale0 = Math::sin((1.0 - t) * omega) / sinom;
- scale1 = Math::sin(t * omega) / sinom;
+ scale0 = Math::sin((1.0 - p_weight) * omega) / sinom;
+ scale1 = Math::sin(p_weight * omega) / sinom;
} else {
// "from" and "to" quaternions are very close
// ... so we can do a linear interpolation
- scale0 = 1.0 - t;
- scale1 = t;
+ scale0 = 1.0 - p_weight;
+ scale1 = p_weight;
}
// calculate final values
return Quat(
@@ -193,14 +193,14 @@ Quat Quat::slerp(const Quat &q, const real_t &t) const {
scale0 * w + scale1 * to1.w);
}
-Quat Quat::slerpni(const Quat &q, const real_t &t) const {
+Quat Quat::slerpni(const Quat &p_to, const real_t &p_weight) const {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The start quaternion must be normalized.");
- ERR_FAIL_COND_V_MSG(!q.is_normalized(), Quat(), "The end quaternion must be normalized.");
+ ERR_FAIL_COND_V_MSG(!p_to.is_normalized(), Quat(), "The end quaternion must be normalized.");
#endif
const Quat &from = *this;
- real_t dot = from.dot(q);
+ real_t dot = from.dot(p_to);
if (Math::absf(dot) > 0.9999) {
return from;
@@ -208,24 +208,24 @@ Quat Quat::slerpni(const Quat &q, const real_t &t) const {
real_t theta = Math::acos(dot),
sinT = 1.0 / Math::sin(theta),
- newFactor = Math::sin(t * theta) * sinT,
- invFactor = Math::sin((1.0 - t) * theta) * sinT;
+ newFactor = Math::sin(p_weight * theta) * sinT,
+ invFactor = Math::sin((1.0 - p_weight) * theta) * sinT;
- return Quat(invFactor * from.x + newFactor * q.x,
- invFactor * from.y + newFactor * q.y,
- invFactor * from.z + newFactor * q.z,
- invFactor * from.w + newFactor * q.w);
+ return Quat(invFactor * from.x + newFactor * p_to.x,
+ invFactor * from.y + newFactor * p_to.y,
+ invFactor * from.z + newFactor * p_to.z,
+ invFactor * from.w + newFactor * p_to.w);
}
-Quat Quat::cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const {
+Quat Quat::cubic_slerp(const Quat &p_b, const Quat &p_pre_a, const Quat &p_post_b, const real_t &p_weight) const {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V_MSG(!is_normalized(), Quat(), "The start quaternion must be normalized.");
- ERR_FAIL_COND_V_MSG(!q.is_normalized(), Quat(), "The end quaternion must be normalized.");
+ ERR_FAIL_COND_V_MSG(!p_b.is_normalized(), Quat(), "The end quaternion must be normalized.");
#endif
//the only way to do slerp :|
- real_t t2 = (1.0 - t) * t * 2;
- Quat sp = this->slerp(q, t);
- Quat sq = prep.slerpni(postq, t);
+ real_t t2 = (1.0 - p_weight) * p_weight * 2;
+ Quat sp = this->slerp(p_b, p_weight);
+ Quat sq = p_pre_a.slerpni(p_post_b, p_weight);
return sp.slerpni(sq, t2);
}
diff --git a/core/math/quat.h b/core/math/quat.h
index f8ab537d7b..bb980f7677 100644
--- a/core/math/quat.h
+++ b/core/math/quat.h
@@ -63,7 +63,7 @@ public:
Quat normalized() const;
bool is_normalized() const;
Quat inverse() const;
- _FORCE_INLINE_ real_t dot(const Quat &q) const;
+ _FORCE_INLINE_ real_t dot(const Quat &p_q) const;
void set_euler_xyz(const Vector3 &p_euler);
Vector3 get_euler_xyz() const;
@@ -73,9 +73,9 @@ public:
void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); };
Vector3 get_euler() const { return get_euler_yxz(); };
- Quat slerp(const Quat &q, const real_t &t) const;
- Quat slerpni(const Quat &q, const real_t &t) const;
- Quat cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const;
+ Quat slerp(const Quat &p_to, const real_t &p_weight) const;
+ Quat slerpni(const Quat &p_to, const real_t &p_weight) const;
+ Quat cubic_slerp(const Quat &p_b, const Quat &p_pre_a, const Quat &p_post_b, const real_t &p_weight) const;
void set_axis_angle(const Vector3 &axis, const real_t &angle);
_FORCE_INLINE_ void get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
@@ -86,8 +86,8 @@ public:
r_axis.z = z * r;
}
- void operator*=(const Quat &q);
- Quat operator*(const Quat &q) const;
+ void operator*=(const Quat &p_q);
+ Quat operator*(const Quat &p_q) const;
Quat operator*(const Vector3 &v) const {
return Quat(w * v.x + y * v.z - z * v.y,
@@ -109,8 +109,8 @@ public:
return inverse().xform(v);
}
- _FORCE_INLINE_ void operator+=(const Quat &q);
- _FORCE_INLINE_ void operator-=(const Quat &q);
+ _FORCE_INLINE_ void operator+=(const Quat &p_q);
+ _FORCE_INLINE_ void operator-=(const Quat &p_q);
_FORCE_INLINE_ void operator*=(const real_t &s);
_FORCE_INLINE_ void operator/=(const real_t &s);
_FORCE_INLINE_ Quat operator+(const Quat &q2) const;
@@ -141,18 +141,18 @@ public:
Quat(const Vector3 &axis, const real_t &angle) { set_axis_angle(axis, angle); }
Quat(const Vector3 &euler) { set_euler(euler); }
- Quat(const Quat &q) :
- x(q.x),
- y(q.y),
- z(q.z),
- w(q.w) {
+ Quat(const Quat &p_q) :
+ x(p_q.x),
+ y(p_q.y),
+ z(p_q.z),
+ w(p_q.w) {
}
- Quat &operator=(const Quat &q) {
- x = q.x;
- y = q.y;
- z = q.z;
- w = q.w;
+ Quat &operator=(const Quat &p_q) {
+ x = p_q.x;
+ y = p_q.y;
+ z = p_q.z;
+ w = p_q.w;
return *this;
}
@@ -178,26 +178,26 @@ public:
}
};
-real_t Quat::dot(const Quat &q) const {
- return x * q.x + y * q.y + z * q.z + w * q.w;
+real_t Quat::dot(const Quat &p_q) const {
+ return x * p_q.x + y * p_q.y + z * p_q.z + w * p_q.w;
}
real_t Quat::length_squared() const {
return dot(*this);
}
-void Quat::operator+=(const Quat &q) {
- x += q.x;
- y += q.y;
- z += q.z;
- w += q.w;
+void Quat::operator+=(const Quat &p_q) {
+ x += p_q.x;
+ y += p_q.y;
+ z += p_q.z;
+ w += p_q.w;
}
-void Quat::operator-=(const Quat &q) {
- x -= q.x;
- y -= q.y;
- z -= q.z;
- w -= q.w;
+void Quat::operator-=(const Quat &p_q) {
+ x -= p_q.x;
+ y -= p_q.y;
+ z -= p_q.z;
+ w -= p_q.w;
}
void Quat::operator*=(const real_t &s) {
diff --git a/core/math/random_number_generator.cpp b/core/math/random_number_generator.cpp
index a124f63030..f045213fb9 100644
--- a/core/math/random_number_generator.cpp
+++ b/core/math/random_number_generator.cpp
@@ -34,6 +34,9 @@ void RandomNumberGenerator::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_seed", "seed"), &RandomNumberGenerator::set_seed);
ClassDB::bind_method(D_METHOD("get_seed"), &RandomNumberGenerator::get_seed);
+ ClassDB::bind_method(D_METHOD("set_state", "state"), &RandomNumberGenerator::set_state);
+ ClassDB::bind_method(D_METHOD("get_state"), &RandomNumberGenerator::get_state);
+
ClassDB::bind_method(D_METHOD("randi"), &RandomNumberGenerator::randi);
ClassDB::bind_method(D_METHOD("randf"), &RandomNumberGenerator::randf);
ClassDB::bind_method(D_METHOD("randfn", "mean", "deviation"), &RandomNumberGenerator::randfn, DEFVAL(0.0), DEFVAL(1.0));
@@ -42,6 +45,8 @@ void RandomNumberGenerator::_bind_methods() {
ClassDB::bind_method(D_METHOD("randomize"), &RandomNumberGenerator::randomize);
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
- // Default value is non-deterministic, override it for doc generation purposes.
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "state"), "set_state", "get_state");
+ // Default values are non-deterministic, override for doc generation purposes.
ADD_PROPERTY_DEFAULT("seed", 0);
+ ADD_PROPERTY_DEFAULT("state", 0);
}
diff --git a/core/math/random_number_generator.h b/core/math/random_number_generator.h
index 0d0ea17205..7728fd09c0 100644
--- a/core/math/random_number_generator.h
+++ b/core/math/random_number_generator.h
@@ -44,19 +44,17 @@ protected:
public:
_FORCE_INLINE_ void set_seed(uint64_t p_seed) { randbase.seed(p_seed); }
-
_FORCE_INLINE_ uint64_t get_seed() { return randbase.get_seed(); }
+ _FORCE_INLINE_ void set_state(uint64_t p_state) { randbase.set_state(p_state); }
+ _FORCE_INLINE_ uint64_t get_state() const { return randbase.get_state(); }
+
_FORCE_INLINE_ void randomize() { randbase.randomize(); }
_FORCE_INLINE_ uint32_t randi() { return randbase.rand(); }
-
_FORCE_INLINE_ real_t randf() { return randbase.randf(); }
-
_FORCE_INLINE_ real_t randf_range(real_t p_from, real_t p_to) { return randbase.random(p_from, p_to); }
-
_FORCE_INLINE_ real_t randfn(real_t p_mean = 0.0, real_t p_deviation = 1.0) { return randbase.randfn(p_mean, p_deviation); }
-
_FORCE_INLINE_ int randi_range(int p_from, int p_to) { return randbase.random(p_from, p_to); }
RandomNumberGenerator() {}
diff --git a/core/math/random_pcg.h b/core/math/random_pcg.h
index fe6b1b5639..2e257cb5b7 100644
--- a/core/math/random_pcg.h
+++ b/core/math/random_pcg.h
@@ -61,7 +61,7 @@ static int __bsr_clz32(uint32_t x) {
class RandomPCG {
pcg32_random_t pcg;
- uint64_t current_seed; // seed with this to get the same state
+ uint64_t current_seed; // The seed the current generator state started from.
uint64_t current_inc;
public:
@@ -76,13 +76,14 @@ public:
}
_FORCE_INLINE_ uint64_t get_seed() { return current_seed; }
+ _FORCE_INLINE_ void set_state(uint64_t p_state) { pcg.state = p_state; }
+ _FORCE_INLINE_ uint64_t get_state() const { return pcg.state; }
+
void randomize();
_FORCE_INLINE_ uint32_t rand() {
- current_seed = pcg.state;
return pcg32_random_r(&pcg);
}
_FORCE_INLINE_ uint32_t rand(uint32_t bounds) {
- current_seed = pcg.state;
return pcg32_boundedrand_r(&pcg, bounds);
}
diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp
index 75e742a5f1..f9c2eeb57d 100644
--- a/core/math/vector2.cpp
+++ b/core/math/vector2.cpp
@@ -118,8 +118,8 @@ Vector2 Vector2::posmodv(const Vector2 &p_modv) const {
return Vector2(Math::fposmod(x, p_modv.x), Math::fposmod(y, p_modv.y));
}
-Vector2 Vector2::project(const Vector2 &p_b) const {
- return p_b * (dot(p_b) / p_b.length_squared());
+Vector2 Vector2::project(const Vector2 &p_to) const {
+ return p_to * (dot(p_to) / p_to.length_squared());
}
Vector2 Vector2::snapped(const Vector2 &p_by) const {
@@ -139,13 +139,13 @@ Vector2 Vector2::clamped(real_t p_len) const {
return v;
}
-Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const {
+Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_weight) const {
Vector2 p0 = p_pre_a;
Vector2 p1 = *this;
Vector2 p2 = p_b;
Vector2 p3 = p_post_b;
- real_t t = p_t;
+ real_t t = p_weight;
real_t t2 = t * t;
real_t t3 = t2 * t;
diff --git a/core/math/vector2.h b/core/math/vector2.h
index 8cb63b2fb5..33f815a39c 100644
--- a/core/math/vector2.h
+++ b/core/math/vector2.h
@@ -77,21 +77,21 @@ struct Vector2 {
real_t distance_squared_to(const Vector2 &p_vector2) const;
real_t angle_to(const Vector2 &p_vector2) const;
real_t angle_to_point(const Vector2 &p_vector2) const;
- _FORCE_INLINE_ Vector2 direction_to(const Vector2 &p_b) const;
+ _FORCE_INLINE_ Vector2 direction_to(const Vector2 &p_to) const;
real_t dot(const Vector2 &p_other) const;
real_t cross(const Vector2 &p_other) const;
Vector2 posmod(const real_t p_mod) const;
Vector2 posmodv(const Vector2 &p_modv) const;
- Vector2 project(const Vector2 &p_b) const;
+ Vector2 project(const Vector2 &p_to) const;
Vector2 plane_project(real_t p_d, const Vector2 &p_vec) const;
Vector2 clamped(real_t p_len) const;
- _FORCE_INLINE_ Vector2 lerp(const Vector2 &p_b, real_t p_t) const;
- _FORCE_INLINE_ Vector2 slerp(const Vector2 &p_b, real_t p_t) const;
- Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const;
+ _FORCE_INLINE_ Vector2 lerp(const Vector2 &p_to, real_t p_weight) const;
+ _FORCE_INLINE_ Vector2 slerp(const Vector2 &p_to, real_t p_weight) const;
+ Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_weight) const;
Vector2 move_toward(const Vector2 &p_to, const real_t p_delta) const;
Vector2 slide(const Vector2 &p_normal) const;
@@ -230,25 +230,25 @@ _FORCE_INLINE_ bool Vector2::operator!=(const Vector2 &p_vec2) const {
return x != p_vec2.x || y != p_vec2.y;
}
-Vector2 Vector2::lerp(const Vector2 &p_b, real_t p_t) const {
+Vector2 Vector2::lerp(const Vector2 &p_to, real_t p_weight) const {
Vector2 res = *this;
- res.x += (p_t * (p_b.x - x));
- res.y += (p_t * (p_b.y - y));
+ res.x += (p_weight * (p_to.x - x));
+ res.y += (p_weight * (p_to.y - y));
return res;
}
-Vector2 Vector2::slerp(const Vector2 &p_b, real_t p_t) const {
+Vector2 Vector2::slerp(const Vector2 &p_to, real_t p_weight) const {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V_MSG(!is_normalized(), Vector2(), "The start Vector2 must be normalized.");
#endif
- real_t theta = angle_to(p_b);
- return rotated(theta * p_t);
+ real_t theta = angle_to(p_to);
+ return rotated(theta * p_weight);
}
-Vector2 Vector2::direction_to(const Vector2 &p_b) const {
- Vector2 ret(p_b.x - x, p_b.y - y);
+Vector2 Vector2::direction_to(const Vector2 &p_to) const {
+ Vector2 ret(p_to.x - x, p_to.y - y);
ret.normalize();
return ret;
}
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index 568df48c62..23f5bb88fe 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -72,7 +72,7 @@ Vector3 Vector3::snapped(Vector3 p_val) const {
return v;
}
-Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const {
+Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const {
Vector3 p0 = p_pre_a;
Vector3 p1 = *this;
Vector3 p2 = p_b;
@@ -93,7 +93,7 @@ Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a,
}
}
- real_t t = p_t;
+ real_t t = p_weight;
real_t t2 = t * t;
real_t t3 = t2 * t;
@@ -105,13 +105,13 @@ Vector3 Vector3::cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a,
return out;
}
-Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const {
+Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const {
Vector3 p0 = p_pre_a;
Vector3 p1 = *this;
Vector3 p2 = p_b;
Vector3 p3 = p_post_b;
- real_t t = p_t;
+ real_t t = p_weight;
real_t t2 = t * t;
real_t t3 = t2 * t;
diff --git a/core/math/vector3.h b/core/math/vector3.h
index ae8b9376cf..69e79627f3 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -86,10 +86,10 @@ struct Vector3 {
/* Static Methods between 2 vector3s */
- _FORCE_INLINE_ Vector3 lerp(const Vector3 &p_b, real_t p_t) const;
- _FORCE_INLINE_ Vector3 slerp(const Vector3 &p_b, real_t p_t) const;
- Vector3 cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const;
- Vector3 cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_t) const;
+ _FORCE_INLINE_ Vector3 lerp(const Vector3 &p_to, real_t p_weight) const;
+ _FORCE_INLINE_ Vector3 slerp(const Vector3 &p_to, real_t p_weight) const;
+ Vector3 cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const;
+ Vector3 cubic_interpolaten(const Vector3 &p_b, const Vector3 &p_pre_a, const Vector3 &p_post_b, real_t p_weight) const;
Vector3 move_toward(const Vector3 &p_to, const real_t p_delta) const;
_FORCE_INLINE_ Vector3 cross(const Vector3 &p_b) const;
@@ -103,15 +103,15 @@ struct Vector3 {
_FORCE_INLINE_ Vector3 ceil() const;
_FORCE_INLINE_ Vector3 round() const;
- _FORCE_INLINE_ real_t distance_to(const Vector3 &p_b) const;
- _FORCE_INLINE_ real_t distance_squared_to(const Vector3 &p_b) const;
+ _FORCE_INLINE_ real_t distance_to(const Vector3 &p_to) const;
+ _FORCE_INLINE_ real_t distance_squared_to(const Vector3 &p_to) const;
_FORCE_INLINE_ Vector3 posmod(const real_t p_mod) const;
_FORCE_INLINE_ Vector3 posmodv(const Vector3 &p_modv) const;
- _FORCE_INLINE_ Vector3 project(const Vector3 &p_b) const;
+ _FORCE_INLINE_ Vector3 project(const Vector3 &p_to) const;
- _FORCE_INLINE_ real_t angle_to(const Vector3 &p_b) const;
- _FORCE_INLINE_ Vector3 direction_to(const Vector3 &p_b) const;
+ _FORCE_INLINE_ real_t angle_to(const Vector3 &p_to) const;
+ _FORCE_INLINE_ Vector3 direction_to(const Vector3 &p_to) const;
_FORCE_INLINE_ Vector3 slide(const Vector3 &p_normal) const;
_FORCE_INLINE_ Vector3 bounce(const Vector3 &p_normal) const;
@@ -195,24 +195,24 @@ Vector3 Vector3::round() const {
return Vector3(Math::round(x), Math::round(y), Math::round(z));
}
-Vector3 Vector3::lerp(const Vector3 &p_b, real_t p_t) const {
+Vector3 Vector3::lerp(const Vector3 &p_to, real_t p_weight) const {
return Vector3(
- x + (p_t * (p_b.x - x)),
- y + (p_t * (p_b.y - y)),
- z + (p_t * (p_b.z - z)));
+ x + (p_weight * (p_to.x - x)),
+ y + (p_weight * (p_to.y - y)),
+ z + (p_weight * (p_to.z - z)));
}
-Vector3 Vector3::slerp(const Vector3 &p_b, real_t p_t) const {
- real_t theta = angle_to(p_b);
- return rotated(cross(p_b).normalized(), theta * p_t);
+Vector3 Vector3::slerp(const Vector3 &p_to, real_t p_weight) const {
+ real_t theta = angle_to(p_to);
+ return rotated(cross(p_to).normalized(), theta * p_weight);
}
-real_t Vector3::distance_to(const Vector3 &p_b) const {
- return (p_b - *this).length();
+real_t Vector3::distance_to(const Vector3 &p_to) const {
+ return (p_to - *this).length();
}
-real_t Vector3::distance_squared_to(const Vector3 &p_b) const {
- return (p_b - *this).length_squared();
+real_t Vector3::distance_squared_to(const Vector3 &p_to) const {
+ return (p_to - *this).length_squared();
}
Vector3 Vector3::posmod(const real_t p_mod) const {
@@ -223,16 +223,16 @@ Vector3 Vector3::posmodv(const Vector3 &p_modv) const {
return Vector3(Math::fposmod(x, p_modv.x), Math::fposmod(y, p_modv.y), Math::fposmod(z, p_modv.z));
}
-Vector3 Vector3::project(const Vector3 &p_b) const {
- return p_b * (dot(p_b) / p_b.length_squared());
+Vector3 Vector3::project(const Vector3 &p_to) const {
+ return p_to * (dot(p_to) / p_to.length_squared());
}
-real_t Vector3::angle_to(const Vector3 &p_b) const {
- return Math::atan2(cross(p_b).length(), dot(p_b));
+real_t Vector3::angle_to(const Vector3 &p_to) const {
+ return Math::atan2(cross(p_to).length(), dot(p_to));
}
-Vector3 Vector3::direction_to(const Vector3 &p_b) const {
- Vector3 ret(p_b.x - x, p_b.y - y, p_b.z - z);
+Vector3 Vector3::direction_to(const Vector3 &p_to) const {
+ Vector3 ret(p_to.x - x, p_to.y - y, p_to.z - z);
ret.normalize();
return ret;
}
diff --git a/core/object/script_language.h b/core/object/script_language.h
index 72586780ae..ddd884a4f3 100644
--- a/core/object/script_language.h
+++ b/core/object/script_language.h
@@ -316,7 +316,7 @@ public:
virtual bool has_named_classes() const = 0;
virtual bool supports_builtin_mode() const = 0;
virtual bool supports_documentation() const { return false; }
- virtual bool can_inherit_from_file() { return false; }
+ virtual bool can_inherit_from_file() const { return false; }
virtual int find_function(const String &p_function, const String &p_code) const = 0;
virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const = 0;
virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return ERR_UNAVAILABLE; }
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index 214c424013..d588c83809 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -987,9 +987,9 @@ static void _register_variant_builtin_methods() {
bind_method(Vector2, posmod, sarray("mod"), varray());
bind_method(Vector2, posmodv, sarray("modv"), varray());
bind_method(Vector2, project, sarray("b"), varray());
- bind_method(Vector2, lerp, sarray("with", "t"), varray());
- bind_method(Vector2, slerp, sarray("with", "t"), varray());
- bind_method(Vector2, cubic_interpolate, sarray("b", "pre_a", "post_b", "t"), varray());
+ bind_method(Vector2, lerp, sarray("to", "weight"), varray());
+ bind_method(Vector2, slerp, sarray("to", "weight"), varray());
+ bind_method(Vector2, cubic_interpolate, sarray("b", "pre_a", "post_b", "weight"), varray());
bind_method(Vector2, move_toward, sarray("to", "delta"), varray());
bind_method(Vector2, rotated, sarray("phi"), varray());
bind_method(Vector2, tangent, sarray(), varray());
@@ -1060,9 +1060,9 @@ static void _register_variant_builtin_methods() {
bind_method(Vector3, inverse, sarray(), varray());
bind_method(Vector3, snapped, sarray("by"), varray());
bind_method(Vector3, rotated, sarray("by_axis", "phi"), varray());
- bind_method(Vector3, lerp, sarray("b", "t"), varray());
- bind_method(Vector3, slerp, sarray("b", "t"), varray());
- bind_method(Vector3, cubic_interpolate, sarray("b", "pre_a", "post_b", "t"), varray());
+ bind_method(Vector3, lerp, sarray("to", "weight"), varray());
+ bind_method(Vector3, slerp, sarray("to", "weight"), varray());
+ bind_method(Vector3, cubic_interpolate, sarray("b", "pre_a", "post_b", "weight"), varray());
bind_method(Vector3, move_toward, sarray("to", "delta"), varray());
bind_method(Vector3, dot, sarray("with"), varray());
bind_method(Vector3, cross, sarray("with"), varray());
@@ -1109,9 +1109,9 @@ static void _register_variant_builtin_methods() {
bind_method(Quat, is_equal_approx, sarray("to"), varray());
bind_method(Quat, inverse, sarray(), varray());
bind_method(Quat, dot, sarray("with"), varray());
- bind_method(Quat, slerp, sarray("b", "t"), varray());
- bind_method(Quat, slerpni, sarray("b", "t"), varray());
- bind_method(Quat, cubic_slerp, sarray("b", "pre_a", "post_b", "t"), varray());
+ bind_method(Quat, slerp, sarray("to", "weight"), varray());
+ bind_method(Quat, slerpni, sarray("to", "weight"), varray());
+ bind_method(Quat, cubic_slerp, sarray("b", "pre_a", "post_b", "weight"), varray());
bind_method(Quat, get_euler, sarray(), varray());
// FIXME: Quat is atomic, this should be done via construcror
@@ -1128,7 +1128,7 @@ static void _register_variant_builtin_methods() {
bind_method(Color, to_rgba64, sarray(), varray());
bind_method(Color, inverted, sarray(), varray());
- bind_method(Color, lerp, sarray("b", "t"), varray());
+ bind_method(Color, lerp, sarray("to", "weight"), varray());
bind_method(Color, lightened, sarray("amount"), varray());
bind_method(Color, darkened, sarray("amount"), varray());
bind_method(Color, to_html, sarray("with_alpha"), varray(true));
@@ -1195,7 +1195,7 @@ static void _register_variant_builtin_methods() {
bind_method(Transform2D, translated, sarray("offset"), varray());
bind_method(Transform2D, basis_xform, sarray("v"), varray());
bind_method(Transform2D, basis_xform_inv, sarray("v"), varray());
- bind_method(Transform2D, interpolate_with, sarray("xform", "t"), varray());
+ bind_method(Transform2D, interpolate_with, sarray("xform", "weight"), varray());
bind_method(Transform2D, is_equal_approx, sarray("xform"), varray());
/* Basis */
@@ -1212,7 +1212,7 @@ static void _register_variant_builtin_methods() {
bind_method(Basis, tdoty, sarray("with"), varray());
bind_method(Basis, tdotz, sarray("with"), varray());
bind_method(Basis, get_orthogonal_index, sarray(), varray());
- bind_method(Basis, slerp, sarray("b", "t"), varray());
+ bind_method(Basis, slerp, sarray("to", "weight"), varray());
bind_method(Basis, is_equal_approx, sarray("b"), varray());
bind_method(Basis, get_rotation_quat, sarray(), varray());