Commit Graph

28330 Commits

Author SHA1 Message Date
Hans Goudey
07333adc72 Cleanup: Make CustomData function private 2025-04-16 13:56:02 -04:00
Hans Goudey
63957cf541 Cleanup: Move CustomData_blend_write_prepare to proper section 2025-04-16 13:56:02 -04:00
Habib Gahbiche
535d9c63e1 UI: Improve default position of shader nodes
After creating a new shading material, the new node tree might become invisible and the user has to scroll down to see the nodes.

The idea of this PR is to create nodes with x-positions centered around zero, such that they are always visible no matter the screen size or workspace setup. Ideally, the nodes' position should depend on the region's zoom and pan. However, the node creation code currently does not depend on `SpaceNode`, so such solution would complicate the code a bit. Also, this heuristic seem to work well enough for most cases.

Note: this only affects newly created materials. The material of the default cube and the default world material still have invisible nodes sometimes. This is because they are saved in the startup file, which will be addressed in a different patch.

Pull Request: https://projects.blender.org/blender/blender/pulls/136926
2025-04-16 16:25:20 +02:00
Omar Emara
7f02fd3192 Compositor: Turn Pixelate node options into inputs
This patch turns the options of the Pixelate node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137603
2025-04-16 15:34:50 +02:00
Omar Emara
55cc96b556 Compositor: Turn Inpaint node options into inputs
This patch turns the options of the Inpaint node into inputs.

The Distance options were renamed to Size for consistency with other
nodes.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137597
2025-04-16 14:56:00 +02:00
Jacques Lucke
f301dfbb10 Cleanup: Nodes: deduplicate logic to get zone for node
Since nodes are not uniquely assigned to zones (some nodes are in two
zones at the same time), it's better not to expose this detail in multiple
APIs. This avoids having to explain the behavior multiple times.

Now one just has to use `get_zone_by_node/socket` and can then use
a seperate method to get the zone stack for that zone like before.
2025-04-16 14:09:48 +02:00
Omar Emara
e361054df4 Compositor: Turn Dilate node options into inputs
This patch turns the options of the Dilate node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137593
2025-04-16 12:50:46 +02:00
Omar Emara
e7778593f8 Compositor: Turn Tone Map node options into inputs
This patch turns the options of the Tone Map node into inputs.

In the process, a few changes were made. Input ranges were adjusted to
remove artificial limits. The papers indeed mention those limits, but
they were only mentioned as typical values, not valid ranges.

- The Key option is no longer limited to 1.
- Gamma is no longer limited to a value of 3.
- Intensity is no longer limited to [-8, 8].
- Contrast is no longer limited to [0, 1].

A few renames were done to clarify options and match the reference
papers.

- Offset was renamed to Balance, since it is not really an offset, but
  balances between shadows and highlights. This can be looked up in the
  paper.
- Correction was renamed to Chromatic Adaptation, since it doesn't
  really correct anything.
- Adaptation was renamed to Light Adaptation to distinguish from
  Chromatic Adaptation and now default to global tone mapping, since
  this is more useful by default.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137589
