Commit Graph

25966 Commits

Author SHA1 Message Date
Habib Gahbiche
90ea4f88f3 Refactor: Use test fixtures and C++ style initialization
Initiliaze global context only once per test suite. Test data relevant
to the respective tests is still allocated and freed with every test
case.

Also, `scene->nodetree` will be deprecated in a future PR, so use
`material->nodetree` to test embedded trees instead.

Pull Request: https://projects.blender.org/blender/blender/pulls/137895
2025-05-01 15:37:26 +02:00
Campbell Barton
e1e0c041cf Fix: incorrect peak sharpen calculation with the ocean modifier
The initial port [0] incorrectly use `sqrt` where `sqr` was used in the
original code. This mistake was made in two places but the second
causes a significant change in behavior, so this has been left as is
noting the difference in a comment.

Resolve the following issues:

- Use square instead of sqrt when calculating the peak value,
  besides following the original implementation it avoids the result
  being NAN when "Fetch" is below 30.

- Pass in `sqrt(m_omega)` matching the `omega` argument to
  `alpha_beta_spectrum` as well as following the upstream code.

In most cases the user visible changes are subtle.

Ref !137607

Co-authored-by: Nicolas Paris <nicolas.paris490@gmail.com>

[0]: 6ce709dceb
2025-05-01 11:04:45 +00:00
Nathan Vegdahl
30698cf885 Fix #137932: compute correct armature bounds
There were actually two issues here:

1. The dimension reported for armatures were often wildly incorrect,
   including negative values and zero!
2. The dimensions reported for objects are supposed to be invariant with
   rotation, representing the dimensions along the object's local axes.
   However, armature objects' reported dimensions changed with rotation.

The respective causes were:

1. `BKE_armature_min_max()` was using an incorrect formula (acknowledged
   in a comment) for transforming the bounding box between spaces. This
   worked fine for some of the places that `BKE_armature_min_max()` was
   called, since they just reverse the transform using the same(!)
   erroneous formula, but it didn't work for others.
2. `BKE_armature_min_max()` first computed the bounds in world space,
   and then transformed them into object space, rather than computing
   them in object space directly like the respective functions for other
   object types. Even when done correctly, this causes the reported
   dimension to vary with rotation.

This PR fixes these issues by simply computing the armature bounding box
in object space directly instead.

There is one place in the code base that was directly using the
world-space bounds: `view3d_calc_minmax_selected()`. However, for every
object type other than armatures, it takes the object-space bounds and
transforms them (with an incorrect formula!) to world space.  So this PR
also changes `view3d_calc_minmax_selected()`'s armature code to do the
same, except with a correct formula.

Note that the reason for using the correct transform formula (departing
from other object types) is that the world-space bounds for armatures
were already correct prior to this PR due to being computed in that
space. Therefore using the incorrect formula has the potential to
introduce regressions in this case.

Pull Request: https://projects.blender.org/blender/blender/pulls/137961
2025-05-01 12:25:52 +02:00
Sybren A. Stüvel
a3b8ea843c Anim: Add 'unshare' node to driver evaluation dependency graph
Add a new node to the dependency graph, to act as a single entry point
before drivers are evaluated in parallel.

The node will take all the driven RNA properties, and write their
current value to the property again. This ensures that any implicitly
shared data is copied to ensure writability. Subsequent concurrent
writes by the driver evaluation will then be safe, as the
thread-unsafe part has already been performed.

Fixes: #132423

Pull Request: https://projects.blender.org/blender/blender/pulls/135802
2025-05-01 11:49:21 +02:00
Habib Gahbiche
987fc14ada Cleanup: simplify logic in node tree iterator
Return separately for each node tree type.

This patch originally started as a refactor to change the logic of
iterating through compositing node trees but we ended up choosing
a different solution so only the small cleanup part is submitted here.

Pull Request: https://projects.blender.org/blender/blender/pulls/138205
2025-05-01 11:08:13 +02:00
Habib Gahbiche
5c801a7600 Cleanup: Initialize memory of default materials
Pull Request: https://projects.blender.org/blender/blender/pulls/138219
2025-05-01 10:58:24 +02:00
Omar Emara
510130de07 Compositor: Turn Bilateral Blur options to inputs
This patch turns the options of the Bilateral Blur node into inputs.

