summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp29
-rw-r--r--main/main_timer_sync.cpp26
-rw-r--r--main/main_timer_sync.h22
-rw-r--r--main/performance.cpp8
-rw-r--r--main/performance.h12
5 files changed, 54 insertions, 43 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 0651f4b93f..92ab52eecd 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -986,11 +986,13 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else if (I->get() == "-d" || I->get() == "--debug") {
debug_uri = "local://";
OS::get_singleton()->_debug_stdout = true;
-#if defined(DEBUG_ENABLED) && !defined(SERVER_ENABLED)
+#if defined(DEBUG_ENABLED)
} else if (I->get() == "--debug-collisions") {
debug_collisions = true;
} else if (I->get() == "--debug-navigation") {
debug_navigation = true;
+ } else if (I->get() == "--debug-stringnames") {
+ StringName::set_debug_stringnames(true);
#endif
} else if (I->get() == "--remote-debug") {
if (I->next()) {
@@ -1078,7 +1080,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#else
const String error_msg = "Error: Couldn't load project data at path \"" + project_path + "\". Is the .pck file missing?\nIf you've renamed the executable, the associated .pck file should also be renamed to match the executable's name (without the extension).\n";
OS::get_singleton()->print("%s", error_msg.ascii().get_data());
- DisplayServer::get_singleton()->alert(error_msg);
+ OS::get_singleton()->alert(error_msg);
goto error;
#endif
@@ -1087,6 +1089,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
// Initialize user data dir.
OS::get_singleton()->ensure_user_data_dir();
+ ResourceUID::get_singleton()->load_from_cache(); // load UUIDs from cache.
+
GLOBAL_DEF("memory/limits/multithreaded_server/rid_pool_prealloc", 60);
ProjectSettings::get_singleton()->set_custom_property_info("memory/limits/multithreaded_server/rid_pool_prealloc",
PropertyInfo(Variant::INT,
@@ -1592,6 +1596,13 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
rendering_server->set_print_gpu_profile(true);
}
+#ifdef UNIX_ENABLED
+ // Print warning after initializing the renderer but before initializing audio.
+ if (OS::get_singleton()->get_environment("USER") == "root" && !OS::get_singleton()->has_environment("GODOT_SILENCE_ROOT_WARNING")) {
+ WARN_PRINT("Started the engine as `root`/superuser. This is a security risk, and subsystems like audio may not work correctly.\nSet the environment variable `GODOT_SILENCE_ROOT_WARNING` to 1 to silence this warning.");
+ }
+#endif
+
OS::get_singleton()->initialize_joypads();
/* Initialize Audio Driver */
@@ -2013,6 +2024,7 @@ bool Main::start() {
// Let's throw an error gently. The code leading to this is pretty brittle so
// this might end up triggered by valid usage, in which case we'll have to
// fine-tune further.
+ OS::get_singleton()->alert("Couldn't detect whether to run the editor, the project manager or a specific project. Aborting.");
ERR_FAIL_V_MSG(false, "Couldn't detect whether to run the editor, the project manager or a specific project. Aborting.");
}
#endif
@@ -2042,9 +2054,8 @@ bool Main::start() {
if (obj) {
memdelete(obj);
}
- ERR_FAIL_V_MSG(false,
- vformat("Can't load the script \"%s\" as it doesn't inherit from SceneTree or MainLoop.",
- script));
+ OS::get_singleton()->alert(vformat("Can't load the script \"%s\" as it doesn't inherit from SceneTree or MainLoop.", script));
+ ERR_FAIL_V_MSG(false, vformat("Can't load the script \"%s\" as it doesn't inherit from SceneTree or MainLoop.", script));
}
script_loop->set_initialize_script(script_res);
@@ -2063,7 +2074,7 @@ bool Main::start() {
if (obj) {
memdelete(obj);
}
- DisplayServer::get_singleton()->alert("Error: Invalid MainLoop script base type: " + script_base);
+ OS::get_singleton()->alert("Error: Invalid MainLoop script base type: " + script_base);
ERR_FAIL_V_MSG(false, vformat("The global class %s does not inherit from SceneTree or MainLoop.", main_loop_type));
}
script_loop->set_initialize_script(script_res);
@@ -2077,7 +2088,7 @@ bool Main::start() {
if (!main_loop) {
if (!ClassDB::class_exists(main_loop_type)) {
- DisplayServer::get_singleton()->alert("Error: MainLoop type doesn't exist: " + main_loop_type);
+ OS::get_singleton()->alert("Error: MainLoop type doesn't exist: " + main_loop_type);
return false;
} else {
Object *ml = ClassDB::instantiate(main_loop_type);
@@ -2167,8 +2178,8 @@ bool Main::start() {
}
}
- for (List<Node *>::Element *E = to_add.front(); E; E = E->next()) {
- sml->get_root()->add_child(E->get());
+ for (Node *E : to_add) {
+ sml->get_root()->add_child(E);
}
}
}
diff --git a/main/main_timer_sync.cpp b/main/main_timer_sync.cpp
index 93448d0904..94e62bea97 100644
--- a/main/main_timer_sync.cpp
+++ b/main/main_timer_sync.cpp
@@ -30,7 +30,7 @@
#include "main_timer_sync.h"
-void MainFrameTime::clamp_process_step(float min_process_step, float max_process_step) {
+void MainFrameTime::clamp_process_step(double min_process_step, double max_process_step) {
if (process_step < min_process_step) {
process_step = min_process_step;
} else if (process_step > max_process_step) {
@@ -43,25 +43,25 @@ void MainFrameTime::clamp_process_step(float min_process_step, float max_process
// returns the fraction of p_physics_step required for the timer to overshoot
// before advance_core considers changing the physics_steps return from
// the typical values as defined by typical_physics_steps
-float MainTimerSync::get_physics_jitter_fix() {
+double MainTimerSync::get_physics_jitter_fix() {
return Engine::get_singleton()->get_physics_jitter_fix();
}
// gets our best bet for the average number of physics steps per render frame
// return value: number of frames back this data is consistent
-int MainTimerSync::get_average_physics_steps(float &p_min, float &p_max) {
+int MainTimerSync::get_average_physics_steps(double &p_min, double &p_max) {
p_min = typical_physics_steps[0];
p_max = p_min + 1;
for (int i = 1; i < CONTROL_STEPS; ++i) {
- const float typical_lower = typical_physics_steps[i];
- const float current_min = typical_lower / (i + 1);
+ const double typical_lower = typical_physics_steps[i];
+ const double current_min = typical_lower / (i + 1);
if (current_min > p_max) {
return i; // bail out of further restrictions would void the interval
} else if (current_min > p_min) {
p_min = current_min;
}
- const float current_max = (typical_lower + 1) / (i + 1);
+ const double current_max = (typical_lower + 1) / (i + 1);
if (current_max < p_min) {
return i;
} else if (current_max < p_max) {
@@ -73,7 +73,7 @@ int MainTimerSync::get_average_physics_steps(float &p_min, float &p_max) {
}
// advance physics clock by p_process_step, return appropriate number of steps to simulate
-MainFrameTime MainTimerSync::advance_core(float p_physics_step, int p_physics_fps, float p_process_step) {
+MainFrameTime MainTimerSync::advance_core(double p_physics_step, int p_physics_fps, double p_process_step) {
MainFrameTime ret;
ret.process_step = p_process_step;
@@ -146,7 +146,7 @@ MainFrameTime MainTimerSync::advance_core(float p_physics_step, int p_physics_fp
}
// calls advance_core, keeps track of deficit it adds to animaption_step, make sure the deficit sum stays close to zero
-MainFrameTime MainTimerSync::advance_checked(float p_physics_step, int p_physics_fps, float p_process_step) {
+MainFrameTime MainTimerSync::advance_checked(double p_physics_step, int p_physics_fps, double p_process_step) {
if (fixed_fps != -1) {
p_process_step = 1.0 / fixed_fps;
}
@@ -163,7 +163,7 @@ MainFrameTime MainTimerSync::advance_checked(float p_physics_step, int p_physics
// first, least important clamping: keep ret.process_step consistent with typical_physics_steps.
// this smoothes out the process steps and culls small but quick variations.
{
- float min_average_physics_steps, max_average_physics_steps;
+ double min_average_physics_steps, max_average_physics_steps;
int consistent_steps = get_average_physics_steps(min_average_physics_steps, max_average_physics_steps);
if (consistent_steps > 3) {
ret.clamp_process_step(min_average_physics_steps * p_physics_step, max_average_physics_steps * p_physics_step);
@@ -171,7 +171,7 @@ MainFrameTime MainTimerSync::advance_checked(float p_physics_step, int p_physics
}
// second clamping: keep abs(time_deficit) < jitter_fix * frame_slise
- float max_clock_deviation = get_physics_jitter_fix() * p_physics_step;
+ double max_clock_deviation = get_physics_jitter_fix() * p_physics_step;
ret.clamp_process_step(p_process_step - max_clock_deviation, p_process_step + max_clock_deviation);
// last clamping: make sure time_accum is between 0 and p_physics_step for consistency between physics and process
@@ -191,7 +191,7 @@ MainFrameTime MainTimerSync::advance_checked(float p_physics_step, int p_physics
}
// determine wall clock step since last iteration
-float MainTimerSync::get_cpu_process_step() {
+double MainTimerSync::get_cpu_process_step() {
uint64_t cpu_ticks_elapsed = current_cpu_ticks_usec - last_cpu_ticks_usec;
last_cpu_ticks_usec = current_cpu_ticks_usec;
@@ -220,8 +220,8 @@ void MainTimerSync::set_fixed_fps(int p_fixed_fps) {
}
// advance one physics frame, return timesteps to take
-MainFrameTime MainTimerSync::advance(float p_physics_step, int p_physics_fps) {
- float cpu_process_step = get_cpu_process_step();
+MainFrameTime MainTimerSync::advance(double p_physics_step, int p_physics_fps) {
+ double cpu_process_step = get_cpu_process_step();
return advance_checked(p_physics_step, p_physics_fps, cpu_process_step);
}
diff --git a/main/main_timer_sync.h b/main/main_timer_sync.h
index 884978bf96..abdec18f6d 100644
--- a/main/main_timer_sync.h
+++ b/main/main_timer_sync.h
@@ -34,11 +34,11 @@
#include "core/config/engine.h"
struct MainFrameTime {
- float process_step; // delta time to advance during process()
+ double process_step; // delta time to advance during process()
int physics_steps; // number of times to iterate the physics engine
- float interpolation_fraction; // fraction through the current physics tick
+ double interpolation_fraction; // fraction through the current physics tick
- void clamp_process_step(float min_process_step, float max_process_step);
+ void clamp_process_step(double min_process_step, double max_process_step);
};
class MainTimerSync {
@@ -47,10 +47,10 @@ class MainTimerSync {
uint64_t current_cpu_ticks_usec = 0;
// logical game time since last physics timestep
- float time_accum = 0;
+ double time_accum = 0;
// current difference between wall clock time and reported sum of process_steps
- float time_deficit = 0;
+ double time_deficit = 0;
// number of frames back for keeping accumulated physics steps roughly constant.
// value of 12 chosen because that is what is required to make 144 Hz monitors
@@ -70,20 +70,20 @@ protected:
// returns the fraction of p_physics_step required for the timer to overshoot
// before advance_core considers changing the physics_steps return from
// the typical values as defined by typical_physics_steps
- float get_physics_jitter_fix();
+ double get_physics_jitter_fix();
// gets our best bet for the average number of physics steps per render frame
// return value: number of frames back this data is consistent
- int get_average_physics_steps(float &p_min, float &p_max);
+ int get_average_physics_steps(double &p_min, double &p_max);
// advance physics clock by p_process_step, return appropriate number of steps to simulate
- MainFrameTime advance_core(float p_physics_step, int p_physics_fps, float p_process_step);
+ MainFrameTime advance_core(double p_physics_step, int p_physics_fps, double p_process_step);
// calls advance_core, keeps track of deficit it adds to animaption_step, make sure the deficit sum stays close to zero
- MainFrameTime advance_checked(float p_physics_step, int p_physics_fps, float p_process_step);
+ MainFrameTime advance_checked(double p_physics_step, int p_physics_fps, double p_process_step);
// determine wall clock step since last iteration
- float get_cpu_process_step();
+ double get_cpu_process_step();
public:
MainTimerSync();
@@ -96,7 +96,7 @@ public:
void set_fixed_fps(int p_fixed_fps);
// advance one frame, return timesteps to take
- MainFrameTime advance(float p_physics_step, int p_physics_fps);
+ MainFrameTime advance(double p_physics_step, int p_physics_fps);
};
#endif // MAIN_TIMER_SYNC_H
diff --git a/main/performance.cpp b/main/performance.cpp
index 9f5be7b8c4..f9ff34c05d 100644
--- a/main/performance.cpp
+++ b/main/performance.cpp
@@ -77,7 +77,7 @@ void Performance::_bind_methods() {
BIND_ENUM_CONSTANT(MONITOR_MAX);
}
-float Performance::_get_node_count() const {
+int Performance::_get_node_count() const {
MainLoop *ml = OS::get_singleton()->get_main_loop();
SceneTree *sml = Object::cast_to<SceneTree>(ml);
if (!sml) {
@@ -118,7 +118,7 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
return names[p_monitor];
}
-float Performance::get_monitor(Monitor p_monitor) const {
+double Performance::get_monitor(Monitor p_monitor) const {
switch (p_monitor) {
case TIME_FPS:
return Engine::get_singleton()->get_frames_per_second();
@@ -207,11 +207,11 @@ Performance::MonitorType Performance::get_monitor_type(Monitor p_monitor) const
return types[p_monitor];
}
-void Performance::set_process_time(float p_pt) {
+void Performance::set_process_time(double p_pt) {
_process_time = p_pt;
}
-void Performance::set_physics_process_time(float p_pt) {
+void Performance::set_physics_process_time(double p_pt) {
_physics_process_time = p_pt;
}
diff --git a/main/performance.h b/main/performance.h
index 174b3500d1..4653051ebb 100644
--- a/main/performance.h
+++ b/main/performance.h
@@ -43,10 +43,10 @@ class Performance : public Object {
static Performance *singleton;
static void _bind_methods();
- float _get_node_count() const;
+ int _get_node_count() const;
- float _process_time;
- float _physics_process_time;
+ double _process_time;
+ double _physics_process_time;
class MonitorCall {
Callable _callable;
@@ -96,13 +96,13 @@ public:
MONITOR_TYPE_TIME
};
- float get_monitor(Monitor p_monitor) const;
+ double get_monitor(Monitor p_monitor) const;
String get_monitor_name(Monitor p_monitor) const;
MonitorType get_monitor_type(Monitor p_monitor) const;
- void set_process_time(float p_pt);
- void set_physics_process_time(float p_pt);
+ void set_process_time(double p_pt);
+ void set_physics_process_time(double p_pt);
void add_custom_monitor(const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args);
void remove_custom_monitor(const StringName &p_id);