Commit Graph

145197 Commits

Author SHA1 Message Date
Lukas Tönne
d27e0fcbaf Fix #130855: RegionView3D matrices need to be reset before transforming points
- In "Surface" mode the depth buffer needs to be cached after constructing the base DrawingPlacement, otherwise there is no depth data for projection and the origin is used as a fallback.
- The DrawingPlacement relies on the RegionView3D matrices to project from the rendered image back into 3D space. Because the boundary projection is called while the rv3d matrices are still set up for the image render it will look up the wrong pixels from the depth buffer. The solution is to make sure the viewport reset happens before projecting the boundary, i.e. by making sure the reset function is called before `process_image`.
- The aspect ratio needs to be taken into account for the boundary-to-strokes transform, otherwise the placement is wrong depending on how much the region aspect deviates from square.

The code for computing the zoom factor and offset has also been cleaned up and documented somewhat better, and now uses the `Bounds<float2>` struct instead of old `rctf`.

Pull Request: https://projects.blender.org/blender/blender/pulls/131321
2025-01-10 12:17:38 +01:00
Aras Pranckevicius
1b322de0aa Fix #124588: Do not select strip handles when clicking inside time ruler
Inside sequencer_main_cursor, the logic for showing a custom cursor
was already ignoring the time scrub ruler area, and not showing
the strip edge resizing cursors. However confusingly enough, actually
clicking there was still going into the
ED_sequencer_pick_strip_and_handle which found a strip edge and
returned it. Modify ED_sequencer_pick_strip_and_handle to return empty
selection when mouse is inside the time scrub ruler.

Pull Request: https://projects.blender.org/blender/blender/pulls/132891
2025-01-10 11:57:31 +01:00
Habib Gahbiche
9b484b5251 UI: Add hint for snapping inversion in status bar
Followup to https://projects.blender.org/blender/blender/pulls/130379

Status bar now shows correctly that pressing `ctrl` while snapping will invert snapping.

Pull Request: https://projects.blender.org/blender/blender/pulls/131009
2025-01-10 10:12:27 +01:00
Lukas Tönne
fadde9da75 Fix: Regression of Grease Pencil arguments when caching depth buffer
Depth buffer caching was broken in 62897317bd. The `use_basic` parameter was removed but `use_gpencil`
should remain unmodified. This caused overlays to be included in the depth buffer for Grease Pencil.

Pull Request: https://projects.blender.org/blender/blender/pulls/132871
2025-01-10 10:11:26 +01:00
Lukas Tönne
9348d5ec05 Fix #132418: Joining Grease Pencil object creates invalid duplicate of nested layers
The `copy_layer_group_content` function was using the `LayerGroup::nodes()` API
for iterating over layers and inserting unique copies into the target geometry.
This function lists __all__ the layers inside a group, not just direct children.
A layer inside a group will be copied twice or more this way, once for the root
layer and for any of its parent groups. Looping only over directly child layers
and groups is the correct thing to do here.

Pull Request: https://projects.blender.org/blender/blender/pulls/132868
2025-01-10 08:56:07 +01:00
Pratik Borhade
905d6c435a Fix #132807: Grease Pencil: Joining strokes removes selection
Ensure selection attribute for last stroke after join operation.

Pull Request: https://projects.blender.org/blender/blender/pulls/132840
2025-01-10 08:05:45 +01:00
Jesse Yurkovich
75f3fab268 USD: Add test for the export_texture_mode option
Add tests covering the PRESERVE and KEEP export_texture_mode options.

Pull Request: https://projects.blender.org/blender/blender/pulls/132885
2025-01-10 06:34:27 +01:00
Campbell Barton
372ecb847f Fix #108658: Geometry with non-finite coordinates crashes bevel 2025-01-10 16:30:52 +11:00
Hans Goudey
c8dbde8779 Cleanup: Remove unused includes in space node folder
Pull Request: https://projects.blender.org/blender/blender/pulls/132882
2025-01-10 03:09:00 +01:00
Alaska
9f6d605743 Tests: Add render tests for a few missing simple shader tests
There are a few simple shader nodes that were missing test files.
This commit adds tests for those nodes:
- Camera data
- Fresnel
- Layer weight
- Hue/Saturation/Value
- Invert
- Normal
- Wavelength

