summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/canvas_item.cpp6
-rw-r--r--scene/main/canvas_item.h1
-rw-r--r--scene/main/node.cpp79
-rw-r--r--scene/main/node.h13
-rw-r--r--scene/main/scene_tree.cpp2
-rw-r--r--scene/main/scene_tree.h5
6 files changed, 25 insertions, 81 deletions
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index f2415eaf71..f329332725 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -151,9 +151,7 @@ void CanvasItem::_update_callback() {
current_item_drawn = this;
notification(NOTIFICATION_DRAW);
emit_signal(SceneStringNames::get_singleton()->draw);
- if (get_script_instance()) {
- get_script_instance()->call(SceneStringNames::get_singleton()->_draw);
- }
+ GDVIRTUAL_CALL(_draw);
current_item_drawn = nullptr;
drawing = false;
}
@@ -934,7 +932,7 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_clip_children", "enable"), &CanvasItem::set_clip_children);
ClassDB::bind_method(D_METHOD("is_clipping_children"), &CanvasItem::is_clipping_children);
- BIND_VMETHOD(MethodInfo("_draw"));
+ GDVIRTUAL_BIND(_draw);
ADD_GROUP("Visibility", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible");
diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h
index dc7ad2bf5d..a591cab485 100644
--- a/scene/main/canvas_item.h
+++ b/scene/main/canvas_item.h
@@ -142,6 +142,7 @@ protected:
void _notification(int p_what);
static void _bind_methods();
+ GDVIRTUAL0(_draw)
public:
enum {
NOTIFICATION_TRANSFORM_CHANGED = SceneTree::NOTIFICATION_TRANSFORM_CHANGED, //unique
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index d869b465ed..1d617d1ff7 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -54,20 +54,11 @@ int Node::orphan_node_count = 0;
void Node::_notification(int p_notification) {
switch (p_notification) {
case NOTIFICATION_PROCESS: {
- if (get_script_instance()) {
- double d_time = get_process_delta_time();
- data.process_cumulative_time += d_time;
- Variant time = d_time;
- get_script_instance()->call(SceneStringNames::get_singleton()->_process, time);
- }
+ GDVIRTUAL_CALL(_process, get_process_delta_time());
+
} break;
case NOTIFICATION_PHYSICS_PROCESS: {
- if (get_script_instance()) {
- double d_time = get_physics_process_delta_time();
- data.physics_process_cumulative_time += d_time;
- Variant time = d_time;
- get_script_instance()->call(SceneStringNames::get_singleton()->_physics_process, time);
- }
+ GDVIRTUAL_CALL(_physics_process, get_process_delta_time());
} break;
case NOTIFICATION_ENTER_TREE: {
@@ -144,15 +135,14 @@ void Node::_notification(int p_notification) {
set_process_unhandled_key_input(true);
}
- if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_process)) {
+ if (GDVIRTUAL_IS_OVERRIDEN(_process)) {
set_process(true);
}
-
- if (get_script_instance()->has_method(SceneStringNames::get_singleton()->_physics_process)) {
+ if (GDVIRTUAL_IS_OVERRIDEN(_physics_process)) {
set_physics_process(true);
}
- get_script_instance()->call(SceneStringNames::get_singleton()->_ready);
+ GDVIRTUAL_CALL(_ready);
}
if (data.filename.length()) {
ERR_FAIL_COND(!is_inside_tree());
@@ -225,9 +215,7 @@ void Node::_propagate_enter_tree() {
notification(NOTIFICATION_ENTER_TREE);
- if (get_script_instance()) {
- get_script_instance()->call(SceneStringNames::get_singleton()->_enter_tree);
- }
+ GDVIRTUAL_CALL(_enter_tree);
emit_signal(SceneStringNames::get_singleton()->tree_entered);
@@ -273,9 +261,8 @@ void Node::_propagate_exit_tree() {
data.blocked--;
- if (get_script_instance()) {
- get_script_instance()->call(SceneStringNames::get_singleton()->_exit_tree);
- }
+ GDVIRTUAL_CALL(_exit_tree);
+
emit_signal(SceneStringNames::get_singleton()->tree_exiting);
notification(NOTIFICATION_EXIT_TREE, true);
@@ -724,22 +711,6 @@ double Node::get_physics_process_delta_time() const {
}
}
-double Node::get_physics_process_cumulative_time() const {
- if (data.tree) {
- return data.physics_process_cumulative_time;
- } else {
- return 0;
- }
-}
-
-double Node::get_physics_process_total_time() const {
- if (data.tree) {
- return data.tree->get_physics_total_time();
- } else {
- return 0;
- }
-}
-
double Node::get_process_delta_time() const {
if (data.tree) {
return data.tree->get_process_time();
@@ -766,22 +737,6 @@ bool Node::is_processing() const {
return data.process;
}
-double Node::get_process_cumulative_time() const {
- if (data.tree) {
- return data.process_cumulative_time;
- } else {
- return 0;
- }
-}
-
-double Node::get_process_total_time() const {
- if (data.tree) {
- return data.tree->get_process_total_time();
- } else {
- return 0;
- }
-}
-
void Node::set_process_internal(bool p_process_internal) {
if (data.process_internal == p_process_internal) {
return;
@@ -2627,12 +2582,8 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("propagate_call", "method", "args", "parent_first"), &Node::propagate_call, DEFVAL(Array()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_physics_process", "enable"), &Node::set_physics_process);
ClassDB::bind_method(D_METHOD("get_physics_process_delta_time"), &Node::get_physics_process_delta_time);
- ClassDB::bind_method(D_METHOD("get_physics_process_cumulative_time"), &Node::get_physics_process_cumulative_time);
- ClassDB::bind_method(D_METHOD("get_physics_process_total_time"), &Node::get_physics_process_total_time);
ClassDB::bind_method(D_METHOD("is_physics_processing"), &Node::is_physics_processing);
ClassDB::bind_method(D_METHOD("get_process_delta_time"), &Node::get_process_delta_time);
- ClassDB::bind_method(D_METHOD("get_process_cumulative_time"), &Node::get_process_cumulative_time);
- ClassDB::bind_method(D_METHOD("get_process_total_time"), &Node::get_process_total_time);
ClassDB::bind_method(D_METHOD("set_process", "enable"), &Node::set_process);
ClassDB::bind_method(D_METHOD("set_process_priority", "priority"), &Node::set_process_priority);
ClassDB::bind_method(D_METHOD("get_process_priority"), &Node::get_process_priority);
@@ -2777,11 +2728,13 @@ void Node::_bind_methods() {
ADD_GROUP("Editor Description", "editor_");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "editor_description", PROPERTY_HINT_MULTILINE_TEXT, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_INTERNAL), "set_editor_description", "get_editor_description");
- BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::FLOAT, "delta")));
- BIND_VMETHOD(MethodInfo("_physics_process", PropertyInfo(Variant::FLOAT, "delta")));
- BIND_VMETHOD(MethodInfo("_enter_tree"));
- BIND_VMETHOD(MethodInfo("_exit_tree"));
- BIND_VMETHOD(MethodInfo("_ready"));
+ GDVIRTUAL_BIND(_process, "delta");
+ GDVIRTUAL_BIND(_physics_process, "delta");
+ GDVIRTUAL_BIND(_enter_tree);
+ GDVIRTUAL_BIND(_exit_tree);
+ GDVIRTUAL_BIND(_ready);
+ GDVIRTUAL_BIND(_get_configuration_warnings);
+
BIND_VMETHOD(MethodInfo("_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
BIND_VMETHOD(MethodInfo("_unhandled_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
BIND_VMETHOD(MethodInfo("_unhandled_key_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEventKey")));
diff --git a/scene/main/node.h b/scene/main/node.h
index b800d2401e..8aa56aa97f 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -122,9 +122,6 @@ private:
int network_master = 1; // Server by default.
Vector<MultiplayerAPI::RPCConfig> rpc_methods;
- double process_cumulative_time = 0.0;
- double physics_process_cumulative_time = 0.0;
-
// Variables used to properly sort the node when processing, ignored otherwise.
// TODO: Should move all the stuff below to bits.
bool physics_process = false;
@@ -211,6 +208,12 @@ protected:
void _set_owner_nocheck(Node *p_owner);
void _set_name_nocheck(const StringName &p_name);
+ GDVIRTUAL1(_process, double)
+ GDVIRTUAL1(_physics_process, double)
+ GDVIRTUAL0(_enter_tree)
+ GDVIRTUAL0(_exit_tree)
+ GDVIRTUAL0(_ready)
+ GDVIRTUAL0RC(Vector<String>, _get_configuration_warnings)
public:
enum {
// you can make your own, but don't use the same numbers as other notifications in other nodes
@@ -344,14 +347,10 @@ public:
/* PROCESSING */
void set_physics_process(bool p_process);
double get_physics_process_delta_time() const;
- double get_physics_process_cumulative_time() const;
- double get_physics_process_total_time() const;
bool is_physics_processing() const;
void set_process(bool p_process);
double get_process_delta_time() const;
- double get_process_cumulative_time() const;
- double get_process_total_time() const;
bool is_processing() const;
void set_physics_process_internal(bool p_process_internal);
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 606b9df3a3..5b707498a7 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -412,7 +412,6 @@ bool SceneTree::physics_process(double p_time) {
MainLoop::physics_process(p_time);
physics_process_time = p_time;
- physics_total_time += p_time;
emit_signal(SNAME("physics_frame"));
@@ -439,7 +438,6 @@ bool SceneTree::process(double p_time) {
MainLoop::process(p_time);
process_time = p_time;
- process_total_time += p_time;
if (multiplayer_poll) {
multiplayer->poll();
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index ff6ca52a69..cfb95bd6b5 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -92,10 +92,7 @@ private:
uint64_t tree_version = 1;
double physics_process_time = 1.0;
- double physics_total_time = 0.0;
- double process_total_time = 0.0;
double process_time = 1.0;
-
bool accept_quit = true;
bool quit_on_go_back = true;
@@ -251,9 +248,7 @@ public:
void quit(int p_exit_code = EXIT_SUCCESS);
_FORCE_INLINE_ double get_physics_process_time() const { return physics_process_time; }
- _FORCE_INLINE_ double get_physics_total_time() const { return physics_total_time; }
_FORCE_INLINE_ double get_process_time() const { return process_time; }
- _FORCE_INLINE_ double get_process_total_time() const { return process_total_time; }
#ifdef TOOLS_ENABLED
bool is_node_being_edited(const Node *p_node) const;