summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-11-08 10:41:17 +0100
committerGitHub <noreply@github.com>2020-11-08 10:41:17 +0100
commit90edd839d5f67d4252923a720feeef6ad0d76107 (patch)
treea1dd3ae46bf575cb8296df38568dfce237c6ecd8 /core/math
parent30b6db99a99a94c64d906c1b828ff44f79a1bc75 (diff)
parent127458ed175c5aeac8dee7f09d23fae4c8928eb7 (diff)
Merge pull request #43385 from reduz/reorganize-core
Reorganize and clean up core/ directory
Diffstat (limited to 'core/math')
-rw-r--r--core/math/a_star.cpp2
-rw-r--r--core/math/a_star.h4
-rw-r--r--core/math/aabb.cpp4
-rw-r--r--core/math/basis.cpp2
-rw-r--r--core/math/camera_matrix.cpp2
-rw-r--r--core/math/color.cpp580
-rw-r--r--core/math/color.h256
-rw-r--r--core/math/color_names.inc160
-rw-r--r--core/math/delaunay_3d.h10
-rw-r--r--core/math/disjoint_set.h4
-rw-r--r--core/math/expression.cpp33
-rw-r--r--core/math/expression.h3
-rw-r--r--core/math/geometry_2d.h4
-rw-r--r--core/math/geometry_3d.cpp2
-rw-r--r--core/math/geometry_3d.h4
-rw-r--r--core/math/math_fieldwise.h2
-rw-r--r--core/math/math_funcs.cpp2
-rw-r--r--core/math/octree.h8
-rw-r--r--core/math/plane.cpp2
-rw-r--r--core/math/quat.cpp2
-rw-r--r--core/math/quat.h2
-rw-r--r--core/math/quick_hull.cpp2
-rw-r--r--core/math/quick_hull.h4
-rw-r--r--core/math/random_number_generator.h2
-rw-r--r--core/math/transform.cpp2
-rw-r--r--core/math/triangle_mesh.cpp2
-rw-r--r--core/math/triangle_mesh.h2
-rw-r--r--core/math/vector2.h2
-rw-r--r--core/math/vector3.h2
-rw-r--r--core/math/vector3i.h2
30 files changed, 1038 insertions, 70 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 30f712b2c3..b4410acf7d 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -31,7 +31,7 @@
#include "a_star.h"
#include "core/math/geometry_3d.h"
-#include "core/script_language.h"
+#include "core/object/script_language.h"
#include "scene/scene_string_names.h"
int AStar::get_available_point_id() const {
diff --git a/core/math/a_star.h b/core/math/a_star.h
index ba1c3033b8..a6fa771b30 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -31,8 +31,8 @@
#ifndef A_STAR_H
#define A_STAR_H
-#include "core/oa_hash_map.h"
-#include "core/reference.h"
+#include "core/object/reference.h"
+#include "core/templates/oa_hash_map.h"
/**
A* pathfinding algorithm
diff --git a/core/math/aabb.cpp b/core/math/aabb.cpp
index e868ebc7c8..08673d0dd1 100644
--- a/core/math/aabb.cpp
+++ b/core/math/aabb.cpp
@@ -30,8 +30,8 @@
#include "aabb.h"
-#include "core/print_string.h"
-#include "core/variant.h"
+#include "core/string/print_string.h"
+#include "core/variant/variant.h"
real_t AABB::get_area() const {
return size.x * size.y * size.z;
diff --git a/core/math/basis.cpp b/core/math/basis.cpp
index a712ae7e3e..c6030d9757 100644
--- a/core/math/basis.cpp
+++ b/core/math/basis.cpp
@@ -32,7 +32,7 @@
#include "core/math/math_funcs.h"
#include "core/os/copymem.h"
-#include "core/print_string.h"
+#include "core/string/print_string.h"
#define cofac(row1, col1, row2, col2) \
(elements[row1][col1] * elements[row2][col2] - elements[row1][col2] * elements[row2][col1])
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index c154d57a13..5e5efb6356 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -31,7 +31,7 @@
#include "camera_matrix.h"
#include "core/math/math_funcs.h"
-#include "core/print_string.h"
+#include "core/string/print_string.h"
float CameraMatrix::determinant() const {
return matrix[0][3] * matrix[1][2] * matrix[2][1] * matrix[3][0] - matrix[0][2] * matrix[1][3] * matrix[2][1] * matrix[3][0] -
diff --git a/core/math/color.cpp b/core/math/color.cpp
new file mode 100644
index 0000000000..6e0f68a2d6
--- /dev/null
+++ b/core/math/color.cpp
@@ -0,0 +1,580 @@
+/*************************************************************************/
+/* color.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "color.h"
+
+#include "color_names.inc"
+#include "core/math/math_funcs.h"
+#include "core/string/print_string.h"
+#include "core/templates/map.h"
+
+uint32_t Color::to_argb32() const {
+ uint32_t c = (uint8_t)Math::round(a * 255);
+ c <<= 8;
+ c |= (uint8_t)Math::round(r * 255);
+ c <<= 8;
+ c |= (uint8_t)Math::round(g * 255);
+ c <<= 8;
+ c |= (uint8_t)Math::round(b * 255);
+
+ return c;
+}
+
+uint32_t Color::to_abgr32() const {
+ uint32_t c = (uint8_t)Math::round(a * 255);
+ c <<= 8;
+ c |= (uint8_t)Math::round(b * 255);
+ c <<= 8;
+ c |= (uint8_t)Math::round(g * 255);
+ c <<= 8;
+ c |= (uint8_t)Math::round(r * 255);
+
+ return c;
+}
+
+uint32_t Color::to_rgba32() const {
+ uint32_t c = (uint8_t)Math::round(r * 255);
+ c <<= 8;
+ c |= (uint8_t)Math::round(g * 255);
+ c <<= 8;
+ c |= (uint8_t)Math::round(b * 255);
+ c <<= 8;
+ c |= (uint8_t)Math::round(a * 255);
+
+ return c;
+}
+
+uint64_t Color::to_abgr64() const {
+ uint64_t c = (uint16_t)Math::round(a * 65535);
+ c <<= 16;
+ c |= (uint16_t)Math::round(b * 65535);
+ c <<= 16;
+ c |= (uint16_t)Math::round(g * 65535);
+ c <<= 16;
+ c |= (uint16_t)Math::round(r * 65535);
+
+ return c;
+}
+
+uint64_t Color::to_argb64() const {
+ uint64_t c = (uint16_t)Math::round(a * 65535);
+ c <<= 16;
+ c |= (uint16_t)Math::round(r * 65535);
+ c <<= 16;
+ c |= (uint16_t)Math::round(g * 65535);
+ c <<= 16;
+ c |= (uint16_t)Math::round(b * 65535);
+
+ return c;
+}
+
+uint64_t Color::to_rgba64() const {
+ uint64_t c = (uint16_t)Math::round(r * 65535);
+ c <<= 16;
+ c |= (uint16_t)Math::round(g * 65535);
+ c <<= 16;
+ c |= (uint16_t)Math::round(b * 65535);
+ c <<= 16;
+ c |= (uint16_t)Math::round(a * 65535);
+
+ return c;
+}
+
+float Color::get_h() const {
+ float min = MIN(r, g);
+ min = MIN(min, b);
+ float max = MAX(r, g);
+ max = MAX(max, b);
+
+ float delta = max - min;
+
+ if (delta == 0) {
+ return 0;
+ }
+
+ float h;
+ if (r == max) {
+ h = (g - b) / delta; // between yellow & magenta
+ } else if (g == max) {
+ h = 2 + (b - r) / delta; // between cyan & yellow
+ } else {
+ h = 4 + (r - g) / delta; // between magenta & cyan
+ }
+
+ h /= 6.0;
+ if (h < 0) {
+ h += 1.0;
+ }
+
+ return h;
+}
+
+float Color::get_s() const {
+ float min = MIN(r, g);
+ min = MIN(min, b);
+ float max = MAX(r, g);
+ max = MAX(max, b);
+
+ float delta = max - min;
+
+ return (max != 0) ? (delta / max) : 0;
+}
+
+float Color::get_v() const {
+ float max = MAX(r, g);
+ max = MAX(max, b);
+ return max;
+}
+
+void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
+ int i;
+ float f, p, q, t;
+ a = p_alpha;
+
+ if (p_s == 0) {
+ // acp_hromatic (grey)
+ r = g = b = p_v;
+ return;
+ }
+
+ p_h *= 6.0;
+ p_h = Math::fmod(p_h, 6);
+ i = Math::floor(p_h);
+
+ f = p_h - i;
+ p = p_v * (1 - p_s);
+ q = p_v * (1 - p_s * f);
+ t = p_v * (1 - p_s * (1 - f));
+
+ switch (i) {
+ case 0: // Red is the dominant color
+ r = p_v;
+ g = t;
+ b = p;
+ break;
+ case 1: // Green is the dominant color
+ r = q;
+ g = p_v;
+ b = p;
+ break;
+ case 2:
+ r = p;
+ g = p_v;
+ b = t;
+ break;
+ case 3: // Blue is the dominant color
+ r = p;
+ g = q;
+ b = p_v;
+ break;
+ case 4:
+ r = t;
+ g = p;
+ b = p_v;
+ break;
+ default: // (5) Red is the dominant color
+ r = p_v;
+ g = p;
+ b = q;
+ break;
+ }
+}
+
+bool Color::is_equal_approx(const Color &p_color) const {
+ return Math::is_equal_approx(r, p_color.r) && Math::is_equal_approx(g, p_color.g) && Math::is_equal_approx(b, p_color.b) && Math::is_equal_approx(a, p_color.a);
+}
+
+void Color::invert() {
+ r = 1.0 - r;
+ g = 1.0 - g;
+ b = 1.0 - b;
+}
+
+Color Color::hex(uint32_t p_hex) {
+ float a = (p_hex & 0xFF) / 255.0;
+ p_hex >>= 8;
+ float b = (p_hex & 0xFF) / 255.0;
+ p_hex >>= 8;
+ float g = (p_hex & 0xFF) / 255.0;
+ p_hex >>= 8;
+ float r = (p_hex & 0xFF) / 255.0;
+
+ return Color(r, g, b, a);
+}
+
+Color Color::hex64(uint64_t p_hex) {
+ float a = (p_hex & 0xFFFF) / 65535.0;
+ p_hex >>= 16;
+ float b = (p_hex & 0xFFFF) / 65535.0;
+ p_hex >>= 16;
+ float g = (p_hex & 0xFFFF) / 65535.0;
+ p_hex >>= 16;
+ float r = (p_hex & 0xFFFF) / 65535.0;
+
+ return Color(r, g, b, a);
+}
+
+Color Color::from_rgbe9995(uint32_t p_rgbe) {
+ float r = p_rgbe & 0x1ff;
+ float g = (p_rgbe >> 9) & 0x1ff;
+ float b = (p_rgbe >> 18) & 0x1ff;
+ float e = (p_rgbe >> 27);
+ float m = Math::pow(2, e - 15.0 - 9.0);
+
+ float rd = r * m;
+ float gd = g * m;
+ float bd = b * m;
+
+ return Color(rd, gd, bd, 1.0f);
+}
+
+static int _parse_col4(const String &p_str, int p_ofs) {
+ char character = p_str[p_ofs];
+
+ if (character >= '0' && character <= '9') {
+ return character - '0';
+ } else if (character >= 'a' && character <= 'f') {
+ return character + (10 - 'a');
+ } else if (character >= 'A' && character <= 'F') {
+ return character + (10 - 'A');
+ }
+ return -1;
+}
+
+static int _parse_col8(const String &p_str, int p_ofs) {
+ return _parse_col4(p_str, p_ofs) * 16 + _parse_col4(p_str, p_ofs + 1);
+}
+
+Color Color::inverted() const {
+ Color c = *this;
+ c.invert();
+ return c;
+}
+
+Color Color::html(const String &p_rgba) {
+ String color = p_rgba;
+ if (color.length() == 0) {
+ return Color();
+ }
+ if (color[0] == '#') {
+ color = color.substr(1);
+ }
+
+ // If enabled, use 1 hex digit per channel instead of 2.
+ // Other sizes aren't in the HTML/CSS spec but we could add them if desired.
+ bool is_shorthand = color.length() < 5;
+ bool alpha = false;
+
+ if (color.length() == 8) {
+ alpha = true;
+ } else if (color.length() == 6) {
+ alpha = false;
+ } else if (color.length() == 4) {
+ alpha = true;
+ } else if (color.length() == 3) {
+ alpha = false;
+ } else {
+ ERR_FAIL_V_MSG(Color(), "Invalid color code: " + p_rgba + ".");
+ }
+
+ float r, g, b, a = 1.0;
+ if (is_shorthand) {
+ r = _parse_col4(color, 0) / 15.0;
+ g = _parse_col4(color, 1) / 15.0;
+ b = _parse_col4(color, 2) / 15.0;
+ if (alpha) {
+ a = _parse_col4(color, 3) / 15.0;
+ }
+ } else {
+ r = _parse_col8(color, 0) / 255.0;
+ g = _parse_col8(color, 2) / 255.0;
+ b = _parse_col8(color, 4) / 255.0;
+ if (alpha) {
+ a = _parse_col8(color, 6) / 255.0;
+ }
+ }
+ ERR_FAIL_COND_V_MSG(r < 0, Color(), "Invalid color code: " + p_rgba + ".");
+ ERR_FAIL_COND_V_MSG(g < 0, Color(), "Invalid color code: " + p_rgba + ".");
+ ERR_FAIL_COND_V_MSG(b < 0, Color(), "Invalid color code: " + p_rgba + ".");
+ ERR_FAIL_COND_V_MSG(a < 0, Color(), "Invalid color code: " + p_rgba + ".");
+
+ return Color(r, g, b, a);
+}
+
+bool Color::html_is_valid(const String &p_color) {
+ String color = p_color;
+
+ if (color.length() == 0) {
+ return false;
+ }
+ if (color[0] == '#') {
+ color = color.substr(1);
+ }
+
+ // Check if the amount of hex digits is valid.
+ int len = color.length();
+ if (!(len == 3 || len == 4 || len == 6 || len == 8)) {
+ return false;
+ }
+
+ // Check if each hex digit is valid.
+ for (int i = 0; i < len; i++) {
+ if (_parse_col4(color, i) == -1) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+Color Color::named(const String &p_name) {
+ String name = p_name;
+ // Normalize name
+ name = name.replace(" ", "");
+ name = name.replace("-", "");
+ name = name.replace("_", "");
+ name = name.replace("'", "");
+ name = name.replace(".", "");
+ name = name.to_lower();
+
+ int idx = 0;
+ while (named_colors[idx].name != nullptr) {
+ if (name == named_colors[idx].name) {
+ return named_colors[idx].color;
+ }
+ idx++;
+ }
+
+ ERR_FAIL_V_MSG(Color(), "Invalid color name: " + p_name + ".");
+
+ return Color();
+}
+
+int Color::get_named_color_count() {
+ int idx = 0;
+ while (named_colors[idx].name != nullptr) {
+ idx++;
+ }
+ return idx;
+}
+String Color::get_named_color_name(int p_idx) {
+ return named_colors[p_idx].name;
+}
+Color Color::get_named_color(int p_idx) {
+ return named_colors[p_idx].color;
+}
+
+String _to_hex(float p_val) {
+ int v = Math::round(p_val * 255);
+ v = CLAMP(v, 0, 255);
+ String ret;
+
+ for (int i = 0; i < 2; i++) {
+ char32_t c[2] = { 0, 0 };
+ int lv = v & 0xF;
+ if (lv < 10) {
+ c[0] = '0' + lv;
+ } else {
+ c[0] = 'a' + lv - 10;
+ }
+
+ v >>= 4;
+ String cs = (const char32_t *)c;
+ ret = cs + ret;
+ }
+
+ return ret;
+}
+
+String Color::to_html(bool p_alpha) const {
+ String txt;
+ txt += _to_hex(r);
+ txt += _to_hex(g);
+ txt += _to_hex(b);
+ if (p_alpha) {
+ txt += _to_hex(a);
+ }
+ return txt;
+}
+
+Color Color::from_hsv(float p_h, float p_s, float p_v, float p_a) const {
+ p_h = Math::fmod(p_h * 360.0f, 360.0f);
+ if (p_h < 0.0) {
+ p_h += 360.0f;
+ }
+
+ const float h_ = p_h / 60.0f;
+ const float c = p_v * p_s;
+ const float x = c * (1.0f - Math::abs(Math::fmod(h_, 2.0f) - 1.0f));
+ float r, g, b;
+
+ switch ((int)h_) {
+ case 0: {
+ r = c;
+ g = x;
+ b = 0;
+ } break;
+ case 1: {
+ r = x;
+ g = c;
+ b = 0;
+ } break;
+ case 2: {
+ r = 0;
+ g = c;
+ b = x;
+ } break;
+ case 3: {
+ r = 0;
+ g = x;
+ b = c;
+ } break;
+ case 4: {
+ r = x;
+ g = 0;
+ b = c;
+ } break;
+ case 5: {
+ r = c;
+ g = 0;
+ b = x;
+ } break;
+ default: {
+ r = 0;
+ g = 0;
+ b = 0;
+ } break;
+ }
+
+ const float m = p_v - c;
+ return Color(m + r, m + g, m + b, p_a);
+}
+
+Color::operator String() const {
+ return rtos(r) + ", " + rtos(g) + ", " + rtos(b) + ", " + rtos(a);
+}
+
+Color Color::operator+(const Color &p_color) const {
+ return Color(
+ r + p_color.r,
+ g + p_color.g,
+ b + p_color.b,
+ a + p_color.a);
+}
+
+Color Color::operator-(const Color &p_color) const {
+ return Color(
+ r - p_color.r,
+ g - p_color.g,
+ b - p_color.b,
+ a - p_color.a);
+}
+
+void Color::operator-=(const Color &p_color) {
+ r = r - p_color.r;
+ g = g - p_color.g;
+ b = b - p_color.b;
+ a = a - p_color.a;
+}
+
+Color Color::operator*(const Color &p_color) const {
+ return Color(
+ r * p_color.r,
+ g * p_color.g,
+ b * p_color.b,
+ a * p_color.a);
+}
+
+Color Color::operator*(real_t rvalue) const {
+ return Color(
+ r * rvalue,
+ g * rvalue,
+ b * rvalue,
+ a * rvalue);
+}
+
+void Color::operator*=(const Color &p_color) {
+ r = r * p_color.r;
+ g = g * p_color.g;
+ b = b * p_color.b;
+ a = a * p_color.a;
+}
+
+void Color::operator*=(real_t rvalue) {
+ r = r * rvalue;
+ g = g * rvalue;
+ b = b * rvalue;
+ a = a * rvalue;
+}
+
+Color Color::operator/(const Color &p_color) const {
+ return Color(
+ r / p_color.r,
+ g / p_color.g,
+ b / p_color.b,
+ a / p_color.a);
+}
+
+Color Color::operator/(real_t rvalue) const {
+ return Color(
+ r / rvalue,
+ g / rvalue,
+ b / rvalue,
+ a / rvalue);
+}
+
+void Color::operator/=(const Color &p_color) {
+ r = r / p_color.r;
+ g = g / p_color.g;
+ b = b / p_color.b;
+ a = a / p_color.a;
+}
+
+void Color::operator/=(real_t rvalue) {
+ if (rvalue == 0) {
+ r = 1.0;
+ g = 1.0;
+ b = 1.0;
+ a = 1.0;
+ } else {
+ r = r / rvalue;
+ g = g / rvalue;
+ b = b / rvalue;
+ a = a / rvalue;
+ }
+}
+
+Color Color::operator-() const {
+ return Color(
+ 1.0 - r,
+ 1.0 - g,
+ 1.0 - b,
+ 1.0 - a);
+}
diff --git a/core/math/color.h b/core/math/color.h
new file mode 100644
index 0000000000..a03ddbf5af
--- /dev/null
+++ b/core/math/color.h
@@ -0,0 +1,256 @@
+/*************************************************************************/
+/* color.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef COLOR_H
+#define COLOR_H
+
+#include "core/math/math_funcs.h"
+#include "core/string/ustring.h"
+
+struct Color {
+ union {
+ struct {
+ float r;
+ float g;
+ float b;
+ float a;
+ };
+ float components[4] = { 0, 0, 0, 1.0 };
+ };
+
+ bool operator==(const Color &p_color) const { return (r == p_color.r && g == p_color.g && b == p_color.b && a == p_color.a); }
+ bool operator!=(const Color &p_color) const { return (r != p_color.r || g != p_color.g || b != p_color.b || a != p_color.a); }
+
+ uint32_t to_rgba32() const;
+ uint32_t to_argb32() const;
+ uint32_t to_abgr32() const;
+ uint64_t to_rgba64() const;
+ uint64_t to_argb64() const;
+ uint64_t to_abgr64() const;
+ float get_h() const;
+ float get_s() const;
+ float get_v() const;
+ void set_hsv(float p_h, float p_s, float p_v, float p_alpha = 1.0);
+
+ _FORCE_INLINE_ float &operator[](int idx) {
+ return components[idx];
+ }
+ _FORCE_INLINE_ const float &operator[](int idx) const {
+ return components[idx];
+ }
+
+ Color operator+(const Color &p_color) const;
+ _FORCE_INLINE_ void operator+=(const Color &p_color) {
+ r = r + p_color.r;
+ g = g + p_color.g;
+ b = b + p_color.b;
+ a = a + p_color.a;
+ }
+
+ Color operator-() const;
+ Color operator-(const Color &p_color) const;
+ void operator-=(const Color &p_color);
+
+ Color operator*(const Color &p_color) const;
+ Color operator*(real_t rvalue) const;
+ void operator*=(const Color &p_color);
+ void operator*=(real_t rvalue);
+
+ Color operator/(const Color &p_color) const;
+ Color operator/(real_t rvalue) const;
+ void operator/=(const Color &p_color);
+ void operator/=(real_t rvalue);
+
+ bool is_equal_approx(const Color &p_color) const;
+
+ void invert();
+ Color inverted() const;
+
+ _FORCE_INLINE_ Color lerp(const Color &p_b, float p_t) 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));
+
+ return res;
+ }
+
+ _FORCE_INLINE_ Color darkened(float p_amount) const {
+ Color res = *this;
+ res.r = res.r * (1.0f - p_amount);
+ res.g = res.g * (1.0f - p_amount);
+ res.b = res.b * (1.0f - p_amount);
+ return res;
+ }
+
+ _FORCE_INLINE_ Color lightened(float p_amount) const {
+ Color res = *this;
+ res.r = res.r + (1.0f - res.r) * p_amount;
+ res.g = res.g + (1.0f - res.g) * p_amount;
+ res.b = res.b + (1.0f - res.b) * p_amount;
+ return res;
+ }
+
+ _FORCE_INLINE_ uint32_t to_rgbe9995() const {
+ const float pow2to9 = 512.0f;
+ const float B = 15.0f;
+ //const float Emax = 31.0f;
+ const float N = 9.0f;
+
+ float sharedexp = 65408.000f; //(( pow2to9 - 1.0f)/ pow2to9)*powf( 2.0f, 31.0f - 15.0f);
+
+ float cRed = MAX(0.0f, MIN(sharedexp, r));
+ float cGreen = MAX(0.0f, MIN(sharedexp, g));
+ float cBlue = MAX(0.0f, MIN(sharedexp, b));
+
+ float cMax = MAX(cRed, MAX(cGreen, cBlue));
+
+ // expp = MAX(-B - 1, log2(maxc)) + 1 + B
+
+ float expp = MAX(-B - 1.0f, floor(Math::log(cMax) / Math_LN2)) + 1.0f + B;
+
+ float sMax = (float)floor((cMax / Math::pow(2.0f, expp - B - N)) + 0.5f);
+
+ float exps = expp + 1.0f;
+
+ if (0.0 <= sMax && sMax < pow2to9) {
+ exps = expp;
+ }
+
+ float sRed = Math::floor((cRed / pow(2.0f, exps - B - N)) + 0.5f);
+ float sGreen = Math::floor((cGreen / pow(2.0f, exps - B - N)) + 0.5f);
+ float sBlue = Math::floor((cBlue / pow(2.0f, exps - B - N)) + 0.5f);
+
+ return (uint32_t(Math::fast_ftoi(sRed)) & 0x1FF) | ((uint32_t(Math::fast_ftoi(sGreen)) & 0x1FF) << 9) | ((uint32_t(Math::fast_ftoi(sBlue)) & 0x1FF) << 18) | ((uint32_t(Math::fast_ftoi(exps)) & 0x1F) << 27);
+ }
+
+ _FORCE_INLINE_ Color blend(const Color &p_over) const {
+ Color res;
+ float sa = 1.0 - p_over.a;
+ res.a = a * sa + p_over.a;
+ if (res.a == 0) {
+ return Color(0, 0, 0, 0);
+ } else {
+ res.r = (r * a * sa + p_over.r * p_over.a) / res.a;
+ res.g = (g * a * sa + p_over.g * p_over.a) / res.a;
+ res.b = (b * a * sa + p_over.b * p_over.a) / res.a;
+ }
+ return res;
+ }
+
+ _FORCE_INLINE_ Color to_linear() const {
+ return Color(
+ r < 0.04045 ? r * (1.0 / 12.92) : Math::pow((r + 0.055) * (1.0 / (1 + 0.055)), 2.4),
+ g < 0.04045 ? g * (1.0 / 12.92) : Math::pow((g + 0.055) * (1.0 / (1 + 0.055)), 2.4),
+ b < 0.04045 ? b * (1.0 / 12.92) : Math::pow((b + 0.055) * (1.0 / (1 + 0.055)), 2.4),
+ a);
+ }
+ _FORCE_INLINE_ Color to_srgb() const {
+ return Color(
+ r < 0.0031308 ? 12.92 * r : (1.0 + 0.055) * Math::pow(r, 1.0f / 2.4f) - 0.055,
+ g < 0.0031308 ? 12.92 * g : (1.0 + 0.055) * Math::pow(g, 1.0f / 2.4f) - 0.055,
+ b < 0.0031308 ? 12.92 * b : (1.0 + 0.055) * Math::pow(b, 1.0f / 2.4f) - 0.055, a);
+ }
+
+ static Color hex(uint32_t p_hex);
+ static Color hex64(uint64_t p_hex);
+ static Color html(const String &p_rgba);
+ static bool html_is_valid(const String &p_color);
+ static Color named(const String &p_name);
+ static int get_named_color_count();
+ static String get_named_color_name(int p_idx);
+ static Color get_named_color(int p_idx);
+ String to_html(bool p_alpha = true) const;
+ Color from_hsv(float p_h, float p_s, float p_v, float p_a) const;
+ static Color from_rgbe9995(uint32_t p_rgbe);
+
+ _FORCE_INLINE_ bool operator<(const Color &p_color) const; //used in set keys
+ operator String() const;
+
+ //for binder
+ _FORCE_INLINE_ void set_r8(int32_t r8) { r = (CLAMP(r8, 0, 255) / 255.0); }
+ _FORCE_INLINE_ int32_t get_r8() const { return CLAMP(uint32_t(r * 255.0), 0, 255); }
+ _FORCE_INLINE_ void set_g8(int32_t g8) { g = (CLAMP(g8, 0, 255) / 255.0); }
+ _FORCE_INLINE_ int32_t get_g8() const { return CLAMP(uint32_t(g * 255.0), 0, 255); }
+ _FORCE_INLINE_ void set_b8(int32_t b8) { b = (CLAMP(b8, 0, 255) / 255.0); }
+ _FORCE_INLINE_ int32_t get_b8() const { return CLAMP(uint32_t(b * 255.0), 0, 255); }
+ _FORCE_INLINE_ void set_a8(int32_t a8) { a = (CLAMP(a8, 0, 255) / 255.0); }
+ _FORCE_INLINE_ int32_t get_a8() const { return CLAMP(uint32_t(a * 255.0), 0, 255); }
+
+ _FORCE_INLINE_ void set_h(float h) { set_hsv(h, get_s(), get_v()); }
+ _FORCE_INLINE_ void set_s(float s) { set_hsv(get_h(), s, get_v()); }
+ _FORCE_INLINE_ void set_v(float v) { set_hsv(get_h(), get_s(), v); }
+
+ _FORCE_INLINE_ Color() {}
+
+ /**
+ * RGB / RGBA construct parameters. Alpha is optional, but defaults to 1.0
+ */
+ _FORCE_INLINE_ Color(float p_r, float p_g, float p_b, float p_a = 1.0) {
+ r = p_r;
+ g = p_g;
+ b = p_b;
+ a = p_a;
+ }
+
+ /**
+ * Construct a Color from another Color, but with the specified alpha value.
+ */
+ _FORCE_INLINE_ Color(const Color &p_c, float p_a) {
+ r = p_c.r;
+ g = p_c.g;
+ b = p_c.b;
+ a = p_a;
+ }
+};
+
+bool Color::operator<(const Color &p_color) const {
+ if (r == p_color.r) {
+ if (g == p_color.g) {
+ if (b == p_color.b) {
+ return (a < p_color.a);
+ } else {
+ return (b < p_color.b);
+ }
+ } else {
+ return g < p_color.g;
+ }
+ } else {
+ return r < p_color.r;
+ }
+}
+
+_FORCE_INLINE_ Color operator*(real_t p_real, const Color &p_color) {
+ return p_color * p_real;
+}
+
+#endif // COLOR_H
diff --git a/core/math/color_names.inc b/core/math/color_names.inc
new file mode 100644
index 0000000000..cbc821026e
--- /dev/null
+++ b/core/math/color_names.inc
@@ -0,0 +1,160 @@
+// Names from https://en.wikipedia.org/wiki/X11_color_names
+
+// So this in a way that does not require memory allocation
+// the old way leaked memory
+// this is not used as often as for more performance to make sense
+
+struct NamedColor {
+ const char *name;
+ Color color;
+};
+
+static NamedColor named_colors[] = {
+ { "aliceblue", Color(0.94, 0.97, 1.00) },
+ { "antiquewhite", Color(0.98, 0.92, 0.84) },
+ { "aqua", Color(0.00, 1.00, 1.00) },
+ { "aquamarine", Color(0.50, 1.00, 0.83) },
+ { "azure", Color(0.94, 1.00, 1.00) },
+ { "beige", Color(0.96, 0.96, 0.86) },
+ { "bisque", Color(1.00, 0.89, 0.77) },
+ { "black", Color(0.00, 0.00, 0.00) },
+ { "blanchedalmond", Color(1.00, 0.92, 0.80) },
+ { "blue", Color(0.00, 0.00, 1.00) },
+ { "blueviolet", Color(0.54, 0.17, 0.89) },
+ { "brown", Color(0.65, 0.16, 0.16) },
+ { "burlywood", Color(0.87, 0.72, 0.53) },
+ { "cadetblue", Color(0.37, 0.62, 0.63) },
+ { "chartreuse", Color(0.50, 1.00, 0.00) },
+ { "chocolate", Color(0.82, 0.41, 0.12) },
+ { "coral", Color(1.00, 0.50, 0.31) },
+ { "cornflower", Color(0.39, 0.58, 0.93) },
+ { "cornsilk", Color(1.00, 0.97, 0.86) },
+ { "crimson", Color(0.86, 0.08, 0.24) },
+ { "cyan", Color(0.00, 1.00, 1.00) },
+ { "darkblue", Color(0.00, 0.00, 0.55) },
+ { "darkcyan", Color(0.00, 0.55, 0.55) },
+ { "darkgoldenrod", Color(0.72, 0.53, 0.04) },
+ { "darkgray", Color(0.66, 0.66, 0.66) },
+ { "darkgreen", Color(0.00, 0.39, 0.00) },
+ { "darkkhaki", Color(0.74, 0.72, 0.42) },
+ { "darkmagenta", Color(0.55, 0.00, 0.55) },
+ { "darkolivegreen", Color(0.33, 0.42, 0.18) },
+ { "darkorange", Color(1.00, 0.55, 0.00) },
+ { "darkorchid", Color(0.60, 0.20, 0.80) },
+ { "darkred", Color(0.55, 0.00, 0.00) },
+ { "darksalmon", Color(0.91, 0.59, 0.48) },
+ { "darkseagreen", Color(0.56, 0.74, 0.56) },
+ { "darkslateblue", Color(0.28, 0.24, 0.55) },
+ { "darkslategray", Color(0.18, 0.31, 0.31) },
+ { "darkturquoise", Color(0.00, 0.81, 0.82) },
+ { "darkviolet", Color(0.58, 0.00, 0.83) },
+ { "deeppink", Color(1.00, 0.08, 0.58) },
+ { "deepskyblue", Color(0.00, 0.75, 1.00) },
+ { "dimgray", Color(0.41, 0.41, 0.41) },
+ { "dodgerblue", Color(0.12, 0.56, 1.00) },
+ { "firebrick", Color(0.70, 0.13, 0.13) },
+ { "floralwhite", Color(1.00, 0.98, 0.94) },
+ { "forestgreen", Color(0.13, 0.55, 0.13) },
+ { "fuchsia", Color(1.00, 0.00, 1.00) },
+ { "gainsboro", Color(0.86, 0.86, 0.86) },
+ { "ghostwhite", Color(0.97, 0.97, 1.00) },
+ { "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) },
+ { "indianred", Color(0.80, 0.36, 0.36) },
+ { "indigo", Color(0.29, 0.00, 0.51) },
+ { "ivory", Color(1.00, 1.00, 0.94) },
+ { "khaki", Color(0.94, 0.90, 0.55) },
+ { "lavender", Color(0.90, 0.90, 0.98) },
+ { "lavenderblush", Color(1.00, 0.94, 0.96) },
+ { "lawngreen", Color(0.49, 0.99, 0.00) },
+ { "lemonchiffon", Color(1.00, 0.98, 0.80) },
+ { "lightblue", Color(0.68, 0.85, 0.90) },
+ { "lightcoral", Color(0.94, 0.50, 0.50) },
+ { "lightcyan", Color(0.88, 1.00, 1.00) },
+ { "lightgoldenrod", Color(0.98, 0.98, 0.82) },
+ { "lightgray", Color(0.83, 0.83, 0.83) },
+ { "lightgreen", Color(0.56, 0.93, 0.56) },
+ { "lightpink", Color(1.00, 0.71, 0.76) },
+ { "lightsalmon", Color(1.00, 0.63, 0.48) },
+ { "lightseagreen", Color(0.13, 0.70, 0.67) },
+ { "lightskyblue", Color(0.53, 0.81, 0.98) },
+ { "lightslategray", Color(0.47, 0.53, 0.60) },
+ { "lightsteelblue", Color(0.69, 0.77, 0.87) },
+ { "lightyellow", Color(1.00, 1.00, 0.88) },
+ { "lime", Color(0.00, 1.00, 0.00) },
+ { "limegreen", Color(0.20, 0.80, 0.20) },
+ { "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) },
+ { "mediumpurple", Color(0.58, 0.44, 0.86) },
+ { "mediumseagreen", Color(0.24, 0.70, 0.44) },
+ { "mediumslateblue", Color(0.48, 0.41, 0.93) },
+ { "mediumspringgreen", Color(0.00, 0.98, 0.60) },
+ { "mediumturquoise", Color(0.28, 0.82, 0.80) },
+ { "mediumvioletred", Color(0.78, 0.08, 0.52) },
+ { "midnightblue", Color(0.10, 0.10, 0.44) },
+ { "mintcream", Color(0.96, 1.00, 0.98) },
+ { "mistyrose", Color(1.00, 0.89, 0.88) },
+ { "moccasin", Color(1.00, 0.89, 0.71) },
+ { "navajowhite", Color(1.00, 0.87, 0.68) },
+ { "navyblue", Color(0.00, 0.00, 0.50) },
+ { "oldlace", Color(0.99, 0.96, 0.90) },
+ { "olive", Color(0.50, 0.50, 0.00) },
+ { "olivedrab", Color(0.42, 0.56, 0.14) },
+ { "orange", Color(1.00, 0.65, 0.00) },
+ { "orangered", Color(1.00, 0.27, 0.00) },
+ { "orchid", Color(0.85, 0.44, 0.84) },
+ { "palegoldenrod", Color(0.93, 0.91, 0.67) },
+ { "palegreen", Color(0.60, 0.98, 0.60) },
+ { "paleturquoise", Color(0.69, 0.93, 0.93) },
+ { "palevioletred", Color(0.86, 0.44, 0.58) },
+ { "papayawhip", Color(1.00, 0.94, 0.84) },
+ { "peachpuff", Color(1.00, 0.85, 0.73) },
+ { "peru", Color(0.80, 0.52, 0.25) },
+ { "pink", Color(1.00, 0.75, 0.80) },
+ { "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) },
+ { "royalblue", Color(0.25, 0.41, 0.88) },
+ { "saddlebrown", Color(0.55, 0.27, 0.07) },
+ { "salmon", Color(0.98, 0.50, 0.45) },
+ { "sandybrown", Color(0.96, 0.64, 0.38) },
+ { "seagreen", Color(0.18, 0.55, 0.34) },
+ { "seashell", Color(1.00, 0.96, 0.93) },
+ { "sienna", Color(0.63, 0.32, 0.18) },
+ { "silver", Color(0.75, 0.75, 0.75) },
+ { "skyblue", Color(0.53, 0.81, 0.92) },
+ { "slateblue", Color(0.42, 0.35, 0.80) },
+ { "slategray", Color(0.44, 0.50, 0.56) },
+ { "snow", Color(1.00, 0.98, 0.98) },
+ { "springgreen", Color(0.00, 1.00, 0.50) },
+ { "steelblue", Color(0.27, 0.51, 0.71) },
+ { "tan", Color(0.82, 0.71, 0.55) },
+ { "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) },
+ { "violet", Color(0.93, 0.51, 0.93) },
+ { "wheat", Color(0.96, 0.87, 0.70) },
+ { "white", Color(1.00, 1.00, 1.00) },
+ { "whitesmoke", Color(0.96, 0.96, 0.96) },
+ { "yellow", Color(1.00, 1.00, 0.00) },
+ { "yellowgreen", Color(0.60, 0.80, 0.20) },
+ { nullptr, Color(0.60, 0.80, 0.20) },
+};
diff --git a/core/math/delaunay_3d.h b/core/math/delaunay_3d.h
index 014b4c4621..ea8655cfff 100644
--- a/core/math/delaunay_3d.h
+++ b/core/math/delaunay_3d.h
@@ -31,15 +31,15 @@
#ifndef DELAUNAY_3D_H
#define DELAUNAY_3D_H
-#include "core/local_vector.h"
#include "core/math/aabb.h"
#include "core/math/camera_matrix.h"
#include "core/math/vector3.h"
-#include "core/oa_hash_map.h"
#include "core/os/file_access.h"
-#include "core/print_string.h"
-#include "core/variant.h"
-#include "core/vector.h"
+#include "core/string/print_string.h"
+#include "core/templates/local_vector.h"
+#include "core/templates/oa_hash_map.h"
+#include "core/templates/vector.h"
+#include "core/variant/variant.h"
#include "thirdparty/misc/r128.h"
diff --git a/core/math/disjoint_set.h b/core/math/disjoint_set.h
index 198f46e111..51b9ce81af 100644
--- a/core/math/disjoint_set.h
+++ b/core/math/disjoint_set.h
@@ -31,8 +31,8 @@
#ifndef DISJOINT_SET_H
#define DISJOINT_SET_H
-#include "core/map.h"
-#include "core/vector.h"
+#include "core/templates/map.h"
+#include "core/templates/vector.h"
/**
@author Marios Staikopoulos <marios@staik.net>
diff --git a/core/math/expression.cpp b/core/math/expression.cpp
index 0e72b153e4..426586fc9c 100644
--- a/core/math/expression.cpp
+++ b/core/math/expression.cpp
@@ -30,13 +30,12 @@
#include "expression.h"
-#include "core/class_db.h"
-#include "core/func_ref.h"
#include "core/io/marshalls.h"
#include "core/math/math_funcs.h"
+#include "core/object/class_db.h"
+#include "core/object/reference.h"
#include "core/os/os.h"
-#include "core/reference.h"
-#include "core/variant_parser.h"
+#include "core/variant/variant_parser.h"
const char *Expression::func_name[Expression::FUNC_MAX] = {
"sin",
@@ -93,7 +92,6 @@ const char *Expression::func_name[Expression::FUNC_MAX] = {
"clamp",
"nearest_po2",
"weakref",
- "funcref",
"convert",
"typeof",
"type_exists",
@@ -185,7 +183,6 @@ int Expression::get_func_argument_count(BuiltinFunc p_func) {
case MATH_CARTESIAN2POLAR:
case LOGIC_MAX:
case LOGIC_MIN:
- case FUNC_FUNCREF:
case TYPE_CONVERT:
case COLORN:
return 2;
@@ -556,30 +553,6 @@ void Expression::exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant
}
} break;
- case FUNC_FUNCREF: {
- if (p_inputs[0]->get_type() != Variant::OBJECT) {
- r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_error.argument = 0;
- r_error.expected = Variant::OBJECT;
-
- return;
- }
- if (p_inputs[1]->get_type() != Variant::STRING && p_inputs[1]->get_type() != Variant::NODE_PATH) {
- r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
- r_error.argument = 1;
- r_error.expected = Variant::STRING;
-
- return;
- }
-
- Ref<FuncRef> fr = memnew(FuncRef);
-
- fr->set_instance(*p_inputs[0]);
- fr->set_function(*p_inputs[1]);
-
- *r_return = fr;
-
- } break;
case TYPE_CONVERT: {
VALIDATE_ARG_NUM(1);
int type = *p_inputs[1];
diff --git a/core/math/expression.h b/core/math/expression.h
index 80aeb98589..991554f4fd 100644
--- a/core/math/expression.h
+++ b/core/math/expression.h
@@ -31,7 +31,7 @@
#ifndef EXPRESSION_H
#define EXPRESSION_H
-#include "core/reference.h"
+#include "core/object/reference.h"
class Expression : public Reference {
GDCLASS(Expression, Reference);
@@ -92,7 +92,6 @@ public:
LOGIC_CLAMP,
LOGIC_NEAREST_PO2,
OBJ_WEAKREF,
- FUNC_FUNCREF,
TYPE_CONVERT,
TYPE_OF,
TYPE_EXISTS,
diff --git a/core/math/geometry_2d.h b/core/math/geometry_2d.h
index cfd7abfacb..12bad5768e 100644
--- a/core/math/geometry_2d.h
+++ b/core/math/geometry_2d.h
@@ -34,8 +34,8 @@
#include "core/math/delaunay_2d.h"
#include "core/math/rect2.h"
#include "core/math/triangulate.h"
-#include "core/object.h"
-#include "core/vector.h"
+#include "core/object/object.h"
+#include "core/templates/vector.h"
class Geometry2D {
Geometry2D();
diff --git a/core/math/geometry_3d.cpp b/core/math/geometry_3d.cpp
index 2c19fe2085..56353de783 100644
--- a/core/math/geometry_3d.cpp
+++ b/core/math/geometry_3d.cpp
@@ -30,7 +30,7 @@
#include "geometry_3d.h"
-#include "core/print_string.h"
+#include "core/string/print_string.h"
#include "thirdparty/misc/clipper.hpp"
#include "thirdparty/misc/triangulator.h"
diff --git a/core/math/geometry_3d.h b/core/math/geometry_3d.h
index 11cac8f108..f10fbeaaaf 100644
--- a/core/math/geometry_3d.h
+++ b/core/math/geometry_3d.h
@@ -32,8 +32,8 @@
#define GEOMETRY_3D_H
#include "core/math/face3.h"
-#include "core/object.h"
-#include "core/vector.h"
+#include "core/object/object.h"
+#include "core/templates/vector.h"
class Geometry3D {
Geometry3D();
diff --git a/core/math/math_fieldwise.h b/core/math/math_fieldwise.h
index c1ee9ec8f0..e8aac0dced 100644
--- a/core/math/math_fieldwise.h
+++ b/core/math/math_fieldwise.h
@@ -33,7 +33,7 @@
#ifdef TOOLS_ENABLED
-#include "core/variant.h"
+#include "core/variant/variant.h"
Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const String &p_field);
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 80413e5c22..e57257b442 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -30,7 +30,7 @@
#include "math_funcs.h"
-#include "core/error_macros.h"
+#include "core/error/error_macros.h"
RandomPCG Math::default_rand(RandomPCG::DEFAULT_SEED, RandomPCG::DEFAULT_INC);
diff --git a/core/math/octree.h b/core/math/octree.h
index 5d9688d442..40201f99b1 100644
--- a/core/math/octree.h
+++ b/core/math/octree.h
@@ -31,13 +31,13 @@
#ifndef OCTREE_H
#define OCTREE_H
-#include "core/list.h"
-#include "core/map.h"
#include "core/math/aabb.h"
#include "core/math/geometry_3d.h"
#include "core/math/vector3.h"
-#include "core/print_string.h"
-#include "core/variant.h"
+#include "core/string/print_string.h"
+#include "core/templates/list.h"
+#include "core/templates/map.h"
+#include "core/variant/variant.h"
typedef uint32_t OctreeElementID;
diff --git a/core/math/plane.cpp b/core/math/plane.cpp
index ae2021d2f6..e1ae3288ed 100644
--- a/core/math/plane.cpp
+++ b/core/math/plane.cpp
@@ -31,7 +31,7 @@
#include "plane.h"
#include "core/math/math_funcs.h"
-#include "core/variant.h"
+#include "core/variant/variant.h"
void Plane::set_normal(const Vector3 &p_normal) {
normal = p_normal;
diff --git a/core/math/quat.cpp b/core/math/quat.cpp
index c10f5da494..b6a017dd41 100644
--- a/core/math/quat.cpp
+++ b/core/math/quat.cpp
@@ -31,7 +31,7 @@
#include "quat.h"
#include "core/math/basis.h"
-#include "core/print_string.h"
+#include "core/string/print_string.h"
// set_euler_xyz expects a vector containing the Euler angles in the format
// (ax,ay,az), where ax is the angle of rotation around x axis,
diff --git a/core/math/quat.h b/core/math/quat.h
index 1ab64a2655..f8ab537d7b 100644
--- a/core/math/quat.h
+++ b/core/math/quat.h
@@ -36,7 +36,7 @@
#include "core/math/math_defs.h"
#include "core/math/math_funcs.h"
-#include "core/ustring.h"
+#include "core/string/ustring.h"
class Quat {
public:
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index 8ba1ba9286..8dff13c050 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -30,7 +30,7 @@
#include "quick_hull.h"
-#include "core/map.h"
+#include "core/templates/map.h"
uint32_t QuickHull::debug_stop_after = 0xFFFFFFFF;
diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h
index cac8e58d23..80f32e191b 100644
--- a/core/math/quick_hull.h
+++ b/core/math/quick_hull.h
@@ -31,10 +31,10 @@
#ifndef QUICK_HULL_H
#define QUICK_HULL_H
-#include "core/list.h"
#include "core/math/aabb.h"
#include "core/math/geometry_3d.h"
-#include "core/set.h"
+#include "core/templates/list.h"
+#include "core/templates/set.h"
class QuickHull {
public:
diff --git a/core/math/random_number_generator.h b/core/math/random_number_generator.h
index 08e41d6c1c..0d0ea17205 100644
--- a/core/math/random_number_generator.h
+++ b/core/math/random_number_generator.h
@@ -32,7 +32,7 @@
#define RANDOM_NUMBER_GENERATOR_H
#include "core/math/random_pcg.h"
-#include "core/reference.h"
+#include "core/object/reference.h"
class RandomNumberGenerator : public Reference {
GDCLASS(RandomNumberGenerator, Reference);
diff --git a/core/math/transform.cpp b/core/math/transform.cpp
index 0274dd18af..d36fd6a63d 100644
--- a/core/math/transform.cpp
+++ b/core/math/transform.cpp
@@ -32,7 +32,7 @@
#include "core/math/math_funcs.h"
#include "core/os/copymem.h"
-#include "core/print_string.h"
+#include "core/string/print_string.h"
void Transform::affine_invert() {
basis.invert();
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index c9a546e385..cfe8422d80 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -30,7 +30,7 @@
#include "triangle_mesh.h"
-#include "core/sort_array.h"
+#include "core/templates/sort_array.h"
int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, int p_depth, int &max_depth, int &max_alloc) {
if (p_depth > max_depth) {
diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h
index 86412cf725..d719822ec3 100644
--- a/core/math/triangle_mesh.h
+++ b/core/math/triangle_mesh.h
@@ -32,7 +32,7 @@
#define TRIANGLE_MESH_H
#include "core/math/face3.h"
-#include "core/reference.h"
+#include "core/object/reference.h"
class TriangleMesh : public Reference {
GDCLASS(TriangleMesh, Reference);
diff --git a/core/math/vector2.h b/core/math/vector2.h
index 31bb7208d3..8cb63b2fb5 100644
--- a/core/math/vector2.h
+++ b/core/math/vector2.h
@@ -32,7 +32,7 @@
#define VECTOR2_H
#include "core/math/math_funcs.h"
-#include "core/ustring.h"
+#include "core/string/ustring.h"
struct Vector2i;
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 5370b297f1..ae8b9376cf 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -33,7 +33,7 @@
#include "core/math/math_funcs.h"
#include "core/math/vector3i.h"
-#include "core/ustring.h"
+#include "core/string/ustring.h"
class Basis;
diff --git a/core/math/vector3i.h b/core/math/vector3i.h
index 89774e9395..1bfd6d5ab2 100644
--- a/core/math/vector3i.h
+++ b/core/math/vector3i.h
@@ -31,8 +31,8 @@
#ifndef VECTOR3I_H
#define VECTOR3I_H
+#include "core/string/ustring.h"
#include "core/typedefs.h"
-#include "core/ustring.h"
struct Vector3i {
enum Axis {