Ref: blender/blender-test-data!39
2025-01-10 02:44:13 +01:00
Harley Acheson
fe071cd076 Fix #124814: Correctly Collapse Long Non-Categorized Lists
Multi-column lists are supposed to collapse to single-column when they
are estimated to be wider than the available window width. However,
current code has two errors. First the calculation of the maximum
number of possible rows is based on entire screen height when the most
available is a bit less than half. This too-large value was used in
the calculation of widths, yet the maximum rows is actually clamped
to about 24 for uncategorized lists. Whenever the former is greater
than the latter this could cause collapsing to not occur. This issue is
only really noticeable for lists in Nodes as these can be shown much
smaller than regular size.  This PR fixes the max-row calculation and
uses this correctly when breaking lists without categories.

Pull Request: https://projects.blender.org/blender/blender/pulls/132881
2025-01-10 00:56:33 +01:00
Harley Acheson
e5e45dc140 Fix #132122: Default Value for Camera FOV Angle
In a Camera's properties you can "Reset to Default" on "Focal Length"
because "lens" is a direct member of Camera and it has "50.0f" as its
default value in DNA_camera_defaults.h. However change the "Len Unit"
to "Field of View" and what you are changing is "angle". This is not
a member of Camera but is a calculated value based on sensor size. So
"reset to default" makes this "0", which is invalid and otherwise not
possible to enter.  This PR uses RNA_def_property_float_default to set
a default value of 0.6911504f radians which is the 39.6° FOV for the
default 50mm lens.

Pull Request: https://projects.blender.org/blender/blender/pulls/132364
2025-01-09 21:52:10 +01:00
Pratik Borhade
60ac0421b3 Fix #132830: Regression: Cursor restores the update in GN input
For node region, `event_cursor` is true, it sends update to the cursor
every draw call, this restores the cursor `WM_CURSOR_X_MOVE`.
Issue is originally caused by e6d941cdf4 and it introduced couple other
issues. So best fix would be to revert the commit. And to fix #129178,
restore modal cursor after drawing context menu, i.e. execution of
`ui_popup_context_menu_for_button`.

Pull Request: https://projects.blender.org/blender/blender/pulls/132848
2025-01-09 21:21:30 +01:00
Xavier Hallade
ce463bd6b1 Cycles: oneAPI: optimize device<->host copies
There is a large overhead when doing copies between a device and non-USM host memory.
Using the prepare/release API avoids it, as presented in the optimization guide:
https://www.intel.com/content/www/us/en/docs/oneapi/optimization-guide-gpu/2025-0/optimizing-data-transfers.html

This currently translates to a 4-5% overall rendering speedups on my Arc B580 in most scenes.

Pull Request: https://projects.blender.org/blender/blender/pulls/132859
2025-01-09 21:00:12 +01:00
Hans Goudey
954d708d99 Cleanup: Formatting 2025-01-09 14:29:47 -05:00
Hans Goudey
f2c9fccee0 Cleanup: Move legacy node integer types defines to separate header
Moving these defines to a separate header makes their "legacy" status
more obvious. This commit just adds the include wherever necessary.

Followup to 971c96a92c.

Pull Request: https://projects.blender.org/blender/blender/pulls/132875
2025-01-09 20:03:08 +01:00
Sean Kim
e2d6517109 Sculpt: Allow running performance test in 4.3 releases
Unfortunately, the tests as they are right now will likely not work with
4.2 and previous versions, as the brush asset changes will need to be
accounted for.

Pull Request: https://projects.blender.org/blender/blender/pulls/132827
2025-01-09 19:27:20 +01:00
Hans Goudey
7c775c6f57 Cleanup: Move some node editors functions to C++ namespace
Pull Request: https://projects.blender.org/blender/blender/pulls/132873
2025-01-09 19:19:06 +01:00
Hans Goudey
b44a86e281 Cleanup: A few clang tidy fixes in node_draw.cc
- Remove unused headers
- Use const arguments
- Add default case
- Remove unnecessary casts
2025-01-09 19:19:05 +01:00
Miguel Pozo
f005f4d562 FIx #132007: Overlay-Next: Center view to mouse sculpt flicker
Skip passes that draw to render_fb directly if is_depth_only_drawing.
2025-01-09 18:21:37 +01:00
Jacques Lucke
6ddebc0888 Fix #132831: memory leak when deleting simulation zone
The leak happened because the bake data of the removed zone was only partially freed.

