mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Fix implementation of property_can_revert() in various classes
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user