Core: Integrate Ref::instantiate where possible

This commit is contained in:
Thaddeus Crews 2024-06-09 15:21:41 -05:00
parent 0f5f3bc954
commit 925b690c98
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84
44 changed files with 81 additions and 81 deletions

View File

@ -112,7 +112,7 @@ Ref<StreamPeerTCP> TCPServer::take_connection() {
return conn; return conn;
} }
conn = Ref<StreamPeerTCP>(memnew(StreamPeerTCP)); conn.instantiate();
conn->accept_socket(ns, ip, port); conn->accept_socket(ns, ip, port);
return conn; return conn;
} }

View File

@ -151,7 +151,7 @@ void EditorHelpSearch::_update_results() {
search_flags |= SEARCH_SHOW_HIERARCHY; 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. // Clear old search flags to force rebuild on short term.
old_search_flags = 0; old_search_flags = 0;
@ -162,7 +162,7 @@ void EditorHelpSearch::_update_results() {
hierarchy_button->set_disabled(true); hierarchy_button->set_disabled(true);
// Always show hierarchy for short searches. // 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; old_search_flags = search_flags;
set_process(true); set_process(true);

View File

@ -2153,7 +2153,7 @@ void EditorNode::_dialog_action(String p_file) {
} }
if (ml.is_null()) { 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); MeshLibraryEditor::update_library_file(editor_data.get_edited_scene_root(), ml, merge_with_existing_library, apply_mesh_instance_transforms);

View File

@ -1229,7 +1229,7 @@ fail:
extra_config->set_value("init_projects", "list", list); extra_config->set_value("init_projects", "list", list);
} }
singleton = Ref<EditorSettings>(memnew(EditorSettings)); singleton.instantiate();
singleton->set_path(config_file_path, true); singleton->set_path(config_file_path, true);
singleton->save_changed_setting = true; singleton->save_changed_setting = true;
singleton->_load_defaults(extra_config); singleton->_load_defaults(extra_config);

View File

