RNA: generate valid infinite float property default values #113854

Manually merged
Sybren A. Stüvel merged 1 commits from dr.sybren/blender:pr/rna-float-infinite-defaults into main 2023-10-19 14:55:58 +02:00

In makesrna, generate valid default values for float properties, when those defaults are positive/negative infinity.

Blender would currently generate the strings inff and -inff, which are not valid C++. This PR changes that to std::numeric_limits<float>::infinity() and -std::numeric_limits<float>::infinity().

Context: the layered animation system (see #113594) will have animation layers with strips on them. It will have the concept of "infinite strips", where from a user's perspective there aren't even any strips at all, and the layer seems to directly contain the keys themselves. This is purely a UI distinction though, where we simply won't draw the outline of infinite strips. Being able to work with ±∞ as floating point values has clear advantages, as then the strip.frame_start and strip.frame_end properties will always "tell the truth".

This particular change is necessary to allow these values as defaults. It is not intended that users will have property sliders for these properties when their value is "infinite" (but rather a button 'make finite' or something along those lines), so interaction with the UI code will likely be minimal.

In `makesrna`, generate valid default values for float properties, when those defaults are positive/negative infinity. Blender would currently generate the strings `inff` and `-inff`, which are not valid C++. This PR changes that to `std::numeric_limits<float>::infinity()` and `-std::numeric_limits<float>::infinity()`. Context: the layered animation system (see #113594) will have animation layers with strips on them. It will have the concept of "infinite strips", where from a user's perspective there aren't even any strips at all, and the layer seems to directly contain the keys themselves. This is purely a UI distinction though, where we simply won't draw the outline of infinite strips. Being able to work with ±∞ as floating point values has clear advantages, as then the `strip.frame_start` and `strip.frame_end` properties will always "tell the truth". This particular change is necessary to allow these values as defaults. It is not intended that users will have property sliders for these properties when their value is "infinite" (but rather a button 'make finite' or something along those lines), so interaction with the UI code will likely be minimal.
Sybren A. Stüvel added the
Module
Core
label 2023-10-17 18:29:41 +02:00
Sybren A. Stüvel added 1 commit 2023-10-17 18:29:52 +02:00
b559d8676c RNA: generate valid infinite float property default values
In `makesrna`, generate valid default values for float properties, when
those defaults are positive/negative infinity.

Blender would currently generate the strings `inff` and `-inff`, which
are not valid C++. This PR changes that to
`std::numeric_limits<float>::infinity()` and
`-std::numeric_limits<float>::infinity()`.
Sybren A. Stüvel requested review from Bastien Montagne 2023-10-17 18:30:08 +02:00
Sybren A. Stüvel added this to the Animation & Rigging project 2023-10-17 18:30:14 +02:00

That looks good in general, since current behavior is broken anyway. But have you also checked how the python binding code deals with these new float values?

That looks good in general, since current behavior is broken anyway. But have you also checked how the python binding code deals with these new float values?
Author
Member

Yes, it works just fine. I can assign strip.frame_start = -inf just fine.

Even the sliders display the values pretty well:

Screenshot of Blender, showing -inf and inf as slider values

Editing doesn't work properly (the hard limits are still FLT_MAX), but that's not for this PR. I just wanted to be sure that nothing would crash when displaying those values, and that's all 👌 .

Yes, it works just fine. I can assign `strip.frame_start = -inf` just fine. Even the sliders display the values pretty well: ![Screenshot of Blender, showing `-inf` and `inf` as slider values](/attachments/4a24253b-c43c-4189-a48a-1cd920b19486) Editing doesn't work properly (the hard limits are still `FLT_MAX`), but that's not for this PR. I just wanted to be sure that nothing would crash when displaying those values, and that's all 👌 .
7.3 KiB
Bastien Montagne approved these changes 2023-10-19 13:57:43 +02:00
Bastien Montagne left a comment
Owner

LGTM then, thx.

LGTM then, thx.
Sybren A. Stüvel manually merged commit 395ac4c41f into main 2023-10-19 14:55:58 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser Project (Legacy)
Interest
Asset System
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 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#113854
No description provided.