In the process, the Sigma Space and Iterations were joined into a single
Size input, previously they were just added together then ceiled to get
the blur size. Furthermore, Sigma Color was renamed to threshold and now
represents the average color difference, not the sum, so it was
previously multiplied by 3.

Versioning and RNA compatibility is not perfect due to joining the two
size options.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/138249
2025-05-01 09:57:57 +02:00
Campbell Barton
43af16a4c1 Cleanup: spelling in comments, correct comment block formatting
Also use doxygen comments more consistently.
2025-05-01 11:44:33 +10:00
John Kiril Swenson
2ab59859c9 Cleanup: VSE: Replace remaining seq and sequence references
Ref: #132179

Renames:
- `Editing.act_seq` -> `Editing.act_strip`
- `SequenceModifierData` -> `StripModifierData`
  - Its member `mask_sequence` is now `mask_strip`.
- `MetaStack.parseq` -> `MetaStack.parent_strip`
- Remaining function names/parameters that were not dealt with in #132748
- Various references to `seq` or `sequence` throughout code and docs when
  referring to a strip

Also moves `_get` to the end of the renamed function names where
applicable for standardization (unless "by" or "from" are used).

There should be no changes to current behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/138077
2025-05-01 00:22:04 +02:00
Omar Emara
f216b3ca62 Compositor: Turn Directional Blur options to inputs
This patch turns the options of the Directional Blur node into inputs.

In the process, the node now allows scaling down, not just scaling up.
The transformation options were renamed to Translation, Rotation, and
Scale as opposed to Distance, Spin, and Zoom. Finally, scaling is now
defined as a scale instead of a delta. So 1 is identity, 2 means scale
up two times, and so on. While previously, 0 was an identity scale, 1
means scale up by two types.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/138198
2025-04-30 14:40:13 +02:00
Sergey Sharybin
6ff0726ef2 Refactor: const-correctness in GPU viewport
Make GPU_viewport_colorspace_set() const-crrect w.r.t view_settings.

Instead of doing in-place modifications of the view_settings argument
with restoring them later introduce new function for copying view
settings which keeps curve mapping unchanged in the destination.

Should be no functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/138189
2025-04-30 14:03:26 +02:00
Damien Picard
a4669e3a8f Fix: Bring back UI translation of node header labels
Translation of node header labels was removed in cleanup
commit 02281dd26a, likely by mistake.

Issue reported by Gabriel Gazzán.

Pull Request: https://projects.blender.org/blender/blender/pulls/138052
2025-04-30 12:29:00 +02:00
Omar Emara
7a6acfac62 Compositor: Turn Sun Beams options to inputs
This patch turns the options of the Sun Beams node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/138184
2025-04-30 11:46:36 +02:00
Sean Kim
8c2888d578 Sculpt: Lower Mesh BVH leaf limit to 2500
This commit reduces the Mesh paint BVH node limit on vertices from
10000 to 2500. In general, a lower value here improves performance for
both raycasting and brush strokes, as smaller leaf nodes mean more nodes
can be filtered in the broad sphere tests instead of needing each
vertex to be processed.

There are a number of considerations that go into profiling this value:
* This change is most impactful for large meshes, where the user is
  going to be modifying a small total percentage of the model's area.
* Lower values may improve CPU performance, but overall responsiveness
  as perceived by the user goes down with values much smaller than 2500.

  This is likely due to GPU overhead, as each BVH node corresponds to a
  VBO.
* A lower node limits increase the BVH building time.

The new limit of 2500 corresponds to the following performance changes
as compared to the prior baseline:
* 1.12x ~ 1.52x FPS increase depending on the ratio of brush to mesh
  size.
* 1.27x ~ 2.88x performance increase for the brush evaluation.
* 1.31x slower BVH build times on a mesh with 10 million verts
  (0.2864s to 0.3761s).

