You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Material Conversion Error Handling
Material Conversion Plugins now ERR_FAIL if called on an unitialized material.
FileSystemDock no longer crashes if Conversion Plugin fails and returns a null ref.
(cherry picked from commit 05fd79af7c)
This commit is contained in:
committed by
Thaddeus Crews
parent
3e17d7f028
commit
0af3765f77
@@ -1880,6 +1880,7 @@ void FileSystemDock::_convert_dialog_action() {
|
||||
for (const String &target : cached_valid_conversion_targets) {
|
||||
if (conversion_id == selected_conversion_id && conversion->converts_to() == target) {
|
||||
Ref<Resource> converted_res = conversion->convert(res);
|
||||
ERR_FAIL_COND(converted_res.is_null());
|
||||
ERR_FAIL_COND(res.is_null());
|
||||
converted_resources.push_back(converted_res);
|
||||
resources_to_erase_history_for.insert(res);
|
||||
|
||||
@@ -450,6 +450,7 @@ bool StandardMaterial3DConversionPlugin::handles(const Ref<Resource> &p_resource
|
||||
Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p_resource) const {
|
||||
Ref<StandardMaterial3D> mat = p_resource;
|
||||
ERR_FAIL_COND_V(mat.is_null(), Ref<Resource>());
|
||||
ERR_FAIL_COND_V(!mat->_is_initialized(), Ref<Resource>());
|
||||
|
||||
Ref<ShaderMaterial> smat;
|
||||
smat.instantiate();
|
||||
@@ -496,6 +497,7 @@ bool ORMMaterial3DConversionPlugin::handles(const Ref<Resource> &p_resource) con
|
||||
Ref<Resource> ORMMaterial3DConversionPlugin::convert(const Ref<Resource> &p_resource) const {
|
||||
Ref<ORMMaterial3D> mat = p_resource;
|
||||
ERR_FAIL_COND_V(mat.is_null(), Ref<Resource>());
|
||||
ERR_FAIL_COND_V(!mat->_is_initialized(), Ref<Resource>());
|
||||
|
||||
Ref<ShaderMaterial> smat;
|
||||
smat.instantiate();
|
||||
@@ -542,6 +544,7 @@ bool ParticleProcessMaterialConversionPlugin::handles(const Ref<Resource> &p_res
|
||||
Ref<Resource> ParticleProcessMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
|
||||
Ref<ParticleProcessMaterial> mat = p_resource;
|
||||
ERR_FAIL_COND_V(mat.is_null(), Ref<Resource>());
|
||||
ERR_FAIL_COND_V(!mat->_is_initialized(), Ref<Resource>());
|
||||
|
||||
Ref<ShaderMaterial> smat;
|
||||
smat.instantiate();
|
||||
@@ -581,6 +584,7 @@ bool CanvasItemMaterialConversionPlugin::handles(const Ref<Resource> &p_resource
|
||||
Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
|
||||
Ref<CanvasItemMaterial> mat = p_resource;
|
||||
ERR_FAIL_COND_V(mat.is_null(), Ref<Resource>());
|
||||
ERR_FAIL_COND_V(!mat->_is_initialized(), Ref<Resource>());
|
||||
|
||||
Ref<ShaderMaterial> smat;
|
||||
smat.instantiate();
|
||||
@@ -620,6 +624,7 @@ bool ProceduralSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resou
|
||||
Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
|
||||
Ref<ProceduralSkyMaterial> mat = p_resource;
|
||||
ERR_FAIL_COND_V(mat.is_null(), Ref<Resource>());
|
||||
ERR_FAIL_COND_V(!mat->_is_initialized(), Ref<Resource>());
|
||||
|
||||
Ref<ShaderMaterial> smat;
|
||||
smat.instantiate();
|
||||
@@ -659,6 +664,7 @@ bool PanoramaSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resourc
|
||||
Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
|
||||
Ref<PanoramaSkyMaterial> mat = p_resource;
|
||||
ERR_FAIL_COND_V(mat.is_null(), Ref<Resource>());
|
||||
ERR_FAIL_COND_V(!mat->_is_initialized(), Ref<Resource>());
|
||||
|
||||
Ref<ShaderMaterial> smat;
|
||||
smat.instantiate();
|
||||
@@ -698,6 +704,7 @@ bool PhysicalSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resourc
|
||||
Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
|
||||
Ref<PhysicalSkyMaterial> mat = p_resource;
|
||||
ERR_FAIL_COND_V(mat.is_null(), Ref<Resource>());
|
||||
ERR_FAIL_COND_V(!mat->_is_initialized(), Ref<Resource>());
|
||||
|
||||
Ref<ShaderMaterial> smat;
|
||||
smat.instantiate();
|
||||
@@ -737,6 +744,7 @@ bool FogMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const
|
||||
Ref<Resource> FogMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const {
|
||||
Ref<FogMaterial> mat = p_resource;
|
||||
ERR_FAIL_COND_V(mat.is_null(), Ref<Resource>());
|
||||
ERR_FAIL_COND_V(!mat->_is_initialized(), Ref<Resource>());
|
||||
|
||||
Ref<ShaderMaterial> smat;
|
||||
smat.instantiate();
|
||||
|
||||
@@ -65,7 +65,6 @@ protected:
|
||||
|
||||
void _mark_ready();
|
||||
void _mark_initialized(const Callable &p_add_to_dirty_list, const Callable &p_update_shader);
|
||||
bool _is_initialized() { return init_state == INIT_STATE_READY; }
|
||||
|
||||
GDVIRTUAL0RC_REQUIRED(RID, _get_shader_rid)
|
||||
GDVIRTUAL0RC_REQUIRED(Shader::Mode, _get_shader_mode)
|
||||
@@ -76,6 +75,9 @@ public:
|
||||
RENDER_PRIORITY_MAX = RS::MATERIAL_RENDER_PRIORITY_MAX,
|
||||
RENDER_PRIORITY_MIN = RS::MATERIAL_RENDER_PRIORITY_MIN,
|
||||
};
|
||||
|
||||
bool _is_initialized() { return init_state == INIT_STATE_READY; }
|
||||
|
||||
void set_next_pass(const Ref<Material> &p_pass);
|
||||
Ref<Material> get_next_pass() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user