@ -1381,14 +1381,14 @@ Error CodeSign::_codesign_file(bool p_use_hardened_runtime, bool p_force, const
r_error_msg = TTR("Invalid entitlements file."); r_error_msg = TTR("Invalid entitlements file.");
ERR_FAIL_V_MSG(FAILED, "CodeSign: Invalid entitlements file."); ERR_FAIL_V_MSG(FAILED, "CodeSign: Invalid entitlements file.");
} }
cet = Ref<CodeSignEntitlementsText>(memnew(CodeSignEntitlementsText(entitlements))); cet.instantiate(entitlements);
ceb = Ref<CodeSignEntitlementsBinary>(memnew(CodeSignEntitlementsBinary(entitlements))); ceb.instantiate(entitlements);
} }
print_verbose("CodeSign: Generating requirements..."); print_verbose("CodeSign: Generating requirements...");
Ref<CodeSignRequirements> rq; Ref<CodeSignRequirements> rq;
String team_id = ""; String team_id = "";
rq = Ref<CodeSignRequirements>(memnew(CodeSignRequirements())); rq.instantiate();
// Sign executables. // Sign executables.
for (int i = 0; i < files_to_sign.size(); i++) { 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..."); print_verbose("CodeSign: Generating signature...");
Ref<CodeSignSignature> cs; Ref<CodeSignSignature> cs;
cs = Ref<CodeSignSignature>(memnew(CodeSignSignature())); cs.instantiate();
print_verbose("CodeSign: Writing signature superblob..."); print_verbose("CodeSign: Writing signature superblob...");
// Write signature data to the executable. // Write signature data to the executable.

View File

@ -1263,7 +1263,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
//bleh, must ignore invalid //bleh, must ignore invalid
ERR_FAIL_COND_V(!collada.state.mesh_data_map.has(meshid), ERR_INVALID_DATA); 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]; const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
String name = meshdata.name; String name = meshdata.name;
if (name.is_empty()) { if (name.is_empty()) {

View File

@ -3092,7 +3092,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
if (!scr.is_valid()) { if (!scr.is_valid()) {
EditorNode::add_io_error(TTR("Couldn't load post-import script:") + " " + post_import_script_path); EditorNode::add_io_error(TTR("Couldn't load post-import script:") + " " + post_import_script_path);
} else { } else {
post_import_script = Ref<EditorScenePostImport>(memnew(EditorScenePostImport)); post_import_script.instantiate();
post_import_script->set_script(scr); post_import_script->set_script(scr);
if (!post_import_script->get_script_instance()) { if (!post_import_script->get_script_instance()) {
EditorNode::add_io_error(TTR("Invalid/broken script for post-import (check console):") + " " + post_import_script_path); EditorNode::add_io_error(TTR("Invalid/broken script for post-import (check console):") + " " + post_import_script_path);

View File

@ -1265,7 +1265,7 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
open_file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); open_file->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
open_file->connect("file_selected", callable_mp(this, &AnimationNodeBlendTreeEditor::_file_opened)); 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); EditorInspector::add_inspector_plugin(animation_node_inspector_plugin);
} }

View File

@ -5620,7 +5620,7 @@ CanvasItemEditor::CanvasItemEditor() {
snap_dialog->connect(SceneStringName(confirmed), callable_mp(this, &CanvasItemEditor::_snap_changed)); snap_dialog->connect(SceneStringName(confirmed), callable_mp(this, &CanvasItemEditor::_snap_changed));
add_child(snap_dialog); add_child(snap_dialog);
select_sb = Ref<StyleBoxTexture>(memnew(StyleBoxTexture)); select_sb.instantiate();
selection_menu = memnew(PopupMenu); selection_menu = memnew(PopupMenu);
add_child(selection_menu); add_child(selection_menu);

View File

@ -36,7 +36,7 @@
#include "scene/3d/marker_3d.h" #include "scene/3d/marker_3d.h"
Marker3DGizmoPlugin::Marker3DGizmoPlugin() { Marker3DGizmoPlugin::Marker3DGizmoPlugin() {
pos3d_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); pos3d_mesh.instantiate();
Vector<Vector3> cursor_points; Vector<Vector3> cursor_points;
Vector<Color> cursor_colors; Vector<Color> cursor_colors;

View File

@ -35,8 +35,8 @@
Ref<OccluderPolygon2D> LightOccluder2DEditor::_ensure_occluder() const { Ref<OccluderPolygon2D> LightOccluder2DEditor::_ensure_occluder() const {
Ref<OccluderPolygon2D> occluder = node->get_occluder_polygon(); Ref<OccluderPolygon2D> occluder = node->get_occluder_polygon();
if (!occluder.is_valid()) { if (occluder.is_null()) {
occluder = Ref<OccluderPolygon2D>(memnew(OccluderPolygon2D)); occluder.instantiate();
node->set_occluder_polygon(occluder); node->set_occluder_polygon(occluder);
} }
return occluder; return occluder;

View File

@ -542,7 +542,7 @@ NavigationObstacle3DEditor::NavigationObstacle3DEditor() {
point_lines_meshinstance->set_mesh(point_lines_mesh); point_lines_meshinstance->set_mesh(point_lines_mesh);
point_lines_meshinstance->set_transform(Transform3D(Basis(), Vector3(0, 0, 0.00001))); 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_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
line_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); line_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); 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_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
line_material->set_albedo(Color(1, 1, 1)); 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_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true); handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true);
handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);

View File

@ -38,8 +38,8 @@
Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navpoly() const { Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navpoly() const {
Ref<NavigationPolygon> navpoly = node->get_navigation_polygon(); Ref<NavigationPolygon> navpoly = node->get_navigation_polygon();
if (!navpoly.is_valid()) { if (navpoly.is_null()) {
navpoly = Ref<NavigationPolygon>(memnew(NavigationPolygon)); navpoly.instantiate();
node->set_navigation_polygon(navpoly); node->set_navigation_polygon(navpoly);
} }
return navpoly; return navpoly;

View File

@ -7050,12 +7050,12 @@ void fragment() {
col.a = EDITOR_GET("editors/3d/manipulator_gizmo_opacity"); col.a = EDITOR_GET("editors/3d/manipulator_gizmo_opacity");
move_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); move_gizmo[i].instantiate();
move_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); move_plane_gizmo[i].instantiate();
rotate_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); rotate_gizmo[i].instantiate();
scale_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); scale_gizmo[i].instantiate();
scale_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); scale_plane_gizmo[i].instantiate();
axis_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); axis_gizmo[i].instantiate();
Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D); Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D);
mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
@ -7286,7 +7286,7 @@ void fragment() {
border_mat->set_shader(border_shader); border_mat->set_shader(border_shader);
border_mat->set_shader_parameter("albedo", Color(0.75, 0.75, 0.75, col.a / 3.0)); 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]->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arrays);
rotate_gizmo[3]->surface_set_material(0, border_mat); rotate_gizmo[3]->surface_set_material(0, border_mat);
} }
@ -8639,7 +8639,7 @@ Node3DEditor::Node3DEditor() {
gizmo.visible = true; gizmo.visible = true;
gizmo.scale = 1.0; gizmo.scale = 1.0;
viewport_environment = Ref<Environment>(memnew(Environment)); viewport_environment.instantiate();
VBoxContainer *vbc = this; VBoxContainer *vbc = this;
custom_camera = nullptr; custom_camera = nullptr;

View File

@ -922,7 +922,7 @@ Ref<EditorNode3DGizmo> Path3DGizmoPlugin::create_gizmo(Node3D *p_spatial) {
Path3D *path = Object::cast_to<Path3D>(p_spatial); Path3D *path = Object::cast_to<Path3D>(p_spatial);
if (path) { if (path) {
ref = Ref<Path3DGizmo>(memnew(Path3DGizmo(path, disk_size))); ref.instantiate(path, disk_size);
} }
return ref; return ref;

View File

@ -554,7 +554,7 @@ Polygon3DEditor::Polygon3DEditor() {
imgeom->set_mesh(imesh); imgeom->set_mesh(imesh);
imgeom->set_transform(Transform3D(Basis(), Vector3(0, 0, 0.00001))); 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_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
line_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); line_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); 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_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
line_material->set_albedo(Color(1, 1, 1)); 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_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true); handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true);
handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);

