-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathadd_custom_iterator.patch
86 lines (75 loc) · 3.19 KB
/
add_custom_iterator.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
diff --git a/SConstruct b/SConstruct
index 9dcc6c554f..6e98983e18 100644
--- a/SConstruct
+++ b/SConstruct
@@ -646,6 +646,15 @@ if selected_platform in platform_list:
env.module_icons_paths.append(path + "/" + "icons")
modules_enabled[name] = path
+ if getattr(config, "has_custom_iterator", False) and config.has_custom_iterator():
+ env.AppendUnique(CPPDEFINES=["CUSTOM_ITERATOR"])
+
+ if getattr(config, "has_custom_physics_iterator", False) and config.has_custom_physics_iterator():
+ env.AppendUnique(CPPDEFINES=["CUSTOM_PHYSICS_ITERATOR"])
+
+ if getattr(config, "has_custom_audio_iterator", False) and config.has_custom_audio_iterator():
+ env.AppendUnique(CPPDEFINES=["CUSTOM_AUDIO_ITERATOR"])
+
sys.path.remove(path)
sys.modules.pop("config")
diff --git a/core/config/engine.h b/core/config/engine.h
index ae33acede2..045a5215b6 100644
--- a/core/config/engine.h
+++ b/core/config/engine.h
@@ -92,8 +92,10 @@ public:
uint64_t get_frames_drawn();
+ void set_physics_frames(uint32_t p_physics_frames) { _physics_frames = p_physics_frames; }
uint64_t get_physics_frames() const { return _physics_frames; }
uint64_t get_process_frames() const { return _process_frames; }
+ void set_in_physics_frame(bool p_in_physics) { _in_physics = p_in_physics; }
bool is_in_physics_frame() const { return _in_physics; }
uint64_t get_frame_ticks() const { return _frame_ticks; }
double get_process_step() const { return _process_step; }
diff --git a/main/main.cpp b/main/main.cpp
index 9b7f960660..449fb531f4 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -2639,6 +2639,13 @@ bool Main::iteration() {
// process all our active interfaces
XRServer::get_singleton()->_process();
+#ifdef CUSTOM_ITERATOR
+ exit = custom_iteration(process_step, physics_step, &advance, time_scale);
+#endif
+
+#ifndef CUSTOM_PHYSICS_ITERATOR
+ Engine::get_singleton()->_in_physics = true;
+
for (int iters = 0; iters < advance.physics_steps; ++iters) {
if (Input::get_singleton()->is_using_input_buffering() && agile_input_event_flushing) {
Input::get_singleton()->flush_buffered_events();
@@ -2681,6 +2688,8 @@ bool Main::iteration() {
if (Input::get_singleton()->is_using_input_buffering() && agile_input_event_flushing) {
Input::get_singleton()->flush_buffered_events();
}
+ Engine::get_singleton()->_in_physics = false;
+#endif
uint64_t process_begin = OS::get_singleton()->get_ticks_usec();
@@ -2713,7 +2722,9 @@ bool Main::iteration() {
ScriptServer::get_language(i)->frame();
}
+#ifndef CUSTOM_AUDIO_ITERATOR
AudioServer::get_singleton()->update();
+#endif
if (EngineDebugger::is_active()) {
EngineDebugger::get_singleton()->iteration(frame_time, process_ticks, physics_process_ticks, physics_step);
diff --git a/main/main.h b/main/main.h
index 4911ff42b4..9441d7fc85 100644
--- a/main/main.h
+++ b/main/main.h
@@ -56,6 +56,9 @@ public:
#endif
static bool start();
+#ifdef CUSTOM_ITERATOR
+ static bool custom_iteration(float p_process_delta, float p_physics_delta, struct MainFrameTime *p_frame_time, float p_time_scale);
+#endif
static bool iteration();
static void force_redraw();