2025-04-16 11:59:04 +02:00
Hans Goudey
f445df26f7 Refactor: Mesh: Don't share code between "clear geomtry" and "free"
Clearing a mesh's geometry without freeing the mesh has the requirement
that the mesh remain initialized afterwards. Freeing the mesh doesn't
have that requirement and corresponds to a destructor rather than move
construction with the default value. Avoiding conflating the two
operations simplifies some future feature additions (including #122398).
2025-04-15 18:52:20 -04:00
Hans Goudey
26ed4eec96 Fix #137548: Assert propagating unsupported string attribute type
All users of `retrieve_attributes_for_transfer` don't support string
attributes. This needs a check similar to the other functions in this file.
2025-04-15 18:20:01 -04:00
Bastien Montagne
699d071414 Fix #137412: Make Local on liboverride can break hierarchy.
Making local an intermediate collection in a liboverride hierarchy e.g.
will likely break the link between the objects in that collection, and
their hierarchy root ID (typically the top overridden collection).

This is fixed by this commit, by:
* Adding a new util, `lib_override_root_is_valid`, that check whether a
  given liboverride ID is still 'connected' to its hierarchy root.
* Using this test in `BKE_lib_override_library_main_hierarchy_root_ensure`
  to strengthen the detection of invalid root hierarchy pointers.
2025-04-15 22:30:07 +02:00
Hans Goudey
7b88604396 Fix: Missing point cloud bounds update when deleting points 2025-04-15 13:24:32 -04:00
Bastien Montagne
436a7d0333 LibOverride: Ignore loopback relationships in hierarchies handling.
Not sure why it was not done before... But it should be fine to
completely ignore the loopback relationships (mainly liboverride
hierarchy root pointers themselves, and owners of embedded and
shape key IDs) when handling hierarchies.

Quick tests on complex production cases here also showed no obvious
issue (or even change at all) with this tweak, so think it's safe to try
it out in main.
2025-04-15 17:28:14 +02:00
Hans Goudey
bbb9b16c88 Fix: Mesh true vert normals uses incorrect face normals 2025-04-15 10:12:52 -04:00
Omar Emara
4940418317 Compositor: Turn Z Combine node options into inputs
This patch turns the options of the Z Combine node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137534
2025-04-15 15:20:02 +02:00
Omar Emara
ab81cd7bbb Compositor: Turn Invert node options into inputs
This patch turns the options of the Invert node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137527
2025-04-15 14:18:04 +02:00
Bastien Montagne
22818f4a6d Fix #136894: Crashes due to invalid code in ID management.
Own mistake in 3e03576b09, confused `BLI_listbase_findafter_string_ptr`
with a (not yet existing) `BLI_listbase_findafter_string` function.
2025-04-15 12:35:54 +02:00
Omar Emara
a4e7028b4c Compositor: Turn Split node options into inputs
This patch turns the options of the Split node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137518
2025-04-15 11:43:20 +02:00
Omar Emara
f71358d281 Compositor: Turn Switch node options into inputs
This patch turns the options of the Switch node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137512
2025-04-15 11:04:20 +02:00
Jacques Lucke
234cfbb865 Nodes: add zone utility functions
Those are used by #137403.
2025-04-15 10:32:00 +02:00
Campbell Barton
8e40e21124 Cleanup: use boolean for "found" vars & return values 2025-04-15 12:08:08 +10:00
Jacques Lucke
7f1a99e862 Refactor: BLI: Make some CPPType properties public instead of using methods
This makes accessing these properties more convenient. Since we only ever have
const references to `CPPType`, there isn't really a benefit to using methods to
avoid mutation.

Pull Request: https://projects.blender.org/blender/blender/pulls/137482
2025-04-14 17:48:17 +02:00
Jacques Lucke
be266a1c0c Refactor: Geometry Nodes: replace ComputeContextBuilder with ComputeContextCache
While `ComputeContextBuilder` worked well for building simple linear compute
contexts, it was fairly limiting for all the slightly more complex cases where
an entire tree of compute contexts is built. Using `ComputeContextCache` that is
easier to do more explicitly. There were only very few cases where using
`ComputeContextBuilder` would have still helped a bit, but it's not really worth
keeping that abstraction around just for those few cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/137370
2025-04-14 17:47:56 +02:00
Omar Emara
bc9176e5e1 Compositor: Turn Mask options into inputs
This patch turns the options of the Mask node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137479
2025-04-14 17:00:44 +02:00
Omar Emara
10af6e8ca5 Compositor: Turn Time Curve options into inputs
This patch turns the options of the Time Curve node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137465
2025-04-14 13:03:50 +02:00
Bastien Montagne
742c631d04 Fix #136432: Linked Data: Relocating libraries can assert in some cases.
As Relocate code temporarily removes some linked IDs from Main, this can
make collection hierarchy data invalid, in a way that will break
`BKE_main_collections_parent_relations_rebuild`.

For now, simply move that call outside of `BLO_library_link_end` and do
it after adding back all linked IDs to main.

Pull Request: https://projects.blender.org/blender/blender/pulls/135936
2025-04-14 12:54:50 +02:00
Bastien Montagne
3fa35aa4ee LibOverride: Improve resync when relocating linked data.
Relocation is the only case where old and new linked data may have
a different library. This makes remapping dependencies IDs for the
liboverrides that use these linked data somewhat more challenging and
complicated.

From basic tests with both simple data, and full production-level
Mikassa char, it seems to behave fairly well now.
2025-04-14 12:54:48 +02:00
Bastien Montagne
0eba8caaf9 Core: Add 'relocate' operation on individual linked ID.
So far it was only possible to relocate a whole library, now one can
also relocate a single linked ID (pulling in all of its dependencies).

This is essentially linking the new data, remapping local usages of the
old linked data to the new one, removing no more used IDs, and updating
liboverrides if needed.
2025-04-14 12:54:48 +02:00
Omar Emara
08e73814d7 Compositor: Turn Bokeh Image options into inputs
This patch turns the options of the Bokeh Image node into inputs.

Reference #137223.

Pull Request: https://projects.blender.org/blender/blender/pulls/137350
2025-04-14 11:26:55 +02:00
Jacques Lucke
223412b6d5 Geometry Nodes: name based internal links in Evaluate Closure node
Previously, internal links used the same heuristics as most other nodes. However,
this is more problematic here, because I intend to use the same internal links
for the case when no closure is connected. The behavior in this case should not
change in the future if we decide to change the heuristic for internal links for
muted nodes.
2025-04-13 12:27:01 +02:00
Campbell Barton
5affe5fc6d Cleanup: spelling in comments (make check_spelling_*) 2025-04-12 19:31:29 +10:00
Campbell Barton
0fb6cc72fd Cleanup: add STRNLEN macros to prevent incorrect sizeof() use
Missed in recent cleanup.
2025-04-12 13:38:22 +10:00
Campbell Barton
2c8bb61187 Cleanup: add STRNLEN macros to prevent incorrect sizeof() use
This would have prevented the error fixed in
be53bab1cb.
2025-04-12 13:03:01 +10:00
Campbell Barton
3bf92a6e83 Cleanup: rename nullptr to null for null-characters 2025-04-11 23:55:00 +00:00
Nicola
0373a4ef94 Sculpt: Add BVH node parent index to optimize bounds update
Previously, the BVH bounds were updated with a top-down approach
starting at the root. As explained in #136471, algorithms that visit
every node of the tree can become a bottleneck when sculpting high-res
meshes.

This patch refactors `flush_bounds_to_parents` by using a bottom-up
approach starting from the dirty leaf nodes. This requires calculating
and storing the parents of the nodes during the BVH build.

The change reduces the overhead measured in #136471 to near zero. The
same tests give the following results:

| Radius | Node Ratio | Speedup |
|--------------|---------|------------|
| 0.10m | 297 | 1.25x |
| 0.25m | 297 | 1.23x |
| 0.50m | 551 | 1.18x |
| 1.00m | 1930 | 1.13x |

where node ratio is the ratio between total nodes and nodes affected by
the brush. For reference, typical ratios when sculpting something like
a character are very roughly:

- tens when sculpting main forms
- low hundreds when sculpting secondary forms
- high hundreds to thousands when sculpting tertiary details

Pull Request: https://projects.blender.org/blender/blender/pulls/137019
2025-04-12 00:50:03 +02:00
Jacques Lucke
aab2b6004b Geometry Nodes: add compute context cache
For various purposes we traverse the computation done by a node tree (e.g. for
gizmos and socket usage infeferencing). For that we generally have to keep track
of the compute context we're in at any given time. During the traversal, it's
common to enter and exist the same compute contexts multiple times. Currently,
we'd always build a new compute context when that happens. That happens even
though the old one is generally still around, because other data may reference
it. This patch implements a `ComputeContextHash` type that avoids rebuilding the
same compute contexts over and over again.

I'm considering to also replace the usage of `ComputeContextBuilder` with this
cache somehow, but will see how that works out.

The reason I'm working on this now is that I have to traverse the node tree a
bit again to find where closures might be evaluated. I wanted to be able to
cache the compute contexts for a while already.

Pull Request: https://projects.blender.org/blender/blender/pulls/137360
2025-04-11 21:36:41 +02:00
Jacques Lucke
183dfa68c9 Geometry Nodes: log closure evaluations
The goal is to log information about which closures are evaluated where. This
information is not exposed in the UI yet, but will be needed to be able to debug
the evaluation and inspect socket values within closures.

Pull Request: https://projects.blender.org/blender/blender/pulls/137351
2025-04-11 17:58:40 +02:00
Omar Emara
3b43f6ba57 Compositor: Make Rotate Star 45 option an input
This patch converts the Rotate Star 45 option in the Glare node into an
exposed input, with code to handle backward and forward compatibility.

Pull Request: https://projects.blender.org/blender/blender/pulls/137140
2025-04-11 16:51:03 +02:00
Jacques Lucke
6b92972dcc Geometry Nodes: initial boilerplate for viewer path for closure evaluation
This will be necessary for supporting viewers inside of closures.
2025-04-11 16:41:46 +02:00
RedMser
ba04393fde Cleanup: Remove deprecated Python and Rigid Body Joint constraints
Remove long-deprecated constraints that will likely never be
implemented in this form.

- Rigid Body Joint Constraint was removed in 2.80, but some references
  remained in the code. Versioning code was written that tried to
  remove them on load, but since constraint initialization code sets
  the type to CONSTRAINT_TYPE_NULL before versioning gets a chance,
  the versioning code ended up never running. This has all been
  removed.
- Python/Script Constraint never worked since 2.50 and showed an error
  message in the UI panel.

These constraints now load as 'null' constraint, as seems to be
(looking at the code) the way that Blender currently deals with
removed constraint types. These still show up in the outliner and
python API, but have no UI panel. Removing such constraints completely
will be left for another time, as it is beyond the scope of removing
these two specific constraint types.

Pull Request: https://projects.blender.org/blender/blender/pulls/136672
2025-04-11 11:38:29 +02:00
Campbell Barton
6d6c695619 Fix: integer overflows calculating the number of pixels in imbuf
Use IMB_get_pixel_count to prevent integer overflow.
2025-04-11 18:52:38 +10:00
Habib Gahbiche
51c2cf2b9d Fix #137268: CTRL+Shift clicking creates additional Material Outputs
Only geometry nodes is allowed to have no active output (the group output node acts as an explicit node tree output). The previous fix only considered geometry nodes and compositor cases, which was not enough.

Pull Request: https://projects.blender.org/blender/blender/pulls/137288
2025-04-11 10:04:56 +02:00
Sean Kim
f711010c12 Fix: Brushes incorrectly show gravity as an option when unsupported
Prior to this commit, the set of brushes that ignore the gravity brush
effect and the set of brushes that dim the display of the related
options were mismatched.

Pull Request: https://projects.blender.org/blender/blender/pulls/137309
2025-04-11 02:25:01 +02:00
Sean Kim
001b8912ff Cleanup: Consolidate sculpt brush capability checks into BKE_brush.hh
Prior to this commit, whether or not a brush was capable of using
certain options in Sculpt mode and whether or not these properties would
be shown to the user was spread across a number of files and
inconsistently applied.

This commit moves most of these checks to the bke::brush namespace so
that we have a single source of truth for these checks.

In total this commit:
* Changes all BrushCapabilitiesSculpt methods to use the equivalent
  bke::brush function
* Removes brush type macros
* Renames BKE_brush_supports_secondary_color to fit the new pattern
* Refactors inverted logic for the `direction` property

Pull Request: https://projects.blender.org/blender/blender/pulls/137249
2025-04-10 22:05:23 +02:00
Mattias Fredriksson
6f0e814ff9 Curves: Simplified Curve Tangent Evaluation
Simplifies implementation of curve tangent calculation for polylines
and evaluated curves. Loop now re-uses results from previous
iteration and adjusts for 0-length segments in the same loop,
removing need for a conditional extra loop.

Performance gain comes from removing a normalization and difference per
iteration. Curves with 0-length segments can benefit further.
For a single  curve containing 860K points containing 0-length segments
measured improvement was 1.43x (from 33ms to 23ms).

Test does not utilize threading since it's threaded for curves, adding
threading to single/large curves might be better but would require
the current dependency to previous iterations to be removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/137182
2025-04-10 21:21:23 +02:00
Jacques Lucke
b92fdff697 Refactor: BLI: use FunctionRef in BLI_uniquename api
This simplifies the API usage, removes the need for intermediate structs
and reduces the overall amount of code.

Pull Request: https://projects.blender.org/blender/blender/pulls/137300
2025-04-10 20:30:45 +02:00
Falk David
afc3ae623c Fix: Geometry Nodes: Attribute search not working for Grease Pencil drawings
The attribute search for e.g the attribute name input in
the `Store Named Attribute` node did not list attributes
inside Grease Pencil drawings (curve and point domain).

The fix ensures that for the `GeometryComponent::Type::GreasePencil`
we also iterate over the attributes of each evaluated drawing.

Pull Request: https://projects.blender.org/blender/blender/pulls/137267
2025-04-10 14:16:22 +02:00
Brecht Van Lommel
1e49a7e135 Fix #137197: Grease pencil duplicating materials on custom brushes
Always compare absolute file paths.

Pull Request: https://projects.blender.org/blender/blender/pulls/137229
2025-04-10 13:06:27 +02:00
Jacques Lucke
dcc8d28859 Refactor: Geometry Nodes: store tree identifier in tree logger
The main goal here is to add `GeoTreeLogger.tree_orig_session_uid`. Previously,
it was always possible to derive this information in `ensure_node_warnings`.
However, with closures that's not possible in general anymore, because the
Evaluate Closure node does not know statically which node tree the closure zone
is from that it evaluates. Therefore, this information has to be logged as well.

This patch initializes `tree_orig_session_uid` the same way it initializes
`parent_node_id`, by scanning the compute context when creating the tree logger.
To make this work properly, some extra contextual data had to be stored in some
compute contexts.

This is just a refactor with no expected functional changes. Node warnings for
closures are still not properly logged, because that requires storing
source-location data in closures, which will be implemented separately.

Pull Request: https://projects.blender.org/blender/blender/pulls/137208
2025-04-10 08:56:02 +02:00
Campbell Barton
b2dbfa7d77 Cleanup: spelling in comments, use doxygen comments 2025-04-10 13:02:29 +10:00