5541 Commits

Author SHA1 Message Date
Jorn Visser
7df175c326 Fix: Unused result warning
Check the result of the write function to avoid an unused result
warning.

Pull Request: https://projects.blender.org/blender/blender/pulls/148198
2025-10-16 15:29:03 +02:00
Jorn Visser
b3ba6465f4 Fix #139387: Crash reading invalid images from network drives on WIN32
Improve mmap handling of IO errors on WIN32.

Make MMAP gracefully handle IO errors on Windows by replacing the
mapping with zeros using a vectored exception handler when an
EXCEPTION_IN_PAGE_ERROR is raised. This is similar to how such errors
are handled on non-Windows platforms.

On Windows, this is implemented by first creating a placeholder
allocation and then mapping the file into it. When an error occurs, the
exception handler unmaps the file, keeping the placeholder intact, and
creates an anonymous mapping into it, after which execution can
continue.

Since some required functions don't exist on older Windows versions,
the error handling will only work on Windows 10, version 1803 or newer.

Ref !139739
2025-10-14 22:38:10 +00:00
Jacques Lucke
3e0df5d2d7 BLI: inline fast case of CacheMutex.ensure
I can measure a few percent speedup by doing that in the file from #146949.

Pull Request: https://projects.blender.org/blender/blender/pulls/147608
2025-10-08 12:23:22 +02:00
Andrej730
dec032e12e Anim: Indicate Parent Inverse Matrix State in UI
Show the Parent Inverse matrix in the Object properties, Transform
panel. The matrix is shown decomposed as location/rotation/scale.

Pull Request: https://projects.blender.org/blender/blender/pulls/113364
2025-10-08 11:13:24 +02:00
Jacques Lucke
b24cc091f0 Fix #147510: crash showing integer attribute in spreadsheet on some platforms
The issue here was that I wrongly assumed that the locale would always be available.
Instead just use our built-in function to add thousands-separators (which I didn't
find last time).

Pull Request: https://projects.blender.org/blender/blender/pulls/147515
2025-10-07 11:52:40 +02:00
Campbell Barton
2752b8a400 BLI_kdtree: use the index as a tie breaker when finding duplicates
Use the index as a tie breaker for deterministic results with the
"Merge by Distance" operator.

Ref !147252
2025-10-03 12:07:51 +10:00
Hans Goudey
a68d39e9d9 Cleanup: Formatting
Run `make format` after the library update in the previous commit.
2025-10-02 12:55:42 -04:00
Campbell Barton
2107bd7326 Cleanup: rename as_needed -> if_needed
Follow the naming convention used elsewhere in the code.
2025-10-01 16:01:48 +10:00
Campbell Barton
a59be80d38 Fix #146836: Auto merge not working in edit mode
Regression in [0] removed checks for indices referencing themselves
which need to be kept but can still be used as targets.

