summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/math/color.cpp85
-rw-r--r--core/math/color.h8
-rw-r--r--core/math/convex_hull.cpp20
-rw-r--r--core/math/static_raycaster.h16
-rw-r--r--core/object/worker_thread_pool.cpp22
-rw-r--r--core/object/worker_thread_pool.h4
-rw-r--r--core/os/time.cpp8
-rw-r--r--core/register_core_types.cpp12
-rw-r--r--core/variant/variant_call.cpp1
-rw-r--r--core/variant/variant_setget.cpp4
-rw-r--r--core/variant/variant_setget.h4
11 files changed, 39 insertions, 145 deletions
diff --git a/core/math/color.cpp b/core/math/color.cpp
index f4b8903157..0d9325f236 100644
--- a/core/math/color.cpp
+++ b/core/math/color.cpp
@@ -188,32 +188,6 @@ float Color::get_v() const {
return max;
}
-float Color::get_hsl_h() const {
- return get_h();
-}
-
-float Color::get_hsl_s() const {
- float min = MIN(MIN(r, g), b);
- float max = MAX(MAX(r, g), b);
-
- float mid = (min + max) / 2.0f;
-
- if (mid == 0.0f || mid == 1.0f) {
- return 0.0f;
- }
-
- float delta = max - min;
-
- return delta / (1.0f - Math::abs(2.0f * mid - 1.0f));
-}
-
-float Color::get_hsl_l() const {
- float min = MIN(MIN(r, g), b);
- float max = MAX(MAX(r, g), b);
-
- return (min + max) / 2.0f;
-}
-
void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
int i;
float f, p, q, t;
@@ -268,59 +242,6 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
}
}
-void Color::set_hsl(float p_h, float p_s, float p_l, float p_alpha) {
- a = p_alpha;
-
- if (p_s == 0.0f) {
- // Achromatic (gray)
- r = g = b = p_l;
- return;
- }
-
- p_h *= 6.0f;
- p_h = Math::fmod(p_h, 6.0f);
-
- float c = (1.0f - Math::abs(2.0f * p_l - 1.0f)) * p_s;
- float x = c * (1.0f - Math::abs(Math::fmod(p_h, 2.0f) - 1.0f));
- float m = p_l - c / 2.0f;
-
- c += m;
- x += m;
-
- switch ((int)p_h) {
- case 0: // Red is the dominant color
- r = c;
- g = x;
- b = m;
- break;
- case 1: // Green is the dominant color
- r = x;
- g = c;
- b = m;
- break;
- case 2:
- r = m;
- g = c;
- b = x;
- break;
- case 3: // Blue is the dominant color
- r = m;
- g = x;
- b = c;
- break;
- case 4:
- r = x;
- g = m;
- b = c;
- break;
- default: // (5) Red is the dominant color
- r = c;
- g = m;
- b = x;
- break;
- }
-}
-
void Color::set_ok_hsl(float p_h, float p_s, float p_l, float p_alpha) {
ok_color::HSL hsl;
hsl.h = p_h;
@@ -547,12 +468,6 @@ Color Color::from_hsv(float p_h, float p_s, float p_v, float p_alpha) {
return c;
}
-Color Color::from_hsl(float p_h, float p_s, float p_l, float p_alpha) {
- Color c;
- c.set_hsl(p_h, p_s, p_l, p_alpha);
- return c;
-}
-
Color Color::from_rgbe9995(uint32_t p_rgbe) {
float r = p_rgbe & 0x1ff;
float g = (p_rgbe >> 9) & 0x1ff;
diff --git a/core/math/color.h b/core/math/color.h
index 4a056335c1..65d7377c1c 100644
--- a/core/math/color.h
+++ b/core/math/color.h
@@ -57,10 +57,6 @@ struct _NO_DISCARD_ Color {
float get_s() const;
float get_v() const;
void set_hsv(float p_h, float p_s, float p_v, float p_alpha = 1.0f);
- float get_hsl_h() const;
- float get_hsl_s() const;
- float get_hsl_l() const;
- void set_hsl(float p_h, float p_s, float p_l, float p_alpha = 1.0f);
float get_ok_hsl_h() const;
float get_ok_hsl_s() const;
float get_ok_hsl_l() const;
@@ -202,7 +198,6 @@ struct _NO_DISCARD_ Color {
static Color get_named_color(int p_idx);
static Color from_string(const String &p_string, const Color &p_default);
static Color from_hsv(float p_h, float p_s, float p_v, float p_alpha = 1.0f);
- static Color from_hsl(float p_h, float p_s, float p_l, float p_alpha = 1.0f);
static Color from_ok_hsl(float p_h, float p_s, float p_l, float p_alpha = 1.0f);
static Color from_rgbe9995(uint32_t p_rgbe);
@@ -222,9 +217,6 @@ struct _NO_DISCARD_ Color {
_FORCE_INLINE_ void set_h(float p_h) { set_hsv(p_h, get_s(), get_v(), a); }
_FORCE_INLINE_ void set_s(float p_s) { set_hsv(get_h(), p_s, get_v(), a); }
_FORCE_INLINE_ void set_v(float p_v) { set_hsv(get_h(), get_s(), p_v, a); }
- _FORCE_INLINE_ void set_hsl_h(float p_h) { set_hsl(p_h, get_hsl_s(), get_hsl_l(), a); }
- _FORCE_INLINE_ void set_hsl_s(float p_s) { set_hsl(get_hsl_h(), p_s, get_hsl_l(), a); }
- _FORCE_INLINE_ void set_hsl_l(float p_l) { set_hsl(get_hsl_h(), get_hsl_s(), p_l, a); }
_FORCE_INLINE_ void set_ok_hsl_h(float p_h) { set_ok_hsl(p_h, get_ok_hsl_s(), get_ok_hsl_l(), a); }
_FORCE_INLINE_ void set_ok_hsl_s(float p_s) { set_ok_hsl(get_ok_hsl_h(), p_s, get_ok_hsl_l(), a); }
_FORCE_INLINE_ void set_ok_hsl_l(float p_l) { set_ok_hsl(get_ok_hsl_h(), get_ok_hsl_s(), p_l, a); }
diff --git a/core/math/convex_hull.cpp b/core/math/convex_hull.cpp
index a03438a339..76b3062944 100644
--- a/core/math/convex_hull.cpp
+++ b/core/math/convex_hull.cpp
@@ -596,9 +596,9 @@ private:
}
};
- enum Orientation { NONE,
- CLOCKWISE,
- COUNTER_CLOCKWISE };
+ enum Orientation { ORIENTATION_NONE,
+ ORIENTATION_CLOCKWISE,
+ ORIENTATION_COUNTER_CLOCKWISE };
Vector3 scaling;
Vector3 center;
@@ -1140,13 +1140,13 @@ ConvexHullInternal::Orientation ConvexHullInternal::get_orientation(const Edge *
CHULL_ASSERT(!m.is_zero());
int64_t dot = n.dot(m);
CHULL_ASSERT(dot != 0);
- return (dot > 0) ? COUNTER_CLOCKWISE : CLOCKWISE;
+ return (dot > 0) ? ORIENTATION_COUNTER_CLOCKWISE : ORIENTATION_CLOCKWISE;
}
- return COUNTER_CLOCKWISE;
+ return ORIENTATION_COUNTER_CLOCKWISE;
} else if (p_prev->prev == p_next) {
- return CLOCKWISE;
+ return ORIENTATION_CLOCKWISE;
} else {
- return NONE;
+ return ORIENTATION_NONE;
}
}
@@ -1176,7 +1176,7 @@ ConvexHullInternal::Edge *ConvexHullInternal::find_max_angle(bool p_ccw, const V
} else if ((cmp = cot.compare(p_min_cot)) < 0) {
p_min_cot = cot;
min_edge = e;
- } else if ((cmp == 0) && (p_ccw == (get_orientation(min_edge, e, p_s, t) == COUNTER_CLOCKWISE))) {
+ } else if ((cmp == 0) && (p_ccw == (get_orientation(min_edge, e, p_s, t) == ORIENTATION_COUNTER_CLOCKWISE))) {
min_edge = e;
}
}
@@ -1375,7 +1375,7 @@ void ConvexHullInternal::merge(IntermediateHull &p_h0, IntermediateHull &p_h1) {
int64_t dot = (*e->target - *c0).dot(normal);
CHULL_ASSERT(dot <= 0);
if ((dot == 0) && ((*e->target - *c0).dot(t) > 0)) {
- if (!start0 || (get_orientation(start0, e, s, Point32(0, 0, -1)) == CLOCKWISE)) {
+ if (!start0 || (get_orientation(start0, e, s, Point32(0, 0, -1)) == ORIENTATION_CLOCKWISE)) {
start0 = e;
}
}
@@ -1390,7 +1390,7 @@ void ConvexHullInternal::merge(IntermediateHull &p_h0, IntermediateHull &p_h1) {
int64_t dot = (*e->target - *c1).dot(normal);
CHULL_ASSERT(dot <= 0);
if ((dot == 0) && ((*e->target - *c1).dot(t) > 0)) {
- if (!start1 || (get_orientation(start1, e, s, Point32(0, 0, -1)) == COUNTER_CLOCKWISE)) {
+ if (!start1 || (get_orientation(start1, e, s, Point32(0, 0, -1)) == ORIENTATION_COUNTER_CLOCKWISE)) {
start1 = e;
}
}
diff --git a/core/math/static_raycaster.h b/core/math/static_raycaster.h
index 1bafc29c57..c53868e12d 100644
--- a/core/math/static_raycaster.h
+++ b/core/math/static_raycaster.h
@@ -59,15 +59,15 @@ public:
/*! Constructs a ray from origin, direction, and ray segment. Near
* has to be smaller than far. */
- _FORCE_INLINE_ Ray(const Vector3 &org,
- const Vector3 &dir,
- float tnear = 0.0f,
- float tfar = INFINITY) :
- org(org),
- tnear(tnear),
- dir(dir),
+ _FORCE_INLINE_ Ray(const Vector3 &p_org,
+ const Vector3 &p_dir,
+ float p_tnear = 0.0f,
+ float p_tfar = INFINITY) :
+ org(p_org),
+ tnear(p_tnear),
+ dir(p_dir),
time(0.0f),
- tfar(tfar),
+ tfar(p_tfar),
mask(-1),
u(0.0),
v(0.0),
diff --git a/core/object/worker_thread_pool.cpp b/core/object/worker_thread_pool.cpp
index 721c8d0a10..3dca6b73a6 100644
--- a/core/object/worker_thread_pool.cpp
+++ b/core/object/worker_thread_pool.cpp
@@ -140,9 +140,9 @@ void WorkerThreadPool::_process_task(Task *p_task) {
task_queue.add_last(&low_prio_task->task_elem);
post = true;
} else {
- low_priority_threads_used.decrement();
+ low_priority_threads_used--;
}
- task_mutex.lock();
+ task_mutex.unlock();
if (post) {
task_available_semaphore.post();
}
@@ -152,7 +152,7 @@ void WorkerThreadPool::_process_task(Task *p_task) {
void WorkerThreadPool::_thread_function(void *p_user) {
while (true) {
singleton->task_available_semaphore.wait();
- if (singleton->exit_threads.is_set()) {
+ if (singleton->exit_threads) {
break;
}
singleton->_process_task_queue();
@@ -168,14 +168,13 @@ void WorkerThreadPool::_post_task(Task *p_task, bool p_high_priority) {
task_mutex.lock();
p_task->low_priority = !p_high_priority;
if (!p_high_priority && use_native_low_priority_threads) {
- task_mutex.unlock();
p_task->low_priority_thread = native_thread_allocator.alloc();
+ task_mutex.unlock();
p_task->low_priority_thread->start(_native_low_priority_thread_function, p_task); // Pask task directly to thread.
-
- } else if (p_high_priority || low_priority_threads_used.get() < max_low_priority_threads) {
+ } else if (p_high_priority || low_priority_threads_used < max_low_priority_threads) {
task_queue.add_last(&p_task->task_elem);
if (!p_high_priority) {
- low_priority_threads_used.increment();
+ low_priority_threads_used++;
}
task_mutex.unlock();
task_available_semaphore.post();
@@ -251,6 +250,8 @@ void WorkerThreadPool::wait_for_task_completion(TaskID p_task_id) {
if (use_native_low_priority_threads && task->low_priority) {
task->low_priority_thread->wait_to_finish();
+
+ task_mutex.lock();
native_thread_allocator.free(task->low_priority_thread);
} else {
int *index = thread_ids.getptr(Thread::get_caller_id());
@@ -272,9 +273,10 @@ void WorkerThreadPool::wait_for_task_completion(TaskID p_task_id) {
} else {
task->done_semaphore.wait();
}
+
+ task_mutex.lock();
}
- task_mutex.lock();
tasks.erase(p_task_id);
task_allocator.free(task);
task_mutex.unlock();
@@ -379,8 +381,8 @@ void WorkerThreadPool::wait_for_group_task_completion(GroupID p_group) {
if (group->low_priority_native_tasks.size() > 0) {
for (Task *task : group->low_priority_native_tasks) {
task->low_priority_thread->wait_to_finish();
- native_thread_allocator.free(task->low_priority_thread);
task_mutex.lock();
+ native_thread_allocator.free(task->low_priority_thread);
task_allocator.free(task);
task_mutex.unlock();
}
@@ -443,7 +445,7 @@ void WorkerThreadPool::finish() {
}
task_mutex.unlock();
- exit_threads.set_to(true);
+ exit_threads = true;
for (uint32_t i = 0; i < threads.size(); i++) {
task_available_semaphore.post();
diff --git a/core/object/worker_thread_pool.h b/core/object/worker_thread_pool.h
index c62e05fc28..d47c6ad714 100644
--- a/core/object/worker_thread_pool.h
+++ b/core/object/worker_thread_pool.h
@@ -107,7 +107,7 @@ private:
};
TightLocalVector<ThreadData> threads;
- SafeFlag exit_threads;
+ bool exit_threads = false;
HashMap<Thread::ID, int> thread_ids;
HashMap<TaskID, Task *> tasks;
@@ -115,7 +115,7 @@ private:
bool use_native_low_priority_threads = false;
uint32_t max_low_priority_threads = 0;
- SafeNumeric<uint32_t> low_priority_threads_used;
+ uint32_t low_priority_threads_used = 0;
uint64_t last_task = 1;
diff --git a/core/os/time.cpp b/core/os/time.cpp
index 12e6f08525..038e4adc03 100644
--- a/core/os/time.cpp
+++ b/core/os/time.cpp
@@ -382,10 +382,10 @@ String Time::get_time_string_from_system(bool p_utc) const {
Dictionary Time::get_time_zone_from_system() const {
OS::TimeZoneInfo info = OS::get_singleton()->get_time_zone_info();
- Dictionary timezone;
- timezone["bias"] = info.bias;
- timezone["name"] = info.name;
- return timezone;
+ Dictionary ret_timezone;
+ ret_timezone["bias"] = info.bias;
+ ret_timezone["name"] = info.name;
+ return ret_timezone;
}
double Time::get_unix_time_from_system() const {
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index a374e7c009..b8b8119618 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -302,15 +302,9 @@ void register_core_settings() {
GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "network/limits/packet_peer_stream/max_buffer_po2", PROPERTY_HINT_RANGE, "0,64,1,or_greater"), (16));
GLOBAL_DEF(PropertyInfo(Variant::STRING, "network/tls/certificate_bundle_override", PROPERTY_HINT_FILE, "*.crt"), "");
- int worker_threads = GLOBAL_DEF("threading/worker_pool/max_threads", -1);
- bool low_priority_use_system_threads = GLOBAL_DEF("threading/worker_pool/use_system_threads_for_low_priority_tasks", true);
- float low_property_ratio = GLOBAL_DEF("threading/worker_pool/low_priority_thread_ratio", 0.3);
-
- if (Engine::get_singleton()->is_editor_hint() || Engine::get_singleton()->is_project_manager_hint()) {
- worker_thread_pool->init();
- } else {
- worker_thread_pool->init(worker_threads, low_priority_use_system_threads, low_property_ratio);
- }
+ GLOBAL_DEF("threading/worker_pool/max_threads", -1);
+ GLOBAL_DEF("threading/worker_pool/use_system_threads_for_low_priority_tasks", true);
+ GLOBAL_DEF("threading/worker_pool/low_priority_thread_ratio", 0.3);
}
void register_core_singletons() {
diff --git a/core/variant/variant_call.cpp b/core/variant/variant_call.cpp
index e22970ef5c..0a836c125a 100644
--- a/core/variant/variant_call.cpp
+++ b/core/variant/variant_call.cpp
@@ -2002,7 +2002,6 @@ static void _register_variant_builtin_methods() {
bind_static_method(Color, html_is_valid, sarray("color"), varray());
bind_static_method(Color, from_string, sarray("str", "default"), varray());
bind_static_method(Color, from_hsv, sarray("h", "s", "v", "alpha"), varray(1.0));
- bind_static_method(Color, from_hsl, sarray("h", "s", "l", "alpha"), varray(1.0));
bind_static_method(Color, from_ok_hsl, sarray("h", "s", "l", "alpha"), varray(1.0));
bind_static_method(Color, from_rgbe9995, sarray("rgbe"), varray());
diff --git a/core/variant/variant_setget.cpp b/core/variant/variant_setget.cpp
index ce035f5f7a..30fb5d0e9f 100644
--- a/core/variant/variant_setget.cpp
+++ b/core/variant/variant_setget.cpp
@@ -139,10 +139,6 @@ void register_named_setters_getters() {
REGISTER_MEMBER(Color, h);
REGISTER_MEMBER(Color, s);
REGISTER_MEMBER(Color, v);
-
- REGISTER_MEMBER(Color, hsl_h);
- REGISTER_MEMBER(Color, hsl_s);
- REGISTER_MEMBER(Color, hsl_l);
}
void unregister_named_setters_getters() {
diff --git a/core/variant/variant_setget.h b/core/variant/variant_setget.h
index db6e273817..176967344f 100644
--- a/core/variant/variant_setget.h
+++ b/core/variant/variant_setget.h
@@ -344,10 +344,6 @@ SETGET_NUMBER_STRUCT_FUNC(Color, double, h, set_h, get_h)
SETGET_NUMBER_STRUCT_FUNC(Color, double, s, set_s, get_s)
SETGET_NUMBER_STRUCT_FUNC(Color, double, v, set_v, get_v)
-SETGET_NUMBER_STRUCT_FUNC(Color, double, hsl_h, set_hsl_h, get_hsl_h)
-SETGET_NUMBER_STRUCT_FUNC(Color, double, hsl_s, set_hsl_s, get_hsl_s)
-SETGET_NUMBER_STRUCT_FUNC(Color, double, hsl_l, set_hsl_l, get_hsl_l)
-
SETGET_NUMBER_STRUCT_FUNC(Color, double, ok_hsl_h, set_ok_hsl_h, get_ok_hsl_h)
SETGET_NUMBER_STRUCT_FUNC(Color, double, ok_hsl_s, set_ok_hsl_s, get_ok_hsl_s)
SETGET_NUMBER_STRUCT_FUNC(Color, double, ok_hsl_l, set_ok_hsl_l, get_ok_hsl_l)