Commit Graph

6919 Commits

Author SHA1 Message Date
Christoph Neuhauser
a889aa9e38 WM: Switch to high-resolution timers on Windows for sleeping
This PR introduces a more precise sleep function `BLI_time_sleep_duration`
using high-resolution timers on Windows. By default, Windows only has a
resolution of 15.25ms for the regular `Sleep` function. Using more precise
timers makes sure that Blender can wake from sleep quicker and improves
performance at high frame rates.

High-resolution timers may have better energy efficiency than using
`timeBeginPeriod`/`timeEndPeriod` that change the timer resolution globally
on some versions of Windows.

Pull Request: https://projects.blender.org/blender/blender/pulls/140221
2025-07-15 10:02:09 +02:00
Campbell Barton
f62422884b Fix: correction to recent WM_cursor_time fix
Recent fix to ensure cursors never display negative numbers [0]
didn't work when the input value was std::numeric_limits<int>::min().

Resolve using an unsigned cast before negating.

[0]: 747ab523c3
2025-07-15 15:27:01 +10:00
Campbell Barton
747ab523c3 Fix: crash displaying negative numbers in WM_cursor_time
Displaying negative numbers would attempt to read from a negative
array index on systems that don't support RGBA cursors.
Resolving by making the value absolute before displaying.
2025-07-15 14:33:50 +10:00
Campbell Barton
3a55348492 WM: various improvements to text cursors
- Use a bounding box based on the fonts dimensions to fix jittering
  as numbers change because of differences in glyph bounds.
- Always show a cursor even if the text is empty.
- Use integer arithmetic to simplify bounds calculations and avoid
  having to round the resulting values.
- Increase the maximum width of the text to twice the cursor size
  since the text could be quite small when limited to the cursor size.
- Extract buffer flip-Y into a function.
- Define CURSOR_HARDWARE_SIZE_MAX and reuse this constant.
2025-07-15 13:55:22 +10:00
Guillermo Venegas
1a247fbaa8 Refactor: WM: Make OperatorCallContext an enum class, move to namespace
This allows forward declaring `OpCallContext`, avoiding the
transitive include `WM_Types.hh` in `UI_interface_layout.hh`

Pull Request: https://projects.blender.org/blender/blender/pulls/141804
2025-07-15 03:08:04 +02:00
Jacques Lucke
00c81f5113 Merge branch 'blender-v4.5-release' 2025-07-14 16:30:38 +02:00
YimingWu
4096309753 Fix #141819: Interface Use a flag for WM_set_locked_interface
Different operations may need to lock different part of the interface,
e.g. for rendering, the image editor may still need refreshing while the
interface is locked, but when baking data into a scene, the image editor
needs to be locked because it is not thread safe to get data from a
partially evaluated depsgraph.

This is a better fix on top of 7c8b8b2457
that addresses the root cause with more flexibility for future
operations that requires different interface locking strategy as
well.

Pull Request: https://projects.blender.org/blender/blender/pulls/141866
2025-07-14 16:17:46 +02:00
Hans Goudey
14e2876b73 Core: Replace BLI_buffer.hh with blender::Vector
The C++ Vector container has the benefits of the older C type,
along with improved performance, better type and memory safety,
and significantly improved ergonomics.

Pull Request: https://projects.blender.org/blender/blender/pulls/141759
2025-07-13 17:13:59 +02:00
Campbell Barton
ec8751f826 Cleanup: white-space around C-style comment blocks
Also use C++ style comments for disabling code.
2025-07-13 21:58:53 +10:00
Campbell Barton
a34c943e37 WM: correct own regression in recent cursor size clamping
When calculating the font size clamp by the requested cursor size
instead of 256.

This will often make the cursor smaller since allowing 256px wide
cursors is quite large.