Restore this logic as well as fixing another problem (#147022)
where auto-merge would not merge into the nearest vertex, this
was especially noticeable then the threshold was set to a large value
but would happen at smaller values too.

[0]: bdae3e28a2
2025-09-30 17:37:17 +10:00
luz paz
279e20a9f2 Cleanup: Fix typos in source/blender/blenlib
Fixes some user-facing and non-user-facing typos. Found via codespell.

Pull Request: https://projects.blender.org/blender/blender/pulls/146111
2025-09-24 15:37:57 +02:00
Campbell Barton
1a93cd9148 Cleanup: quiet undeclared function warnings
Resolve warnings from !127711.

Ref !146685
2025-09-24 04:40:38 +00:00
Campbell Barton
8930b1a96a Cleanup: format 2025-09-24 14:00:43 +10:00
Campbell Barton
30485e6122 Cleanup: grammar, confusing wording 2025-09-24 03:06:11 +00:00
Tenkai Raiko
f8d579d153 Nodes: Add Radial Tiling Node
On its own, the main functionality of the Radial Tiling node
is the ability to divide a 2D Cartesian coordinate system into
as many radial segments as specified by the "Segments" input.
Each segment has its own affinely transformed coordinate system,
provided through the "Segment Coordinates" output, which can be
used to tile textures in a radially symmetric manner.

Additionally, a unique index is provided for every segment through
the "Segment ID" output, the width of each segment at Y-coordinate
of the "Segment Coordinates" output without normalization = 0 is
provided through the "Segment Width" output and the rotation value
of the affine transformation of the coordinate system of each segment
is provided through the "Segment Rotation" output.

The roundness of the coordinate lines of the "Segment Coordinates"
output can be controlled through the "Roundness" inputs.
This can be used to make the coordinate systems of the segments
a mix of Cartesian and polar coordinates.

Lastly, the lines of points of the "Segment Coordinates" output with
constant Y-coordinates have the shape of polygon with rounded corners,
which can be used to procedurally create rounded polygons.

Pull Request: https://projects.blender.org/blender/blender/pulls/127711
2025-09-22 16:02:37 +02:00
Campbell Barton
e59aab4d12 Cleanup: relocate doc-strings to header 2025-09-20 13:18:55 +10:00
Campbell Barton
bdae3e28a2 Modeling: use the central vertex when finding duplicates
Previously the method of picking the "target" duplicate wasn't
deterministic from a user perspective.

The behavior has been changed so:

- For a cluster of 3 or more vertices,
  use the vertex closest to the centroid.
- For a cluster of 2 use the lowest index.

This mitigates #78916, solving some cases where clusters have a
central vertex although can't be considered fixed as the 2 vertex
case doesn't work so well.

Added a BLI_kdtree_{N}d_calc_duplicates_cb function that lets the
caller choose the index to keep from a cluster of duplicates.

Refactored from !145851.

Ref !146492

Co-authored-by: tariqsulley <tariqsulley3c@gmail.com>
2025-09-20 12:42:06 +10:00
Campbell Barton
20bea06f4a Revert "Fix #78916: unpredictable results with merge by distance"
This reverts commit 69e27b4855.

Own oversight in the approach since this modified vertices from a
bmesh operator intended to "find" duplicates.
2025-09-19 16:22:35 +10:00
tariqsulley
69e27b4855 Fix #78916: unpredictable results with merge by distance
The previous implementation used KDTree duplicate search with
BLI_kdtree_3d_calc_duplicates_fast(). The survivor was always
one of the input vertices, not the centroid of the cluster.

This caused cases where merging a line of vertices did not
collapse to their average position, resulting in jagged loops.

Now vertices within the threshold are clustered, their centroid
is computed, and the chosen survivor is snapped to this centroid.
This ensures predictable and consistent merge results.

Ref !145851
2025-09-19 15:09:14 +10:00
Campbell Barton
d1b76b6554 Cleanup: only use "r_" prefix for return arguments
Ref !146253
2025-09-14 11:08:50 +00:00
Campbell Barton
e6c0a204f6 Cleanup: use of doxygen params in doc-strings 2025-09-14 15:15:33 +10:00
Campbell Barton
1e2ed785f7 Cleanup: use assume attribute to quiet array bounds warning for GCC 15
Ref !146150
2025-09-12 22:03:35 +10:00
Ray Molenkamp
8c7332cdfb Win: Improve crash reporting
When reporting a crash with unknown exception we just display
UNKNOWN EXCEPTION which is not as helpful as it could be. this
commit adds the actual exception code for all reports.

Also adds a msvc specific exception to the known list for easy
identification.

the exception record from #145762 goes from

ExceptionCode         : UNKNOWN EXCEPTION

to

ExceptionCode         : Microsoft C++ Exception (0xe06d7363)
2025-09-06 09:33:52 -06:00
Brecht Van Lommel
ffa4f8c7ad Refactor: Split off lighter BLI_color_types.hh from BLI_color.hh
Functions for convert between the color types and ostream support are
now outside the classes.

Many files were changed to fix cases where direct includes for headers
were missing.

Pull Request: https://projects.blender.org/blender/blender/pulls/145756
2025-09-05 11:11:32 +02:00
Brecht Van Lommel
7d829e58d3 Refactor: Move linear color space matrices from imbuf to blenlib
We want to be able to use them in BLI_color.hh.

Pull Request: https://projects.blender.org/blender/blender/pulls/145755
2025-09-05 11:11:32 +02:00
Christoph Neuhauser
1e523e2f5d Fix #143653: Add use of Quality of Service (QoS) API on Windows
This PR adds code for setting the Quality of Service (QoS) level of the
process on Windows. This can, e.g., make sure that on hybrid systems
P-cores are utilized even when the app window is out of focus.

In the following cases, it is adjusted from the default behavior:
- In wm_jobs.cc the QoS level is raised while a priority job is running.
- The command line option `--qos [high|eco|default]` can be used to
  change the QoS level of the process.
- By default, the QoS level is raised for the EEVEE performance tests,
  as they check viewport rendering performance and would otherwise be
  reliant on never going out of focus to not get a downgraded QoS level.
  By default, they are created with an out of focus window at the time
  of landing this PR. This PR makes sure that they actually measure the
  animation replay performance attainable during real-world use.

Pull Request: https://projects.blender.org/blender/blender/pulls/144224
2025-09-01 11:19:17 +02:00
Hans Goudey
c01d4a4ee6 Refactor: Deduplicate position transform utilities
The pattern of transforming many position vectors at once is quite
common, both with separate source and result arrays, and when modifying
an array in place. In some cases at least we used a separate function
with a consistent name across files, but there were also many duplicate
parallel transform implementations.

This commit adds these utilities to the BLI_math_matrix.hh API and uses
them where many positions from contiguous arrays are transformed at
once. While there might be a more ideal location for these utilities,
it's consistent with 3936d7a93e, and certainly better
than duplicating them.

This also reduces binary size of my build by 15 KB.

Pull Request: https://projects.blender.org/blender/blender/pulls/145352
2025-08-28 19:27:17 +02:00
Jacques Lucke
2e4d2ad5ab Refactor: BLI: reduce code size for virtual arrays
Previously, `VArrayImpl` had a `materialize` and `materialize_to_uninitialized`
function. Now both are merged into one with an additional `bool
dst_is_uninitialized` parameter.  The same is done for the
`materialize_compressed` method as all as `GVArrayImpl`.

While this kind of merging is typically not ideal, it reduces the binary size by
~200kb while being basically free performance wise. The cost of this predictable
boolean check is expected to be negligible even if only very few indices are
materialized. Additionally, in most cases, this parameter does not even have to
be checked, because for trivial types it does not matter if the destination
array is already initialized or not when overwriting it.

It saves this much memory, because there are quite a few implementations being
generated with e.g. `VArray::from_func` and a lot of code was duplicated for
each instantiation.

This changes only the actual `(G)VArrayImpl`, but not the `VArray` and `GVArray`
API which is typically used to work with virtual arrays.

Pull Request: https://projects.blender.org/blender/blender/pulls/145144
2025-08-28 14:24:25 +02:00
Sybren A. Stüvel
7f4096be41 Core: treat already-existing directory as 'ok' in recursive mkdir
When creating a directory recursively (via
`BLI_file_ensure_parent_dir_exists()` or `BLI_dir_create_recursive()`,
filter out errors that indicate that the directory already exists.
This is now also covered by a unit test.

I've also removed `BLI_assert(BLI_exists(dirname) == 0);` from
`dir_create_recursive()` (the workhorse for the above-mentioned
functions), for two reasons:

- The function is only used in an "ensure this directory exist"
  context, so the directory existing should be fine, and
- the assertion doesn't guarantee that the subsequent call to
  `mkdir()` actually succeeds. Race conditions between Blender and
  other processes (potentially on other computers, when using
  networked filesystems) will make such a precondition test
  unreliable.

This is a followup of 00abaa571a.

Pull Request: https://projects.blender.org/blender/blender/pulls/145173
2025-08-26 18:30:46 +02:00
Hans Goudey
f4421dfc8e Curves: Cache whether any curve is cyclic
Replacing the "cyclic offsets" cache from cfb8696a73.
That was more information than was necessary in the end.
This is implemented by de-duplicating the existing "contains"
function that's implemented twice for boolean virtual arrays.

Pull Request: https://projects.blender.org/blender/blender/pulls/144761
2025-08-25 18:22:36 +02:00
Campbell Barton
420d45ceb4 BLI_noise: suppress signed int overflow warnings for hash_pcg2d_*
Ref !144986
2025-08-22 14:33:24 +00:00
Aras Pranckevicius
3d9155eb0a PointCache: improve performance and compression, always compress
Point Caches (used by particle system, cloth, boids etc.) are now
always compressed, uzing zstd coupled with lossless data filtering.

- This is both smaller cache files _and_ faster than the old
  "Heavy" compression mode,
- And smaller data files and same or slightly faster speed than
  using no compression at all,
- There was not much difference between compression levels once
  data filtering got added, so option to pick them was removed.
- So there's no downside to just always using the compression,
  which makes for a simpler UI.
- RNA change: removes PointCache.compression property.

More details and cache size / performance numbers in the PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/144356
2025-08-13 16:38:46 +02:00
Campbell Barton
66803e4441 Cleanup: use function style casts 2025-08-12 02:46:51 +00:00
Jesse Yurkovich
225f6c8f94 Core: Don't get/set PWD env var for working directory functions
Depend only on `getcwd` and `chdir` rather than attempting to also
consider the `PWD` environment variable.

There's situations where these differ, and most easily seen when running
the Python tests. Calling `pathlib.Path.cwd()` will return something
like `/home/blender/git/blender-vexp/build_asserts/tests/python` while
PWD is `/home/blender/git/blender-vexp/build_asserts`. In this case,
calling `getcwd` will match what Python shows.

Additionally, this now matches what Windows and Mac do for these
affected APIs.

Pull Request: https://projects.blender.org/blender/blender/pulls/144235
2025-08-11 20:13:10 +02:00
Campbell Barton
cccc2c77c5 Cleanup: consistent for C-style comment blocks 2025-08-08 07:37:33 +10:00
Campbell Barton
4958be0394 Cleanup: remove redundant loop 2025-08-07 10:18:23 +10:00
Campbell Barton
b07a1adf04 Core: remove use of the environment variable TMP on Unix
This isn't a standard and seems only to be included for historic reasons.

Ref !144100
2025-08-07 10:17:51 +10:00
Campbell Barton
accacc65fc BLI_string_ref: add copy_bytes_truncated method
Needed to copy non UTF8 bytes into a null terminated string.

Ref !144052
2025-08-07 06:25:29 +10:00
Campbell Barton
558d1c4774 Cleanup: use the suffix "_maxncpy" instead of "_len" for string sizes
The term "_len" is too easily confused with the strlen(),
excluding the nil byte.
2025-08-07 06:18:21 +10:00
Aras Pranckevicius
8222cb0cfd VSE: Faster waveform & vectorscope calculation
Waveform, Parade and Vectorscopes were calculated by copying the
rendered image, transforming it into display space, and calculating
the the scope from that. On large resolutions, this
copy+transform+free of the image was taking up majority of the time.
Especially for default case when the display transform is a no-op.
Change the code so that display transform, if needed, is done directly
inside scope calculation, without needing a full-size temporary image.

Additionally, the vectorscope calculation was single threaded.
Multi-thread it by doing a parallel reduction, where each job
calculates their own scope image, and they are merged. Since job
payload is fairly large (512x512 bytes), make jobs pretty large
(256k pixels each).

Time (in ms) taken to calculate scope at 4K resolution (Ryzen 5950X,
Windows). Default color management settings:

- Waveform, PNG/SDR: 5.5 -> 5.2
- Waveform, EXR/HDR: 33.5 -> 10.3
- Vectorscope, PNG/SDR: 32.4 -> 4.5
- Vectorscope, EXR/HDR: 53.2 -> 9.8

Timings when additional color space management is needed (display
space set to Display P3, sequencer kept at sRGB):

- Waveform, PNG/SDR: 29.5 -> 10.9
- Waveform, EXR/HDR: 67.6 -> 10.9
- Vectorscope, PNG/SDR: 56.8 -> 12.0
- Vectorscope, EXR/HDR: 85.9 -> 13.4

This also fixes calculation of waveform / vectorscope on float (HDR)
images that have alpha channel; the scope was wrongly calculated on
premultiplied color values, which was not consistent with how it was
calculated on the byte images.

Pull Request: https://projects.blender.org/blender/blender/pulls/144059
2025-08-06 16:24:05 +02:00
Campbell Barton
e8501d2f54 Cleanup: grammar corrections, minor improvements to wording
Also back-tick quote some code references in comments
to differentiate them from English text.
2025-08-06 00:20:39 +00:00
Damien Picard
5998795aa6 UI: Replace contractions with long-form text
Avoid using contractions for can't, aren't, doesn't, and shouldn't.
Following the writing style guide in the Human Interface Guidelines.

Pull Request: https://projects.blender.org/blender/blender/pulls/143852
2025-08-05 11:16:22 +02:00
Campbell Barton
2c27d2be54 Cleanup: grammar corrections, minor improvements to wording 2025-08-01 21:41:24 +10:00
Jean-Silas
95422b95ee Fix: UI: Fuzzy Search: incorrect max acceptable edit distance for deletions in short words
This fixes an edge case in how the max acceptable edit distance is calculated
for deletions in fuzzy search, wherein the padding added to the max error count
could be negative when the query was longer than the matched term, producing a
max distance of zero.

This came up in chat a while back, where someone noted that, in the compositor,
searching for "bluir" wouldn't return the blur nodes; "blu" worked, "blui"
worked,  but "bluir" returned no results, despite all three having equal edit
distances (1 insertion, 1 substitution, and 1 deletion, respectively). The edit
distance metrics themselves are calculated correctly; the issue was just with
how the distance threshold was set.

Pull Request: https://projects.blender.org/blender/blender/pulls/143741
2025-07-31 20:47:06 +02:00
Campbell Barton
f3e4b45115 Cleanup: typos in code comments 2025-07-31 06:17:48 +00:00
Campbell Barton
32f9b65cc5 BLI_convexhull_2d: ensure stable order, correct doc-strings
Since [0], removing degenerate points at the beginning of the hull
would re-order points so the last were moved to the beginning.

While this isn't an error, having the resulting hull *sometimes*
re-ordering it's result based on internal error correction isn't ideal.

Document that the first point in the hull has the lowest Y value and
update tests to ensure this.

Also correct the doc-string regarding the hulls cross-product
and tests this is working as documented.

[0]: 87f9fd8fb3
2025-07-31 02:06:43 +00:00
Campbell Barton
f281f5a500 Cleanup: header grouping
Group includes, this is mostly being done already but had become mixed
up in some areas.
2025-07-30 14:22:06 +10:00
Campbell Barton
61fe1f09e0 Cleanup: quiet compiler warnings
Also remove operation check in `file_os_operations_menu_item` since a
zero value is never passed in.
2025-07-30 10:10:44 +10:00
Campbell Barton
0da99335e8 Cleanup: various minor changes to convexhull_2d
- Only use `float2` from blender's namespace
  otherwise reference blender namespace explicitly.
- Improve code comment formatting.
- Replace defines with std::numeric_limits.
- Replace `float[2]` with `float2 &`.
2025-07-29 21:18:09 +10:00
Campbell Barton
77945b7cd2 BLI_convexhull_2d: enable USE_ANGLE_ITER_ORDER_ASSERT
The fix for #143390 allows the assertion that angle iteration is
in-order to be enabled again.
2025-07-29 18:01:58 +10:00
Campbell Barton
87f9fd8fb3 Fix #143390: Incorrect results from BLI_convexhull_aabb_fit_points_2d
Resolve an error in `BLI_convexhull_2d` where *almost* overlapping
points could result in the hull including *concave* points.
This tended to happen with larger polygons in the range of 100-500.

The regression is likely caused by [0] since this optimization
relies on the input not having any concave coordinates.

[0]: 888c4d0766
2025-07-29 07:35:53 +00:00