OBJECT_OT_shape_key_clear ignores slider_min and slider_max #109011

Open
opened 2023-06-15 15:46:54 +02:00 by Thomas Barlow · 4 comments
Member

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 531.41

Blender Version
Broken: version: 2.79, 3.5.1, 4.0.0 Alpha, branch: main, commit date: 2023-06-03 14:21, hash: ab6860f3de0f
Worked:

Short description of error
The OBJECT_OT_shape_key_clear operator clears the .value of each Shape Key, setting it back to zero, but Shape Keys have .slider_min and .slider_max attributes which specify the minimum and maximum values for .value. OBJECT_OT_shape_key_clear does not respect the .slider_min/max values when it clears the .value of each Shape Key, setting .value to an otherwise impossible value when either .slider_min is greater than zero or .slider_max is less than zero.

Exact steps for others to reproduce the error
Attached is a .blend (authored in 4.0.0a) with steps 1-4 already set up.

  1. Create two non-'Basis' shape keys on a default cube
  2. On the first shape key, set its .slider_min to 0.5
  3. On the second shape key, set its .slider_min to -1.0
  4. On the second shape key, set its .slider_max to -0.5
  5. Click the button in the UI to Clear Shape Keys, or run bpy.ops.object.shape_key_clear()
    image
  6. Observe that the .value of each shape key is now set to 0.0
**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 531.41 **Blender Version** Broken: version: 2.79, 3.5.1, 4.0.0 Alpha, branch: main, commit date: 2023-06-03 14:21, hash: `ab6860f3de0f` Worked: **Short description of error** The OBJECT_OT_shape_key_clear operator clears the `.value` of each Shape Key, setting it back to zero, but Shape Keys have `.slider_min` and `.slider_max` attributes which specify the minimum and maximum values for `.value`. OBJECT_OT_shape_key_clear does not respect the `.slider_min/max` values when it clears the `.value` of each Shape Key, setting `.value` to an otherwise impossible value when either `.slider_min` is greater than zero or `.slider_max` is less than zero. **Exact steps for others to reproduce the error** Attached is a .blend (authored in 4.0.0a) with steps 1-4 already set up. 1) Create two non-'Basis' shape keys on a default cube 1) On the first shape key, set its `.slider_min` to 0.5 1) On the second shape key, set its `.slider_min` to -1.0 1) On the second shape key, set its `.slider_max` to -0.5 1) Click the button in the UI to Clear Shape Keys, or run `bpy.ops.object.shape_key_clear()` ![image](/attachments/130c5fd7-b187-4674-8cb7-90b03296f2e9) 1) Observe that the `.value` of each shape key is now set to 0.0
Thomas Barlow added the
Status
Needs Triage
Type
Report
Priority
Normal
labels 2023-06-15 15:46:55 +02:00
Member

I can confirm that. From the description I guess the expected value should be 0.5 and -0.5 (as in 0 clamped by slider_min and slider_max) ?

The slider is more about restricting the value on the interface. OBJECT_OT_shape_key_clear operator may intend to reset everything to zero so you can see the original mesh, if you have a min/max value that doesn't cover 0, the suggested behaviour would not reset everything to zero and some layers will still have influence to the original mesh, this might lead to confusion.

Maybe an option can be added to the operator that allows it to respect min/max values.

I can confirm that. From the description I guess the expected value should be `0.5` and `-0.5` (as in 0 clamped by `slider_min` and `slider_max`) ? The slider is more about restricting the value on the interface. `OBJECT_OT_shape_key_clear` operator may intend to reset everything to zero so you can see the original mesh, if you have a min/max value that doesn't cover 0, the suggested behaviour would not reset everything to zero and some layers will still have influence to the original mesh, this might lead to confusion. Maybe an option can be added to the operator that allows it to respect min/max values.
YimingWu added
Module
Animation & Rigging
Status
Needs Info from Developers
and removed
Status
Needs Triage
labels 2023-06-16 04:41:25 +02:00
Author
Member

0.0 clamped by slider_min and slider_max would be what I expected because that matches what happens when you try to set the value directly to 0.0 with the Python API, or when setting "value" with foreach_set.

If the slider_min and slider_max instead acted like a soft_min and soft_max whereby values outside of the slider range could be entered manually, then I think it would be fine for the operator to set the values to zero. A soft range would certainly make Python scripts that need to set specific shape key values less of a pain so that there's no need to check for weird slider_min and slider_max values, but I unfortunately suspect it would break drivers on shape key values that rely on the min and max values.

I would agree that it's questionable whether the operator is achieving its intent if it doesn't set all the values to zero.

`0.0` clamped by `slider_min` and `slider_max` would be what I expected because that matches what happens when you try to set the `value` directly to `0.0` with the Python API, or when setting `"value"` with `foreach_set`. If the `slider_min` and `slider_max` instead acted like a `soft_min` and `soft_max` whereby values outside of the slider range could be entered manually, then I think it would be fine for the operator to set the values to zero. A soft range would certainly make Python scripts that need to set specific shape key values less of a pain so that there's no need to check for weird `slider_min` and `slider_max` values, but I unfortunately suspect it would break drivers on shape key values that rely on the min and max values. I would agree that it's questionable whether the operator is achieving its intent if it doesn't set all the values to zero.
Member

If the slider_min and slider_max instead acted like a soft_min and soft_max whereby values outside of the slider range could be entered manually, then I think it would be fine for the operator to set the values to zero.

Yeah, it seems to be a inconsistency there, while you can't manually set 0 if it's outside the min/max range, the operator does do that.

> If the slider_min and slider_max instead acted like a soft_min and soft_max whereby values outside of the slider range could be entered manually, then I think it would be fine for the operator to set the values to zero. Yeah, it seems to be a inconsistency there, while you can't manually set 0 if it's outside the min/max range, the operator does do that.
Member

Looks like no one is looking at this thing due to other higher priority isues, I guess I'll make a patch.

Looks like no one is looking at this thing due to other higher priority isues, I guess I'll make a patch.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#109011
No description provided.