View File

@ -1186,8 +1186,8 @@ Skeleton3DEditor::Skeleton3DEditor(EditorInspectorPluginSkeleton *e_plugin, Skel
singleton = this; singleton = this;
// Handle. // Handle.
handle_material = Ref<ShaderMaterial>(memnew(ShaderMaterial)); handle_material.instantiate();
handle_shader = Ref<Shader>(memnew(Shader)); handle_shader.instantiate();
handle_shader->set_code(R"( handle_shader->set_code(R"(
// Skeleton 3D gizmo handle shader. // Skeleton 3D gizmo handle shader.

View File

@ -113,7 +113,7 @@ Ref<ENetPacketPeer> ENetConnection::connect_to_host(const String &p_address, int
if (peer == nullptr) { if (peer == nullptr) {
return nullptr; return nullptr;
} }
out = Ref<ENetPacketPeer>(memnew(ENetPacketPeer(peer))); out.instantiate(peer);
peers.push_back(out); peers.push_back(out);
return out; return out;
} }

View File

@ -117,7 +117,7 @@ static Ref<ImporterMesh> _mesh_to_importer_mesh(Ref<Mesh> p_mesh) {
mat_name = mat->get_name(); mat_name = mat->get_name();
} else { } else {
// Assign default material when no material is assigned. // 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), 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, 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(); mat_name = mat->get_name();
} else { } else {
// Assign default material when no material is assigned. // 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), mesh->add_surface(csg_mesh->surface_get_primitive_type(surface_i),

View File

@ -801,8 +801,8 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
if (!g.navigation_debug_edge_connections_instance.is_valid()) { if (!g.navigation_debug_edge_connections_instance.is_valid()) {
g.navigation_debug_edge_connections_instance = RenderingServer::get_singleton()->instance_create(); g.navigation_debug_edge_connections_instance = RenderingServer::get_singleton()->instance_create();
} }
if (!g.navigation_debug_edge_connections_mesh.is_valid()) { if (g.navigation_debug_edge_connections_mesh.is_null()) {
g.navigation_debug_edge_connections_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); g.navigation_debug_edge_connections_mesh.instantiate();
} }
_update_octant_navigation_debug_edge_connections_mesh(p_key); _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(); g.navigation_debug_edge_connections_instance = RenderingServer::get_singleton()->instance_create();
} }
if (!g.navigation_debug_edge_connections_mesh.is_valid()) { if (g.navigation_debug_edge_connections_mesh.is_null()) {
g.navigation_debug_edge_connections_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); g.navigation_debug_edge_connections_mesh.instantiate();
} }
g.navigation_debug_edge_connections_mesh->clear_surfaces(); g.navigation_debug_edge_connections_mesh->clear_surfaces();

View File