Also de-duplicate size checks & round the text size to an integer to
avoid fractional scaling from subtle changes to the text.
2025-07-13 13:44:10 +10:00
Campbell Barton
4820bcc7cc Cleanup: doc-strings for currsor rasterization
Also add a safeguard to ensure the resulting cursor
never exceeds the requested size.
2025-07-13 12:28:32 +10:00
Campbell Barton
566afb8201 WM: access the windows DPI directly to calculate the mouse-cursor scaling
Instead of relying on the the `U.ui_scale` being set when activating
the window, calculate the cursor size from the windows DPI.

This also de-duplicates cursor scale calculation.
2025-07-13 11:57:29 +10:00
Campbell Barton
41fc42697c Cleanup: rename WM_window_{set_dpi => dpi_set_userdef}
The name read as if it was setting the DPI however the window DPI
was being calculated and written into the #UserDef (U).
2025-07-13 11:31:41 +10:00
Campbell Barton
a3d30afca1 Cleanup: move cursor details into struct doc-strings 2025-07-13 11:25:09 +10:00
Campbell Barton
10fab706f5 Cleanup: pass the cursor size to cursor_bitmap_from_text
Rename cursor_size() to wm_cursor_size() to allow this to be used
as an argument name without shadowing.
2025-07-12 20:54:27 +10:00
Campbell Barton
31ac70e6c2 Refactor: extract cursor rasterization into separate function calls
Prepare for dynamic cursor generation from !141597.
2025-07-12 20:36:01 +10:00
Campbell Barton
deda15f386 Cleanup: minor changes to wm_cursors.cc
- Use "g_" prefix for cursors to signify that it's global but local to
  the file.
- Use `const` cast passing pixel data to GHOST_SetCustomCursorShape.
- Remove redundant cast.
2025-07-12 19:24:14 +10:00
Campbell Barton
420a6a5bb6 WM: restore test code from previous commit
Restore UI_SCALE_FAC use for disabled testing logic.
2025-07-12 19:10:35 +10:00
Campbell Barton
eb836d8ae1 WM: use the systems DPI for cursor scale instead of the UI scale
Cursor size calculation now uses the GHOST DPI without the UI scale
since the UI scale doesn't impact system cursors.
2025-07-12 19:01:32 +10:00
Harley Acheson
bea1dbfab0 UI: Cursor Time for RGBA Platforms
The Windows and Wayland platforms can both create antialiased mouse
cursors from SVG sources. Platforms with WM_CAPABILITY_CURSOR_RGBA
can therefore show a better version of "WM_cursor_time". Instead of
four blocky digits in two rows this displays beautiful digits in a
single row.

Pull Request: https://projects.blender.org/blender/blender/pulls/141367
2025-07-12 05:22:41 +02:00
Hans Goudey
8f198a85b4 Refactor: Add RNA_string_get function returning a string
This can replace most uses `RNA_string_get_alloc` and give us
better type safety and generally simpler code.

Internally, this uses the function added in 50076993f3.

Pull Request: https://projects.blender.org/blender/blender/pulls/141358
2025-07-11 16:24:13 +02:00
Guillermo Venegas
1f34dc9155 Refactor: UI: Replace uiItemsEnumO with class method uiLayout::op_enum
This converts the public uiItemsEnumO and uiItemsFullEnumO functions
to an object-oriented API (as uiLayout::op_enum overloads), matching
recent changes in the API.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/141748
2025-07-11 15:25:30 +02:00
Campbell Barton
6a2a999173 Merge branch 'blender-v4.5-release' 2025-07-11 15:48:27 +10:00
Campbell Barton
29a7b60a40 Fix #141667: Erratic behavior with orthographic camera gizmo
Regression in 3.6 caused the orthographic camera gizmo to enter a
feedback loop where the gizmo range was changed while being interacted
with.

Resolve by preventing the range being updated during modal interaction.
2025-07-11 15:36:16 +10:00
Sergey Sharybin
93be12fde0 ImBuf: Linearize float buffers from FFmpeg
Blender expects float buffers to be in scene linear space, which was
violated bu the 1012bit movie reading code. While such image buffers
can be displayed correctly, performing operations in various areas
of Blender might lead to unexpected results.

