summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-06-09 15:21:41 -0500
committerThaddeus Crews <repiteo@outlook.com>2024-11-10 12:41:26 -0600
commit925b690c989dea13d0dfc06d2a7b1edc8de6b34f (patch)
tree444f95d5deffb18f2a1a91f6a06c0dd132d83600
parent0f5f3bc9546b46b2029fc8896dc859697f1eab97 (diff)
downloadredot-engine-925b690c989dea13d0dfc06d2a7b1edc8de6b34f.tar.gz
Core: Integrate `Ref::instantiate` where possible
-rw-r--r--core/io/tcp_server.cpp2
-rw-r--r--editor/editor_help_search.cpp4
-rw-r--r--editor/editor_node.cpp2
-rw-r--r--editor/editor_settings.cpp2
-rw-r--r--editor/export/codesign.cpp8
-rw-r--r--editor/import/3d/editor_import_collada.cpp2
-rw-r--r--editor/import/3d/resource_importer_scene.cpp2
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp2
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp2
-rw-r--r--editor/plugins/gizmos/marker_3d_gizmo_plugin.cpp2
-rw-r--r--editor/plugins/light_occluder_2d_editor_plugin.cpp4
-rw-r--r--editor/plugins/navigation_obstacle_3d_editor_plugin.cpp4
-rw-r--r--editor/plugins/navigation_polygon_editor_plugin.cpp4
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp16
-rw-r--r--editor/plugins/path_3d_editor_plugin.cpp2
-rw-r--r--editor/plugins/polygon_3d_editor_plugin.cpp4
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp4
-rw-r--r--modules/enet/enet_connection.cpp2
-rw-r--r--modules/gltf/gltf_document.cpp4
-rw-r--r--modules/gridmap/grid_map.cpp8
-rw-r--r--modules/mono/csharp_script.cpp2
-rw-r--r--modules/multiplayer/scene_multiplayer.cpp6
-rw-r--r--modules/openxr/extensions/openxr_composition_layer_extension.cpp2
-rw-r--r--modules/theora/video_stream_theora.cpp2
-rw-r--r--platform/ios/export/export_plugin.cpp2
-rw-r--r--scene/2d/touch_screen_button.cpp2
-rw-r--r--scene/3d/label_3d.cpp2
-rw-r--r--scene/3d/navigation_agent_3d.cpp4
-rw-r--r--scene/3d/navigation_link_3d.cpp4
-rw-r--r--scene/3d/navigation_obstacle_3d.cpp8
-rw-r--r--scene/3d/navigation_region_3d.cpp8
-rw-r--r--scene/3d/path_3d.cpp4
-rw-r--r--scene/3d/physics/ray_cast_3d.cpp2
-rw-r--r--scene/3d/physics/shape_cast_3d.cpp2
-rw-r--r--scene/3d/sprite_3d.cpp2
-rw-r--r--scene/gui/graph_edit.cpp2
-rw-r--r--scene/main/scene_tree.cpp2
-rw-r--r--scene/main/viewport.cpp8
-rw-r--r--scene/resources/3d/shape_3d.cpp2
-rw-r--r--scene/resources/mesh.cpp2
-rw-r--r--scene/resources/navigation_mesh.cpp4
-rw-r--r--scene/resources/packed_scene.cpp4
-rw-r--r--scene/resources/portable_compressed_texture.cpp4
-rw-r--r--tests/scene/test_viewport.h2
44 files changed, 81 insertions, 81 deletions
diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp
index f2b3d5e56a..d69d1f1b29 100644
--- a/core/io/tcp_server.cpp
+++ b/core/io/tcp_server.cpp
@@ -112,7 +112,7 @@ Ref<StreamPeerTCP> TCPServer::take_connection() {
return conn;
}
- conn = Ref<StreamPeerTCP>(memnew(StreamPeerTCP));
+ conn.instantiate();
conn->accept_socket(ns, ip, port);
return conn;
}
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp
index d11bf7720c..b0c06475f8 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -151,7 +151,7 @@ void EditorHelpSearch::_update_results() {
search_flags |= SEARCH_SHOW_HIERARCHY;
}
- search = Ref<Runner>(memnew(Runner(results_tree, results_tree, &tree_cache, term, search_flags)));
+ search.instantiate(results_tree, results_tree, &tree_cache, term, search_flags);
// Clear old search flags to force rebuild on short term.
old_search_flags = 0;
@@ -162,7 +162,7 @@ void EditorHelpSearch::_update_results() {
hierarchy_button->set_disabled(true);
// Always show hierarchy for short searches.
- search = Ref<Runner>(memnew(Runner(results_tree, results_tree, &tree_cache, term, search_flags | SEARCH_SHOW_HIERARCHY)));
+ search.instantiate(results_tree, results_tree, &tree_cache, term, search_flags | SEARCH_SHOW_HIERARCHY);
old_search_flags = search_flags;
set_process(true);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 36b43b7e9b..f8e23ecc9d 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2153,7 +2153,7 @@ void EditorNode::_dialog_action(String p_file) {
}
if (ml.is_null()) {
- ml = Ref<MeshLibrary>(memnew(MeshLibrary));
+ ml.instantiate();
}
MeshLibraryEditor::update_library_file(editor_data.get_edited_scene_root(), ml, merge_with_existing_library, apply_mesh_instance_transforms);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index eeb8ceb1ed..9d29e8e035 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -1229,7 +1229,7 @@ fail:
extra_config->set_value("init_projects", "list", list);
}
- singleton = Ref<EditorSettings>(memnew(EditorSettings));
+ singleton.instantiate();
singleton->set_path(config_file_path, true);
singleton->save_changed_setting = true;
singleton->_load_defaults(extra_config);
diff --git a/editor/export/codesign.cpp b/editor/export/codesign.cpp
index 72d496b04d..cc53068d48 100644
--- a/editor/export/codesign.cpp
+++ b/editor/export/codesign.cpp
@@ -1381,14 +1381,14 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const
r_error_msg = TTR("Invalid entitlements file.");
ERR_FAIL_V_MSG(FAILED, "CodeSign: Invalid entitlements file.");
}
- cet = Ref<CodeSignEntitlementsText>(memnew(CodeSignEntitlementsText(entitlements)));
- ceb = Ref<CodeSignEntitlementsBinary>(memnew(CodeSignEntitlementsBinary(entitlements)));
+ cet.instantiate(entitlements);
+ ceb.instantiate(entitlements);
}
print_verbose("CodeSign: Generating requirements...");
Ref<CodeSignRequirements> rq;
String team_id = "";
- rq = Ref<CodeSignRequirements>(memnew(CodeSignRequirements()));
+ rq.instantiate();
// Sign executables.
for (int i = 0; i < files_to_sign.size(); i++) {
@@ -1487,7 +1487,7 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const
print_verbose("CodeSign: Generating signature...");
Ref<CodeSignSignature> cs;
- cs = Ref<CodeSignSignature>(memnew(CodeSignSignature()));
+ cs.instantiate();
print_verbose("CodeSign: Writing signature superblob...");
// Write signature data to the executable.
diff --git a/editor/import/3d/editor_import_collada.cpp b/editor/import/3d/editor_import_collada.cpp
index 04a3f23154..c04278fc55 100644
--- a/editor/import/3d/editor_import_collada.cpp
+++ b/editor/import/3d/editor_import_collada.cpp
@@ -1263,7 +1263,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
//bleh, must ignore invalid
ERR_FAIL_COND_V(!collada.state.mesh_data_map.has(meshid), ERR_INVALID_DATA);
- mesh = Ref<ImporterMesh>(memnew(ImporterMesh));
+ mesh.instantiate();
const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
String name = meshdata.name;
if (name.is_empty()) {
diff --git a/editor/import/3d/resource_importer_scene.cpp b/editor/import/3d/resource_importer_scene.cpp
index edf7aa66f0..50082e45bf 100644
--- a/editor/import/3d/resource_importer_scene.cpp
+++ b/editor/import/3d/resource_importer_scene.cpp
@@ -3092,7 +3092,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
if (!scr.is_valid()) {
EditorNode::add_io_error(TTR("Couldn't load post-import script:") + " " + post_import_script_path);
} else {
- post_import_script = Ref<EditorScenePostImport>(memnew(EditorScenePostImport));
+ post_import_script.instantiate();
post_import_script->set_script(scr);
if (!post_import_script->get_script_instance()) {
EditorNode::add_io_error(TTR("Invalid/broken script for post-import (check console):") + " " + post_import_script_path);
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 34c0040cb7..eef890d013 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -1265,7 +1265,7 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
open_file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
open_file->connect("file_selected", callable_mp(this, &AnimationNodeBlendTreeEditor::_file_opened));
- animation_node_inspector_plugin = Ref<EditorInspectorPluginAnimationNodeAnimation>(memnew(EditorInspectorPluginAnimationNodeAnimation));
+ animation_node_inspector_plugin.instantiate();
EditorInspector::add_inspector_plugin(animation_node_inspector_plugin);
}
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index e3cf3dbbf2..62793fbcb5 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -5620,7 +5620,7 @@ CanvasItemEditor::CanvasItemEditor() {
snap_dialog->connect(SceneStringName(confirmed), callable_mp(this, &CanvasItemEditor::_snap_changed));
add_child(snap_dialog);
- select_sb = Ref<StyleBoxTexture>(memnew(StyleBoxTexture));
+ select_sb.instantiate();
selection_menu = memnew(PopupMenu);
add_child(selection_menu);
diff --git a/editor/plugins/gizmos/marker_3d_gizmo_plugin.cpp b/editor/plugins/gizmos/marker_3d_gizmo_plugin.cpp
index 39ae020d53..5a6527f876 100644
--- a/editor/plugins/gizmos/marker_3d_gizmo_plugin.cpp
+++ b/editor/plugins/gizmos/marker_3d_gizmo_plugin.cpp
@@ -36,7 +36,7 @@
#include "scene/3d/marker_3d.h"
Marker3DGizmoPlugin::Marker3DGizmoPlugin() {
- pos3d_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ pos3d_mesh.instantiate();
Vector<Vector3> cursor_points;
Vector<Color> cursor_colors;
diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp
index 429add4540..e3b59f9bfb 100644
--- a/editor/plugins/light_occluder_2d_editor_plugin.cpp
+++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp
@@ -35,8 +35,8 @@
Ref<OccluderPolygon2D> LightOccluder2DEditor::_ensure_occluder() const {
Ref<OccluderPolygon2D> occluder = node->get_occluder_polygon();
- if (!occluder.is_valid()) {
- occluder = Ref<OccluderPolygon2D>(memnew(OccluderPolygon2D));
+ if (occluder.is_null()) {
+ occluder.instantiate();
node->set_occluder_polygon(occluder);
}
return occluder;
diff --git a/editor/plugins/navigation_obstacle_3d_editor_plugin.cpp b/editor/plugins/navigation_obstacle_3d_editor_plugin.cpp
index 2eaab0fcbd..8b938d6f60 100644
--- a/editor/plugins/navigation_obstacle_3d_editor_plugin.cpp
+++ b/editor/plugins/navigation_obstacle_3d_editor_plugin.cpp
@@ -542,7 +542,7 @@ NavigationObstacle3DEditor::NavigationObstacle3DEditor() {
point_lines_meshinstance->set_mesh(point_lines_mesh);
point_lines_meshinstance->set_transform(Transform3D(Basis(), Vector3(0, 0, 0.00001)));
- line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ line_material.instantiate();
line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
line_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
@@ -550,7 +550,7 @@ NavigationObstacle3DEditor::NavigationObstacle3DEditor() {
line_material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
line_material->set_albedo(Color(1, 1, 1));
- handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ handle_material.instantiate();
handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true);
handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp
index 3c71040408..c11a7cf20e 100644
--- a/editor/plugins/navigation_polygon_editor_plugin.cpp
+++ b/editor/plugins/navigation_polygon_editor_plugin.cpp
@@ -38,8 +38,8 @@
Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navpoly() const {
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
- if (!navpoly.is_valid()) {
- navpoly = Ref<NavigationPolygon>(memnew(NavigationPolygon));
+ if (navpoly.is_null()) {
+ navpoly.instantiate();
node->set_navigation_polygon(navpoly);
}
return navpoly;
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 5afe01025d..810d1674ca 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -7050,12 +7050,12 @@ void fragment() {
col.a = EDITOR_GET("editors/3d/manipulator_gizmo_opacity");
- move_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
- move_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
- rotate_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
- scale_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
- scale_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
- axis_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh));
+ move_gizmo[i].instantiate();
+ move_plane_gizmo[i].instantiate();
+ rotate_gizmo[i].instantiate();
+ scale_gizmo[i].instantiate();
+ scale_plane_gizmo[i].instantiate();
+ axis_gizmo[i].instantiate();
Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D);
mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
@@ -7286,7 +7286,7 @@ void fragment() {
border_mat->set_shader(border_shader);
border_mat->set_shader_parameter("albedo", Color(0.75, 0.75, 0.75, col.a / 3.0));
- rotate_gizmo[3] = Ref<ArrayMesh>(memnew(ArrayMesh));
+ rotate_gizmo[3].instantiate();
rotate_gizmo[3]->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arrays);
rotate_gizmo[3]->surface_set_material(0, border_mat);
}
@@ -8639,7 +8639,7 @@ Node3DEditor::Node3DEditor() {
gizmo.visible = true;
gizmo.scale = 1.0;
- viewport_environment = Ref<Environment>(memnew(Environment));
+ viewport_environment.instantiate();
VBoxContainer *vbc = this;
custom_camera = nullptr;
diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp
index 91cff9f8e2..3a4b3a0ea2 100644
--- a/editor/plugins/path_3d_editor_plugin.cpp
+++ b/editor/plugins/path_3d_editor_plugin.cpp
@@ -922,7 +922,7 @@ Ref<EditorNode3DGizmo> Path3DGizmoPlugin::create_gizmo(Node3D *p_spatial) {
Path3D *path = Object::cast_to<Path3D>(p_spatial);
if (path) {
- ref = Ref<Path3DGizmo>(memnew(Path3DGizmo(path, disk_size)));
+ ref.instantiate(path, disk_size);
}
return ref;
diff --git a/editor/plugins/polygon_3d_editor_plugin.cpp b/editor/plugins/polygon_3d_editor_plugin.cpp
index 9bb2d81549..017504f0d6 100644
--- a/editor/plugins/polygon_3d_editor_plugin.cpp
+++ b/editor/plugins/polygon_3d_editor_plugin.cpp
@@ -554,7 +554,7 @@ Polygon3DEditor::Polygon3DEditor() {
imgeom->set_mesh(imesh);
imgeom->set_transform(Transform3D(Basis(), Vector3(0, 0, 0.00001)));
- line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ line_material.instantiate();
line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
line_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
@@ -562,7 +562,7 @@ Polygon3DEditor::Polygon3DEditor() {
line_material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
line_material->set_albedo(Color(1, 1, 1));
- handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ handle_material.instantiate();
handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true);
handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index 19fbd2dd3b..369a1fc864 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -1186,8 +1186,8 @@ Skeleton3DEditor::Skeleton3DEditor(EditorInspectorPluginSkeleton *e_plugin, Skel
singleton = this;
// Handle.
- handle_material = Ref<ShaderMaterial>(memnew(ShaderMaterial));
- handle_shader = Ref<Shader>(memnew(Shader));
+ handle_material.instantiate();
+ handle_shader.instantiate();
handle_shader->set_code(R"(
// Skeleton 3D gizmo handle shader.
diff --git a/modules/enet/enet_connection.cpp b/modules/enet/enet_connection.cpp
index 2ccfd5d326..9c9302a51c 100644
--- a/modules/enet/enet_connection.cpp
+++ b/modules/enet/enet_connection.cpp
@@ -113,7 +113,7 @@ Ref<ENetPacketPeer> ENetConnection::connect_to_host(const String &p_address, int
if (peer == nullptr) {
return nullptr;
}
- out = Ref<ENetPacketPeer>(memnew(ENetPacketPeer(peer)));
+ out.instantiate(peer);
peers.push_back(out);
return out;
}
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index aa482615da..2b815b7de9 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -117,7 +117,7 @@ static Ref<ImporterMesh> _mesh_to_importer_mesh(Ref<Mesh> p_mesh) {
mat_name = mat->get_name();
} else {
// Assign default material when no material is assigned.
- mat = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ mat.instantiate();
}
importer_mesh->add_surface(p_mesh->surface_get_primitive_type(surface_i),
array, p_mesh->surface_get_blend_shape_arrays(surface_i), p_mesh->surface_get_lods(surface_i), mat,
@@ -5913,7 +5913,7 @@ void GLTFDocument::_convert_csg_shape_to_gltf(CSGShape3D *p_current, GLTFNodeInd
mat_name = mat->get_name();
} else {
// Assign default material when no material is assigned.
- mat = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
+ mat.instantiate();
}
mesh->add_surface(csg_mesh->surface_get_primitive_type(surface_i),
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 71171be3f1..0588ba034a 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -801,8 +801,8 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
if (!g.navigation_debug_edge_connections_instance.is_valid()) {
g.navigation_debug_edge_connections_instance = RenderingServer::get_singleton()->instance_create();
}
- if (!g.navigation_debug_edge_connections_mesh.is_valid()) {
- g.navigation_debug_edge_connections_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ if (g.navigation_debug_edge_connections_mesh.is_null()) {
+ g.navigation_debug_edge_connections_mesh.instantiate();
}
_update_octant_navigation_debug_edge_connections_mesh(p_key);
@@ -1386,8 +1386,8 @@ void GridMap::_update_octant_navigation_debug_edge_connections_mesh(const Octant
g.navigation_debug_edge_connections_instance = RenderingServer::get_singleton()->instance_create();
}
- if (!g.navigation_debug_edge_connections_mesh.is_valid()) {
- g.navigation_debug_edge_connections_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ if (g.navigation_debug_edge_connections_mesh.is_null()) {
+ g.navigation_debug_edge_connections_mesh.instantiate();
}
g.navigation_debug_edge_connections_mesh->clear_surfaces();
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 6ae9ce56c6..380b401683 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -2826,7 +2826,7 @@ Ref<Resource> ResourceFormatLoaderCSharpScript::load(const String &p_path, const
GDMonoCache::managed_callbacks.ScriptManagerBridge_GetOrCreateScriptBridgeForPath(&p_path, &scr);
ERR_FAIL_COND_V_MSG(scr.is_null(), Ref<Resource>(), "Could not create C# script '" + real_path + "'.");
} else {
- scr = Ref<CSharpScript>(memnew(CSharpScript));
+ scr.instantiate();
}
#if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED)
diff --git a/modules/multiplayer/scene_multiplayer.cpp b/modules/multiplayer/scene_multiplayer.cpp
index e245101eeb..dde14034e6 100644
--- a/modules/multiplayer/scene_multiplayer.cpp
+++ b/modules/multiplayer/scene_multiplayer.cpp
@@ -684,9 +684,9 @@ void SceneMultiplayer::_bind_methods() {
SceneMultiplayer::SceneMultiplayer() {
relay_buffer.instantiate();
- cache = Ref<SceneCacheInterface>(memnew(SceneCacheInterface(this)));
- replicator = Ref<SceneReplicationInterface>(memnew(SceneReplicationInterface(this, cache.ptr())));
- rpc = Ref<SceneRPCInterface>(memnew(SceneRPCInterface(this, cache.ptr(), replicator.ptr())));
+ cache.instantiate(this);
+ replicator.instantiate(this, cache.ptr());
+ rpc.instantiate(this, cache.ptr(), replicator.ptr());
set_multiplayer_peer(Ref<OfflineMultiplayerPeer>(memnew(OfflineMultiplayerPeer)));
}
diff --git a/modules/openxr/extensions/openxr_composition_layer_extension.cpp b/modules/openxr/extensions/openxr_composition_layer_extension.cpp
index 2d29b8a82c..1e3490d1ed 100644
--- a/modules/openxr/extensions/openxr_composition_layer_extension.cpp
+++ b/modules/openxr/extensions/openxr_composition_layer_extension.cpp
@@ -281,7 +281,7 @@ void OpenXRViewportCompositionLayerProvider::create_android_surface() {
composition_layer_extension->create_android_surface_swapchain(&info, &android_surface.swapchain, &surface);
if (surface) {
- android_surface.surface = Ref<JavaObject>(memnew(JavaObject(JavaClassWrapper::get_singleton()->wrap("android.view.Surface"), surface)));
+ android_surface.surface.instantiate(JavaClassWrapper::get_singleton()->wrap("android.view.Surface"), surface);
}
}
#endif
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index 8b2c58acd5..372885b0b4 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -629,7 +629,7 @@ void VideoStreamPlaybackTheora::_streaming_thread(void *ud) {
#endif
VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() {
- texture = Ref<ImageTexture>(memnew(ImageTexture));
+ texture.instantiate();
#ifdef THEORA_USE_THREAD_STREAMING
int rb_power = nearest_shift(RB_SIZE_KB * 1024);
diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp
index d6cd2e0f3c..3c5a930bab 100644
--- a/platform/ios/export/export_plugin.cpp
+++ b/platform/ios/export/export_plugin.cpp
@@ -1082,7 +1082,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor
}
if (splash.is_null()) {
- splash = Ref<Image>(memnew(Image(boot_splash_png)));
+ splash.instantiate(boot_splash_png);
}
// Using same image for both @2x and @3x
diff --git a/scene/2d/touch_screen_button.cpp b/scene/2d/touch_screen_button.cpp
index b968f39ccb..220608a250 100644
--- a/scene/2d/touch_screen_button.cpp
+++ b/scene/2d/touch_screen_button.cpp
@@ -430,6 +430,6 @@ void TouchScreenButton::_bind_methods() {
}
TouchScreenButton::TouchScreenButton() {
- unit_rect = Ref<RectangleShape2D>(memnew(RectangleShape2D));
+ unit_rect.instantiate();
unit_rect->set_size(Vector2(1, 1));
}
diff --git a/scene/3d/label_3d.cpp b/scene/3d/label_3d.cpp
index 6b3510a72a..01f15137be 100644
--- a/scene/3d/label_3d.cpp
+++ b/scene/3d/label_3d.cpp
@@ -318,7 +318,7 @@ Ref<TriangleMesh> Label3D::generate_triangle_mesh() const {
facesw[j] = vtx;
}
- triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh));
+ triangle_mesh.instantiate();
triangle_mesh->create(faces);
return triangle_mesh;
diff --git a/scene/3d/navigation_agent_3d.cpp b/scene/3d/navigation_agent_3d.cpp
index 9242c2a2ea..faf138896a 100644
--- a/scene/3d/navigation_agent_3d.cpp
+++ b/scene/3d/navigation_agent_3d.cpp
@@ -1081,8 +1081,8 @@ void NavigationAgent3D::_update_debug_path() {
debug_path_instance = RenderingServer::get_singleton()->instance_create();
}
- if (!debug_path_mesh.is_valid()) {
- debug_path_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ if (debug_path_mesh.is_null()) {
+ debug_path_mesh.instantiate();
}
debug_path_mesh->clear_surfaces();
diff --git a/scene/3d/navigation_link_3d.cpp b/scene/3d/navigation_link_3d.cpp
index 0cce21b9d0..9e29384fc9 100644
--- a/scene/3d/navigation_link_3d.cpp
+++ b/scene/3d/navigation_link_3d.cpp
@@ -56,8 +56,8 @@ void NavigationLink3D::_update_debug_mesh() {
debug_instance = RenderingServer::get_singleton()->instance_create();
}
- if (!debug_mesh.is_valid()) {
- debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ if (debug_mesh.is_null()) {
+ debug_mesh.instantiate();
}
RID nav_map = get_world_3d()->get_navigation_map();
diff --git a/scene/3d/navigation_obstacle_3d.cpp b/scene/3d/navigation_obstacle_3d.cpp
index 2eb04a0054..72a7253a10 100644
--- a/scene/3d/navigation_obstacle_3d.cpp
+++ b/scene/3d/navigation_obstacle_3d.cpp
@@ -389,8 +389,8 @@ void NavigationObstacle3D::_update_fake_agent_radius_debug() {
if (!fake_agent_radius_debug_instance.is_valid()) {
fake_agent_radius_debug_instance = RenderingServer::get_singleton()->instance_create();
}
- if (!fake_agent_radius_debug_mesh.is_valid()) {
- fake_agent_radius_debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ if (fake_agent_radius_debug_mesh.is_null()) {
+ fake_agent_radius_debug_mesh.instantiate();
}
fake_agent_radius_debug_mesh->clear_surfaces();
@@ -487,8 +487,8 @@ void NavigationObstacle3D::_update_static_obstacle_debug() {
if (!static_obstacle_debug_instance.is_valid()) {
static_obstacle_debug_instance = RenderingServer::get_singleton()->instance_create();
}
- if (!static_obstacle_debug_mesh.is_valid()) {
- static_obstacle_debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ if (static_obstacle_debug_mesh.is_null()) {
+ static_obstacle_debug_mesh.instantiate();
}
static_obstacle_debug_mesh->clear_surfaces();
diff --git a/scene/3d/navigation_region_3d.cpp b/scene/3d/navigation_region_3d.cpp
index c0c254e7ed..2d67e4334e 100644
--- a/scene/3d/navigation_region_3d.cpp
+++ b/scene/3d/navigation_region_3d.cpp
@@ -492,8 +492,8 @@ void NavigationRegion3D::_update_debug_mesh() {
debug_instance = RenderingServer::get_singleton()->instance_create();
}
- if (!debug_mesh.is_valid()) {
- debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ if (debug_mesh.is_null()) {
+ debug_mesh.instantiate();
}
debug_mesh->clear_surfaces();
@@ -669,8 +669,8 @@ void NavigationRegion3D::_update_debug_edge_connections_mesh() {
debug_edge_connections_instance = RenderingServer::get_singleton()->instance_create();
}
- if (!debug_edge_connections_mesh.is_valid()) {
- debug_edge_connections_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ if (debug_edge_connections_mesh.is_null()) {
+ debug_edge_connections_mesh.instantiate();
}
debug_edge_connections_mesh->clear_surfaces();
diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp
index 64259a24b0..00c83101b9 100644
--- a/scene/3d/path_3d.cpp
+++ b/scene/3d/path_3d.cpp
@@ -88,8 +88,8 @@ void Path3D::_update_debug_mesh() {
return;
}
- if (!debug_mesh.is_valid()) {
- debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ if (debug_mesh.is_null()) {
+ debug_mesh.instantiate();
}
if (!(curve.is_valid())) {
diff --git a/scene/3d/physics/ray_cast_3d.cpp b/scene/3d/physics/ray_cast_3d.cpp
index a9272388c1..b9159f072b 100644
--- a/scene/3d/physics/ray_cast_3d.cpp
+++ b/scene/3d/physics/ray_cast_3d.cpp
@@ -464,7 +464,7 @@ void RayCast3D::_create_debug_shape() {
}
if (debug_mesh.is_null()) {
- debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ debug_mesh.instantiate();
}
}
diff --git a/scene/3d/physics/shape_cast_3d.cpp b/scene/3d/physics/shape_cast_3d.cpp
index 8ad651fdf5..19c74bc925 100644
--- a/scene/3d/physics/shape_cast_3d.cpp
+++ b/scene/3d/physics/shape_cast_3d.cpp
@@ -546,7 +546,7 @@ void ShapeCast3D::_create_debug_shape() {
}
if (debug_mesh.is_null()) {
- debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ debug_mesh.instantiate();
}
}
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 42460eec4c..6e3ada83ad 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -470,7 +470,7 @@ Ref<TriangleMesh> SpriteBase3D::generate_triangle_mesh() const {
facesw[j] = vtx;
}
- triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh));
+ triangle_mesh.instantiate();
triangle_mesh->create(faces);
return triangle_mesh;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index b1c47d858d..7e07f4a202 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -3001,5 +3001,5 @@ GraphEdit::GraphEdit() {
set_clip_contents(true);
- arranger = Ref<GraphEditArranger>(memnew(GraphEditArranger(this)));
+ arranger.instantiate(this);
}
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 60cecfcfe7..16b41c8f9b 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -899,7 +899,7 @@ Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() {
return debug_contact_mesh;
}
- debug_contact_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ debug_contact_mesh.instantiate();
Ref<StandardMaterial3D> mat = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 5a90eb8f3e..1ee99099ec 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1213,7 +1213,7 @@ void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) {
}
} else {
WARN_PRINT("Invalid world_2d");
- world_2d = Ref<World2D>(memnew(World2D));
+ world_2d.instantiate();
}
world_2d->register_viewport(this);
@@ -4386,7 +4386,7 @@ void Viewport::set_world_3d(const Ref<World3D> &p_world_3d) {
own_world_3d = world_3d->duplicate();
world_3d->connect_changed(callable_mp(this, &Viewport::_own_world_3d_changed));
} else {
- own_world_3d = Ref<World3D>(memnew(World3D));
+ own_world_3d.instantiate();
}
}
@@ -4437,7 +4437,7 @@ void Viewport::set_use_own_world_3d(bool p_use_own_world_3d) {
own_world_3d = world_3d->duplicate();
world_3d->connect_changed(callable_mp(this, &Viewport::_own_world_3d_changed));
} else {
- own_world_3d = Ref<World3D>(memnew(World3D));
+ own_world_3d.instantiate();
}
} else {
own_world_3d = Ref<World3D>();
@@ -4963,7 +4963,7 @@ void Viewport::_validate_property(PropertyInfo &p_property) const {
}
Viewport::Viewport() {
- world_2d = Ref<World2D>(memnew(World2D));
+ world_2d.instantiate();
world_2d->register_viewport(this);
viewport = RenderingServer::get_singleton()->viewport_create();
diff --git a/scene/resources/3d/shape_3d.cpp b/scene/resources/3d/shape_3d.cpp
index 5a79392ba5..259d82b7a0 100644
--- a/scene/resources/3d/shape_3d.cpp
+++ b/scene/resources/3d/shape_3d.cpp
@@ -73,7 +73,7 @@ Ref<ArrayMesh> Shape3D::get_debug_mesh() {
Vector<Vector3> lines = get_debug_mesh_lines();
- debug_mesh_cache = Ref<ArrayMesh>(memnew(ArrayMesh));
+ debug_mesh_cache.instantiate();
if (!lines.is_empty()) {
//make mesh
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 848ae2713d..b0353b4f2c 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -385,7 +385,7 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
}
}
- triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh));
+ triangle_mesh.instantiate();
triangle_mesh->create(faces);
return triangle_mesh;
diff --git a/scene/resources/navigation_mesh.cpp b/scene/resources/navigation_mesh.cpp
index 67ed65df0d..034d4d6996 100644
--- a/scene/resources/navigation_mesh.cpp
+++ b/scene/resources/navigation_mesh.cpp
@@ -392,8 +392,8 @@ Ref<ArrayMesh> NavigationMesh::get_debug_mesh() {
return debug_mesh;
}
- if (!debug_mesh.is_valid()) {
- debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
+ if (debug_mesh.is_null()) {
+ debug_mesh.instantiate();
} else {
debug_mesh->clear_surfaces();
}
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index bb3aad0f28..809a77a487 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -2195,7 +2195,7 @@ void PackedScene::replace_state(Ref<SceneState> p_by) {
}
void PackedScene::recreate_state() {
- state = Ref<SceneState>(memnew(SceneState));
+ state.instantiate();
state->set_path(get_path());
#ifdef TOOLS_ENABLED
state->set_last_modified_time(get_last_modified_time());
@@ -2286,5 +2286,5 @@ void PackedScene::_bind_methods() {
}
PackedScene::PackedScene() {
- state = Ref<SceneState>(memnew(SceneState));
+ state.instantiate();
}
diff --git a/scene/resources/portable_compressed_texture.cpp b/scene/resources/portable_compressed_texture.cpp
index 06b5ec6d5a..55bbed7c47 100644
--- a/scene/resources/portable_compressed_texture.cpp
+++ b/scene/resources/portable_compressed_texture.cpp
@@ -89,7 +89,7 @@ void PortableCompressedTexture2D::_set_data(const Vector<uint8_t> &p_data) {
data_size -= mipsize;
}
- image = Ref<Image>(memnew(Image(size.width, size.height, mipmaps, format, image_data)));
+ image.instantiate(size.width, size.height, mipmaps, format, image_data);
} break;
case COMPRESSION_MODE_BASIS_UNIVERSAL: {
@@ -100,7 +100,7 @@ void PortableCompressedTexture2D::_set_data(const Vector<uint8_t> &p_data) {
case COMPRESSION_MODE_S3TC:
case COMPRESSION_MODE_ETC2:
case COMPRESSION_MODE_BPTC: {
- image = Ref<Image>(memnew(Image(size.width, size.height, mipmaps, format, p_data.slice(20))));
+ image.instantiate(size.width, size.height, mipmaps, format, p_data.slice(20));
} break;
}
ERR_FAIL_COND(image.is_null());
diff --git a/tests/scene/test_viewport.h b/tests/scene/test_viewport.h
index dde37944ec..06a38f234b 100644
--- a/tests/scene/test_viewport.h
+++ b/tests/scene/test_viewport.h
@@ -1577,7 +1577,7 @@ TEST_CASE("[SceneTree][Viewport] Physics Picking 2D") {
PickingCollider pc;
pc.a = memnew(TestArea2D);
pc.c = memnew(CollisionShape2D);
- pc.r = Ref<RectangleShape2D>(memnew(RectangleShape2D));
+ pc.r.instantiate();
pc.r->set_size(Size2(150, 150));
pc.c->set_shape(pc.r);
pc.a->add_child(pc.c);