Further performance data and comparison videos can be seen in the
associated PR.

Pull Request: https://projects.blender.org/blender/blender/pulls/137871
2025-04-29 22:27:44 +02:00
Sean Kim
922e40eefe Sculpt: Convert all Scrape, Fill, Flatten brushes to Plane brush
Previously, the bundled essential brushes in Sculpt Mode were changed
from the Scrape, Fill, and Flatten types to the Plane brush type. This
commit does the same thing programmatically and removes the now old code
related to these obsolete brushes.

Resolves #134076

Pull Request: https://projects.blender.org/blender/blender/pulls/138022
2025-04-29 22:20:49 +02:00
Hans Goudey
a2fac05e9d BLI: Add configurable inline buffer to VectorSet
Allow configuring the inline buffer capacity for the slots array, and
add an inline buffer for the keys vector. Previously there was always
an allocation when adding an element.

The inline capacity is manually configured in a few places as part of
this commit.

Pull Request: https://projects.blender.org/blender/blender/pulls/136461
2025-04-29 18:52:30 +02:00
Hans Goudey
6e190bde4a Fix #137843: Crash with invalid NURBS order attribute values
Two separate fixes are needed to resolve the crash. First is in the
store named attribute node, which incorrectly retrieved an attribute
value validator without checking the field type. The other is various
missing checks for the case when the evaluated positions for a
specific curve are empty.

Pull Request: https://projects.blender.org/blender/blender/pulls/137861
2025-04-29 18:28:45 +02:00
Hans Goudey
600380cd98 Fix #137794: Ignore curve radius for legacy curve object bounds
Caused by 06f6d77979.

Legacy curve objects have not taken the radius into account in the
past. Better to stick with that behavior and only affect the new
curve object type. This only affects non-instanced legacy curve
objects; generally generated curves are presented to the depsgraph
iterator as the new object type.

Pull Request: https://projects.blender.org/blender/blender/pulls/137852
2025-04-29 16:16:44 +02:00
Omar Emara
93408e03a4 Compositor: Turn Ellipse Mask options to inputs
This patch turns the options of the Ellipse Mask node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/138130
2025-04-29 15:20:54 +02:00
Omar Emara
3d4900f412 Compositor: Turn Box Mask options to inputs
This patch turns the options of the Box Mask node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/138129
2025-04-29 14:34:23 +02:00
Aras Pranckevicius
8528feb7ee Cleanup: replace some spinlocks with atomics or mutexes
- ImBuf reference counting: turn that into just an atomic integer
- Cachefile safety: turn into a mutex, since work under the spinlock
  was quite heavy (hashtable creation, other memory allocations)
- Movie clip editor: turn into a mutex, since work under the spinlock
  was very heavy (reading files from disk, etc.)
- Mesh intersect: remove the previously commented out spinlock path;
  replace BLI mutex with C++ mutex for shorter code

Pull Request: https://projects.blender.org/blender/blender/pulls/137989
2025-04-29 10:42:45 +02:00
Omar Emara
ddc0f9460d Compositor: Turn Lens Distortion options to inputs
This patch turns the options of the Lens Distortion node into inputs.

The Projector option was turned into an enum between two options.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/138113
2025-04-29 09:54:12 +02:00
Omar Emara
39aa73628d Compositor: Turn Color Correction options to inputs
This patch turns the options of the Color Correction node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/138003
2025-04-28 12:19:42 +02:00
Campbell Barton
c90e8bae0b Cleanup: spelling in comments & replace some use of single quotes
Previously spell checker ignored text in single quotes however this
meant incorrect spelling was ignored in text where it shouldn't have
been.

In cases single quotes were used for literal strings
(such as variables, code & compiler flags),
replace these with back-ticks.

In cases they were used for UI labels,
replace these with double quotes.

In cases they were used to reference symbols,
replace them with doxygens symbol link syntax (leading hash).