The non-linear colorspace for ImBuf is expected to be "internal-only"
to a specific area, like VSE.

This is only done for Image and MovieClip data-blocks, sequencer still
reads movie files in their original colorspace as it helps performance and
sequencer can not be referenced from places where linear colorspace
for float buffer is really important.

Pull Request: https://projects.blender.org/blender/blender/pulls/141603
2025-07-10 17:39:00 +02:00
Brecht Van Lommel
bc507861f2 Logging: Some tweaks to capitalization and log levels
For NDOF, Vulkan context, operators and events.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:27 +02:00
Brecht Van Lommel
d7cc940825 Logging: Log GHOST backend, GPU backend and GPU device
Important information that could not be found directly in the logs yet.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:27 +02:00
Brecht Van Lommel
4653b65f7c Logging: Add DEBUG, TRACE severity, replace numeric levels
The numeric levels have no obvious meaning. This removes the distinction
between severity and levels, instead there is a single list of named levels
with defined meaning.

Debug means information that's mainly useful for developers, and trace is for
very verbose code execution tracing.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Brecht Van Lommel
8d8e61fefd Logging: Change various categories and log levels
* Remove bke, ed and wm prefixes
* Add prefixes like: geom, object, blend, lib.
* Shorten some category names
* A few log level changes to improve --log-level info output

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
2025-07-09 20:59:26 +02:00
Harley Acheson
37f10aaa4a UI: Fix Cursor Size Truncation Issue
Mouse cursor size calculation must use round rather than trunc.
Otherwise there is a decrease in cursor size from 1X -> 1.01X scale.

Pull Request: https://projects.blender.org/blender/blender/pulls/141637
2025-07-08 23:59:47 +02:00
Campbell Barton
439253eab5 Cleanup: use consistent terms in capability flags
Consistently use terms "cursor" & "clipboard" as a prefix
so they auto-complete more usefully.

Previously both ordering was used.
2025-07-08 16:35:42 +10:00
Campbell Barton
7c41250916 Fix large software cursors with Hi-DPI display on Wayland
Since the cursors are now generated from SVG's at the correct size
there is no need to scale them up when drawing software cursors.
2025-07-08 16:35:42 +10:00
Campbell Barton
b054a4557b Cleanup: use an integer to represent the cursor size
The move to SVG cursors used a float for the cursor size which isn't
especially useful as the resulting cursor dimensions are pixels.
2025-07-08 11:43:06 +10:00
Campbell Barton
b2d6af6c2b Cleanup: use const reference for cursor data
Also remove redundant null check.
2025-07-08 11:26:48 +10:00
Campbell Barton
12f0e3ee78 Merge branch 'blender-v4.5-release' 2025-07-08 10:38:10 +10:00
Campbell Barton
4431d7a369 Fix #141514: Broken cryptomatte picking with multi-windows on Wayland
Only perform window under cursor checks for GHOST back-ends that
have the window positioning capability.
2025-07-08 10:36:10 +10:00
Germano Cavalcante
289adf8616 Merge branch 'blender-v4.5-release' 2025-07-07 11:56:35 -03:00
Germano Cavalcante
cd143ca900 Fix: Wrong depth status in gizmo selection
When selecting gizmos (such as one of the scale handles in the
Transform tool), the depth test state does not match what is shown in
the viewport. This can lead to unintuitive gizmo selection.

The issue is caused by the incorrect assumption that the depth state is
already `GPU_DEPTH_NONE` before rendering the gizmos for selection.

The solution is to ensure the status before rendering.

Pull Request: https://projects.blender.org/blender/blender/pulls/141412
2025-07-07 16:54:22 +02:00
Sean Kim
7f3aa617ce Refactor: Move Paint_Runtime out of DNA
This commit takes the previously defined `Paint_Runtime` struct and
moves it into the BKE namespace, initializing it on demand instead of it
being a default-allocated member. This data does not need to be
persisted and is runtime only.