@ -2826,7 +2826,7 @@ Ref<Resource> ResourceFormatLoaderCSharpScript::load(const String &p_path, const
GDMonoCache::managed_callbacks.ScriptManagerBridge_GetOrCreateScriptBridgeForPath(&p_path, &scr); 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 + "'."); ERR_FAIL_COND_V_MSG(scr.is_null(), Ref<Resource>(), "Could not create C# script '" + real_path + "'.");
} else { } else {
scr = Ref<CSharpScript>(memnew(CSharpScript)); scr.instantiate();
} }
#if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED) #if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED)

View File

@ -684,9 +684,9 @@ void SceneMultiplayer::_bind_methods() {
SceneMultiplayer::SceneMultiplayer() { SceneMultiplayer::SceneMultiplayer() {
relay_buffer.instantiate(); relay_buffer.instantiate();
cache = Ref<SceneCacheInterface>(memnew(SceneCacheInterface(this))); cache.instantiate(this);
replicator = Ref<SceneReplicationInterface>(memnew(SceneReplicationInterface(this, cache.ptr()))); replicator.instantiate(this, cache.ptr());
rpc = Ref<SceneRPCInterface>(memnew(SceneRPCInterface(this, cache.ptr(), replicator.ptr()))); rpc.instantiate(this, cache.ptr(), replicator.ptr());
set_multiplayer_peer(Ref<OfflineMultiplayerPeer>(memnew(OfflineMultiplayerPeer))); set_multiplayer_peer(Ref<OfflineMultiplayerPeer>(memnew(OfflineMultiplayerPeer)));
} }

View File

@ -281,7 +281,7 @@ void OpenXRViewportCompositionLayerProvider::create_android_surface() {
composition_layer_extension->create_android_surface_swapchain(&info, &android_surface.swapchain, &surface); composition_layer_extension->create_android_surface_swapchain(&info, &android_surface.swapchain, &surface);
if (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 #endif

View File

@ -629,7 +629,7 @@ void VideoStreamPlaybackTheora::_streaming_thread(void *ud) {
#endif #endif
VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() { VideoStreamPlaybackTheora::VideoStreamPlaybackTheora() {
texture = Ref<ImageTexture>(memnew(ImageTexture)); texture.instantiate();
#ifdef THEORA_USE_THREAD_STREAMING #ifdef THEORA_USE_THREAD_STREAMING
int rb_power = nearest_shift(RB_SIZE_KB * 1024); int rb_power = nearest_shift(RB_SIZE_KB * 1024);

View File

@ -1082,7 +1082,7 @@ Error EditorExportPlatformIOS::_export_loading_screen_file(const Ref<EditorExpor
} }
if (splash.is_null()) { 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 // Using same image for both @2x and @3x

View File

@ -430,6 +430,6 @@ void TouchScreenButton::_bind_methods() {
} }
TouchScreenButton::TouchScreenButton() { TouchScreenButton::TouchScreenButton() {
unit_rect = Ref<RectangleShape2D>(memnew(RectangleShape2D)); unit_rect.instantiate();
unit_rect->set_size(Vector2(1, 1)); unit_rect->set_size(Vector2(1, 1));
} }

View File

@ -318,7 +318,7 @@ Ref<TriangleMesh> Label3D::generate_triangle_mesh() const {
facesw[j] = vtx; facesw[j] = vtx;
} }
triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh)); triangle_mesh.instantiate();
triangle_mesh->create(faces); triangle_mesh->create(faces);
return triangle_mesh; return triangle_mesh;

View File

@ -1081,8 +1081,8 @@ void NavigationAgent3D::_update_debug_path() {
debug_path_instance = RenderingServer::get_singleton()->instance_create(); debug_path_instance = RenderingServer::get_singleton()->instance_create();
} }
if (!debug_path_mesh.is_valid()) { if (debug_path_mesh.is_null()) {
debug_path_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); debug_path_mesh.instantiate();
} }
debug_path_mesh->clear_surfaces(); debug_path_mesh->clear_surfaces();

View File

@ -56,8 +56,8 @@ void NavigationLink3D::_update_debug_mesh() {
debug_instance = RenderingServer::get_singleton()->instance_create(); debug_instance = RenderingServer::get_singleton()->instance_create();
} }
if (!debug_mesh.is_valid()) { if (debug_mesh.is_null()) {
debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); debug_mesh.instantiate();
} }
RID nav_map = get_world_3d()->get_navigation_map(); RID nav_map = get_world_3d()->get_navigation_map();

