diff options
author | kobewi <kobewi4e@gmail.com> | 2024-08-06 00:11:02 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2024-10-04 23:02:04 +0200 |
commit | b9d25580ce2a8d00bf372c5304f6d7c65141fac9 (patch) | |
tree | 23f97ad7851ac2c151b72ac780e0b31979c706b9 /scene | |
parent | db66bd35af704fe0d83ba9348b8c50a48e51b2ba (diff) | |
download | redot-engine-b9d25580ce2a8d00bf372c5304f6d7c65141fac9.tar.gz |
Fix implementation of property_can_revert() in various classes
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/node_3d.cpp | 22 | ||||
-rw-r--r-- | scene/resources/material.cpp | 9 |
2 files changed, 15 insertions, 16 deletions
diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp index 86ce8a881a..85de85a9a6 100644 --- a/scene/3d/node_3d.cpp +++ b/scene/3d/node_3d.cpp @@ -1181,15 +1181,16 @@ void Node3D::_validate_property(PropertyInfo &p_property) const { } bool Node3D::_property_can_revert(const StringName &p_name) const { - if (p_name == "basis") { + const String sname = p_name; + if (sname == "basis") { return true; - } else if (p_name == "scale") { + } else if (sname == "scale") { return true; - } else if (p_name == "quaternion") { + } else if (sname == "quaternion") { return true; - } else if (p_name == "rotation") { + } else if (sname == "rotation") { return true; - } else if (p_name == "position") { + } else if (sname == "position") { return true; } return false; @@ -1198,35 +1199,36 @@ bool Node3D::_property_can_revert(const StringName &p_name) const { bool Node3D::_property_get_revert(const StringName &p_name, Variant &r_property) const { bool valid = false; - if (p_name == "basis") { + const String sname = p_name; + if (sname == "basis") { Variant variant = PropertyUtils::get_property_default_value(this, "transform", &valid); if (valid && variant.get_type() == Variant::Type::TRANSFORM3D) { r_property = Transform3D(variant).get_basis(); } else { r_property = Basis(); } - } else if (p_name == "scale") { + } else if (sname == "scale") { Variant variant = PropertyUtils::get_property_default_value(this, "transform", &valid); if (valid && variant.get_type() == Variant::Type::TRANSFORM3D) { r_property = Transform3D(variant).get_basis().get_scale(); } else { r_property = Vector3(1.0, 1.0, 1.0); } - } else if (p_name == "quaternion") { + } else if (sname == "quaternion") { Variant variant = PropertyUtils::get_property_default_value(this, "transform", &valid); if (valid && variant.get_type() == Variant::Type::TRANSFORM3D) { r_property = Quaternion(Transform3D(variant).get_basis().get_rotation_quaternion()); } else { r_property = Quaternion(); } - } else if (p_name == "rotation") { + } else if (sname == "rotation") { Variant variant = PropertyUtils::get_property_default_value(this, "transform", &valid); if (valid && variant.get_type() == Variant::Type::TRANSFORM3D) { r_property = Transform3D(variant).get_basis().get_euler_normalized(data.euler_rotation_order); } else { r_property = Vector3(); } - } else if (p_name == "position") { + } else if (sname == "position") { Variant variant = PropertyUtils::get_property_default_value(this, "transform", &valid); if (valid) { r_property = Transform3D(variant).get_origin(); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 9df009ec28..ecc1982aa5 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -382,14 +382,11 @@ void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const { bool ShaderMaterial::_property_can_revert(const StringName &p_name) const { if (shader.is_valid()) { - const StringName *pr = remap_cache.getptr(p_name); - if (pr) { - Variant default_value = RenderingServer::get_singleton()->shader_get_parameter_default(shader->get_rid(), *pr); - Variant current_value = get_shader_parameter(*pr); - return default_value.get_type() != Variant::NIL && default_value != current_value; - } else if (p_name == "render_priority" || p_name == "next_pass") { + if (remap_cache.has(p_name)) { return true; } + const String sname = p_name; + return sname == "render_priority" || sname == "next_pass"; } return false; } |