Apply some spelling corrections & tweaks (for check_spelling_* targets).
2025-04-26 11:17:13 +00:00
T0MIS0N
347e294959 Fix #136608: ASAN crash when texture painting
**Problem**
When using Sculpt Texture Paint to paint objects in a debug build,
Blender will crash due to an Address Sanitizer exception,
`stack-use-after-free`. This makes development for Sculpt Texture
Paint harder since the feature can't be used in debug builds without
turning off Address Sanitizer.

Code-wise, the issue here happens when extending UV island borders.
When creating and adding UV primitives to extend the UV border, the
primitives are allocated locally and then added to a list. This means
that when these primitives are accessed later from the list, the ASAN
error is triggered since the primitives have been freed. Freed
primitives are generally accessed when checking if a primitive has
already been added to the primitive list belonging to its connected UV
Edges.

**Solution**
The solution here is to change UV Edges to store the index of a UV
primitive, and not use a pointer to the object itself. This is the best
solution since it makes it fast and simple to check if an UV Edge
already has a reference to its connected primitives, while still
allowing access to the primitive objects since primitives can be
accessed using indexes from mesh data objects.

Co-authored-by: T0MIS0N <50230774+T0MIS0N@users.noreply.github.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/137032
2025-04-25 21:47:08 +02:00
Lukas Stockner
bf412ed9dd Cycles: Support for custom OSL cameras
This allows users to implement arbitrary camera models using OSL by writing
shaders that take an image position as input and compute ray origin and
direction.

The obvious applications for this are e.g. panorama modes, lens distortion
models and realistic lens simulation, but the possibilities are endless.

Currently, this is only supported on devices with OSL support, so CPU and
OptiX. However, it is independent from the shading model used, so custom
cameras can be used without getting the performance hit of OSL shading.

A few samples are provided as Text Editor templates.

One notable current limitation (in addition to the limited device support)
is that inverse mapping is not supported, so Window texture coordinates and
the Vector pass will not work with custom cameras.

Pull Request: https://projects.blender.org/blender/blender/pulls/129495
2025-04-25 19:27:30 +02:00
Hans Goudey
afd8d744e1 Shape Keys: Tweaks to duplicate operator
- The new shape key is added directly below the source.
- The new shape key is made active.
- The flag, including the lock status, is now copied.
2025-04-25 12:28:37 -04:00
Sybren A. Stüvel
1625d9359d Fix #137864: Action Constraint without Action produces invalid result
When there is no Action set on an Action constraint, the matrix returned
by the constraint would be uninitialized. In practice, this meant an
all-zeroes matrix. Now, the unit matrix is returned in such a case.

Pull Request: https://projects.blender.org/blender/blender/pulls/137965
2025-04-25 17:24:11 +02:00
Aras Pranckevicius
393a1d3d88 Cleanup: DURIAN_CAMERA_SWITCH is always on
The DURIAN_CAMERA_SWITCH feature has been always on since c3401eb5cb
(2009, Blender 2.51), remove the preprocessor option to turn it off.

Pull Request: https://projects.blender.org/blender/blender/pulls/137991
2025-04-25 14:20:52 +02:00
Campbell Barton
b096066da5 Revert "Fix #137940: Wider Text Caret for Text Object Editing"
This reverts commit 4856cfa89c.

The change only slightly mitigated the issue, revert in favor
of an alternative fix.
2025-04-25 01:23:13 +00:00
Harley Acheson
4856cfa89c Fix #137940: Wider Text Caret for Text Object Editing
While editing text objects a vertical bar is used as a text caret to
indicate the current cursor position within the string. This is drawn
by the overlay engine with a specific shader that changes size with the
object. Unfortunately this is currently too narrow and will become
subpixel and not display while the text is still readable. This PR just
increases the text caret width so that it is still visible at very
small sizes.