Pull Request: https://projects.blender.org/blender/blender/pulls/132867
2025-01-09 18:19:53 +01:00
Falk David
6f46d5e439 Cleanup: Various C++ cleanups to BKE_material.hh
Pull Request: https://projects.blender.org/blender/blender/pulls/132870
2025-01-09 18:11:48 +01:00
Falk David
d413b0064f Cleanup: Move BKE_material.h to C++
The `BKE_material.h` is only renamed to `.hh` to preserve
the history of the file. Changes to the file are done in
the following commit.
2025-01-09 18:11:46 +01:00
Hans Goudey
b05ef8f739 Nodes: Avoid string copy drawing reroute nodes, use StringRef
Also return early to avoid adding an empty label button.
2025-01-09 12:07:53 -05:00
Hans Goudey
0816234d65 Refactor: Make BMesh normals draw extraction similar to Mesh
This creates more boilerplate code, but it's easier to extend,
it's follows the same structure as the mesh extraction, and
it's more aligned to planned future performance improvements.

Pull Request: https://projects.blender.org/blender/blender/pulls/132866
2025-01-09 17:45:54 +01:00
Philipp Oeser
50648c72d7 Fix #132784: Affect only Origins no longer displays an axis
Was missed in the move to Overlay Next.
Now bring it back in `class Axes: Overlay`

Thx @pragma37 making me aware chaging draw state (not writing depth)
can be done using a subpass!

Pull Request: https://projects.blender.org/blender/blender/pulls/132794
2025-01-09 17:40:40 +01:00
Jacques Lucke
038159e96b Refactor: Nodes: improve node tree update API
Main goals of this refactor:
* Make it more obvious which update function should be used.
* Make it more obvious which parameters are required by using references instead
  of pointers.
* Support passing in multiple modified trees instead of just a single one.

No functional changes are expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/132862
2025-01-09 17:00:05 +01:00
Jacques Lucke
259c98fa72 Nodes: add utility method to check node type
The `bNode.type_legacy` is still used in many places to check if a node is a
specific type. However, going forward it's better to rely more on the idname
than on this legacy integer type. Some more information is available in #132858.

The added utility method can be used like so:
`node->is_type("GeometryNodeMenuSwitch")`. Previously one would have written
`node->type_legacy == GEO_NODE_MENU_SWITCH`. The `is_type` method internally
checks that the passed in string is a valid node identifier to make it more
likely that we catch typos early.

Pull Request: https://projects.blender.org/blender/blender/pulls/132863
2025-01-09 16:59:47 +01:00
Julian Eisel
04f570a01f Refactor: UI: Move View2D files into directory
As proposed in #98518, this moves all `View2D` files into
a `source/blender/editors/inteface/view2d/` directory. This helps
keeping the `interface/` directory clean. In general I think we should
promote a more modular thinking, where coherent parts of the code form a
module or sub-module. The directory structure and its files can reflect
that nicely.

Pull Request: https://projects.blender.org/blender/blender/pulls/132853
2025-01-09 16:55:54 +01:00
Bastien Montagne
4032b853c3 RNA: Add basic tests for the path_from_id() function.
Simply load factory startup file, and recursively iterate over
all (valid) `POINTER` and `COLLECTION` properties of all IDs.

NOTE: A few cases are currently returning invalid rna paths (at least
from quick look), these are skipped for now.

Pull Request: https://projects.blender.org/blender/blender/pulls/132809
2025-01-09 16:46:37 +01:00
Nathan Vegdahl
2d1d4000c7 Fix: invalid memory access in animrig::versioning unit tests
The issue was that we were passing a pointer-to-a-pointer to
`BLI_addtail()`, which expects a pointer to something castable to a
`Link`. This in turn led to an invalid memory access when trying to
access the fields of the supposed `Link`.

This fixes the issue by passing a pointer to a zero-initialized `Link`
instead.

This also takes the opportunity to more simply zero-initialize the
`bAction` structs used in the tests as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/132860
2025-01-09 15:57:33 +01:00
Sybren A. Stüvel
c104fa95d9 Fix: don't use nullptr for std::optional<StringRefNull>
`StringRefNull` cannot reference a `nullptr` string, and so
`uiDefAutoButR()` should get a `std::nullopt` instead of `nullptr`.

Pull Request: https://projects.blender.org/blender/blender/pulls/132852
2025-01-09 15:37:36 +01:00
Jacques Lucke
971c96a92c Nodes: rename integer type of nodes to type_legacy
The new description for `bNode.type_legacy`:
```
  /**
   * Legacy integer type for nodes. It does not uniquely identify a node type, only the `idname`
   * does that. For example, all custom nodes use #NODE_CUSTOM but do have different idnames.
   * This is mainly kept for compatibility reasons.
   *
   * Currently, this type is also used in many parts of Blender, but that should slowly be phased
   * out by either relying on idnames, accessor methods like `node.is_reroute()`.
   *
   * A main benefit of this integer type over using idnames currently is that integer comparison is
   * much cheaper than string comparison, especially if many idnames have the same prefix (e.g.
   * "GeometryNode"). Eventually, we could introduce cheap-to-compare runtime identifier for node
   * types. That could mean e.g. using `ustring` for idnames (where string comparison is just
   * pointer comparison), or using a run-time generated integer that is automatically assigned when
   * node types are registered.
   */
```

Pull Request: https://projects.blender.org/blender/blender/pulls/132858
2025-01-09 15:28:57 +01:00
Jacques Lucke
2f04f2184c Nodes: remove unused NOD_static_types.h file
In various previous commits all the remaining usages of this file were removed
(b1d7e8fcb1, b1d7e8fcb1, 2afd946ba, b43e2168e3). Now this file is finally
completely unused, which means we can remove it.

The main reason why we don't want this file is that it heavily relied on the
preprocessor and makes it hard to decentralize implementation details of
individual nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/132855
2025-01-09 14:05:48 +01:00
Alaska
2874da3f25 Tests: Add Cycles test for baking from selected object
This scene consists of two spheres (shade flat and shade smooth)
having their normals baked onto a plane using the "Bake from selected"
option.