View File

@ -389,8 +389,8 @@ void NavigationObstacle3D::_update_fake_agent_radius_debug() {
if (!fake_agent_radius_debug_instance.is_valid()) { if (!fake_agent_radius_debug_instance.is_valid()) {
fake_agent_radius_debug_instance = RenderingServer::get_singleton()->instance_create(); fake_agent_radius_debug_instance = RenderingServer::get_singleton()->instance_create();
} }
if (!fake_agent_radius_debug_mesh.is_valid()) { if (fake_agent_radius_debug_mesh.is_null()) {
fake_agent_radius_debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); fake_agent_radius_debug_mesh.instantiate();
} }
fake_agent_radius_debug_mesh->clear_surfaces(); fake_agent_radius_debug_mesh->clear_surfaces();
@ -487,8 +487,8 @@ void NavigationObstacle3D::_update_static_obstacle_debug() {
if (!static_obstacle_debug_instance.is_valid()) { if (!static_obstacle_debug_instance.is_valid()) {
static_obstacle_debug_instance = RenderingServer::get_singleton()->instance_create(); static_obstacle_debug_instance = RenderingServer::get_singleton()->instance_create();
} }
if (!static_obstacle_debug_mesh.is_valid()) { if (static_obstacle_debug_mesh.is_null()) {
static_obstacle_debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); static_obstacle_debug_mesh.instantiate();
} }
static_obstacle_debug_mesh->clear_surfaces(); static_obstacle_debug_mesh->clear_surfaces();

View File

@ -492,8 +492,8 @@ void NavigationRegion3D::_update_debug_mesh() {
debug_instance = RenderingServer::get_singleton()->instance_create(); debug_instance = RenderingServer::get_singleton()->instance_create();
} }
if (!debug_mesh.is_valid()) { if (debug_mesh.is_null()) {
debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); debug_mesh.instantiate();
} }
debug_mesh->clear_surfaces(); debug_mesh->clear_surfaces();
@ -669,8 +669,8 @@ void NavigationRegion3D::_update_debug_edge_connections_mesh() {
debug_edge_connections_instance = RenderingServer::get_singleton()->instance_create(); debug_edge_connections_instance = RenderingServer::get_singleton()->instance_create();
} }
if (!debug_edge_connections_mesh.is_valid()) { if (debug_edge_connections_mesh.is_null()) {
debug_edge_connections_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); debug_edge_connections_mesh.instantiate();
} }
debug_edge_connections_mesh->clear_surfaces(); debug_edge_connections_mesh->clear_surfaces();

View File

@ -88,8 +88,8 @@ void Path3D::_update_debug_mesh() {
return; return;
} }
if (!debug_mesh.is_valid()) { if (debug_mesh.is_null()) {
debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); debug_mesh.instantiate();
} }
if (!(curve.is_valid())) { if (!(curve.is_valid())) {

View File

@ -464,7 +464,7 @@ void RayCast3D::_create_debug_shape() {
} }
if (debug_mesh.is_null()) { if (debug_mesh.is_null()) {
debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); debug_mesh.instantiate();
} }
} }

View File

@ -546,7 +546,7 @@ void ShapeCast3D::_create_debug_shape() {
} }
if (debug_mesh.is_null()) { if (debug_mesh.is_null()) {
debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); debug_mesh.instantiate();
} }
} }

View File

@ -470,7 +470,7 @@ Ref<TriangleMesh> SpriteBase3D::generate_triangle_mesh() const {
facesw[j] = vtx; facesw[j] = vtx;
} }
triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh)); triangle_mesh.instantiate();
triangle_mesh->create(faces); triangle_mesh->create(faces);
return triangle_mesh; return triangle_mesh;

View File

@ -3001,5 +3001,5 @@ GraphEdit::GraphEdit() {
set_clip_contents(true); set_clip_contents(true);
arranger = Ref<GraphEditArranger>(memnew(GraphEditArranger(this))); arranger.instantiate(this);
} }

View File

@ -899,7 +899,7 @@ Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() {
return 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)); Ref<StandardMaterial3D> mat = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);

View File

