summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
Diffstat (limited to 'core/math')
-rw-r--r--core/math/a_star.cpp2
-rw-r--r--core/math/a_star.h2
-rw-r--r--core/math/audio_frame.cpp2
-rw-r--r--core/math/audio_frame.h2
-rw-r--r--core/math/bsp_tree.cpp2
-rw-r--r--core/math/bsp_tree.h2
-rw-r--r--core/math/camera_matrix.cpp16
-rw-r--r--core/math/camera_matrix.h2
-rw-r--r--core/math/face3.cpp2
-rw-r--r--core/math/face3.h2
-rw-r--r--core/math/geometry.cpp2
-rw-r--r--core/math/geometry.h31
-rw-r--r--core/math/math_2d.cpp29
-rw-r--r--core/math/math_2d.h3
-rw-r--r--core/math/math_defs.h2
-rw-r--r--core/math/math_funcs.cpp7
-rw-r--r--core/math/math_funcs.h12
-rw-r--r--core/math/matrix3.cpp19
-rw-r--r--core/math/matrix3.h2
-rw-r--r--core/math/octree.h25
-rw-r--r--core/math/plane.cpp2
-rw-r--r--core/math/plane.h2
-rw-r--r--core/math/quat.cpp92
-rw-r--r--core/math/quat.h2
-rw-r--r--core/math/quick_hull.cpp2
-rw-r--r--core/math/quick_hull.h2
-rw-r--r--core/math/rect3.cpp2
-rw-r--r--core/math/rect3.h40
-rw-r--r--core/math/transform.cpp2
-rw-r--r--core/math/transform.h32
-rw-r--r--core/math/triangle_mesh.cpp2
-rw-r--r--core/math/triangle_mesh.h2
-rw-r--r--core/math/triangulate.cpp2
-rw-r--r--core/math/triangulate.h2
-rw-r--r--core/math/vector3.cpp47
-rw-r--r--core/math/vector3.h2
36 files changed, 53 insertions, 348 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 04e4383f03..21516ac768 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/a_star.h b/core/math/a_star.h
index ebf1407c17..d2d2166719 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/audio_frame.cpp b/core/math/audio_frame.cpp
index 30a50c8add..555d3536df 100644
--- a/core/math/audio_frame.cpp
+++ b/core/math/audio_frame.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h
index d54f622197..cfc7331767 100644
--- a/core/math/audio_frame.h
+++ b/core/math/audio_frame.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index e22bc2b05e..be950568cf 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h
index 8296e57943..2e762ba4de 100644
--- a/core/math/bsp_tree.h
+++ b/core/math/bsp_tree.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index a1666ccd8b..0512cdd798 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -180,19 +180,7 @@ void CameraMatrix::set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear
}
void CameraMatrix::set_frustum(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_near, real_t p_far) {
-#if 0
- ///@TODO, give a check to this. I'm not sure if it's working.
- set_identity();
- matrix[0][0]=(2*p_near) / (p_right-p_left);
- matrix[0][2]=(p_right+p_left) / (p_right-p_left);
- matrix[1][1]=(2*p_near) / (p_top-p_bottom);
- matrix[1][2]=(p_top+p_bottom) / (p_top-p_bottom);
- matrix[2][2]=-(p_far+p_near) / ( p_far-p_near);
- matrix[2][3]=-(2*p_far*p_near) / (p_far-p_near);
- matrix[3][2]=-1;
- matrix[3][3]=0;
-#else
real_t *te = &matrix[0][0];
real_t x = 2 * p_near / (p_right - p_left);
real_t y = 2 * p_near / (p_top - p_bottom);
@@ -218,8 +206,6 @@ void CameraMatrix::set_frustum(real_t p_left, real_t p_right, real_t p_bottom, r
te[13] = 0;
te[14] = d;
te[15] = 0;
-
-#endif
}
real_t CameraMatrix::get_z_far() const {
diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h
index 4be8ffab8c..175d0cdb1b 100644
--- a/core/math/camera_matrix.h
+++ b/core/math/camera_matrix.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index 0e292500bf..748faad28f 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/face3.h b/core/math/face3.h
index 3d02ae4014..8e4a25fb7a 100644
--- a/core/math/face3.h
+++ b/core/math/face3.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index 9a5811244a..7c8fb6f17d 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/geometry.h b/core/math/geometry.h
index 909d8164c3..cd069bd7a3 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -105,7 +105,7 @@ public:
}
static void get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2, Vector3 &c1, Vector3 &c2) {
-#if 1
+
//do the function 'd' as defined by pb. I think is is dot product of some sort
#define d_of(m, n, o, p) ((m.x - n.x) * (o.x - p.x) + (m.y - n.y) * (o.y - p.y) + (m.z - n.z) * (o.z - p.z))
@@ -120,33 +120,6 @@ public:
if (mub > 1) mub = 1;
c1 = p1.linear_interpolate(p2, mua);
c2 = q1.linear_interpolate(q2, mub);
-#else
- //this is broken do not use
- Vector3 u = p2 - p1;
- Vector3 v = q2 - q1;
- Vector3 w = p1 - q1;
- float a = u.dot(u);
- float b = u.dot(v);
- float c = v.dot(v); // always >= 0
- float d = u.dot(w);
- float e = v.dot(w);
- float D = a * c - b * b; // always >= 0
- float sc, tc;
-
- // compute the line parameters of the two closest points
- if (D < CMP_EPSILON) { // the lines are almost parallel
- sc = 0.0;
- tc = (b > c ? d / b : e / c); // use the largest denominator
- } else {
- sc = (b * e - c * d) / D;
- tc = (a * e - b * d) / D;
- }
-
- c1 = w + sc * u;
- c2 = w + tc * v;
-// get the difference of the two closest points
-//Vector dP = w + (sc * u) - (tc * v); // = L1(sc) - L2(tc)
-#endif
}
static real_t get_closest_distance_between_segments(const Vector3 &p_from_a, const Vector3 &p_to_a, const Vector3 &p_from_b, const Vector3 &p_to_b) {
diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp
index 956cfe5258..c77fe96ff2 100644
--- a/core/math/math_2d.cpp
+++ b/core/math/math_2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -205,33 +205,6 @@ Vector2 Vector2::clamped(real_t p_len) const {
return v;
}
-Vector2 Vector2::cubic_interpolate_soft(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const {
-#if 0
- k[0] = ((*this) (vi[0] + 1, vi[1], vi[2])) - ((*this) (vi[0],
- vi[1],vi[2])); //fk = a0
- k[1] = (((*this) (vi[0] + 1, vi[1], vi[2])) - ((*this) ((int) (v(0) -
- 1), vi[1],vi[2])))*0.5; //dk = a1
- k[2] = (((*this) ((int) (v(0) + 2), vi[1], vi[2])) - ((*this) (vi[0],
- vi[1],vi[2])))*0.5; //dk+1
- k[3] = k[0]*3 - k[1]*2 - k[2];//a2
- k[4] = k[1] + k[2] - k[0]*2;//a3
-
- //ip = a3(t-tk)³ + a2(t-tk)² + a1(t-tk) + a0
- //
- //a3 = dk + dk+1 - Dk
- //a2 = 3Dk - 2dk - dk+1
- //a1 = dk
- //a0 = fk
- //
- //dk = (fk+1 - fk-1)*0.5
- //Dk = (fk+1 - fk)
-
- real_t dk =
-#endif
-
- return Vector2();
-}
-
Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const {
Vector2 p0 = p_pre_a;
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index 6fea6c8adb..d215df8a43 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -113,7 +113,6 @@ struct Vector2 {
_FORCE_INLINE_ static Vector2 linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_t);
_FORCE_INLINE_ Vector2 linear_interpolate(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;
- Vector2 cubic_interpolate_soft(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const;
Vector2 slide(const Vector2 &p_normal) const;
Vector2 bounce(const Vector2 &p_normal) const;
diff --git a/core/math/math_defs.h b/core/math/math_defs.h
index 3d9eb63e11..904cbc1abc 100644
--- a/core/math/math_defs.h
+++ b/core/math/math_defs.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 9f5a9c193a..6fb688f16b 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,16 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "math_funcs.h"
+
#include "core/os/os.h"
pcg32_random_t Math::default_pcg = { 12047754176567800795ULL, PCG_DEFAULT_INC_64 };
#define PHI 0x9e3779b9
-#if 0
-static uint32_t Q[4096];
-#endif
-
// TODO: we should eventually expose pcg.inc too
uint32_t Math::rand_from_seed(uint64_t *seed) {
pcg32_random_t pcg = { *seed, PCG_DEFAULT_INC_64 };
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 45509a0808..9651e37f3e 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -153,8 +153,14 @@ public:
static _ALWAYS_INLINE_ double rad2deg(double p_y) { return p_y * 180.0 / Math_PI; }
static _ALWAYS_INLINE_ float rad2deg(float p_y) { return p_y * 180.0 / Math_PI; }
- static _ALWAYS_INLINE_ double lerp(double a, double b, double c) { return a + (b - a) * c; }
- static _ALWAYS_INLINE_ float lerp(float a, float b, float c) { return a + (b - a) * c; }
+ static _ALWAYS_INLINE_ double lerp(double p_from, double p_to, double p_weight) { return p_from + (p_to - p_from) * p_weight; }
+ static _ALWAYS_INLINE_ float lerp(float p_from, float p_to, float p_weight) { return p_from + (p_to - p_from) * p_weight; }
+
+ static _ALWAYS_INLINE_ double inverse_lerp(double p_from, double p_to, double p_value) { return (p_value - p_from) / (p_to - p_from); }
+ static _ALWAYS_INLINE_ float inverse_lerp(float p_from, float p_to, float p_value) { return (p_value - p_from) / (p_to - p_from); }
+
+ static _ALWAYS_INLINE_ double range_lerp(double p_value, double p_istart, double p_istop, double p_ostart, double p_ostop) { return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value)); }
+ static _ALWAYS_INLINE_ float range_lerp(float p_value, float p_istart, float p_istop, float p_ostart, float p_ostop) { return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value)); }
static _ALWAYS_INLINE_ double linear2db(double p_linear) { return Math::log(p_linear) * 8.6858896380650365530225783783321; }
static _ALWAYS_INLINE_ float linear2db(float p_linear) { return Math::log(p_linear) * 8.6858896380650365530225783783321; }
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index f2f6ff93cf..c7e2a8f307 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -365,14 +365,10 @@ Vector3 Basis::get_euler_xyz() const {
if (euler.y < Math_PI * 0.5) {
if (euler.y > -Math_PI * 0.5) {
//if rotation is Y-only, return a proper -pi,pi range like in x or z for the same case.
- if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[0][0] < 0.0) {
+ if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[1][2] == 0 && elements[2][1] == 0 && elements[1][1] == 1) {
euler.x = 0;
+ euler.y = atan2(elements[0][2], elements[0][0]);
euler.z = 0;
-
- if (euler.y > 0.0)
- euler.y = Math_PI - euler.y;
- else
- euler.y = -(Math_PI + euler.y);
} else {
euler.x = Math::atan2(-elements[1][2], elements[2][2]);
euler.z = Math::atan2(-elements[0][1], elements[0][0]);
@@ -436,15 +432,10 @@ Vector3 Basis::get_euler_yxz() const {
if (m12 < 1) {
if (m12 > -1) {
- if (elements[1][0] == 0 && elements[0][1] == 0 && elements[2][2] < 0) { // use pure x rotation
- real_t x = asin(-m12);
+ if (elements[1][0] == 0 && elements[0][1] == 0 && elements[0][2] == 0 && elements[2][0] == 0 && elements[0][0] == 1) { // use pure x rotation
+ euler.x = atan2(-m12, elements[1][1]);
euler.y = 0;
euler.z = 0;
-
- if (x > 0.0)
- euler.x = Math_PI - x;
- else
- euler.x = -(Math_PI + x);
} else {
euler.x = asin(-m12);
euler.y = atan2(elements[0][2], elements[2][2]);
diff --git a/core/math/matrix3.h b/core/math/matrix3.h
index 74e6564578..be85c244bd 100644
--- a/core/math/matrix3.h
+++ b/core/math/matrix3.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/octree.h b/core/math/octree.h
index 2e37056030..95a67943fd 100644
--- a/core/math/octree.h
+++ b/core/math/octree.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -851,28 +851,6 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) {
ERR_FAIL_COND(!E);
Element &e = E->get();
-#if 0
-
- pass++;
- if (!e.aabb.has_no_surface()) {
- _remove_element(&e);
- }
-
- e.aabb=p_aabb;
-
- if (!e.aabb.has_no_surface()) {
- _ensure_valid_root(p_aabb);
-
- _insert_element(&e,root);
- if (use_pairs)
- _element_check_pairs(&e);
-
- }
-
- _optimize();
-
-#else
-
bool old_has_surf = !e.aabb.has_no_surface();
bool new_has_surf = !p_aabb.has_no_surface();
@@ -979,7 +957,6 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) {
}
_optimize();
-#endif
}
template <class T, bool use_pairs, class AL>
diff --git a/core/math/plane.cpp b/core/math/plane.cpp
index 17928d07c3..08395ed07b 100644
--- a/core/math/plane.cpp
+++ b/core/math/plane.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/plane.h b/core/math/plane.h
index 73d584e553..559a735817 100644
--- a/core/math/plane.h
+++ b/core/math/plane.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/quat.cpp b/core/math/quat.cpp
index 5984cdf657..cebc5b9522 100644
--- a/core/math/quat.cpp
+++ b/core/math/quat.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -139,48 +139,6 @@ Quat Quat::inverse() const {
Quat Quat::slerp(const Quat &q, const real_t &t) const {
-#if 0
-
-
- Quat dst=q;
- Quat src=*this;
-
- src.normalize();
- dst.normalize();
-
- real_t cosine = dst.dot(src);
-
- if (cosine < 0 && true) {
- cosine = -cosine;
- dst = -dst;
- } else {
- dst = dst;
- }
-
- if (Math::abs(cosine) < 1 - CMP_EPSILON) {
- // Standard case (slerp)
- real_t sine = Math::sqrt(1 - cosine*cosine);
- real_t angle = Math::atan2(sine, cosine);
- real_t inv_sine = 1.0 / sine;
- real_t coeff_0 = Math::sin((1.0 - t) * angle) * inv_sine;
- real_t coeff_1 = Math::sin(t * angle) * inv_sine;
- Quat ret= src * coeff_0 + dst * coeff_1;
-
- return ret;
- } else {
- // There are two situations:
- // 1. "rkP" and "q" are very close (cosine ~= +1), so we can do a linear
- // interpolation safely.
- // 2. "rkP" and "q" are almost invedste of each other (cosine ~= -1), there
- // are an infinite number of possibilities interpolation. but we haven't
- // have method to fix this case, so just use linear interpolation here.
- Quat ret = src * (1.0 - t) + dst *t;
- // taking the complement requires renormalisation
- ret.normalize();
- return ret;
- }
-#else
-
Quat to1;
real_t omega, cosom, sinom, scale0, scale1;
@@ -221,7 +179,6 @@ Quat Quat::slerp(const Quat &q, const real_t &t) const {
scale0 * y + scale1 * to1.y,
scale0 * z + scale1 * to1.z,
scale0 * w + scale1 * to1.w);
-#endif
}
Quat Quat::slerpni(const Quat &q, const real_t &t) const {
@@ -241,53 +198,6 @@ Quat Quat::slerpni(const Quat &q, const real_t &t) const {
invFactor * from.y + newFactor * q.y,
invFactor * from.z + newFactor * q.z,
invFactor * from.w + newFactor * q.w);
-
-#if 0
- real_t to1[4];
- real_t omega, cosom, sinom, scale0, scale1;
-
-
- // calc cosine
- cosom = x * q.x + y * q.y + z * q.z
- + w * q.w;
-
-
- // adjust signs (if necessary)
- if ( cosom <0.0 && false) {
- cosom = -cosom;to1[0] = - q.x;
- to1[1] = - q.y;
- to1[2] = - q.z;
- to1[3] = - q.w;
- } else {
- to1[0] = q.x;
- to1[1] = q.y;
- to1[2] = q.z;
- to1[3] = q.w;
- }
-
-
- // calculate coefficients
-
- if ( (1.0 - cosom) > CMP_EPSILON ) {
- // 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;
- } else {
- // "from" and "to" quaternions are very close
- // ... so we can do a linear interpolation
- scale0 = 1.0 - t;
- scale1 = t;
- }
- // calculate final values
- return Quat(
- scale0 * x + scale1 * to1[0],
- scale0 * y + scale1 * to1[1],
- scale0 * z + scale1 * to1[2],
- scale0 * w + scale1 * to1[3]
- );
-#endif
}
Quat Quat::cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const {
diff --git a/core/math/quat.h b/core/math/quat.h
index 0e378eb4e4..9668f8c7a3 100644
--- a/core/math/quat.h
+++ b/core/math/quat.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index 54b97ac38c..e9a383df40 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h
index 49600649e3..47ed22615b 100644
--- a/core/math/quick_hull.h
+++ b/core/math/quick_hull.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/rect3.cpp b/core/math/rect3.cpp
index 973607f565..6f01000f61 100644
--- a/core/math/rect3.cpp
+++ b/core/math/rect3.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/rect3.h b/core/math/rect3.h
index 4890a19d99..c3a2f5fbfb 100644
--- a/core/math/rect3.h
+++ b/core/math/rect3.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -189,8 +189,6 @@ Vector3 Rect3::get_endpoint(int p_point) const {
bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const {
-#if 1
-
Vector3 half_extents = size * 0.5;
Vector3 ofs = position + half_extents;
@@ -206,42 +204,6 @@ bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) co
}
return true;
-#else
- //cache all points to check against!
- // #warning should be easy to optimize, just use the same as when taking the support and use only that point
- Vector3 points[8] = {
- Vector3(position.x, position.y, position.z),
- Vector3(position.x, position.y, position.z + size.z),
- Vector3(position.x, position.y + size.y, position.z),
- Vector3(position.x, position.y + size.y, position.z + size.z),
- Vector3(position.x + size.x, position.y, position.z),
- Vector3(position.x + size.x, position.y, position.z + size.z),
- Vector3(position.x + size.x, position.y + size.y, position.z),
- Vector3(position.x + size.x, position.y + size.y, position.z + size.z),
- };
-
- for (int i = 0; i < p_plane_count; i++) { //for each plane
-
- const Plane &plane = p_planes[i];
- bool all_points_over = true;
- //test if it has all points over!
-
- for (int j = 0; j < 8; j++) {
-
- if (!plane.is_point_over(points[j])) {
-
- all_points_over = false;
- break;
- }
- }
-
- if (all_points_over) {
-
- return false;
- }
- }
- return true;
-#endif
}
bool Rect3::has_point(const Vector3 &p_point) const {
diff --git a/core/math/transform.cpp b/core/math/transform.cpp
index 3a86fbfc6c..60df69a509 100644
--- a/core/math/transform.cpp
+++ b/core/math/transform.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/transform.h b/core/math/transform.h
index 48467f2ed7..566bf482a9 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -154,8 +154,7 @@ _FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const {
}
_FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const {
-/* define vertices */
-#if 1
+ /* define vertices */
Vector3 x = basis.get_axis(0) * p_aabb.size.x;
Vector3 y = basis.get_axis(1) * p_aabb.size.y;
Vector3 z = basis.get_axis(2) * p_aabb.size.z;
@@ -171,31 +170,8 @@ _FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const {
new_aabb.expand_to(pos + y + z);
new_aabb.expand_to(pos + x + y + z);
return new_aabb;
-#else
-
- Vector3 vertices[8] = {
- Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z),
- Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z),
- Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z),
- Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z),
- Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z),
- Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z),
- Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z),
- Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z)
- };
-
- AABB ret;
-
- ret.pos = xform(vertices[0]);
-
- for (int i = 1; i < 8; i++) {
-
- ret.expand_to(xform(vertices[i]));
- }
-
- return ret;
-#endif
}
+
_FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const {
/* define vertices */
@@ -222,4 +198,4 @@ _FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const {
return ret;
}
-#endif
+#endif // TRANSFORM_H
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index 1df3c8c298..614104f698 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h
index 166f10c577..2bf67fffcb 100644
--- a/core/math/triangle_mesh.h
+++ b/core/math/triangle_mesh.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/triangulate.cpp b/core/math/triangulate.cpp
index 4a5d0a078e..b20f2e06d5 100644
--- a/core/math/triangulate.cpp
+++ b/core/math/triangulate.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/triangulate.h b/core/math/triangulate.h
index 3f0ad00033..21e148249e 100644
--- a/core/math/triangulate.h
+++ b/core/math/triangulate.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index efffacb36e..144234f4d1 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -125,51 +125,6 @@ Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, c
return out;
}
-#if 0
-Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,real_t p_t) const {
-
- Vector3 p0=p_pre_a;
- Vector3 p1=*this;
- Vector3 p2=p_b;
- Vector3 p3=p_post_b;
-
- if (true) {
-
- real_t ab = p0.distance_to(p1);
- real_t bc = p1.distance_to(p2);
- real_t cd = p2.distance_to(p3);
-
- //if (ab>bc) {
- if (ab>0)
- p0 = p1+(p0-p1)*(bc/ab);
- //}
-
- //if (cd>bc) {
- if (cd>0)
- p3 = p2+(p3-p2)*(bc/cd);
- //}
- }
-
- real_t t = p_t;
- real_t t2 = t * t;
- real_t t3 = t2 * t;
-
- Vector3 out;
- out.x = 0.5 * ( ( 2.0 * p1.x ) +
- ( -p0.x + p2.x ) * t +
- ( 2.0 * p0.x - 5.0 * p1.x + 4 * p2.x - p3.x ) * t2 +
- ( -p0.x + 3.0 * p1.x - 3.0 * p2.x + p3.x ) * t3 );
- out.y = 0.5 * ( ( 2.0 * p1.y ) +
- ( -p0.y + p2.y ) * t +
- ( 2.0 * p0.y - 5.0 * p1.y + 4 * p2.y - p3.y ) * t2 +
- ( -p0.y + 3.0 * p1.y - 3.0 * p2.y + p3.y ) * t3 );
- out.z = 0.5 * ( ( 2.0 * p1.z ) +
- ( -p0.z + p2.z ) * t +
- ( 2.0 * p0.z - 5.0 * p1.z + 4 * p2.z - p3.z ) * t2 +
- ( -p0.z + 3.0 * p1.z - 3.0 * p2.z + p3.z ) * t3 );
- return out;
-}
-#endif
Vector3::operator String() const {
return (rtos(x) + ", " + rtos(y) + ", " + rtos(z));
diff --git a/core/math/vector3.h b/core/math/vector3.h
index c58a86fbdb..74c822fcd7 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */