summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2017-04-07 16:17:16 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2017-04-07 16:35:55 +0200
commit665bf529481c0dbe9345d2473bce8f8d99ece0c5 (patch)
treec878883448dfbba3cf1095f8d0f6b09537fd7655 /scene
parent65f8210e503dd6cc8fdfcae7de5cb7d9a1bed854 (diff)
Optimize-out some debug and/or non-tools methods
Collisions and nav debug are conditionally compiled depending on DEBUG_ENABLED is_editor_hint() and is_node_being_edited() are compiled only with TOOLS_ENABLED Every affected method is implemented in the header in case its macro is not present (the getters just returning false and the setters having an empty body) so the compiler can inline and finally no-op-out them as likely as possible. is_node_being_edited() already showed a similar optimization effort and has been adapted to this change. Furthermore, and as a consequence, -debugcol and -debugnav will not work on non-debug (strict release) builds. This can bring a little bit of runtime performance on release and non-tooled builds (less code, so less cycles to spend and maybe more cache friendly).
Diffstat (limited to 'scene')
-rw-r--r--scene/main/scene_main_loop.cpp13
-rw-r--r--scene/main/scene_main_loop.h21
2 files changed, 29 insertions, 5 deletions
diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp
index 79ee4a6f75..c7aecd784d 100644
--- a/scene/main/scene_main_loop.cpp
+++ b/scene/main/scene_main_loop.cpp
@@ -678,24 +678,24 @@ void SceneTree::set_quit_on_go_back(bool p_enable) {
quit_on_go_back = p_enable;
}
+#ifdef TOOLS_ENABLED
void SceneTree::set_editor_hint(bool p_enabled) {
editor_hint = p_enabled;
}
bool SceneTree::is_node_being_edited(const Node *p_node) const {
-#ifdef TOOLS_ENABLED
+
return editor_hint && edited_scene_root && edited_scene_root->is_a_parent_of(p_node);
-#else
- return false;
-#endif
}
bool SceneTree::is_editor_hint() const {
return editor_hint;
}
+#endif
+#ifdef DEBUG_ENABLED
void SceneTree::set_debug_collisions_hint(bool p_enabled) {
debug_collisions_hint = p_enabled;
@@ -715,6 +715,7 @@ bool SceneTree::is_debugging_navigation_hint() const {
return debug_navigation_hint;
}
+#endif
void SceneTree::set_debug_collisions_color(const Color &p_color) {
@@ -2260,9 +2261,13 @@ SceneTree::SceneTree() {
singleton = this;
_quit = false;
initialized = false;
+#ifdef TOOLS_ENABLED
editor_hint = false;
+#endif
+#ifdef DEBUG_ENABLED
debug_collisions_hint = false;
debug_navigation_hint = false;
+#endif
debug_collisions_color = GLOBAL_DEF("debug/collision/shape_color", Color(0.0, 0.6, 0.7, 0.5));
debug_collision_contact_color = GLOBAL_DEF("debug/collision/contact_color", Color(1.0, 0.2, 0.1, 0.8));
debug_navigation_color = GLOBAL_DEF("debug/navigation/geometry_color", Color(0.1, 1.0, 0.7, 0.4));
diff --git a/scene/main/scene_main_loop.h b/scene/main/scene_main_loop.h
index fadf77e30f..2658264604 100644
--- a/scene/main/scene_main_loop.h
+++ b/scene/main/scene_main_loop.h
@@ -108,9 +108,13 @@ private:
bool quit_on_go_back;
uint32_t last_id;
+#ifdef TOOLS_ENABLED
bool editor_hint;
+#endif
+#ifdef DEBUG_ENABLED
bool debug_collisions_hint;
bool debug_navigation_hint;
+#endif
bool pause;
int root_lock;
@@ -353,10 +357,17 @@ public:
_FORCE_INLINE_ float get_fixed_process_time() const { return fixed_process_time; }
_FORCE_INLINE_ float get_idle_process_time() const { return idle_process_time; }
+#ifdef TOOLS_ENABLED
void set_editor_hint(bool p_enabled);
- bool is_editor_hint() const;
+ bool is_editor_hint() const;
bool is_node_being_edited(const Node *p_node) const;
+#else
+ void set_editor_hint(bool p_enabled) {}
+
+ bool is_editor_hint() const { return false; }
+ bool is_node_being_edited(const Node *p_node) const { return false; }
+#endif
void set_pause(bool p_enabled);
bool is_paused() const;
@@ -364,11 +375,19 @@ public:
void set_camera(const RID &p_camera);
RID get_camera() const;
+#ifdef DEBUG_ENABLED
void set_debug_collisions_hint(bool p_enabled);
bool is_debugging_collisions_hint() const;
void set_debug_navigation_hint(bool p_enabled);
bool is_debugging_navigation_hint() const;
+#else
+ void set_debug_collisions_hint(bool p_enabled) {}
+ bool is_debugging_collisions_hint() const { return false; }
+
+ void set_debug_navigation_hint(bool p_enabled) {}
+ bool is_debugging_navigation_hint() const { return false; }
+#endif
void set_debug_collisions_color(const Color &p_color);
Color get_debug_collisions_color() const;