From 1e7c60174ea33c1e50cbb6e137e0db107f326776 Mon Sep 17 00:00:00 2001 From: Ansraer Date: Tue, 13 Feb 2024 15:44:23 +0100 Subject: [PATCH] fix crash on mat creation after orm refactor --- editor/editor_resource_picker.cpp | 2 +- editor/plugins/spatial_editor_plugin.h | 3 +-- modules/fbx/data/fbx_material.cpp | 2 +- modules/gltf/gltf_document.cpp | 6 +++--- modules/gridmap/grid_map_editor_plugin.h | 8 ++++---- scene/3d/mesh_instance.cpp | 2 +- scene/3d/ray_cast.cpp | 2 +- scene/3d/shape_cast.cpp | 2 +- scene/3d/voxel_light_baker.cpp | 2 +- scene/resources/material.cpp | 2 +- scene/resources/material.h | 3 ++- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 5ac14cd5dd1..78d2bb474c0 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -643,7 +643,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ if (at == "SpatialMaterial" && ClassDB::is_parent_class(dropped_resource->get_class(), "Texture")) { // Use existing resource if possible and only replace its data. - Ref mat = edited_resource; + Ref mat = edited_resource; if (mat.is_null()) { mat.instance(); } diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index f761bd66080..e54496abd1a 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -637,9 +637,8 @@ private: RID indicators_instance; RID cursor_mesh; RID cursor_instance; - Ref indicator_mat; + Ref indicator_mat; Ref grid_mat[3]; - Ref cursor_material; // Scene drag and drop support Spatial *preview_node; diff --git a/modules/fbx/data/fbx_material.cpp b/modules/fbx/data/fbx_material.cpp index f8aa99f4b1c..27b79826c49 100644 --- a/modules/fbx/data/fbx_material.cpp +++ b/modules/fbx/data/fbx_material.cpp @@ -253,7 +253,7 @@ Ref FBXMaterial::import_material(ImportState &state) { const String p_fbx_current_directory = state.path; - Ref spatial_material; + Ref spatial_material; // read the material file // is material two sided diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 505ab1cae85..6ddc8f48cdf 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -2919,7 +2919,7 @@ Error GLTFDocument::_parse_meshes(Ref p_state) { //just add it - Ref mat; + Ref mat; if (p.has("material")) { const int material = p["material"]; ERR_FAIL_INDEX_V(material, p_state->materials.size(), ERR_FILE_CORRUPT); @@ -2930,7 +2930,7 @@ Error GLTFDocument::_parse_meshes(Ref p_state) { mat = mat3d; } else if (has_vertex_color) { - Ref mat3d; + Ref mat3d; mat3d.instance(); mat3d->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); mat = mat3d; @@ -3669,7 +3669,7 @@ Error GLTFDocument::_parse_materials(Ref p_state) { for (GLTFMaterialIndex i = 0; i < materials.size(); i++) { const Dictionary &d = materials[i]; - Ref material; + Ref material; material.instance(); if (d.has("name") && !String(d["name"]).empty()) { material->set_name(d["name"]); diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index a89fbfa02a8..4612278aa5f 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -124,10 +124,10 @@ class GridMapEditor : public VBoxContainer { List clipboard_items; - Ref indicator_mat; - Ref inner_mat; - Ref outer_mat; - Ref selection_floor_mat; + Ref indicator_mat; + Ref inner_mat; + Ref outer_mat; + Ref selection_floor_mat; bool updating; diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index 048e81791c6..829511f92ef 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -822,7 +822,7 @@ void MeshInstance::create_debug_tangents() { } if (lines.size()) { - Ref sm; + Ref sm; sm.instance(); sm->set_flag(Material3D::FLAG_UNSHADED, true); diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp index 0d7ae0c4f26..2dfde85c936 100644 --- a/scene/3d/ray_cast.cpp +++ b/scene/3d/ray_cast.cpp @@ -421,7 +421,7 @@ void RayCast::_create_debug_shape() { void RayCast::_update_debug_shape_material(bool p_check_collision) { if (!debug_material.is_valid()) { - Ref material = memnew(Material3D); + Ref material = memnew(SpatialMaterial); debug_material = material; material->set_flag(Material3D::FLAG_UNSHADED, true); diff --git a/scene/3d/shape_cast.cpp b/scene/3d/shape_cast.cpp index a195fced0e1..df5d9971938 100644 --- a/scene/3d/shape_cast.cpp +++ b/scene/3d/shape_cast.cpp @@ -539,7 +539,7 @@ void ShapeCast::_create_debug_shape() { void ShapeCast::_update_debug_shape_material(bool p_check_collision) { if (!debug_material.is_valid()) { - Ref material = memnew(Material3D); + Ref material = memnew(SpatialMaterial); debug_material = material; material->set_flag(Material3D::FLAG_UNSHADED, true); diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp index 4ef6a2d27d2..adf0a5e84b3 100644 --- a/scene/3d/voxel_light_baker.cpp +++ b/scene/3d/voxel_light_baker.cpp @@ -1507,7 +1507,7 @@ Ref VoxelLightBaker::create_debug_multimesh(DebugMode p_mode) { } { - Ref fsm; + Ref fsm; fsm.instance(); fsm->set_flag(Material3D::FLAG_SRGB_VERTEX_COLOR, true); fsm->set_flag(Material3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 85d4075b076..1c9b4319ac4 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1826,7 +1826,7 @@ RID Material3D::get_material_rid_for_2d(bool p_shaded, bool p_transparent, bool return materials_for_2d[hash]->get_rid(); } - Ref material; + Ref material; material.instance(); material->set_flag(FLAG_UNSHADED, !p_shaded); diff --git a/scene/resources/material.h b/scene/resources/material.h index 01204eb1f45..2e0b2e25b9b 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -458,6 +458,8 @@ protected: void _validate_property(PropertyInfo &property) const; virtual bool _can_do_next_pass() const { return true; } + Material3D(bool p_orm = false); + public: void set_albedo(const Color &p_albedo); Color get_albedo() const; @@ -643,7 +645,6 @@ public: virtual Shader::Mode get_shader_mode() const; - Material3D(bool p_orm = false); virtual ~Material3D(); };