Pull Request: https://projects.blender.org/blender/blender/pulls/141413
2025-07-07 16:53:12 +02:00
Pratik Borhade
841c36850c Fix #67806: Delete non existing temp screens
When deleting a window, clear screen ID data if it belongs to
non-main window with single area

Pull Request: https://projects.blender.org/blender/blender/pulls/132978
2025-07-04 11:56:12 +02:00
Guillermo Venegas
b36e5b4b06 Refactor: UI: Replace UI_block_layout with blender::ui::block_layout
This renames `UI_block_layout` API as `blender::ui::block_layout`,
following uiLayout refactors.
This function now returns a layout reference instead of pointer,
this changes applies this return type where the layout can be used
as such reference.

Changes includes the use of `blender::ui::LayoutDirection` and
`blender::ui::LayoutType` as typed enum parameters.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/141401
2025-07-03 22:00:46 +02:00
Guillermo Venegas
d441ac2d6f Fix: Incorrects filepaths on drag and drop with recursive option enabled
Currently drag and drop expects to selection to be in the same folder,
but blender internal file browser allows to select files from different
folders when recursion is active.

When writing to operator properties the `directory` is taken now from
the first file provided, and `files` are now relative to this
`directory` instead of just taking the file name.
When reading from operator properties filepaths are normalized.

I notice this issue while reading about #140942, the issue would
require a proper fix too.

Pull Request: https://projects.blender.org/blender/blender/pulls/140948
2025-07-03 19:21:59 +02:00
Harley Acheson
4df8b950e1 Fix: Correct RGBA Cursor Sizing Error
While calculating the scaling factor when rasterizing SVG files to
cursors there is an extra code line left in that was only used
during testing. Basically the size is correctly calculated and then
this extra line does it again, but in a different way. This can result
in the very bottom single line of the cursor being cut off at some
sizes.

Pull Request: https://projects.blender.org/blender/blender/pulls/141410
2025-07-03 19:05:18 +02:00
Jeroen Bakker
b1fc86cc75 Merge branch 'blender-v4.5-release' 2025-07-03 09:56:23 +02:00
Jeroen Bakker
eeb2dc8a9e Fix #141305: Vulkan: Animation player memory leak
When playing back render result a separate process is started for
playback. This process didn't call the GPU_context_frame_begin/end
functions resulting in post-poning destroying discarded resources until
the playback process was 'exited'.

Pull Request: https://projects.blender.org/blender/blender/pulls/141376
2025-07-03 09:55:09 +02:00
Campbell Barton
21e9be6c5e UI: show the ~/ abbreviation for $HOME in the title on Unix systems
Avoid overly long paths in the title bar using the `~` prefix.

Based on feedback from !141059 there is consensus on supporting this
on Linux, that PR also supports abbreviations on other systems but
platform maintainers had concerns (see PR for details).

Apply the functionality for generic Linux/Unix systems,
the functionality for other platforms can be evaluated separately.
2025-07-03 02:50:38 +00:00
Campbell Barton
3817b476ca Merge branch 'blender-v4.5-release' 2025-07-02 20:13:03 +10:00
Campbell Barton
8ce2756b18 Fix brush toggle not working when using tools with multiple scenes
Follow up to #140668 that fixes the same issue when using multiple
windows & scenes. This is needed as the active tool can apply to
multiple scenes.

Ref !141260
2025-07-02 20:10:53 +10:00
Campbell Barton
9fc300a0ea Cleanup: rename the value used to store the cursor image
Rename `render_bmp` to `bitmap_rgba` since BMP has an assassination
with the BMP file format, and this is an RGBA equivalent of an existing
`bitmap` variable.
2025-07-01 17:13:50 +10:00
Campbell Barton
bd5346e94b Fix: missing error check when loading SVG cursors 2025-07-01 17:04:10 +10:00