Ref: blender/blender#132716
Ref: blender/blender-test-data!37
2025-01-09 13:38:51 +01:00
Lukas Tönne
fd83be0fa5 Fix: Grease Pencil: Strokes are locked when material index is out-of-range
When the material index of a stroke is out-of-range of the material slots, the
strokes are never editable. This makes it hard to even re-assign the material or
otherwise remove such strokes. A negative index can happen when curves are added
while a Grease Pencil object has no material slots (see #123887).

Since `material_index` is a generic attribute and should be allowed any value,
strokes with out-of-range indices should be considered editable by default.
This patch slightly changes the `get_editable_material_indices` function for
tools, such that only __valid__ materials with the "Locked" flag set are
considered non-editable.

Pull Request: https://projects.blender.org/blender/blender/pulls/132806
2025-01-09 13:34:31 +01:00
Falk David
b4d5e256cb Fix #132828: Grease Pencil: "Smooth Stroke" smooths end points of ranges
The `smooth_curve_attribute` function smoothes individual
ranges of points that are selected within a stroke.

When smoothing a single range, the `gaussian_blur_1D` function
shouldn't treat this range as cyclic.

Instead, we check if the entire curve is selected and only use
the `cyclic` boolean in this case. For ranges, we always
treat them as non-cyclic.

Pull Request: https://projects.blender.org/blender/blender/pulls/132850
2025-01-09 13:19:37 +01:00
Alaska
4ca207a145 Cycles: Align Camera data output between SVM and OSL
The `ZDepth` output of the camera data node was different between SVM
and OSL.

SVM would output the `ZDepth`, with negative distances for points
behind the camera. While OSL would output the absolute of the distance,
which resulted in points behind the camera becoming positive.

Align OSL to SVM and allow outputting the negative distance as it
allows users to differentiate between what's in front or behind the
camera.

Pull Request: https://projects.blender.org/blender/blender/pulls/132837
2025-01-09 12:44:52 +01:00
Jacques Lucke
b1d7e8fcb1 Nodes: define node rna without NOD_static_types.h
This removes the last usage of `NOD_static_types.h` after #132815. It does so by
essentially inlining it into `rna_nodetree.cc` in a more compact way.

To avoid the need for especial cases for some nodes, all node-specific functions
now also take the `BlenderRNA` as parameter instead of only the `StructRNA`.
This allows such node-specific functions to register additional subtypes if
necessary. I think it should be possible to use this to fully define more
complex dynamic nodes such as repeat zone nodes, but that's not included in this
patch.

Now a line to define a node rna struct looks like so: `define("GeometryNode",
"GeometryNodePointsOfCurve");`

The `GeometryNode` part of it is intentionally somewhat redundant to allow for
better searchability.

Pull Request: https://projects.blender.org/blender/blender/pulls/132823
2025-01-09 12:20:56 +01:00
Jacques Lucke
0fa4c6da18 Refactor: Nodes: avoid using NOD_static_types.hh when creating node types
This removes the second to last usage of `NOD_static_types.hh` which we intend
to remove. A nice benefit is that the idname is now finally more explicit when a
node is registered. Previously it was difficult to search for the definition of
a node in the code when one had only the idname, which is the main identifier
for nodes.

The main change is in `node_type_base`.

Pull Request: https://projects.blender.org/blender/blender/pulls/132815
2025-01-09 12:19:57 +01:00
Lukas Tönne
a46def32b4 Fix #123887: Clamp the Grease Pencil material index in GPU buffers to avoid invalid UBO lookup
The material index in Grease Pencil attributes can be negative, since they are a
generic attribute. The shader, however, requires clamping of the material index
to avoid an invalid lookup. This was already happening for the material buffer
setup (`grease_pencil_object_cache_populate`), but not for the actual VBO.

Fixes #131670

Pull Request: https://projects.blender.org/blender/blender/pulls/132804
2025-01-09 11:37:46 +01:00
Jeroen Bakker
59bc024fd8 Fix #132752: Image Engine: Clearing when no image present
When no image is present the depth and color buffers aren't correctly
cleared, resulting in showing the previous buffers.

Replaced the clear on bind with regular clearing operations.

Alternative implementation for !132751

Pull Request: https://projects.blender.org/blender/blender/pulls/132844
2025-01-09 09:31:44 +01:00
Campbell Barton
1fe52f43e4 Fixes #93103: Crash entering negative numbers for some modifiers
Modifiers: Decimate, Smooth, Corrective Smooth, Laplacian Smooth, Laplacian Deform
& Grease Pencil Simplify allowed negative numbers for values
representing iterations/steps.

Ref: !131479

Co-authored-by: Jason C. Wenger <jcwenger@gmail.com>
2025-01-09 13:27:33 +11:00
Campbell Barton
f829fefabe CMake: disable WITH_PIPEWIRE for lite builds 2025-01-09 13:07:54 +11:00
Campbell Barton
9d0aabe64a Tools: add "--skip-last" argument to addr2line_backtrace for convenience
The last address in a backtrace often reference symbols before main()
which aren't found, making the command take much longer to run.
2025-01-09 12:32:08 +11:00
Campbell Barton
8ab4e8c7ad Fix crash in weight paint's loop selection
Finding the closest edge could use an uninitialized value.

Part of #119932.

Co-authored-by: Philipp Oeser <philipp@blender.org>
2025-01-09 10:36:06 +11:00
Jesse Yurkovich
08e63c4f3e USD: Make consistent Primvar checks during attribute import
- Remove redundant .HasValue() calls
  We are calling `GetPrimvarsWithValues` which will do the HasValue
  checks for us already.
- Consistently skip non-array primvars
  We only want to import in the array attributes. Consistently check for
  this in each of our loops.

Pull Request: https://projects.blender.org/blender/blender/pulls/132816
2025-01-09 00:16:18 +01:00
Campbell Barton
69cc4c708d Cleanup: clarify naming & simplify "+" drawing for UV grid
- Prefer term "size" over "width" as this was used for the height.
- Simplify calculation for drawing the "+".
- Add note that the "+" is slightly off-center (ref #112653).
2025-01-09 10:06:43 +11:00
Iliya Katueshenock
9d13e39585 Geometry Nodes: Avoid extra attribute copy in Sort Elements node
Implicit sharing dramatically reduces the cost of coping geometry
which is extremely helpful for read-only and slight modification.
But case of Sort Elements node implies a total rewrite of whole domain,
so implicit sharing only adds redundant cost for write access. This fix
uses kernel API to create domains without attributes, manually forcing
implicit sharing for offset indices and uses kernel attribute copy
functions to force sharing for all attributes when this is possible.
In all other cases new attributes are created from scratch and copied
as re-ordered only once.

In attached example file shown the difference depend on the number of
attributes on the mesh, benchmark result:

| Attributes | Before | After |
| ---------- | ------ | ----- |
| 1          | 2 ms  | 1.5 ms |
| 5          | 5 ms  | 4 ms   |
| 10         | 9 ms  | 6 ms   |
| 50         | 45 ms | 30 ms  |
| 100        | 89 ms | 59 ms  |

Pull Request: https://projects.blender.org/blender/blender/pulls/117910
2025-01-08 23:06:22 +01:00
Hans Goudey
9945563fac Mesh: Avoid computing corner normals for drawing if unnecessary
Only compute face corner normals if they are required for computing
tangents or if it's required because of the combination of sharp edges
and faces.

Pull Request: https://projects.blender.org/blender/blender/pulls/132821
2025-01-08 21:42:20 +01:00