summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/canvas_layer.cpp10
-rw-r--r--scene/main/http_request.cpp52
-rw-r--r--scene/main/http_request.h6
-rw-r--r--scene/main/instance_placeholder.cpp8
-rw-r--r--scene/main/instance_placeholder.h1
-rw-r--r--scene/main/node.cpp226
-rw-r--r--scene/main/node.h39
-rw-r--r--scene/main/resource_preloader.cpp8
-rw-r--r--scene/main/resource_preloader.h2
-rw-r--r--scene/main/scene_tree.cpp503
-rw-r--r--scene/main/scene_tree.h43
-rwxr-xr-xscene/main/timer.cpp4
-rw-r--r--scene/main/viewport.cpp253
-rw-r--r--scene/main/viewport.h82
14 files changed, 438 insertions, 799 deletions
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index 4ae018a79a..2085fa3a60 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -200,7 +200,7 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) {
if (custom_viewport) {
custom_viewport_id = custom_viewport->get_instance_id();
} else {
- custom_viewport_id = 0;
+ custom_viewport_id = ObjectID();
}
if (is_inside_tree()) {
@@ -307,15 +307,15 @@ void CanvasLayer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "layer", PROPERTY_HINT_RANGE, "-128,128,1"), "set_layer", "get_layer");
ADD_GROUP("Transform", "");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation_degrees", PROPERTY_HINT_RANGE, "-1080,1080,0.1,or_lesser,or_greater", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_rotation", "get_rotation");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation_degrees", PROPERTY_HINT_RANGE, "-1080,1080,0.1,or_lesser,or_greater", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_rotation", "get_rotation");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform");
ADD_GROUP("", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_viewport", PROPERTY_HINT_RESOURCE_TYPE, "Viewport", 0), "set_custom_viewport", "get_custom_viewport");
ADD_GROUP("Follow Viewport", "follow_viewport");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "follow_viewport_enable"), "set_follow_viewport", "is_following_viewport");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "follow_viewport_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001,or_greater,or_lesser"), "set_follow_viewport_scale", "get_follow_viewport_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "follow_viewport_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001,or_greater,or_lesser"), "set_follow_viewport_scale", "get_follow_viewport_scale");
}
CanvasLayer::CanvasLayer() {
@@ -327,7 +327,7 @@ CanvasLayer::CanvasLayer() {
layer = 1;
canvas = VS::get_singleton()->canvas_create();
custom_viewport = NULL;
- custom_viewport_id = 0;
+
sort_index = 0;
follow_viewport = false;
follow_viewport_scale = 1.0;
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index 3c89069816..fee2ada76d 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -118,7 +118,7 @@ Error HTTPRequest::request(const String &p_url, const Vector<String> &p_custom_h
client->set_blocking_mode(false);
err = _request();
if (err != OK) {
- call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PoolStringArray(), PoolByteArray());
+ call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray());
return ERR_CANT_CONNECT;
}
@@ -135,7 +135,7 @@ void HTTPRequest::_thread_func(void *p_userdata) {
Error err = hr->_request();
if (err != OK) {
- hr->call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PoolStringArray(), PoolByteArray());
+ hr->call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray());
} else {
while (!hr->thread_request_quit) {
@@ -180,7 +180,7 @@ void HTTPRequest::cancel_request() {
bool HTTPRequest::_handle_response(bool *ret_value) {
if (!client->has_response()) {
- call_deferred("_request_done", RESULT_NO_RESPONSE, 0, PoolStringArray(), PoolByteArray());
+ call_deferred("_request_done", RESULT_NO_RESPONSE, 0, PackedStringArray(), PackedByteArray());
*ret_value = true;
return true;
}
@@ -200,7 +200,7 @@ bool HTTPRequest::_handle_response(bool *ret_value) {
if (max_redirects >= 0 && redirections >= max_redirects) {
- call_deferred("_request_done", RESULT_REDIRECT_LIMIT_REACHED, response_code, response_headers, PoolByteArray());
+ call_deferred("_request_done", RESULT_REDIRECT_LIMIT_REACHED, response_code, response_headers, PackedByteArray());
*ret_value = true;
return true;
}
@@ -246,7 +246,7 @@ bool HTTPRequest::_update_connection() {
switch (client->get_status()) {
case HTTPClient::STATUS_DISCONNECTED: {
- call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PoolStringArray(), PoolByteArray());
+ call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray());
return true; // End it, since it's doing something
} break;
case HTTPClient::STATUS_RESOLVING: {
@@ -255,7 +255,7 @@ bool HTTPRequest::_update_connection() {
return false;
} break;
case HTTPClient::STATUS_CANT_RESOLVE: {
- call_deferred("_request_done", RESULT_CANT_RESOLVE, 0, PoolStringArray(), PoolByteArray());
+ call_deferred("_request_done", RESULT_CANT_RESOLVE, 0, PackedStringArray(), PackedByteArray());
return true;
} break;
@@ -266,7 +266,7 @@ bool HTTPRequest::_update_connection() {
} break; // Connecting to IP
case HTTPClient::STATUS_CANT_CONNECT: {
- call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PoolStringArray(), PoolByteArray());
+ call_deferred("_request_done", RESULT_CANT_CONNECT, 0, PackedStringArray(), PackedByteArray());
return true;
} break;
@@ -283,7 +283,7 @@ bool HTTPRequest::_update_connection() {
if (_handle_response(&ret_value))
return ret_value;
- call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PoolByteArray());
+ call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PackedByteArray());
return true;
}
if (body_len < 0) {
@@ -292,7 +292,7 @@ bool HTTPRequest::_update_connection() {
return true;
}
- call_deferred("_request_done", RESULT_CHUNKED_BODY_SIZE_MISMATCH, response_code, response_headers, PoolByteArray());
+ call_deferred("_request_done", RESULT_CHUNKED_BODY_SIZE_MISMATCH, response_code, response_headers, PackedByteArray());
return true;
// Request migh have been done
} else {
@@ -300,7 +300,7 @@ bool HTTPRequest::_update_connection() {
Error err = client->request(method, request_string, headers, request_data);
if (err != OK) {
- call_deferred("_request_done", RESULT_CONNECTION_ERROR, 0, PoolStringArray(), PoolByteArray());
+ call_deferred("_request_done", RESULT_CONNECTION_ERROR, 0, PackedStringArray(), PackedByteArray());
return true;
}
@@ -325,7 +325,7 @@ bool HTTPRequest::_update_connection() {
if (!client->is_response_chunked() && client->get_response_body_length() == 0) {
- call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PoolByteArray());
+ call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PackedByteArray());
return true;
}
@@ -334,7 +334,7 @@ bool HTTPRequest::_update_connection() {
body_len = client->get_response_body_length();
if (body_size_limit >= 0 && body_len > body_size_limit) {
- call_deferred("_request_done", RESULT_BODY_SIZE_LIMIT_EXCEEDED, response_code, response_headers, PoolByteArray());
+ call_deferred("_request_done", RESULT_BODY_SIZE_LIMIT_EXCEEDED, response_code, response_headers, PackedByteArray());
return true;
}
@@ -342,7 +342,7 @@ bool HTTPRequest::_update_connection() {
file = FileAccess::open(download_to_file, FileAccess::WRITE);
if (!file) {
- call_deferred("_request_done", RESULT_DOWNLOAD_FILE_CANT_OPEN, response_code, response_headers, PoolByteArray());
+ call_deferred("_request_done", RESULT_DOWNLOAD_FILE_CANT_OPEN, response_code, response_headers, PackedByteArray());
return true;
}
}
@@ -350,14 +350,14 @@ bool HTTPRequest::_update_connection() {
client->poll();
- PoolByteArray chunk = client->read_response_body_chunk();
+ PackedByteArray chunk = client->read_response_body_chunk();
downloaded += chunk.size();
if (file) {
- PoolByteArray::Read r = chunk.read();
- file->store_buffer(r.ptr(), chunk.size());
+ const uint8_t *r = chunk.ptr();
+ file->store_buffer(r, chunk.size());
if (file->get_error() != OK) {
- call_deferred("_request_done", RESULT_DOWNLOAD_FILE_WRITE_ERROR, response_code, response_headers, PoolByteArray());
+ call_deferred("_request_done", RESULT_DOWNLOAD_FILE_WRITE_ERROR, response_code, response_headers, PackedByteArray());
return true;
}
} else {
@@ -365,7 +365,7 @@ bool HTTPRequest::_update_connection() {
}
if (body_size_limit >= 0 && downloaded > body_size_limit) {
- call_deferred("_request_done", RESULT_BODY_SIZE_LIMIT_EXCEEDED, response_code, response_headers, PoolByteArray());
+ call_deferred("_request_done", RESULT_BODY_SIZE_LIMIT_EXCEEDED, response_code, response_headers, PackedByteArray());
return true;
}
@@ -384,11 +384,11 @@ bool HTTPRequest::_update_connection() {
} break; // Request resulted in body: break which must be read
case HTTPClient::STATUS_CONNECTION_ERROR: {
- call_deferred("_request_done", RESULT_CONNECTION_ERROR, 0, PoolStringArray(), PoolByteArray());
+ call_deferred("_request_done", RESULT_CONNECTION_ERROR, 0, PackedStringArray(), PackedByteArray());
return true;
} break;
case HTTPClient::STATUS_SSL_HANDSHAKE_ERROR: {
- call_deferred("_request_done", RESULT_SSL_HANDSHAKE_ERROR, 0, PoolStringArray(), PoolByteArray());
+ call_deferred("_request_done", RESULT_SSL_HANDSHAKE_ERROR, 0, PackedStringArray(), PackedByteArray());
return true;
} break;
}
@@ -396,7 +396,7 @@ bool HTTPRequest::_update_connection() {
ERR_FAIL_V(false);
}
-void HTTPRequest::_request_done(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data) {
+void HTTPRequest::_request_done(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data) {
cancel_request();
emit_signal("request_completed", p_status, p_code, headers, p_data);
@@ -505,12 +505,12 @@ int HTTPRequest::get_timeout() {
void HTTPRequest::_timeout() {
cancel_request();
- call_deferred("_request_done", RESULT_TIMEOUT, 0, PoolStringArray(), PoolByteArray());
+ call_deferred("_request_done", RESULT_TIMEOUT, 0, PackedStringArray(), PackedByteArray());
}
void HTTPRequest::_bind_methods() {
- ClassDB::bind_method(D_METHOD("request", "url", "custom_headers", "ssl_validate_domain", "method", "request_data"), &HTTPRequest::request, DEFVAL(PoolStringArray()), DEFVAL(true), DEFVAL(HTTPClient::METHOD_GET), DEFVAL(String()));
+ ClassDB::bind_method(D_METHOD("request", "url", "custom_headers", "ssl_validate_domain", "method", "request_data"), &HTTPRequest::request, DEFVAL(PackedStringArray()), DEFVAL(true), DEFVAL(HTTPClient::METHOD_GET), DEFVAL(String()));
ClassDB::bind_method(D_METHOD("cancel_request"), &HTTPRequest::cancel_request);
ClassDB::bind_method(D_METHOD("get_http_client_status"), &HTTPRequest::get_http_client_status);
@@ -539,8 +539,6 @@ void HTTPRequest::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_download_chunk_size"), &HTTPRequest::set_download_chunk_size);
ClassDB::bind_method(D_METHOD("get_download_chunk_size"), &HTTPRequest::get_download_chunk_size);
- ClassDB::bind_method(D_METHOD("_timeout"), &HTTPRequest::_timeout);
-
ADD_PROPERTY(PropertyInfo(Variant::STRING, "download_file", PROPERTY_HINT_FILE), "set_download_file", "get_download_file");
ADD_PROPERTY(PropertyInfo(Variant::INT, "download_chunk_size", PROPERTY_HINT_RANGE, "256,16777216"), "set_download_chunk_size", "get_download_chunk_size");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_threads"), "set_use_threads", "is_using_threads");
@@ -548,7 +546,7 @@ void HTTPRequest::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_redirects", PROPERTY_HINT_RANGE, "-1,64"), "set_max_redirects", "get_max_redirects");
ADD_PROPERTY(PropertyInfo(Variant::INT, "timeout", PROPERTY_HINT_RANGE, "0,86400"), "set_timeout", "get_timeout");
- ADD_SIGNAL(MethodInfo("request_completed", PropertyInfo(Variant::INT, "result"), PropertyInfo(Variant::INT, "response_code"), PropertyInfo(Variant::POOL_STRING_ARRAY, "headers"), PropertyInfo(Variant::POOL_BYTE_ARRAY, "body")));
+ ADD_SIGNAL(MethodInfo("request_completed", PropertyInfo(Variant::INT, "result"), PropertyInfo(Variant::INT, "response_code"), PropertyInfo(Variant::PACKED_STRING_ARRAY, "headers"), PropertyInfo(Variant::PACKED_BYTE_ARRAY, "body")));
BIND_ENUM_CONSTANT(RESULT_SUCCESS);
//BIND_ENUM_CONSTANT( RESULT_NO_BODY );
@@ -589,7 +587,7 @@ HTTPRequest::HTTPRequest() {
timer = memnew(Timer);
timer->set_one_shot(true);
- timer->connect("timeout", this, "_timeout");
+ timer->connect("timeout", callable_mp(this, &HTTPRequest::_timeout));
add_child(timer);
timeout = 0;
}
diff --git a/scene/main/http_request.h b/scene/main/http_request.h
index 94b323ae8a..a3d95cd652 100644
--- a/scene/main/http_request.h
+++ b/scene/main/http_request.h
@@ -73,12 +73,12 @@ private:
bool request_sent;
Ref<HTTPClient> client;
- PoolByteArray body;
+ PackedByteArray body;
volatile bool use_threads;
bool got_response;
int response_code;
- PoolVector<String> response_headers;
+ Vector<String> response_headers;
String download_to_file;
@@ -108,7 +108,7 @@ private:
Thread *thread;
- void _request_done(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
+ void _request_done(int p_status, int p_code, const PackedStringArray &headers, const PackedByteArray &p_data);
static void _thread_func(void *p_userdata);
protected:
diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp
index 0128d1a218..fe238af1c4 100644
--- a/scene/main/instance_placeholder.cpp
+++ b/scene/main/instance_placeholder.cpp
@@ -112,15 +112,10 @@ Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene
return scene;
}
-void InstancePlaceholder::replace_by_instance(const Ref<PackedScene> &p_custom_scene) {
- //Deprecated by
- create_instance(true, p_custom_scene);
-}
-
Dictionary InstancePlaceholder::get_stored_values(bool p_with_order) {
Dictionary ret;
- PoolStringArray order;
+ PackedStringArray order;
for (List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) {
ret[E->get().name] = E->get().value;
@@ -138,7 +133,6 @@ void InstancePlaceholder::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_stored_values", "with_order"), &InstancePlaceholder::get_stored_values, DEFVAL(false));
ClassDB::bind_method(D_METHOD("create_instance", "replace", "custom_scene"), &InstancePlaceholder::create_instance, DEFVAL(false), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("replace_by_instance", "custom_scene"), &InstancePlaceholder::replace_by_instance, DEFVAL(Variant()));
ClassDB::bind_method(D_METHOD("get_instance_path"), &InstancePlaceholder::get_instance_path);
}
diff --git a/scene/main/instance_placeholder.h b/scene/main/instance_placeholder.h
index d570b8c247..9f7b84716d 100644
--- a/scene/main/instance_placeholder.h
+++ b/scene/main/instance_placeholder.h
@@ -61,7 +61,6 @@ public:
Dictionary get_stored_values(bool p_with_order = false);
Node *create_instance(bool p_replace = false, const Ref<PackedScene> &p_custom_scene = Ref<PackedScene>());
- void replace_by_instance(const Ref<PackedScene> &p_custom_scene = Ref<PackedScene>());
InstancePlaceholder();
};
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 761fe3f90f..973dff07d2 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -35,6 +35,7 @@
#include "core/message_queue.h"
#include "core/print_string.h"
#include "instance_placeholder.h"
+#include "scene/debugger/scene_debugger.h"
#include "scene/resources/packed_scene.h"
#include "scene/scene_string_names.h"
#include "viewport.h"
@@ -43,6 +44,8 @@
#include "editor/editor_settings.h"
#endif
+#include <stdint.h>
+
VARIANT_ENUM_CAST(Node::PauseMode);
int Node::orphan_node_count = 0;
@@ -242,11 +245,7 @@ void Node::_propagate_enter_tree() {
data.blocked--;
#ifdef DEBUG_ENABLED
-
- if (ScriptDebugger::get_singleton() && data.filename != String()) {
- //used for live edit
- data.tree->live_scene_edit_cache[data.filename].insert(this);
- }
+ SceneDebugger::add_to_cache(data.filename, this);
#endif
// enter groups
}
@@ -266,26 +265,7 @@ void Node::_propagate_exit_tree() {
//block while removing children
#ifdef DEBUG_ENABLED
-
- if (ScriptDebugger::get_singleton() && data.filename != String()) {
- //used for live edit
- Map<String, Set<Node *> >::Element *E = data.tree->live_scene_edit_cache.find(data.filename);
- if (E) {
- E->get().erase(this);
- if (E->get().size() == 0) {
- data.tree->live_scene_edit_cache.erase(E);
- }
- }
-
- Map<Node *, Map<ObjectID, Node *> >::Element *F = data.tree->live_edit_remove_list.find(this);
- if (F) {
- for (Map<ObjectID, Node *>::Element *G = F->get().front(); G; G = G->next()) {
-
- memdelete(G->get());
- }
- data.tree->live_edit_remove_list.erase(F);
- }
- }
+ SceneDebugger::remove_from_cache(data.filename, this);
#endif
data.blocked++;
@@ -498,22 +478,38 @@ bool Node::is_network_master() const {
/***** RPC CONFIG ********/
-void Node::rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_mode) {
+uint16_t Node::rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_mode) {
- if (p_mode == MultiplayerAPI::RPC_MODE_DISABLED) {
- data.rpc_methods.erase(p_method);
+ uint16_t mid = get_node_rpc_method_id(p_method);
+ if (mid == UINT16_MAX) {
+ // It's new
+ NetData nd;
+ nd.name = p_method;
+ nd.mode = p_mode;
+ data.rpc_methods.push_back(nd);
+ return ((uint16_t)data.rpc_properties.size() - 1) | (1 << 15);
} else {
- data.rpc_methods[p_method] = p_mode;
- };
+ int c_mid = (~(1 << 15)) & mid;
+ data.rpc_methods.write[c_mid].mode = p_mode;
+ return mid;
+ }
}
-void Node::rset_config(const StringName &p_property, MultiplayerAPI::RPCMode p_mode) {
+uint16_t Node::rset_config(const StringName &p_property, MultiplayerAPI::RPCMode p_mode) {
- if (p_mode == MultiplayerAPI::RPC_MODE_DISABLED) {
- data.rpc_properties.erase(p_property);
+ uint16_t pid = get_node_rset_property_id(p_property);
+ if (pid == UINT16_MAX) {
+ // It's new
+ NetData nd;
+ nd.name = p_property;
+ nd.mode = p_mode;
+ data.rpc_properties.push_back(nd);
+ return ((uint16_t)data.rpc_properties.size() - 1) | (1 << 15);
} else {
- data.rpc_properties[p_property] = p_mode;
- };
+ int c_pid = (~(1 << 15)) & pid;
+ data.rpc_properties.write[c_pid].mode = p_mode;
+ return pid;
+ }
}
/***** RPC FUNCTIONS ********/
@@ -574,16 +570,16 @@ void Node::rpc_unreliable_id(int p_peer_id, const StringName &p_method, VARIANT_
rpcp(p_peer_id, true, p_method, argptr, argc);
}
-Variant Node::_rpc_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant Node::_rpc_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
if (p_argcount < 1) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
return Variant();
}
if (p_args[0]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
return Variant();
@@ -593,27 +589,27 @@ Variant Node::_rpc_bind(const Variant **p_args, int p_argcount, Variant::CallErr
rpcp(0, false, method, &p_args[1], p_argcount - 1);
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
return Variant();
}
-Variant Node::_rpc_id_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant Node::_rpc_id_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
if (p_argcount < 2) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 2;
return Variant();
}
if (p_args[0]->get_type() != Variant::INT) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::INT;
return Variant();
}
if (p_args[1]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
r_error.expected = Variant::STRING;
return Variant();
@@ -624,20 +620,20 @@ Variant Node::_rpc_id_bind(const Variant **p_args, int p_argcount, Variant::Call
rpcp(peer_id, false, method, &p_args[2], p_argcount - 2);
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
return Variant();
}
-Variant Node::_rpc_unreliable_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant Node::_rpc_unreliable_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
if (p_argcount < 1) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 1;
return Variant();
}
if (p_args[0]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::STRING;
return Variant();
@@ -647,27 +643,27 @@ Variant Node::_rpc_unreliable_bind(const Variant **p_args, int p_argcount, Varia
rpcp(0, true, method, &p_args[1], p_argcount - 1);
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
return Variant();
}
-Variant Node::_rpc_unreliable_id_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant Node::_rpc_unreliable_id_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
if (p_argcount < 2) {
- r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
+ r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
r_error.argument = 2;
return Variant();
}
if (p_args[0]->get_type() != Variant::INT) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 0;
r_error.expected = Variant::INT;
return Variant();
}
if (p_args[1]->get_type() != Variant::STRING) {
- r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
+ r_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
r_error.argument = 1;
r_error.expected = Variant::STRING;
return Variant();
@@ -678,7 +674,7 @@ Variant Node::_rpc_unreliable_id_bind(const Variant **p_args, int p_argcount, Va
rpcp(peer_id, true, method, &p_args[2], p_argcount - 2);
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
return Variant();
}
@@ -731,12 +727,94 @@ void Node::set_custom_multiplayer(Ref<MultiplayerAPI> p_multiplayer) {
multiplayer = p_multiplayer;
}
-const Map<StringName, MultiplayerAPI::RPCMode>::Element *Node::get_node_rpc_mode(const StringName &p_method) {
- return data.rpc_methods.find(p_method);
+uint16_t Node::get_node_rpc_method_id(const StringName &p_method) const {
+ for (int i = 0; i < data.rpc_methods.size(); i++) {
+ if (data.rpc_methods[i].name == p_method) {
+ // Returns `i` with the high bit set to 1 so we know that this id comes
+ // from the node and not the script.
+ return i | (1 << 15);
+ }
+ }
+ return UINT16_MAX;
+}
+
+StringName Node::get_node_rpc_method(const uint16_t p_rpc_method_id) const {
+ // Make sure this is a node generated ID.
+ if (((1 << 15) & p_rpc_method_id) > 0) {
+ int mid = (~(1 << 15)) & p_rpc_method_id;
+ if (mid < data.rpc_methods.size())
+ return data.rpc_methods[mid].name;
+ }
+ return StringName();
+}
+
+MultiplayerAPI::RPCMode Node::get_node_rpc_mode_by_id(const uint16_t p_rpc_method_id) const {
+ // Make sure this is a node generated ID.
+ if (((1 << 15) & p_rpc_method_id) > 0) {
+ int mid = (~(1 << 15)) & p_rpc_method_id;
+ if (mid < data.rpc_methods.size())
+ return data.rpc_methods[mid].mode;
+ }
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+}
+
+MultiplayerAPI::RPCMode Node::get_node_rpc_mode(const StringName &p_method) const {
+ return get_node_rpc_mode_by_id(get_node_rpc_method_id(p_method));
+}
+
+uint16_t Node::get_node_rset_property_id(const StringName &p_property) const {
+ for (int i = 0; i < data.rpc_properties.size(); i++) {
+ if (data.rpc_properties[i].name == p_property) {
+ // Returns `i` with the high bit set to 1 so we know that this id comes
+ // from the node and not the script.
+ return i | (1 << 15);
+ }
+ }
+ return UINT16_MAX;
+}
+
+StringName Node::get_node_rset_property(const uint16_t p_rset_property_id) const {
+ // Make sure this is a node generated ID.
+ if (((1 << 15) & p_rset_property_id) > 0) {
+ int mid = (~(1 << 15)) & p_rset_property_id;
+ if (mid < data.rpc_properties.size())
+ return data.rpc_properties[mid].name;
+ }
+ return StringName();
+}
+
+MultiplayerAPI::RPCMode Node::get_node_rset_mode_by_id(const uint16_t p_rset_property_id) const {
+ if (((1 << 15) & p_rset_property_id) > 0) {
+ int mid = (~(1 << 15)) & p_rset_property_id;
+ if (mid < data.rpc_properties.size())
+ return data.rpc_properties[mid].mode;
+ }
+ return MultiplayerAPI::RPC_MODE_DISABLED;
+}
+
+MultiplayerAPI::RPCMode Node::get_node_rset_mode(const StringName &p_property) const {
+ return get_node_rset_mode_by_id(get_node_rset_property_id(p_property));
}
-const Map<StringName, MultiplayerAPI::RPCMode>::Element *Node::get_node_rset_mode(const StringName &p_property) {
- return data.rpc_properties.find(p_property);
+String Node::get_rpc_md5() const {
+ String rpc_list;
+ for (int i = 0; i < data.rpc_methods.size(); i += 1) {
+ rpc_list += String(data.rpc_methods[i].name);
+ }
+ for (int i = 0; i < data.rpc_properties.size(); i += 1) {
+ rpc_list += String(data.rpc_properties[i].name);
+ }
+ if (get_script_instance()) {
+ Vector<ScriptNetData> rpc = get_script_instance()->get_rpc_methods();
+ for (int i = 0; i < rpc.size(); i += 1) {
+ rpc_list += String(rpc[i].name);
+ }
+ rpc = get_script_instance()->get_rset_properties();
+ for (int i = 0; i < rpc.size(); i += 1) {
+ rpc_list += String(rpc[i].name);
+ }
+ }
+ return rpc_list.md5_text();
}
bool Node::can_process_notification(int p_what) const {
@@ -2260,7 +2338,7 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
NodePath p = p_original->get_path_to(this);
Node *copy = p_copy->get_node(p);
- Node *target = Object::cast_to<Node>(E->get().target);
+ Node *target = Object::cast_to<Node>(E->get().callable.get_object());
if (!target) {
continue;
}
@@ -2268,15 +2346,18 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const {
Node *copytarget = target;
- // Atempt to find a path to the duplicate target, if it seems it's not part
+ // Attempt to find a path to the duplicate target, if it seems it's not part
// of the duplicated and not yet parented hierarchy then at least try to connect
// to the same target as the original
if (p_copy->has_node(ptarget))
copytarget = p_copy->get_node(ptarget);
- if (copy && copytarget && !copy->is_connected(E->get().signal, copytarget, E->get().method)) {
- copy->connect(E->get().signal, copytarget, E->get().method, E->get().binds, E->get().flags);
+ if (copy && copytarget) {
+ const Callable copy_callable = Callable(copytarget, E->get().callable.get_method());
+ if (!copy->is_connected(E->get().signal.get_name(), copy_callable)) {
+ copy->connect(E->get().signal.get_name(), copy_callable, E->get().binds, E->get().flags);
+ }
}
}
}
@@ -2431,10 +2512,10 @@ void Node::_replace_connections_target(Node *p_new_target) {
Connection &c = E->get();
if (c.flags & CONNECT_PERSIST) {
- c.source->disconnect(c.signal, this, c.method);
- bool valid = p_new_target->has_method(c.method) || Ref<Script>(p_new_target->get_script()).is_null() || Ref<Script>(p_new_target->get_script())->has_method(c.method);
- ERR_CONTINUE_MSG(!valid, "Attempt to connect signal '" + c.source->get_class() + "." + c.signal + "' to nonexistent method '" + c.target->get_class() + "." + c.method + "'.");
- c.source->connect(c.signal, p_new_target, c.method, c.binds, c.flags);
+ c.signal.get_object()->disconnect(c.signal.get_name(), Callable(this, c.callable.get_method()));
+ bool valid = p_new_target->has_method(c.callable.get_method()) || Ref<Script>(p_new_target->get_script()).is_null() || Ref<Script>(p_new_target->get_script())->has_method(c.callable.get_method());
+ ERR_CONTINUE_MSG(!valid, "Attempt to connect signal '" + c.signal.get_object()->get_class() + "." + c.signal.get_name() + "' to nonexistent method '" + c.callable.get_object()->get_class() + "." + c.callable.get_method() + "'.");
+ c.signal.get_object()->connect(c.signal.get_name(), Callable(p_new_target, c.callable.get_method()), c.binds, c.flags);
}
}
}
@@ -2722,7 +2803,7 @@ void Node::_bind_methods() {
GLOBAL_DEF("node/name_casing", NAME_CASING_PASCAL_CASE);
ProjectSettings::get_singleton()->set_custom_property_info("node/name_casing", PropertyInfo(Variant::INT, "node/name_casing", PROPERTY_HINT_ENUM, "PascalCase,camelCase,snake_case"));
- ClassDB::bind_method(D_METHOD("add_child_below_node", "node", "child_node", "legible_unique_name"), &Node::add_child_below_node, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("add_child_below_node", "preceding_node", "node", "legible_unique_name"), &Node::add_child_below_node, DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_name", "name"), &Node::set_name);
ClassDB::bind_method(D_METHOD("get_name"), &Node::get_name);
@@ -2826,7 +2907,7 @@ void Node::_bind_methods() {
{
MethodInfo mi;
- mi.arguments.push_back(PropertyInfo(Variant::STRING, "method"));
+ mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "method"));
mi.name = "rpc";
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "rpc", &Node::_rpc_bind, mi);
@@ -2898,20 +2979,15 @@ void Node::_bind_methods() {
ADD_GROUP("Pause", "pause_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "pause_mode", PROPERTY_HINT_ENUM, "Inherit,Stop,Process"), "set_pause_mode", "get_pause_mode");
-#ifdef ENABLE_DEPRECATED
- //no longer exists, but remains for compatibility (keep previous scenes folded
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor/display_folded", PROPERTY_HINT_NONE, "", 0), "set_display_folded", "is_displayed_folded");
-#endif
-
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "name", PROPERTY_HINT_NONE, "", 0), "set_name", "get_name");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "name", PROPERTY_HINT_NONE, "", 0), "set_name", "get_name");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "filename", PROPERTY_HINT_NONE, "", 0), "set_filename", "get_filename");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "owner", PROPERTY_HINT_RESOURCE_TYPE, "Node", 0), "set_owner", "get_owner");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", 0), "", "get_multiplayer");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "custom_multiplayer", PROPERTY_HINT_RESOURCE_TYPE, "MultiplayerAPI", 0), "set_custom_multiplayer", "get_custom_multiplayer");
ADD_PROPERTY(PropertyInfo(Variant::INT, "process_priority"), "set_process_priority", "get_process_priority");
- BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta")));
- BIND_VMETHOD(MethodInfo("_physics_process", PropertyInfo(Variant::REAL, "delta")));
+ 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"));
diff --git a/scene/main/node.h b/scene/main/node.h
index 6f5544d654..d1f75b71ec 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -85,6 +85,11 @@ private:
GroupData() { persistent = false; }
};
+ struct NetData {
+ StringName name;
+ MultiplayerAPI::RPCMode mode;
+ };
+
struct Data {
String filename;
@@ -118,8 +123,8 @@ private:
Node *pause_owner;
int network_master;
- Map<StringName, MultiplayerAPI::RPCMode> rpc_methods;
- Map<StringName, MultiplayerAPI::RPCMode> rpc_properties;
+ Vector<NetData> rpc_methods;
+ Vector<NetData> rpc_properties;
// variables used to properly sort the node when processing, ignored otherwise
//should move all the stuff below to bits
@@ -180,10 +185,10 @@ private:
Array _get_children() const;
Array _get_groups() const;
- Variant _rpc_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
- Variant _rpc_unreliable_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
- Variant _rpc_id_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
- Variant _rpc_unreliable_id_bind(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ Variant _rpc_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
+ Variant _rpc_unreliable_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
+ Variant _rpc_id_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
+ Variant _rpc_unreliable_id_bind(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
friend class SceneTree;
@@ -427,8 +432,8 @@ public:
int get_network_master() const;
bool is_network_master() const;
- void rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_mode); // config a local method for RPC
- void rset_config(const StringName &p_property, MultiplayerAPI::RPCMode p_mode); // config a local property for RPC
+ uint16_t rpc_config(const StringName &p_method, MultiplayerAPI::RPCMode p_mode); // config a local method for RPC
+ uint16_t rset_config(const StringName &p_property, MultiplayerAPI::RPCMode p_mode); // config a local property for RPC
void rpc(const StringName &p_method, VARIANT_ARG_LIST); //rpc call, honors RPCMode
void rpc_unreliable(const StringName &p_method, VARIANT_ARG_LIST); //rpc call, honors RPCMode
@@ -446,8 +451,22 @@ public:
Ref<MultiplayerAPI> get_multiplayer() const;
Ref<MultiplayerAPI> get_custom_multiplayer() const;
void set_custom_multiplayer(Ref<MultiplayerAPI> p_multiplayer);
- const Map<StringName, MultiplayerAPI::RPCMode>::Element *get_node_rpc_mode(const StringName &p_method);
- const Map<StringName, MultiplayerAPI::RPCMode>::Element *get_node_rset_mode(const StringName &p_property);
+
+ /// Returns the rpc method ID, otherwise UINT32_MAX
+ uint16_t get_node_rpc_method_id(const StringName &p_method) const;
+ StringName get_node_rpc_method(const uint16_t p_rpc_method_id) const;
+ MultiplayerAPI::RPCMode get_node_rpc_mode_by_id(const uint16_t p_rpc_method_id) const;
+ MultiplayerAPI::RPCMode get_node_rpc_mode(const StringName &p_method) const;
+
+ /// Returns the rpc property ID, otherwise UINT32_MAX
+ uint16_t get_node_rset_property_id(const StringName &p_property) const;
+ StringName get_node_rset_property(const uint16_t p_rset_property_id) const;
+ MultiplayerAPI::RPCMode get_node_rset_mode_by_id(const uint16_t p_rpc_method_id) const;
+ MultiplayerAPI::RPCMode get_node_rset_mode(const StringName &p_property) const;
+
+ /// Can be used to check if the rpc methods and the rset properties are the
+ /// same across the peers.
+ String get_rpc_md5() const;
Node();
~Node();
diff --git a/scene/main/resource_preloader.cpp b/scene/main/resource_preloader.cpp
index 5582ed59b0..43a61834eb 100644
--- a/scene/main/resource_preloader.cpp
+++ b/scene/main/resource_preloader.cpp
@@ -35,7 +35,7 @@ void ResourcePreloader::_set_resources(const Array &p_data) {
resources.clear();
ERR_FAIL_COND(p_data.size() != 2);
- PoolVector<String> names = p_data[0];
+ Vector<String> names = p_data[0];
Array resdata = p_data[1];
ERR_FAIL_COND(names.size() != resdata.size());
@@ -53,7 +53,7 @@ void ResourcePreloader::_set_resources(const Array &p_data) {
Array ResourcePreloader::_get_resources() const {
- PoolVector<String> names;
+ Vector<String> names;
Array arr;
arr.resize(resources.size());
names.resize(resources.size());
@@ -129,9 +129,9 @@ RES ResourcePreloader::get_resource(const StringName &p_name) const {
return resources[p_name];
}
-PoolVector<String> ResourcePreloader::_get_resource_list() const {
+Vector<String> ResourcePreloader::_get_resource_list() const {
- PoolVector<String> res;
+ Vector<String> res;
res.resize(resources.size());
int i = 0;
for (Map<StringName, RES>::Element *E = resources.front(); E; E = E->next(), i++) {
diff --git a/scene/main/resource_preloader.h b/scene/main/resource_preloader.h
index d03c784883..9ad219dd92 100644
--- a/scene/main/resource_preloader.h
+++ b/scene/main/resource_preloader.h
@@ -41,7 +41,7 @@ class ResourcePreloader : public Node {
void _set_resources(const Array &p_data);
Array _get_resources() const;
- PoolVector<String> _get_resource_list() const;
+ Vector<String> _get_resource_list() const;
protected:
static void _bind_methods();
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index c0e566eed5..370cf6a2a4 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -38,14 +38,16 @@
#include "core/os/os.h"
#include "core/print_string.h"
#include "core/project_settings.h"
+#include "core/script_debugger_remote.h"
#include "main/input_default.h"
#include "node.h"
-#include "scene/debugger/script_debugger_remote.h"
+#include "scene/debugger/scene_debugger.h"
#include "scene/resources/dynamic_font.h"
#include "scene/resources/material.h"
#include "scene/resources/mesh.h"
#include "scene/resources/packed_scene.h"
#include "scene/scene_string_names.h"
+#include "servers/navigation_server.h"
#include "servers/physics_2d_server.h"
#include "servers/physics_server.h"
#include "viewport.h"
@@ -57,7 +59,7 @@ void SceneTreeTimer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_time_left", "time"), &SceneTreeTimer::set_time_left);
ClassDB::bind_method(D_METHOD("get_time_left"), &SceneTreeTimer::get_time_left);
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_left"), "set_time_left", "get_time_left");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_left"), "set_time_left", "get_time_left");
ADD_SIGNAL(MethodInfo("timeout"));
}
@@ -86,7 +88,7 @@ void SceneTreeTimer::release_connections() {
for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
Connection const &connection = E->get();
- disconnect(connection.signal, connection.target, connection.method);
+ disconnect(connection.signal.get_name(), connection.callable);
}
}
@@ -433,7 +435,7 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) {
if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote()) {
//quit from game window using F8
Ref<InputEventKey> k = ev;
- if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_scancode() == KEY_F8) {
+ if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == KEY_F8) {
ScriptDebugger::get_singleton()->request_quit();
}
}
@@ -791,11 +793,11 @@ Ref<Material> SceneTree::get_debug_navigation_material() {
if (navigation_material.is_valid())
return navigation_material;
- Ref<SpatialMaterial> line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
- line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ Ref<StandardMaterial3D> line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ line_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ line_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
+ line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
line_material->set_albedo(get_debug_navigation_color());
navigation_material = line_material;
@@ -808,11 +810,11 @@ Ref<Material> SceneTree::get_debug_navigation_disabled_material() {
if (navigation_disabled_material.is_valid())
return navigation_disabled_material;
- Ref<SpatialMaterial> line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
- line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ Ref<StandardMaterial3D> line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ line_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ line_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
+ line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
line_material->set_albedo(get_debug_navigation_disabled_color());
navigation_disabled_material = line_material;
@@ -824,11 +826,11 @@ Ref<Material> SceneTree::get_debug_collision_material() {
if (collision_material.is_valid())
return collision_material;
- Ref<SpatialMaterial> line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
- line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ Ref<StandardMaterial3D> line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ line_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ line_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
+ line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
line_material->set_albedo(get_debug_collisions_color());
collision_material = line_material;
@@ -843,11 +845,11 @@ Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() {
debug_contact_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
- Ref<SpatialMaterial> mat = Ref<SpatialMaterial>(memnew(SpatialMaterial));
- mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
- mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
- mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
- mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ Ref<StandardMaterial3D> mat = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
+ mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
+ mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
+ mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
mat->set_albedo(get_debug_collision_contact_color());
Vector3 diamond[6] = {
@@ -872,11 +874,11 @@ Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() {
};
/* clang-format on */
- PoolVector<int> indices;
+ Vector<int> indices;
for (int i = 0; i < 8 * 3; i++)
indices.push_back(diamond_faces[i]);
- PoolVector<Vector3> vertices;
+ Vector<Vector3> vertices;
for (int i = 0; i < 6; i++)
vertices.push_back(diamond[i] * 0.1);
@@ -896,6 +898,7 @@ void SceneTree::set_pause(bool p_enabled) {
if (p_enabled == pause)
return;
pause = p_enabled;
+ NavigationServer::get_singleton()->set_active(!p_enabled);
PhysicsServer::get_singleton()->set_active(!p_enabled);
Physics2DServer::get_singleton()->set_active(!p_enabled);
if (get_root())
@@ -1002,14 +1005,14 @@ void SceneMainLoop::_update_listener_2d() {
}
*/
-Variant SceneTree::_call_group_flags(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant SceneTree::_call_group_flags(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
ERR_FAIL_COND_V(p_argcount < 3, Variant());
ERR_FAIL_COND_V(!p_args[0]->is_num(), Variant());
- ERR_FAIL_COND_V(p_args[1]->get_type() != Variant::STRING, Variant());
- ERR_FAIL_COND_V(p_args[2]->get_type() != Variant::STRING, Variant());
+ ERR_FAIL_COND_V(p_args[1]->get_type() != Variant::STRING_NAME && p_args[1]->get_type() != Variant::STRING, Variant());
+ ERR_FAIL_COND_V(p_args[2]->get_type() != Variant::STRING_NAME && p_args[2]->get_type() != Variant::STRING, Variant());
int flags = *p_args[0];
StringName group = *p_args[1];
@@ -1025,13 +1028,13 @@ Variant SceneTree::_call_group_flags(const Variant **p_args, int p_argcount, Var
return Variant();
}
-Variant SceneTree::_call_group(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant SceneTree::_call_group(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
- r_error.error = Variant::CallError::CALL_OK;
+ r_error.error = Callable::CallError::CALL_OK;
ERR_FAIL_COND_V(p_argcount < 2, Variant());
- ERR_FAIL_COND_V(p_args[0]->get_type() != Variant::STRING, Variant());
- ERR_FAIL_COND_V(p_args[1]->get_type() != Variant::STRING, Variant());
+ ERR_FAIL_COND_V(p_args[0]->get_type() != Variant::STRING_NAME && p_args[0]->get_type() != Variant::STRING, Variant());
+ ERR_FAIL_COND_V(p_args[1]->get_type() != Variant::STRING_NAME && p_args[1]->get_type() != Variant::STRING, Variant());
StringName group = *p_args[0];
StringName method = *p_args[1];
@@ -1327,380 +1330,6 @@ void SceneTree::add_current_scene(Node *p_current) {
root->add_child(p_current);
}
-#ifdef DEBUG_ENABLED
-
-static void _fill_array(Node *p_node, Array &array, int p_level) {
-
- array.push_back(p_node->get_child_count());
- array.push_back(p_node->get_name());
- array.push_back(p_node->get_class());
- array.push_back(p_node->get_instance_id());
- for (int i = 0; i < p_node->get_child_count(); i++) {
-
- _fill_array(p_node->get_child(i), array, p_level + 1);
- }
-}
-
-void SceneTree::_debugger_request_tree() {
-
- Array arr;
- _fill_array(root, arr, 0);
- ScriptDebugger::get_singleton()->send_message("scene_tree", arr);
-}
-
-void SceneTree::_live_edit_node_path_func(const NodePath &p_path, int p_id) {
-
- live_edit_node_path_cache[p_id] = p_path;
-}
-
-void SceneTree::_live_edit_res_path_func(const String &p_path, int p_id) {
-
- live_edit_resource_cache[p_id] = p_path;
-}
-
-void SceneTree::_live_edit_node_set_func(int p_id, const StringName &p_prop, const Variant &p_value) {
-
- if (!live_edit_node_path_cache.has(p_id))
- return;
-
- NodePath np = live_edit_node_path_cache[p_id];
- Node *base = NULL;
- if (root->has_node(live_edit_root))
- base = root->get_node(live_edit_root);
-
- Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
- return; //scene not editable
-
- for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
-
- Node *n = F->get();
-
- if (base && !base->is_a_parent_of(n))
- continue;
-
- if (!n->has_node(np))
- continue;
- Node *n2 = n->get_node(np);
-
- n2->set(p_prop, p_value);
- }
-}
-
-void SceneTree::_live_edit_node_set_res_func(int p_id, const StringName &p_prop, const String &p_value) {
-
- RES r = ResourceLoader::load(p_value);
- if (!r.is_valid())
- return;
- _live_edit_node_set_func(p_id, p_prop, r);
-}
-void SceneTree::_live_edit_node_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
-
- if (!live_edit_node_path_cache.has(p_id))
- return;
-
- NodePath np = live_edit_node_path_cache[p_id];
- Node *base = NULL;
- if (root->has_node(live_edit_root))
- base = root->get_node(live_edit_root);
-
- Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
- return; //scene not editable
-
- for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
-
- Node *n = F->get();
-
- if (base && !base->is_a_parent_of(n))
- continue;
-
- if (!n->has_node(np))
- continue;
- Node *n2 = n->get_node(np);
-
- n2->call(p_method, VARIANT_ARG_PASS);
- }
-}
-void SceneTree::_live_edit_res_set_func(int p_id, const StringName &p_prop, const Variant &p_value) {
-
- if (!live_edit_resource_cache.has(p_id))
- return;
-
- String resp = live_edit_resource_cache[p_id];
-
- if (!ResourceCache::has(resp))
- return;
-
- RES r = ResourceCache::get(resp);
- if (!r.is_valid())
- return;
-
- r->set(p_prop, p_value);
-}
-void SceneTree::_live_edit_res_set_res_func(int p_id, const StringName &p_prop, const String &p_value) {
-
- RES r = ResourceLoader::load(p_value);
- if (!r.is_valid())
- return;
- _live_edit_res_set_func(p_id, p_prop, r);
-}
-void SceneTree::_live_edit_res_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE) {
-
- if (!live_edit_resource_cache.has(p_id))
- return;
-
- String resp = live_edit_resource_cache[p_id];
-
- if (!ResourceCache::has(resp))
- return;
-
- RES r = ResourceCache::get(resp);
- if (!r.is_valid())
- return;
-
- r->call(p_method, VARIANT_ARG_PASS);
-}
-
-void SceneTree::_live_edit_root_func(const NodePath &p_scene_path, const String &p_scene_from) {
-
- live_edit_root = p_scene_path;
- live_edit_scene = p_scene_from;
-}
-
-void SceneTree::_live_edit_create_node_func(const NodePath &p_parent, const String &p_type, const String &p_name) {
-
- Node *base = NULL;
- if (root->has_node(live_edit_root))
- base = root->get_node(live_edit_root);
-
- Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
- return; //scene not editable
-
- for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
-
- Node *n = F->get();
-
- if (base && !base->is_a_parent_of(n))
- continue;
-
- if (!n->has_node(p_parent))
- continue;
- Node *n2 = n->get_node(p_parent);
-
- Node *no = Object::cast_to<Node>(ClassDB::instance(p_type));
- if (!no) {
- continue;
- }
-
- no->set_name(p_name);
- n2->add_child(no);
- }
-}
-void SceneTree::_live_edit_instance_node_func(const NodePath &p_parent, const String &p_path, const String &p_name) {
-
- Ref<PackedScene> ps = ResourceLoader::load(p_path);
-
- if (!ps.is_valid())
- return;
-
- Node *base = NULL;
- if (root->has_node(live_edit_root))
- base = root->get_node(live_edit_root);
-
- Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
- return; //scene not editable
-
- for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
-
- Node *n = F->get();
-
- if (base && !base->is_a_parent_of(n))
- continue;
-
- if (!n->has_node(p_parent))
- continue;
- Node *n2 = n->get_node(p_parent);
-
- Node *no = ps->instance();
- if (!no) {
- continue;
- }
-
- no->set_name(p_name);
- n2->add_child(no);
- }
-}
-void SceneTree::_live_edit_remove_node_func(const NodePath &p_at) {
-
- Node *base = NULL;
- if (root->has_node(live_edit_root))
- base = root->get_node(live_edit_root);
-
- Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
- return; //scene not editable
-
- for (Set<Node *>::Element *F = E->get().front(); F;) {
-
- Set<Node *>::Element *N = F->next();
-
- Node *n = F->get();
-
- if (base && !base->is_a_parent_of(n))
- continue;
-
- if (!n->has_node(p_at))
- continue;
- Node *n2 = n->get_node(p_at);
-
- memdelete(n2);
-
- F = N;
- }
-}
-void SceneTree::_live_edit_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_keep_id) {
-
- Node *base = NULL;
- if (root->has_node(live_edit_root))
- base = root->get_node(live_edit_root);
-
- Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
- return; //scene not editable
-
- for (Set<Node *>::Element *F = E->get().front(); F;) {
-
- Set<Node *>::Element *N = F->next();
-
- Node *n = F->get();
-
- if (base && !base->is_a_parent_of(n))
- continue;
-
- if (!n->has_node(p_at))
- continue;
-
- Node *n2 = n->get_node(p_at);
-
- n2->get_parent()->remove_child(n2);
-
- live_edit_remove_list[n][p_keep_id] = n2;
-
- F = N;
- }
-}
-void SceneTree::_live_edit_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_at_pos) {
-
- Node *base = NULL;
- if (root->has_node(live_edit_root))
- base = root->get_node(live_edit_root);
-
- Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
- return; //scene not editable
-
- for (Set<Node *>::Element *F = E->get().front(); F;) {
-
- Set<Node *>::Element *N = F->next();
-
- Node *n = F->get();
-
- if (base && !base->is_a_parent_of(n))
- continue;
-
- if (!n->has_node(p_at))
- continue;
- Node *n2 = n->get_node(p_at);
-
- Map<Node *, Map<ObjectID, Node *> >::Element *EN = live_edit_remove_list.find(n);
-
- if (!EN)
- continue;
-
- Map<ObjectID, Node *>::Element *FN = EN->get().find(p_id);
-
- if (!FN)
- continue;
- n2->add_child(FN->get());
-
- EN->get().erase(FN);
-
- if (EN->get().size() == 0) {
- live_edit_remove_list.erase(EN);
- }
-
- F = N;
- }
-}
-void SceneTree::_live_edit_duplicate_node_func(const NodePath &p_at, const String &p_new_name) {
-
- Node *base = NULL;
- if (root->has_node(live_edit_root))
- base = root->get_node(live_edit_root);
-
- Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
- return; //scene not editable
-
- for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
-
- Node *n = F->get();
-
- if (base && !base->is_a_parent_of(n))
- continue;
-
- if (!n->has_node(p_at))
- continue;
- Node *n2 = n->get_node(p_at);
-
- Node *dup = n2->duplicate(Node::DUPLICATE_SIGNALS | Node::DUPLICATE_GROUPS | Node::DUPLICATE_SCRIPTS);
-
- if (!dup)
- continue;
-
- dup->set_name(p_new_name);
- n2->get_parent()->add_child(dup);
- }
-}
-void SceneTree::_live_edit_reparent_node_func(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) {
-
- Node *base = NULL;
- if (root->has_node(live_edit_root))
- base = root->get_node(live_edit_root);
-
- Map<String, Set<Node *> >::Element *E = live_scene_edit_cache.find(live_edit_scene);
- if (!E)
- return; //scene not editable
-
- for (Set<Node *>::Element *F = E->get().front(); F; F = F->next()) {
-
- Node *n = F->get();
-
- if (base && !base->is_a_parent_of(n))
- continue;
-
- if (!n->has_node(p_at))
- continue;
- Node *nfrom = n->get_node(p_at);
-
- if (!n->has_node(p_new_place))
- continue;
- Node *nto = n->get_node(p_new_place);
-
- nfrom->get_parent()->remove_child(nfrom);
- nfrom->set_name(p_new_name);
-
- nto->add_child(nfrom);
- if (p_at_pos >= 0)
- nto->move_child(nfrom, p_at_pos);
- }
-}
-
-#endif
-
void SceneTree::drop_files(const Vector<String> &p_files, int p_from_screen) {
emit_signal("files_dropped", p_files, p_from_screen);
@@ -1764,21 +1393,21 @@ void SceneTree::set_multiplayer(Ref<MultiplayerAPI> p_multiplayer) {
ERR_FAIL_COND(!p_multiplayer.is_valid());
if (multiplayer.is_valid()) {
- multiplayer->disconnect("network_peer_connected", this, "_network_peer_connected");
- multiplayer->disconnect("network_peer_disconnected", this, "_network_peer_disconnected");
- multiplayer->disconnect("connected_to_server", this, "_connected_to_server");
- multiplayer->disconnect("connection_failed", this, "_connection_failed");
- multiplayer->disconnect("server_disconnected", this, "_server_disconnected");
+ multiplayer->disconnect("network_peer_connected", callable_mp(this, &SceneTree::_network_peer_connected));
+ multiplayer->disconnect("network_peer_disconnected", callable_mp(this, &SceneTree::_network_peer_disconnected));
+ multiplayer->disconnect("connected_to_server", callable_mp(this, &SceneTree::_connected_to_server));
+ multiplayer->disconnect("connection_failed", callable_mp(this, &SceneTree::_connection_failed));
+ multiplayer->disconnect("server_disconnected", callable_mp(this, &SceneTree::_server_disconnected));
}
multiplayer = p_multiplayer;
multiplayer->set_root_node(root);
- multiplayer->connect("network_peer_connected", this, "_network_peer_connected");
- multiplayer->connect("network_peer_disconnected", this, "_network_peer_disconnected");
- multiplayer->connect("connected_to_server", this, "_connected_to_server");
- multiplayer->connect("connection_failed", this, "_connection_failed");
- multiplayer->connect("server_disconnected", this, "_server_disconnected");
+ multiplayer->connect("network_peer_connected", callable_mp(this, &SceneTree::_network_peer_connected));
+ multiplayer->connect("network_peer_disconnected", callable_mp(this, &SceneTree::_network_peer_disconnected));
+ multiplayer->connect("connected_to_server", callable_mp(this, &SceneTree::_connected_to_server));
+ multiplayer->connect("connection_failed", callable_mp(this, &SceneTree::_connection_failed));
+ multiplayer->connect("server_disconnected", callable_mp(this, &SceneTree::_server_disconnected));
}
void SceneTree::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_network_peer) {
@@ -1856,8 +1485,8 @@ void SceneTree::_bind_methods() {
MethodInfo mi;
mi.name = "call_group_flags";
mi.arguments.push_back(PropertyInfo(Variant::INT, "flags"));
- mi.arguments.push_back(PropertyInfo(Variant::STRING, "group"));
- mi.arguments.push_back(PropertyInfo(Variant::STRING, "method"));
+ mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "group"));
+ mi.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "method"));
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_group_flags", &SceneTree::_call_group_flags, mi);
@@ -1866,8 +1495,8 @@ void SceneTree::_bind_methods() {
MethodInfo mi2;
mi2.name = "call_group";
- mi2.arguments.push_back(PropertyInfo(Variant::STRING, "group"));
- mi2.arguments.push_back(PropertyInfo(Variant::STRING, "method"));
+ mi2.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "group"));
+ mi2.arguments.push_back(PropertyInfo(Variant::STRING_NAME, "method"));
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "call_group", &SceneTree::_call_group, mi2);
@@ -1899,11 +1528,6 @@ void SceneTree::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rpc_sender_id"), &SceneTree::get_rpc_sender_id);
ClassDB::bind_method(D_METHOD("set_refuse_new_network_connections", "refuse"), &SceneTree::set_refuse_new_network_connections);
ClassDB::bind_method(D_METHOD("is_refusing_new_network_connections"), &SceneTree::is_refusing_new_network_connections);
- ClassDB::bind_method(D_METHOD("_network_peer_connected"), &SceneTree::_network_peer_connected);
- ClassDB::bind_method(D_METHOD("_network_peer_disconnected"), &SceneTree::_network_peer_disconnected);
- ClassDB::bind_method(D_METHOD("_connected_to_server"), &SceneTree::_connected_to_server);
- ClassDB::bind_method(D_METHOD("_connection_failed"), &SceneTree::_connection_failed);
- ClassDB::bind_method(D_METHOD("_server_disconnected"), &SceneTree::_server_disconnected);
ClassDB::bind_method(D_METHOD("set_use_font_oversampling", "enable"), &SceneTree::set_use_font_oversampling);
ClassDB::bind_method(D_METHOD("is_using_font_oversampling"), &SceneTree::is_using_font_oversampling);
@@ -1931,7 +1555,7 @@ void SceneTree::_bind_methods() {
ADD_SIGNAL(MethodInfo("idle_frame"));
ADD_SIGNAL(MethodInfo("physics_frame"));
- ADD_SIGNAL(MethodInfo("files_dropped", PropertyInfo(Variant::POOL_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "screen")));
+ ADD_SIGNAL(MethodInfo("files_dropped", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files"), PropertyInfo(Variant::INT, "screen")));
ADD_SIGNAL(MethodInfo("global_menu_action", PropertyInfo(Variant::NIL, "id"), PropertyInfo(Variant::NIL, "meta")));
ADD_SIGNAL(MethodInfo("network_peer_connected", PropertyInfo(Variant::INT, "id")));
ADD_SIGNAL(MethodInfo("network_peer_disconnected", PropertyInfo(Variant::INT, "id")));
@@ -2071,22 +1695,10 @@ SceneTree::SceneTree() {
root->set_as_audio_listener_2d(true);
current_scene = NULL;
- int ref_atlas_size = GLOBAL_DEF("rendering/quality/reflections/atlas_size", 2048);
- ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/reflections/atlas_size", PropertyInfo(Variant::INT, "rendering/quality/reflections/atlas_size", PROPERTY_HINT_RANGE, "0,8192,or_greater")); //next_power_of_2 will return a 0 as min value
- int ref_atlas_subdiv = GLOBAL_DEF("rendering/quality/reflections/atlas_subdiv", 8);
- ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/reflections/atlas_subdiv", PropertyInfo(Variant::INT, "rendering/quality/reflections/atlas_subdiv", PROPERTY_HINT_RANGE, "0,32,or_greater")); //next_power_of_2 will return a 0 as min value
int msaa_mode = GLOBAL_DEF("rendering/quality/filters/msaa", 0);
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/msaa", PropertyInfo(Variant::INT, "rendering/quality/filters/msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x,AndroidVR 2x,AndroidVR 4x"));
root->set_msaa(Viewport::MSAA(msaa_mode));
- GLOBAL_DEF("rendering/quality/depth/hdr", true);
- GLOBAL_DEF("rendering/quality/depth/hdr.mobile", false);
-
- bool hdr = GLOBAL_GET("rendering/quality/depth/hdr");
- root->set_hdr(hdr);
-
- VS::get_singleton()->scenario_set_reflection_atlas_size(root->get_world()->get_scenario(), ref_atlas_size, ref_atlas_subdiv);
-
{ //load default fallback environment
//get possible extensions
List<String> exts;
@@ -2126,11 +1738,6 @@ SceneTree::SceneTree() {
_update_root_rect();
if (ScriptDebugger::get_singleton()) {
- if (ScriptDebugger::get_singleton()->is_remote()) {
- ScriptDebuggerRemote *remote_debugger = static_cast<ScriptDebuggerRemote *>(ScriptDebugger::get_singleton());
-
- remote_debugger->set_scene_tree(this);
- }
ScriptDebugger::get_singleton()->set_multiplayer(multiplayer);
}
@@ -2139,12 +1746,6 @@ SceneTree::SceneTree() {
#ifdef TOOLS_ENABLED
edited_scene_root = NULL;
#endif
-
-#ifdef DEBUG_ENABLED
-
- live_edit_root = NodePath("/root");
-
-#endif
}
SceneTree::~SceneTree() {
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 55304fb12d..1bef0d3131 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -44,6 +44,7 @@ class Node;
class Viewport;
class Material;
class Mesh;
+class SceneDebugger;
class SceneTreeTimer : public Reference {
GDCLASS(SceneTreeTimer, Reference);
@@ -208,8 +209,8 @@ private:
void _notify_group_pause(const StringName &p_group, int p_notification);
void _call_input_pause(const StringName &p_group, const StringName &p_method, const Ref<InputEvent> &p_input);
- Variant _call_group_flags(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
- Variant _call_group(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
+ Variant _call_group_flags(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
+ Variant _call_group(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
void _flush_delete_queue();
//optimization
@@ -219,39 +220,8 @@ private:
SelfList<Node>::List xform_change_list;
- friend class ScriptDebuggerRemote;
-#ifdef DEBUG_ENABLED
-
- Map<int, NodePath> live_edit_node_path_cache;
- Map<int, String> live_edit_resource_cache;
-
- NodePath live_edit_root;
- String live_edit_scene;
-
- Map<String, Set<Node *> > live_scene_edit_cache;
- Map<Node *, Map<ObjectID, Node *> > live_edit_remove_list;
-
- void _debugger_request_tree();
-
- void _live_edit_node_path_func(const NodePath &p_path, int p_id);
- void _live_edit_res_path_func(const String &p_path, int p_id);
-
- void _live_edit_node_set_func(int p_id, const StringName &p_prop, const Variant &p_value);
- void _live_edit_node_set_res_func(int p_id, const StringName &p_prop, const String &p_value);
- void _live_edit_node_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE);
- void _live_edit_res_set_func(int p_id, const StringName &p_prop, const Variant &p_value);
- void _live_edit_res_set_res_func(int p_id, const StringName &p_prop, const String &p_value);
- void _live_edit_res_call_func(int p_id, const StringName &p_method, VARIANT_ARG_DECLARE);
- void _live_edit_root_func(const NodePath &p_scene_path, const String &p_scene_from);
-
- void _live_edit_create_node_func(const NodePath &p_parent, const String &p_type, const String &p_name);
- void _live_edit_instance_node_func(const NodePath &p_parent, const String &p_path, const String &p_name);
- void _live_edit_remove_node_func(const NodePath &p_at);
- void _live_edit_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_keep_id);
- void _live_edit_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_at_pos);
- void _live_edit_duplicate_node_func(const NodePath &p_at, const String &p_new_name);
- void _live_edit_reparent_node_func(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos);
-
+#ifdef DEBUG_ENABLED // No live editor in release build.
+ friend class LiveEditor;
#endif
enum {
@@ -411,6 +381,9 @@ public:
bool is_refusing_new_network_connections() const;
static void add_idle_callback(IdleCallback p_callback);
+
+ //default texture settings
+
SceneTree();
~SceneTree();
};
diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp
index cb213be731..7c847095e1 100755
--- a/scene/main/timer.cpp
+++ b/scene/main/timer.cpp
@@ -206,11 +206,11 @@ void Timer::_bind_methods() {
ADD_SIGNAL(MethodInfo("timeout"));
ADD_PROPERTY(PropertyInfo(Variant::INT, "process_mode", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_timer_process_mode", "get_timer_process_mode");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "wait_time", PROPERTY_HINT_EXP_RANGE, "0.001,4096,0.001,or_greater"), "set_wait_time", "get_wait_time");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "wait_time", PROPERTY_HINT_EXP_RANGE, "0.001,4096,0.001,or_greater"), "set_wait_time", "get_wait_time");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "one_shot"), "set_one_shot", "is_one_shot");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autostart"), "set_autostart", "has_autostart");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused", PROPERTY_HINT_NONE, "", 0), "set_paused", "is_paused");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "time_left", PROPERTY_HINT_NONE, "", 0), "", "get_time_left");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "time_left", PROPERTY_HINT_NONE, "", 0), "", "get_time_left");
BIND_ENUM_CONSTANT(TIMER_PROCESS_PHYSICS);
BIND_ENUM_CONSTANT(TIMER_PROCESS_IDLE);
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 72ab817e98..e027ec9b4b 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -74,10 +74,13 @@ void ViewportTexture::setup_local_to_scene() {
vp->viewport_textures.insert(this);
- VS::get_singleton()->texture_set_proxy(proxy, vp->texture_rid);
-
- vp->texture_flags = flags;
- VS::get_singleton()->texture_set_flags(vp->texture_rid, flags);
+ if (proxy_ph.is_valid()) {
+ VS::get_singleton()->texture_proxy_update(proxy, vp->texture_rid);
+ VS::get_singleton()->free(proxy_ph);
+ } else {
+ ERR_FAIL_COND(proxy.is_valid()); //should be invalid
+ proxy = VS::get_singleton()->texture_proxy_create(vp->texture_rid);
+ }
}
void ViewportTexture::set_viewport_path_in_scene(const NodePath &p_path) {
@@ -115,6 +118,10 @@ Size2 ViewportTexture::get_size() const {
RID ViewportTexture::get_rid() const {
//ERR_FAIL_COND_V_MSG(!vp, RID(), "Viewport Texture must be set to use it.");
+ if (proxy.is_null()) {
+ proxy_ph = VS::get_singleton()->texture_2d_placeholder_create();
+ proxy = VS::get_singleton()->texture_proxy_create(proxy_ph);
+ }
return proxy;
}
@@ -125,21 +132,7 @@ bool ViewportTexture::has_alpha() const {
Ref<Image> ViewportTexture::get_data() const {
ERR_FAIL_COND_V_MSG(!vp, Ref<Image>(), "Viewport Texture must be set to use it.");
- return VS::get_singleton()->texture_get_data(vp->texture_rid);
-}
-void ViewportTexture::set_flags(uint32_t p_flags) {
- flags = p_flags;
-
- if (!vp)
- return;
-
- vp->texture_flags = flags;
- VS::get_singleton()->texture_set_flags(vp->texture_rid, flags);
-}
-
-uint32_t ViewportTexture::get_flags() const {
-
- return flags;
+ return VS::get_singleton()->texture_2d_get(vp->texture_rid);
}
void ViewportTexture::_bind_methods() {
@@ -153,9 +146,7 @@ void ViewportTexture::_bind_methods() {
ViewportTexture::ViewportTexture() {
vp = NULL;
- flags = 0;
set_local_to_scene(true);
- proxy = VS::get_singleton()->texture_create();
}
ViewportTexture::~ViewportTexture() {
@@ -164,7 +155,12 @@ ViewportTexture::~ViewportTexture() {
vp->viewport_textures.erase(this);
}
- VS::get_singleton()->free(proxy);
+ if (proxy_ph.is_valid()) {
+ VS::get_singleton()->free(proxy_ph);
+ }
+ if (proxy.is_valid()) {
+ VS::get_singleton()->free(proxy);
+ }
}
/////////////////////////////////////
@@ -304,7 +300,7 @@ void Viewport::_notification(int p_what) {
//3D
PhysicsServer::get_singleton()->space_set_debug_contacts(find_world()->get_space(), get_tree()->get_collision_debug_contact_count());
contact_3d_debug_multimesh = VisualServer::get_singleton()->multimesh_create();
- VisualServer::get_singleton()->multimesh_allocate(contact_3d_debug_multimesh, get_tree()->get_collision_debug_contact_count(), VS::MULTIMESH_TRANSFORM_3D, VS::MULTIMESH_COLOR_8BIT);
+ VisualServer::get_singleton()->multimesh_allocate(contact_3d_debug_multimesh, get_tree()->get_collision_debug_contact_count(), VS::MULTIMESH_TRANSFORM_3D, true);
VisualServer::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh, 0);
VisualServer::get_singleton()->multimesh_set_mesh(contact_3d_debug_multimesh, get_tree()->get_debug_contact_mesh()->get_rid());
contact_3d_debug_instance = VisualServer::get_singleton()->instance_create();
@@ -416,7 +412,7 @@ void Viewport::_notification(int p_what) {
#ifndef _3D_DISABLED
Vector2 last_pos(1e20, 1e20);
CollisionObject *last_object = NULL;
- ObjectID last_id = 0;
+ ObjectID last_id;
#endif
PhysicsDirectSpaceState::RayResult result;
Physics2DDirectSpaceState *ss2d = Physics2DServer::get_singleton()->space_get_direct_state(find_world_2d()->get_space());
@@ -536,7 +532,7 @@ void Viewport::_notification(int p_what) {
} else {
// This Viewport's builtin canvas
canvas_transform = get_canvas_transform();
- canvas_layer_id = 0;
+ canvas_layer_id = ObjectID();
}
Vector2 point = canvas_transform.affine_inverse().xform(pos);
@@ -544,7 +540,7 @@ void Viewport::_notification(int p_what) {
int rc = ss2d->intersect_point_on_canvas(point, canvas_layer_id, res, 64, Set<RID>(), 0xFFFFFFFF, true, true, true);
for (int i = 0; i < rc; i++) {
- if (res[i].collider_id && res[i].collider) {
+ if (res[i].collider_id.is_valid() && res[i].collider) {
CollisionObject2D *co = Object::cast_to<CollisionObject2D>(res[i].collider);
if (co) {
bool send_event = true;
@@ -598,18 +594,18 @@ void Viewport::_notification(int p_what) {
#ifndef _3D_DISABLED
bool captured = false;
- if (physics_object_capture != 0) {
+ if (physics_object_capture.is_valid()) {
CollisionObject *co = Object::cast_to<CollisionObject>(ObjectDB::get_instance(physics_object_capture));
if (co && camera) {
_collision_object_input_event(co, camera, ev, Vector3(), Vector3(), 0);
captured = true;
if (mb.is_valid() && mb->get_button_index() == 1 && !mb->is_pressed()) {
- physics_object_capture = 0;
+ physics_object_capture = ObjectID();
}
} else {
- physics_object_capture = 0;
+ physics_object_capture = ObjectID();
}
}
@@ -617,7 +613,7 @@ void Viewport::_notification(int p_what) {
//none
} else if (pos == last_pos) {
- if (last_id) {
+ if (last_id.is_valid()) {
if (ObjectDB::get_instance(last_id) && last_object) {
//good, exists
_collision_object_input_event(last_object, camera, ev, result.position, result.normal, result.shape);
@@ -637,7 +633,7 @@ void Viewport::_notification(int p_what) {
if (space) {
bool col = space->intersect_ray(from, from + dir * 10000, result, Set<RID>(), 0xFFFFFFFF, true, true, true);
- ObjectID new_collider = 0;
+ ObjectID new_collider;
if (col) {
CollisionObject *co = Object::cast_to<CollisionObject>(result.collider);
@@ -655,7 +651,7 @@ void Viewport::_notification(int p_what) {
if (is_mouse && new_collider != physics_object_over) {
- if (physics_object_over) {
+ if (physics_object_over.is_valid()) {
CollisionObject *co = Object::cast_to<CollisionObject>(ObjectDB::get_instance(physics_object_over));
if (co) {
@@ -663,7 +659,7 @@ void Viewport::_notification(int p_what) {
}
}
- if (new_collider) {
+ if (new_collider.is_valid()) {
CollisionObject *co = Object::cast_to<CollisionObject>(ObjectDB::get_instance(new_collider));
if (co) {
@@ -1128,7 +1124,7 @@ void Viewport::set_world(const Ref<World> &p_world) {
_propagate_exit_world(this);
if (own_world.is_valid() && world.is_valid()) {
- world->disconnect(CoreStringNames::get_singleton()->changed, this, "_own_world_changed");
+ world->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_changed));
}
world = p_world;
@@ -1136,7 +1132,7 @@ void Viewport::set_world(const Ref<World> &p_world) {
if (own_world.is_valid()) {
if (world.is_valid()) {
own_world = world->duplicate();
- world->connect(CoreStringNames::get_singleton()->changed, this, "_own_world_changed");
+ world->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_changed));
} else {
own_world = Ref<World>(memnew(World));
}
@@ -1334,17 +1330,6 @@ Ref<ViewportTexture> Viewport::get_texture() const {
return default_texture;
}
-void Viewport::set_vflip(bool p_enable) {
-
- vflip = p_enable;
- VisualServer::get_singleton()->viewport_set_vflip(viewport, p_enable);
-}
-
-bool Viewport::get_vflip() const {
-
- return vflip;
-}
-
void Viewport::set_clear_mode(ClearMode p_mode) {
clear_mode = p_mode;
@@ -2488,7 +2473,7 @@ List<Control *>::Element *Viewport::_gui_add_root_control(Control *p_control) {
List<Control *>::Element *Viewport::_gui_add_subwindow_control(Control *p_control) {
- p_control->connect("visibility_changed", this, "_subwindow_visibility_changed");
+ p_control->connect("visibility_changed", callable_mp(this, &Viewport::_subwindow_visibility_changed));
if (p_control->is_visible_in_tree()) {
gui.subwindow_order_dirty = true;
@@ -2519,7 +2504,7 @@ void Viewport::_gui_remove_from_modal_stack(List<Control *>::Element *MI, Object
gui.modal_stack.erase(MI);
- if (p_prev_focus_owner) {
+ if (p_prev_focus_owner.is_valid()) {
// for previous window in stack, pass the focus so it feels more
// natural
@@ -2583,7 +2568,7 @@ void Viewport::_gui_remove_subwindow_control(List<Control *>::Element *SI) {
Control *control = SI->get();
- control->disconnect("visibility_changed", this, "_subwindow_visibility_changed");
+ control->disconnect("visibility_changed", callable_mp(this, &Viewport::_subwindow_visibility_changed));
List<Control *>::Element *E = gui.subwindows.find(control);
if (E)
@@ -2716,14 +2701,15 @@ void Viewport::_drop_physics_mouseover() {
}
#ifndef _3D_DISABLED
- if (physics_object_over) {
+ if (physics_object_over.is_valid()) {
CollisionObject *co = Object::cast_to<CollisionObject>(ObjectDB::get_instance(physics_object_over));
if (co) {
co->_mouse_exit();
}
}
- physics_object_over = physics_object_capture = 0;
+ physics_object_over = ObjectID();
+ physics_object_capture = ObjectID();
#endif
}
@@ -2733,7 +2719,7 @@ List<Control *>::Element *Viewport::_gui_show_modal(Control *p_control) {
if (gui.key_focus)
p_control->_modal_set_prev_focus_owner(gui.key_focus->get_instance_id());
else
- p_control->_modal_set_prev_focus_owner(0);
+ p_control->_modal_set_prev_focus_owner(ObjectID());
if (gui.mouse_focus && !p_control->is_a_parent_of(gui.mouse_focus) && !gui.mouse_click_grabber) {
@@ -2864,12 +2850,12 @@ void Viewport::set_use_own_world(bool p_world) {
if (!p_world) {
own_world = Ref<World>();
if (world.is_valid()) {
- world->disconnect(CoreStringNames::get_singleton()->changed, this, "_own_world_changed");
+ world->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_changed));
}
} else {
if (world.is_valid()) {
own_world = world->duplicate();
- world->connect(CoreStringNames::get_singleton()->changed, this, "_own_world_changed");
+ world->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_changed));
} else {
own_world = Ref<World>(memnew(World));
}
@@ -2952,26 +2938,6 @@ bool Viewport::is_input_disabled() const {
return disable_input;
}
-void Viewport::set_disable_3d(bool p_disable) {
- disable_3d = p_disable;
- VS::get_singleton()->viewport_set_disable_3d(viewport, p_disable);
-}
-
-bool Viewport::is_3d_disabled() const {
-
- return disable_3d;
-}
-
-void Viewport::set_keep_3d_linear(bool p_keep_3d_linear) {
- keep_3d_linear = p_keep_3d_linear;
- VS::get_singleton()->viewport_set_keep_3d_linear(viewport, keep_3d_linear);
-}
-
-bool Viewport::get_keep_3d_linear() const {
-
- return keep_3d_linear;
-}
-
Variant Viewport::gui_get_drag_data() const {
return gui.drag_data;
}
@@ -3012,30 +2978,6 @@ Viewport::MSAA Viewport::get_msaa() const {
return msaa;
}
-void Viewport::set_hdr(bool p_hdr) {
-
- if (hdr == p_hdr)
- return;
-
- hdr = p_hdr;
- VS::get_singleton()->viewport_set_hdr(viewport, p_hdr);
-}
-
-bool Viewport::get_hdr() const {
-
- return hdr;
-}
-
-void Viewport::set_usage(Usage p_usage) {
-
- usage = p_usage;
- VS::get_singleton()->viewport_set_usage(viewport, VS::ViewportUsage(p_usage));
-}
-
-Viewport::Usage Viewport::get_usage() const {
- return usage;
-}
-
void Viewport::set_debug_draw(DebugDraw p_debug_draw) {
debug_draw = p_debug_draw;
@@ -3094,9 +3036,50 @@ bool Viewport::is_handling_input_locally() const {
}
void Viewport::_validate_property(PropertyInfo &property) const {
+}
- if (VisualServer::get_singleton()->is_low_end() && property.name == "hdr") {
- property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
+void Viewport::set_default_canvas_item_texture_filter(DefaultCanvasItemTextureFilter p_filter) {
+ if (default_canvas_item_texture_filter == p_filter) {
+ return;
+ }
+ default_canvas_item_texture_filter = p_filter;
+ _propagate_update_default_filter(this);
+}
+
+Viewport::DefaultCanvasItemTextureFilter Viewport::get_default_canvas_item_texture_filter() const {
+ return default_canvas_item_texture_filter;
+}
+
+void Viewport::set_default_canvas_item_texture_repeat(DefaultCanvasItemTextureRepeat p_repeat) {
+ if (default_canvas_item_texture_repeat == p_repeat) {
+ return;
+ }
+ default_canvas_item_texture_repeat = p_repeat;
+ _propagate_update_default_repeat(this);
+}
+Viewport::DefaultCanvasItemTextureRepeat Viewport::get_default_canvas_item_texture_repeat() const {
+ return default_canvas_item_texture_repeat;
+}
+
+void Viewport::_propagate_update_default_filter(Node *p_node) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(p_node);
+ if (ci) {
+ ci->_update_texture_filter_changed(false);
+ }
+
+ for (int i = 0; i < p_node->get_child_count(); i++) {
+ _propagate_update_default_filter(p_node->get_child(i));
+ }
+}
+
+void Viewport::_propagate_update_default_repeat(Node *p_node) {
+ CanvasItem *ci = Object::cast_to<CanvasItem>(p_node);
+ if (ci) {
+ ci->_update_texture_repeat_changed(false);
+ }
+
+ for (int i = 0; i < p_node->get_child_count(); i++) {
+ _propagate_update_default_repeat(p_node->get_child(i));
}
}
@@ -3135,9 +3118,6 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_size_override_stretch", "enabled"), &Viewport::set_size_override_stretch);
ClassDB::bind_method(D_METHOD("is_size_override_stretch_enabled"), &Viewport::is_size_override_stretch_enabled);
- ClassDB::bind_method(D_METHOD("set_vflip", "enable"), &Viewport::set_vflip);
- ClassDB::bind_method(D_METHOD("get_vflip"), &Viewport::get_vflip);
-
ClassDB::bind_method(D_METHOD("set_clear_mode", "mode"), &Viewport::set_clear_mode);
ClassDB::bind_method(D_METHOD("get_clear_mode"), &Viewport::get_clear_mode);
@@ -3147,12 +3127,6 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_msaa", "msaa"), &Viewport::set_msaa);
ClassDB::bind_method(D_METHOD("get_msaa"), &Viewport::get_msaa);
- ClassDB::bind_method(D_METHOD("set_hdr", "enable"), &Viewport::set_hdr);
- ClassDB::bind_method(D_METHOD("get_hdr"), &Viewport::get_hdr);
-
- ClassDB::bind_method(D_METHOD("set_usage", "usage"), &Viewport::set_usage);
- ClassDB::bind_method(D_METHOD("get_usage"), &Viewport::get_usage);
-
ClassDB::bind_method(D_METHOD("set_debug_draw", "debug_draw"), &Viewport::set_debug_draw);
ClassDB::bind_method(D_METHOD("get_debug_draw"), &Viewport::get_debug_draw);
@@ -3195,12 +3169,6 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_disable_input", "disable"), &Viewport::set_disable_input);
ClassDB::bind_method(D_METHOD("is_input_disabled"), &Viewport::is_input_disabled);
- ClassDB::bind_method(D_METHOD("set_disable_3d", "disable"), &Viewport::set_disable_3d);
- ClassDB::bind_method(D_METHOD("is_3d_disabled"), &Viewport::is_3d_disabled);
-
- ClassDB::bind_method(D_METHOD("set_keep_3d_linear", "keep_3d_linear"), &Viewport::set_keep_3d_linear);
- ClassDB::bind_method(D_METHOD("get_keep_3d_linear"), &Viewport::get_keep_3d_linear);
-
ClassDB::bind_method(D_METHOD("_gui_show_tooltip"), &Viewport::_gui_show_tooltip);
ClassDB::bind_method(D_METHOD("_gui_remove_focus"), &Viewport::_gui_remove_focus);
ClassDB::bind_method(D_METHOD("_post_gui_grab_click_focus"), &Viewport::_post_gui_grab_click_focus);
@@ -3220,9 +3188,11 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_handle_input_locally", "enable"), &Viewport::set_handle_input_locally);
ClassDB::bind_method(D_METHOD("is_handling_input_locally"), &Viewport::is_handling_input_locally);
- ClassDB::bind_method(D_METHOD("_subwindow_visibility_changed"), &Viewport::_subwindow_visibility_changed);
+ ClassDB::bind_method(D_METHOD("set_default_canvas_item_texture_filter", "mode"), &Viewport::set_default_canvas_item_texture_filter);
+ ClassDB::bind_method(D_METHOD("get_default_canvas_item_texture_filter"), &Viewport::get_default_canvas_item_texture_filter);
- ClassDB::bind_method(D_METHOD("_own_world_changed"), &Viewport::_own_world_changed);
+ ClassDB::bind_method(D_METHOD("set_default_canvas_item_texture_repeat", "mode"), &Viewport::set_default_canvas_item_texture_repeat);
+ ClassDB::bind_method(D_METHOD("get_default_canvas_item_texture_repeat"), &Viewport::get_default_canvas_item_texture_repeat);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "arvr"), "set_use_arvr", "use_arvr");
@@ -3235,16 +3205,14 @@ void Viewport::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "handle_input_locally"), "set_handle_input_locally", "is_handling_input_locally");
ADD_GROUP("Rendering", "");
ADD_PROPERTY(PropertyInfo(Variant::INT, "msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x,AndroidVR 2x,AndroidVR 4x"), "set_msaa", "get_msaa");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hdr"), "set_hdr", "get_hdr");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_3d"), "set_disable_3d", "is_3d_disabled");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_3d_linear"), "set_keep_3d_linear", "get_keep_3d_linear");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "usage", PROPERTY_HINT_ENUM, "2D,2D No-Sampling,3D,3D No-Effects"), "set_usage", "get_usage");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_direct_to_screen"), "set_use_render_direct_to_screen", "is_using_render_direct_to_screen");
ADD_PROPERTY(PropertyInfo(Variant::INT, "debug_draw", PROPERTY_HINT_ENUM, "Disabled,Unshaded,Overdraw,Wireframe"), "set_debug_draw", "get_debug_draw");
ADD_GROUP("Render Target", "render_target_");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "render_target_v_flip"), "set_vflip", "get_vflip");
ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_clear_mode", PROPERTY_HINT_ENUM, "Always,Never,Next Frame"), "set_clear_mode", "get_clear_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_update_mode", PROPERTY_HINT_ENUM, "Disabled,Once,When Visible,Always"), "set_update_mode", "get_update_mode");
+ ADD_GROUP("Canvas Items", "canvas_item_");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "canvas_item_default_texture_filter", PROPERTY_HINT_ENUM, "Nearest,Linear,MipmapLinear,MipmapNearest"), "set_default_canvas_item_texture_filter", "get_default_canvas_item_texture_filter");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "canvas_item_default_texture_repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirror"), "set_default_canvas_item_texture_repeat", "get_default_canvas_item_texture_repeat");
ADD_GROUP("Audio Listener", "audio_listener_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_listener_enable_2d"), "set_as_audio_listener_2d", "is_audio_listener_2d");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "audio_listener_enable_3d"), "set_as_audio_listener", "is_audio_listener");
@@ -3292,20 +3260,34 @@ void Viewport::_bind_methods() {
BIND_ENUM_CONSTANT(DEBUG_DRAW_OVERDRAW);
BIND_ENUM_CONSTANT(DEBUG_DRAW_WIREFRAME);
+ BIND_ENUM_CONSTANT(DEBUG_DRAW_GI_PROBE_ALBEDO);
+ BIND_ENUM_CONSTANT(DEBUG_DRAW_GI_PROBE_LIGHTING);
+ BIND_ENUM_CONSTANT(DEBUG_DRAW_GI_PROBE_EMISSION);
+ BIND_ENUM_CONSTANT(DEBUG_DRAW_SHADOW_ATLAS);
+ BIND_ENUM_CONSTANT(DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS);
+ BIND_ENUM_CONSTANT(DEBUG_DRAW_SCENE_LUMINANCE);
+ BIND_ENUM_CONSTANT(DEBUG_DRAW_SSAO);
+
BIND_ENUM_CONSTANT(MSAA_DISABLED);
BIND_ENUM_CONSTANT(MSAA_2X);
BIND_ENUM_CONSTANT(MSAA_4X);
BIND_ENUM_CONSTANT(MSAA_8X);
BIND_ENUM_CONSTANT(MSAA_16X);
- BIND_ENUM_CONSTANT(USAGE_2D);
- BIND_ENUM_CONSTANT(USAGE_2D_NO_SAMPLING);
- BIND_ENUM_CONSTANT(USAGE_3D);
- BIND_ENUM_CONSTANT(USAGE_3D_NO_EFFECTS);
-
BIND_ENUM_CONSTANT(CLEAR_MODE_ALWAYS);
BIND_ENUM_CONSTANT(CLEAR_MODE_NEVER);
BIND_ENUM_CONSTANT(CLEAR_MODE_ONLY_NEXT_FRAME);
+
+ BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
+ BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR);
+ BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS);
+ BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);
+
+ BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_MAX);
+ BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
+ BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);
+ BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MIRROR);
+ BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MAX);
}
void Viewport::_subwindow_visibility_changed() {
@@ -3321,14 +3303,13 @@ Viewport::Viewport() {
viewport = VisualServer::get_singleton()->viewport_create();
texture_rid = VisualServer::get_singleton()->viewport_get_texture(viewport);
- texture_flags = 0;
render_direct_to_screen = false;
default_texture.instance();
default_texture->vp = const_cast<Viewport *>(this);
viewport_textures.insert(default_texture.ptr());
- VS::get_singleton()->texture_set_proxy(default_texture->proxy, texture_rid);
+ default_texture->proxy = VS::get_singleton()->texture_proxy_create(texture_rid);
//internal_listener = SpatialSoundServer::get_singleton()->listener_create();
audio_listener = false;
@@ -3346,14 +3327,10 @@ Viewport::Viewport() {
size_override_size = Size2(1, 1);
gen_mipmaps = false;
- vflip = false;
-
//clear=true;
update_mode = UPDATE_WHEN_VISIBLE;
physics_object_picking = false;
- physics_object_capture = 0;
- physics_object_over = 0;
physics_has_last_mousepos = false;
physics_last_mousepos = Vector2(Math_INF, Math_INF);
@@ -3373,15 +3350,13 @@ Viewport::Viewport() {
unhandled_key_input_group = "_vp_unhandled_key_input" + id;
disable_input = false;
- disable_3d = false;
- keep_3d_linear = false;
//window tooltip
gui.tooltip_timer = -1;
//gui.tooltip_timer->force_parent_owned();
gui.tooltip_delay = GLOBAL_DEF("gui/timers/tooltip_delay_sec", 0.5);
- ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/tooltip_delay_sec", PropertyInfo(Variant::REAL, "gui/timers/tooltip_delay_sec", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater")); // No negative numbers
+ ProjectSettings::get_singleton()->set_custom_property_info("gui/timers/tooltip_delay_sec", PropertyInfo(Variant::FLOAT, "gui/timers/tooltip_delay_sec", PROPERTY_HINT_RANGE, "0,5,0.01,or_greater")); // No negative numbers
gui.tooltip = NULL;
gui.tooltip_label = NULL;
@@ -3393,9 +3368,7 @@ Viewport::Viewport() {
gui.last_mouse_focus = NULL;
msaa = MSAA_DISABLED;
- hdr = true;
- usage = USAGE_3D;
debug_draw = DEBUG_DRAW_DISABLED;
clear_mode = CLEAR_MODE_ALWAYS;
@@ -3407,7 +3380,9 @@ Viewport::Viewport() {
physics_last_mouse_state.mouse_mask = 0;
local_input_handled = false;
handle_input_locally = true;
- physics_last_id = 0; //ensures first time there will be a check
+
+ default_canvas_item_texture_filter = DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR;
+ default_canvas_item_texture_repeat = DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED;
}
Viewport::~Viewport() {
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 79b606cda3..30c872b6ed 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -49,17 +49,17 @@ class Timer;
class Viewport;
class CollisionObject;
-class ViewportTexture : public Texture {
+class ViewportTexture : public Texture2D {
- GDCLASS(ViewportTexture, Texture);
+ GDCLASS(ViewportTexture, Texture2D);
NodePath path;
friend class Viewport;
Viewport *vp;
- uint32_t flags;
- RID proxy;
+ mutable RID proxy_ph;
+ mutable RID proxy;
protected:
static void _bind_methods();
@@ -77,9 +77,6 @@ public:
virtual bool has_alpha() const;
- virtual void set_flags(uint32_t p_flags);
- virtual uint32_t get_flags() const;
-
virtual Ref<Image> get_data() const;
ViewportTexture();
@@ -107,7 +104,6 @@ public:
SHADOW_ATLAS_QUADRANT_SUBDIV_256,
SHADOW_ATLAS_QUADRANT_SUBDIV_1024,
SHADOW_ATLAS_QUADRANT_SUBDIV_MAX,
-
};
enum MSAA {
@@ -118,13 +114,6 @@ public:
MSAA_16X,
};
- enum Usage {
- USAGE_2D,
- USAGE_2D_NO_SAMPLING,
- USAGE_3D,
- USAGE_3D_NO_EFFECTS,
- };
-
enum RenderInfo {
RENDER_INFO_OBJECTS_IN_FRAME,
@@ -139,8 +128,18 @@ public:
enum DebugDraw {
DEBUG_DRAW_DISABLED,
DEBUG_DRAW_UNSHADED,
+ DEBUG_DRAW_LIGHTING,
DEBUG_DRAW_OVERDRAW,
DEBUG_DRAW_WIREFRAME,
+ DEBUG_DRAW_NORMAL_BUFFER,
+ DEBUG_DRAW_GI_PROBE_ALBEDO,
+ DEBUG_DRAW_GI_PROBE_LIGHTING,
+ DEBUG_DRAW_GI_PROBE_EMISSION,
+ DEBUG_DRAW_SHADOW_ATLAS,
+ DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS,
+ DEBUG_DRAW_SCENE_LUMINANCE,
+ DEBUG_DRAW_SSAO,
+ DEBUG_DRAW_ROUGHNESS_LIMITER
};
enum ClearMode {
@@ -150,6 +149,21 @@ public:
CLEAR_MODE_ONLY_NEXT_FRAME
};
+ enum DefaultCanvasItemTextureFilter {
+ DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST,
+ DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR,
+ DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS,
+ DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS,
+ DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_MAX
+ };
+
+ enum DefaultCanvasItemTextureRepeat {
+ DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED,
+ DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_ENABLED,
+ DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MIRROR,
+ DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MAX,
+ };
+
private:
friend class ViewportTexture;
@@ -214,7 +228,6 @@ private:
Rect2 last_vp_rect;
bool transparent_bg;
- bool vflip;
ClearMode clear_mode;
bool filter;
bool gen_mipmaps;
@@ -266,22 +279,15 @@ private:
void _update_stretch_transform();
void _update_global_transform();
- bool disable_3d;
- bool keep_3d_linear;
UpdateMode update_mode;
RID texture_rid;
- uint32_t texture_flags;
DebugDraw debug_draw;
- Usage usage;
-
int shadow_atlas_size;
ShadowAtlasQuadrantSubdiv shadow_atlas_quadrant_subdiv[4];
MSAA msaa;
- bool hdr;
-
Ref<ViewportTexture> default_texture;
Set<ViewportTexture *> viewport_textures;
@@ -320,6 +326,12 @@ private:
GUI();
} gui;
+ DefaultCanvasItemTextureFilter default_canvas_item_texture_filter;
+ DefaultCanvasItemTextureRepeat default_canvas_item_texture_repeat;
+
+ void _propagate_update_default_filter(Node *p_node);
+ void _propagate_update_default_repeat(Node *p_node);
+
bool disable_input;
void _gui_call_input(Control *p_control, const Ref<InputEvent> &p_input);
@@ -474,9 +486,6 @@ public:
void set_size_override_stretch(bool p_enable);
bool is_size_override_stretch_enabled() const;
- void set_vflip(bool p_enable);
- bool get_vflip() const;
-
void set_clear_mode(ClearMode p_mode);
ClearMode get_clear_mode() const;
@@ -493,9 +502,6 @@ public:
void set_msaa(MSAA p_msaa);
MSAA get_msaa() const;
- void set_hdr(bool p_hdr);
- bool get_hdr() const;
-
Vector2 get_camera_coords(const Vector2 &p_viewport_coords) const;
Vector2 get_camera_rect_size() const;
@@ -508,12 +514,6 @@ public:
void set_disable_input(bool p_disable);
bool is_input_disabled() const;
- void set_disable_3d(bool p_disable);
- bool is_3d_disabled() const;
-
- void set_keep_3d_linear(bool p_keep_3d_linear);
- bool get_keep_3d_linear() const;
-
void set_attach_to_screen_rect(const Rect2 &p_rect);
Rect2 get_attach_to_screen_rect() const;
@@ -536,9 +536,6 @@ public:
virtual String get_configuration_warning() const;
- void set_usage(Usage p_usage);
- Usage get_usage() const;
-
void set_debug_draw(DebugDraw p_debug_draw);
DebugDraw get_debug_draw() const;
@@ -557,6 +554,12 @@ public:
bool gui_is_dragging() const;
+ void set_default_canvas_item_texture_filter(DefaultCanvasItemTextureFilter p_filter);
+ DefaultCanvasItemTextureFilter get_default_canvas_item_texture_filter() const;
+
+ void set_default_canvas_item_texture_repeat(DefaultCanvasItemTextureRepeat p_repeat);
+ DefaultCanvasItemTextureRepeat get_default_canvas_item_texture_repeat() const;
+
Viewport();
~Viewport();
};
@@ -564,9 +567,10 @@ public:
VARIANT_ENUM_CAST(Viewport::UpdateMode);
VARIANT_ENUM_CAST(Viewport::ShadowAtlasQuadrantSubdiv);
VARIANT_ENUM_CAST(Viewport::MSAA);
-VARIANT_ENUM_CAST(Viewport::Usage);
VARIANT_ENUM_CAST(Viewport::DebugDraw);
VARIANT_ENUM_CAST(Viewport::ClearMode);
VARIANT_ENUM_CAST(Viewport::RenderInfo);
+VARIANT_ENUM_CAST(Viewport::DefaultCanvasItemTextureFilter);
+VARIANT_ENUM_CAST(Viewport::DefaultCanvasItemTextureRepeat);
#endif