@ -1213,7 +1213,7 @@ void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) {
} }
} else { } else {
WARN_PRINT("Invalid world_2d"); WARN_PRINT("Invalid world_2d");
world_2d = Ref<World2D>(memnew(World2D)); world_2d.instantiate();
} }
world_2d->register_viewport(this); 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(); own_world_3d = world_3d->duplicate();
world_3d->connect_changed(callable_mp(this, &Viewport::_own_world_3d_changed)); world_3d->connect_changed(callable_mp(this, &Viewport::_own_world_3d_changed));
} else { } 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(); own_world_3d = world_3d->duplicate();
world_3d->connect_changed(callable_mp(this, &Viewport::_own_world_3d_changed)); world_3d->connect_changed(callable_mp(this, &Viewport::_own_world_3d_changed));
} else { } else {
own_world_3d = Ref<World3D>(memnew(World3D)); own_world_3d.instantiate();
} }
} else { } else {
own_world_3d = Ref<World3D>(); own_world_3d = Ref<World3D>();
@ -4963,7 +4963,7 @@ void Viewport::_validate_property(PropertyInfo &p_property) const {
} }
Viewport::Viewport() { Viewport::Viewport() {
world_2d = Ref<World2D>(memnew(World2D)); world_2d.instantiate();
world_2d->register_viewport(this); world_2d->register_viewport(this);
viewport = RenderingServer::get_singleton()->viewport_create(); viewport = RenderingServer::get_singleton()->viewport_create();

View File

@ -73,7 +73,7 @@ Ref<ArrayMesh> Shape3D::get_debug_mesh() {
Vector<Vector3> lines = get_debug_mesh_lines(); Vector<Vector3> lines = get_debug_mesh_lines();
debug_mesh_cache = Ref<ArrayMesh>(memnew(ArrayMesh)); debug_mesh_cache.instantiate();
if (!lines.is_empty()) { if (!lines.is_empty()) {
//make mesh //make mesh

View File

@ -385,7 +385,7 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
} }
} }
triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh)); triangle_mesh.instantiate();
triangle_mesh->create(faces); triangle_mesh->create(faces);
return triangle_mesh; return triangle_mesh;

View File

@ -392,8 +392,8 @@ Ref<ArrayMesh> NavigationMesh::get_debug_mesh() {
return debug_mesh; return debug_mesh;
} }
if (!debug_mesh.is_valid()) { if (debug_mesh.is_null()) {
debug_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); debug_mesh.instantiate();
} else { } else {
debug_mesh->clear_surfaces(); debug_mesh->clear_surfaces();
} }

View File

@ -2195,7 +2195,7 @@ void PackedScene::replace_state(Ref<SceneState> p_by) {
} }
void PackedScene::recreate_state() { void PackedScene::recreate_state() {
state = Ref<SceneState>(memnew(SceneState)); state.instantiate();
state->set_path(get_path()); state->set_path(get_path());
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
state->set_last_modified_time(get_last_modified_time()); state->set_last_modified_time(get_last_modified_time());
@ -2286,5 +2286,5 @@ void PackedScene::_bind_methods() {
} }
PackedScene::PackedScene() { PackedScene::PackedScene() {
state = Ref<SceneState>(memnew(SceneState)); state.instantiate();
} }

View File

@ -89,7 +89,7 @@ void PortableCompressedTexture2D::_set_data(const Vector<uint8_t> &p_data) {
data_size -= mipsize; 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; } break;
case COMPRESSION_MODE_BASIS_UNIVERSAL: { 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_S3TC:
case COMPRESSION_MODE_ETC2: case COMPRESSION_MODE_ETC2:
case COMPRESSION_MODE_BPTC: { 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; } break;
} }
ERR_FAIL_COND(image.is_null()); ERR_FAIL_COND(image.is_null());

View File

@ -1577,7 +1577,7 @@ TEST_CASE("[SceneTree][Viewport] Physics Picking 2D") {
PickingCollider pc; PickingCollider pc;
pc.a = memnew(TestArea2D); pc.a = memnew(TestArea2D);
pc.c = memnew(CollisionShape2D); pc.c = memnew(CollisionShape2D);
pc.r = Ref<RectangleShape2D>(memnew(RectangleShape2D)); pc.r.instantiate();
pc.r->set_size(Size2(150, 150)); pc.r->set_size(Size2(150, 150));
pc.c->set_shape(pc.r); pc.c->set_shape(pc.r);
pc.a->add_child(pc.c); pc.a->add_child(pc.c);