mirror of
https://github.com/godotengine/godot.git
synced 2026-02-08 03:38:29 +00:00
Merge pull request #106352 from aaronfranke/editor-quat-float-insp
Increase float precision in the editor inspector for Quaternions
This commit is contained in:
@@ -128,7 +128,10 @@ void EditorSpinSlider::gui_input(const Ref<InputEvent> &p_event) {
|
||||
pre_grab_value = get_max();
|
||||
}
|
||||
|
||||
double new_value = pre_grab_value + get_step() * grabbing_spinner_dist_cache;
|
||||
// Prevent dragging properties with very precise steps from being agonizingly slow.
|
||||
const double default_float_step = EDITOR_GET("interface/inspector/default_float_step");
|
||||
const double drag_step = MAX(get_step(), default_float_step);
|
||||
const double new_value = pre_grab_value + drag_step * grabbing_spinner_dist_cache;
|
||||
set_value((mm->is_command_or_control_pressed() && !editing_integer) ? Math::round(new_value) : new_value);
|
||||
}
|
||||
} else if (updown_offset != -1) {
|
||||
|
||||
@@ -4029,7 +4029,14 @@ EditorProperty *EditorInspectorDefaultPlugin::get_editor_for_property(Object *p_
|
||||
} break;
|
||||
case Variant::QUATERNION: {
|
||||
EditorPropertyQuaternion *editor = memnew(EditorPropertyQuaternion);
|
||||
editor->setup(_parse_range_hint(p_hint, p_hint_text, default_float_step), p_hint == PROPERTY_HINT_HIDE_QUATERNION_EDIT);
|
||||
// Quaternions are almost never used for human-readable values that need stepifying,
|
||||
// so we should be more precise with their step, as much as the float precision allows.
|
||||
#ifdef REAL_T_IS_DOUBLE
|
||||
constexpr double QUATERNION_STEP = 1e-14;
|
||||
#else
|
||||
constexpr double QUATERNION_STEP = 1e-6;
|
||||
#endif
|
||||
editor->setup(_parse_range_hint(p_hint, p_hint_text, QUATERNION_STEP), p_hint == PROPERTY_HINT_HIDE_QUATERNION_EDIT);
|
||||
return editor;
|
||||
} break;
|
||||
case Variant::AABB: {
|
||||
|
||||
@@ -78,7 +78,18 @@ void BonePropertiesEditor::create_editors() {
|
||||
|
||||
// Rotation property.
|
||||
rotation_property = memnew(EditorPropertyQuaternion());
|
||||
rotation_property->setup(large_range_hint);
|
||||
// Quaternions are almost never used for human-readable values that need stepifying,
|
||||
// so we should be more precise with their step, as much as the float precision allows.
|
||||
#ifdef REAL_T_IS_DOUBLE
|
||||
constexpr double QUATERNION_STEP = 1e-14;
|
||||
#else
|
||||
constexpr double QUATERNION_STEP = 1e-6;
|
||||
#endif
|
||||
EditorPropertyRangeHint quaternion_range_hint;
|
||||
quaternion_range_hint.min = -1.0;
|
||||
quaternion_range_hint.max = 1.0;
|
||||
quaternion_range_hint.step = QUATERNION_STEP;
|
||||
rotation_property->setup(quaternion_range_hint);
|
||||
rotation_property->set_label("Rotation");
|
||||
rotation_property->set_selectable(false);
|
||||
rotation_property->connect("property_changed", callable_mp(this, &BonePropertiesEditor::_value_changed));
|
||||
|
||||
Reference in New Issue
Block a user