Pull Request: https://projects.blender.org/blender/blender/pulls/137975
2025-04-25 00:13:44 +02:00
Omar Emara
ad49181f90 Compositor: Turn Plane Track Deform options to inputs
This patch turns the options of the Plane Track Deform node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137949
2025-04-24 12:47:15 +02:00
Omar Emara
290c015a75 Compositor: Turn Stabilize node options to inputs
This patch turns the options of the Stabilize node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137911
2025-04-24 09:34:30 +02:00
Philipp Oeser
25bc5788d6 Fix #137877: rigid body affected by forcefield even at strength zero
Blender translates the "Dynamic" setting (`RBO_FLAG_DISABLED`) into a
bullet _kinematic state_ (see `RB_body_set_kinematic_state` /
`CF_KINEMATIC_OBJECT`). This is different from the _activation state_
(done through e.g. `RB_body_set_activation_state`) and also different
from the active/passive type. So we have (at least) three levels to
control this.

And it seems like even though a bullet body is fully intended to be
kinematic (aka animated), it still accumulates forces from the
`RB_body_apply_central_force` call. I have not tracked this down
further, but it _seems_ logical to only apply forces on a body with
the "Dynamic" setting.

Tested this with activation/deactivation (with seems intact), so in my
limited tests I wasnt able to break it

Pull Request: https://projects.blender.org/blender/blender/pulls/137901
2025-04-24 09:23:27 +02:00
Campbell Barton
79583c4ba8 Cleanup: use memcpy whrn when the string size is known 2025-04-24 05:21:01 +00:00
Campbell Barton
2d2da30e7b Cleanup: add utility function to access the screen region by type 2025-04-24 05:14:15 +00:00
Omar Emara
f4e46b3fdd Compositor: Turn ID Mask node options to inputs
This patch turns the options of the ID Mask node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137905
2025-04-23 16:31:27 +02:00
Omar Emara
8c616a8a00 Compositor: Turn Keying node options to inputs
This patch turns the options of the Keying node into inputs.

In the process, some options were renamed for clarity and consistency
with other nodes.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137900
2025-04-23 15:33:22 +02:00
Hans Goudey
2e0a4d23ad Cleanup: Use std::abs instead of fabsf 2025-04-23 09:13:39 -04:00
Laurynas Duburas
1d815fdcb8 Cleanup: Remove unused curves NURBS variable 2025-04-22 17:08:45 -04:00
Habib Gahbiche
ce5fe6e017 Cleanup: Use Assert in tests to avoid crashes when tests fail
Pull Request: https://projects.blender.org/blender/blender/pulls/137857
2025-04-22 17:59:26 +02:00
Omar Emara
8bb1ebb5f7 Compositor: Turn Keying Screen options to inputs
This patch turns the options of the Keying Screen node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137851
2025-04-22 15:57:46 +02:00
Hans Goudey
685894b665 Cleanup: Use Span argument for KeyBlock conversion function 2025-04-22 09:39:52 -04:00
Omar Emara
730cb40f4c Compositor: Turn Color Spill options to inputs
This patch turns the options of the Color Spill node into inputs.

In the process, the Ratio option was renamed to Limit Strength, the
unspill option was renamed to Spill Strength.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137848
2025-04-22 14:51:26 +02:00
Brecht Van Lommel
fb2ba20b67 Refactor: Use more typed MEM_calloc<> and MEM_malloc<>
Pull Request: https://projects.blender.org/blender/blender/pulls/137822
2025-04-22 11:22:18 +02:00
Omar Emara
5e93b6a2cd Compositor: Turn Luminance Key options to inputs
This patch turns the options of the Luminance Key node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137823
2025-04-22 09:09:51 +02:00
Campbell Barton
720b00ae50 Cleanup: use doxygen comments in BKE, consistent comment blocks
Also remove doxygen comment use for comments in the functions body.
2025-04-22 06:13:33 +00:00
Campbell Barton
2372167e96 Fix: building WITH_TBB=OFF
Caused by 388a21e260
2025-04-22 06:13:31 +00:00
Omar Emara
d791ea7cc2 Compositor: Turn Distance Key options to inputs
This patch turns the options of the Distance Key node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137817
2025-04-21 19:28:57 +02:00
Brecht Van Lommel
d061b00455 Refactor: Eliminate various unsafe memcpy and memset
Some of these already have warnings with clang-tidy, others are more
safe in case these structs get (copy) constructors in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/137404
2025-04-21 17:59:41 +02:00