Commit Graph

120055 Commits

Author SHA1 Message Date
Clément Foucault
8bc70f24a1 EEVEE: Film: Reduce amount of compilation stutters at startup
Removes the stutters comming from the film shader.
The number of samples used by the film shader is set
throught a specialization constant. Since the number of
effective sample can depend on jitter position, this
number was fluctuating and trigger compilation on
new specialization until all specialization were
encountered.

Rounding the samples up to the most common sample
count fixes the issue.

Pull Request: https://projects.blender.org/blender/blender/pulls/139154
2025-05-20 12:45:45 +02:00
Clément Foucault
d3053fead0 GPU: Assert that a shader is not bound when deleting it
This caused UB in the tests now that tests are all ran
inside the same context.

A shader could be free but its pointer would be dangling
inside the `Context`. A new shader could have the same
address and generate UB after binding.

This is not the best way to solve this issue but at least
we prevent the use of the UB.

Pull Request: https://projects.blender.org/blender/blender/pulls/139109
2025-05-20 12:43:58 +02:00
Jacques Lucke
ecfd9ec2d7 Fix: Spreadsheet: bad default width for instance reference column
Now the default width of this column type is also derived from its content.
2025-05-20 12:14:33 +02:00
Campbell Barton
7883412cde Cleanup: rename Curve::type -> ob_type, remove BKE_curve_type_get
It's not common for object data to reference it's object type
so name the struct member to make this clear.

Also remove BKE_curve_type_get which is no longer needed.
2025-05-20 10:11:56 +00:00
Campbell Barton
cdaf17031e Docs: update help text for DNA renaming
Also use sha256sum in the example to calculate the sum and sort
definitions.
2025-05-20 19:59:52 +10:00
Aras Pranckevicius
389d770bf4 Fix #122256, #123862: OBJ import Clamp Size option issues
- #122256: Clamp Size option did not work at all, due to mesh
  bounding box still not being calculated (and was firing an assert
  in Debug build).
- #123862: Clamp Size option was rounding the resulting scale to
  powers of ten, which is not what anyone would expect.

This fixes both issues, and adds test coverage.

Co-authored-by: dshot92 <dshot92@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/139145
2025-05-20 11:57:42 +02:00
Campbell Barton
8fea423e00 Fix #139133: Crash entering edit mode for curve/text objects
- Make Curve::type the source of truth for the curve type,
  instead of Curve::vfont, since it's possible for this to be
  set to null from RNA which effectively changed it's type.
  See #138730.

- Update objects to match the curve type on file read.

  Without this, an object may link to a curve in another file which
  can be replaced by a curve data-block of a different type.

  Note that updating the object type was already being done
  when reloading library data and setting object data,
  just not on file load.

Ref !139137
2025-05-20 19:28:49 +10:00
Nathan Vegdahl
d9d399ccb1 Fix: Truncated filepath fields give incorrect path template errors
The Path Template errors reported in tooltips could be incorrect,
depending on whether the field was visually truncated in the UI or not.

For example, if you had a path `/tmp/{blend_name}{foo`, the error is
that the template expression `{foo` is unclosed.  However, if the
available space for the field in the UI is too small, the displayed path
could end up as `/tmp/{blend_na...`.  This is for display purposes only,
and shouldn't effect things like template errors.  However, it did, and
the error checking would be run on that display string, and report that
`{blend_na...` is unclosed, which is incorrect.

The issue was that the code doing the live error checking for the UI was
using the display string because it was conveniently available.

This fixes the issue by properly querying the property value via RNA,
and using that.

Pull Request: https://projects.blender.org/blender/blender/pulls/139144
2025-05-20 11:26:51 +02:00
Clément Foucault
de8f13d1d6 Fix: GPU: Assert caused by specialization constant with primitive expansion
This path was not passing the the specialization constant state
to `GPU_shader_bind`.

Fix #139132
2025-05-20 11:23:42 +02:00
Nathan Vegdahl
984a2b5298 Fix: RNA_property_string_get() always returns zero-length string
The variant of `RNA_property_string_get()` that returns a `std::string`
always returned a string with zero length. The issue is that it was only
calling `reserve()`, which ensures an underlying buffer with enough
*capacity*, but does not set the string length. The property's string
value would then be correctly copied to the reserved buffer, but the
string length would remain zero.

This commit fixes the issue by replacing the call to `reserve()` with a
call to `resize()`, which additionally sets the string length.

Pull Request: https://projects.blender.org/blender/blender/pulls/139106
2025-05-20 10:33:19 +02:00
Christoph Lendenfeld
717fa42e5e Anim: Add more modes to Select Grouped in pose mode
This adds the following options to Select Grouped in pose mode:
* Children
* Immediate Children
* Parents
* Siblings

Doing so means we are more in line with similar operators in edit mode.
Unfortunately re-using existing functionality from edit mode doesn't seem
possible due to the edit/pose bone difference.

The added functionality can handle multiple armatures in pose mode at once.
Also the same operators can be accessed from weight paint mode.

Implements #137274

Pull Request: https://projects.blender.org/blender/blender/pulls/137960
2025-05-20 10:19:31 +02:00
Omar Emara
85cfdf9e04 Cleanup: Assert on unknown enum 2025-05-20 09:45:28 +03:00
Omar Emara
a141d66aa2 Compositor: Add Relative To Pixel node
This patch adds a new Relative To Pixel node in the compositor. The node
converts values that are relative to the image size to values that are
in terms of pixels.

This is useful to use relative values in nodes that take pixel values.
For instance, the Kuwahara node has an input that defines the filter
size in pixels. If one wants to define it relative to the image size
instead, one can use this node.

The node can operate on float and 2D vector values. Further, the node
can do the conversion relative to a number of image properties:

- Per Dimension: Each dimension gets converted independently. The X
  value is relative to the X dimension and the Y value is relative to
  the Y dimension. This mode is special because in float mode, the
  output will be a factor as opposed to a float.
- X: Relative to the x dimension.
- Y: Relative to the y dimension.
- Greater: Relative to the greater dimension.
- Smaller: Relative to the smaller dimension.
- Diagonal: Relative to the diagonal of the image.

Pull Request: https://projects.blender.org/blender/blender/pulls/138773
2025-05-20 08:32:46 +02:00
Omar Emara
c9dc4a0f69 Fix: Crash when all inputs inside panel are unavailable
Blender crashes when a node has a panel whose children input sockets are
all unavailable. This happens when marking sockets as collapsed, where
the non-initialized header_center_y members of such panels are accessed,
causing asserts or crashes.

The update_collapsed_sockets_recursive function has a check that should
avoid such accesses, but it seems wrong due to the negation of the
visibility check.

To fix this, we move the visibility check to a guard condition in the
marking function instead, and simplify the collapsed check in the update
function.

Pull Request: https://projects.blender.org/blender/blender/pulls/139104
2025-05-20 08:26:36 +02:00
Campbell Barton
cd2be77610 Cleanup: remove unnecessary curve type check
Calculating the curve type isn't needed for data which is only written
for text curves.

Note that this complicates a fix for #139133 which changes how curve
type data is accessed, where a version of BKE_curve_type_get that used
old behavior would have had to be kept for version patching.
2025-05-20 15:43:22 +10:00
Campbell Barton
1f37a7d363 Cleanup: remove unused defines 2025-05-20 04:33:43 +00:00
Campbell Barton
277dc3aef4 Cleanup: use doxygen style comments for doc-strings 2025-05-20 04:33:42 +00:00
Campbell Barton
4c794e8e2e Cleanup: early return in node gizmo poll functions
Avoid multiple null checks for SpaceNode, check & return early.
2025-05-20 11:50:35 +10:00
Sean Kim
f365824b40 Cleanup: Remove unused & unimplemented sculpt_paint functions
Pull Request: https://projects.blender.org/blender/blender/pulls/139123
2025-05-20 00:55:42 +02:00
Hans Goudey
867256f4c8 Cleanup: Formatting 2025-05-19 16:13:20 -04:00
Damien Picard
81d9e94218 UI: Fix and improve a few messages
- "Parameters for custom (OSL-based) Cameras" -> "cameras": lower case
  in tooltips.
- "Connect two nodes ... (automatically determined": missing
  parenthesis.
- "Join curve... control points are detected(if disabled...": add
  missing space.
- "Add Selected to Active Objects Collection" -> "Active Object's":
  typo.
- "Duplicate the acive shape key" -> "active": typo.
- "Copy selected points ": remove trailing space.
- "Move cursor" -> "Cursor": title case for operator.
- "Paste text to clipboard" -> "from clipboard": typo.
- "An empty Action considered as both a 'layered' and a 'layered'
  Action." -> "is considered as both a 'legacy' and a 'layered'
  Action": likely copy-paste error.
- "Target's Z axis will constraint..." -> "will constrain": typo.
- "The layer groups is expanded in the UI" -> "layer group": typo.
- Deprecation warnings: add missing parentheses.
- "... on low poly geometry.Offset rays...": add missing space after
  period.
- "... relative to the files directory" -> "... to the file's
  directory": typo.
- "The unit multiplier for pixels per meter" -> "The base unit": this
  property description was copy and pasted.
- "... beyond the faces UVs..." -> "the faces' UVs: typo.
- "Is tracking data contains ..." -> "Whether the tracking data
  contains": grammar.
- "Selected text" -> "Text": title case for prop.
- "The user has been shown the "Online Access" prompt and make a
  choice" -> "made a choice": grammar.
- "Glare ": remove trailing space.
- "Don't collapse a curves" -> "Do not collapse curves": grammar.

Some issues reported by Tamar Mebonia.

Pull Request: https://projects.blender.org/blender/blender/pulls/139118
2025-05-19 22:12:17 +02:00
Hans Goudey
550094b018 Refactor: Attributes: Access active attribute with name
This function to get the active attribute currently returns a custom
data layer pointer. This doesn't work when we transition to the new
`AttributeStorage` system. Returning an optional string is a simple
alternative that also aligns with the idea of changing the source of
truth from an index to a string stored on the geometry.

Pull Request: https://projects.blender.org/blender/blender/pulls/139115
2025-05-19 21:29:57 +02:00
Hans Goudey
b93f4f9449 Fix #139103: Spreadsheet row filters not working
Caused by db7b5a480b.
2025-05-19 14:17:56 -04:00
Hans Goudey
2bcd665659 Cleanup: Pass IndexMask by const reference 2025-05-19 14:17:56 -04:00
Bastien Montagne
bbe9eb647a Cleanup: Remove redundant usage of ID_NEW_SET in Object high-level duplication code.
This is already always done by lower-level `BKE_id_copy_for_duplicate`
(through the call to `BKE_object_duplicate`).
2025-05-19 20:16:43 +02:00
Bastien Montagne
3957b4a11f Cleanup: Improve documentation of BKE_object/collection_duplicate functions.
No functional change expected here.
2025-05-19 20:16:43 +02:00
Jesse Yurkovich
46ec277713 USD: Add support for UsdPrimvarReader_TYPE in materials
Add support for the UsdPrimvarReader_TYPE templates for both import and
export. These are used by several USD test assets and support here
represents the last major piece of the UsdPreviewSurface spec to be
implemented.

On import these become `Attribute` nodes and on export the `Attribute`
nodes will become `UsdPrimvarReader_TYPE`'s accordingly.

Import:
- `UsdPrimvarReader_float` and `UsdPrimvarReader_int` will use the `Fac`
  output
- `UsdPrimvarReader_float3` and `UsdPrimvarReader_float4` will use the
  `Color` output
- `UsdPrimvarReader_vector`, `UsdPrimvarReader_normal`, and
  `UsdPrimvarReader_point` will use the `Vector` output

Export (only `Geometry` Attribute types are considered):
- `Fac` will use `UsdPrimvarReader_float`
- `Color` will use `UsdPrimvarReader_float3`
- `Vector` will use `UsdPrimvarReader_vector`
- `Alpha` is not considered

MaterialX note:
Hydra-native support is a bit more involved and will have to be done
separately. Hydra w/USD sync is trivial to implement but those changes
have been left out here.

Pull Request: https://projects.blender.org/blender/blender/pulls/135143
2025-05-19 19:47:22 +02:00
Sean Kim
dc213cd79e Cleanup: Remove extra whitespace in some sculpt helper methods
Pull Request: https://projects.blender.org/blender/blender/pulls/139041
2025-05-19 19:41:33 +02:00
Sean Kim
8f4ac59f7c Cleanup: Tag Brush toggle_brush field as deprecated
This field's usage was removed with the brush assets project, previously
it was used during runtime in the `PAINT_OT_brush_select` operator.

This commit tags the DNA field as deprecated and marks the overall
`brush.cc` file with `#define DNA_DEPRECATED_ALLOW` to follow a similar
pattern as other BKE files dealing with I/O of ID types.

The field was added in 147b4b13ba and
updated in 7b7aba31f2 to prevent invalid
pointers from remaining on the brush.

Pull Request: https://projects.blender.org/blender/blender/pulls/138578
2025-05-19 19:40:48 +02:00
Hans Goudey
b038e35c2d Fix: Build failure without OpenVDB
Caused by 0837037d13.
2025-05-19 13:34:59 -04:00
илья _
b5dfc9ea70 Fix: Nodes: Apply unit range for Mix factor
Add soft unit range for mix factor in vector non-uniform mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/139024
2025-05-19 19:33:42 +02:00
Jacques Lucke
0837037d13 Geometry Nodes: initial support for volume grids in function nodes
This patch implements basic support for evaluating function nodes on volume
grids. Conceptually, a function node always creates a new grid for the output,
though the output is often a modified version of the input. The topology of the
output grid is a union of all the input grids.

All input grids have to have the same transform. Otherwise one has to use
resampling to make grids compatible.

Non-grid inputs are allowed to be single values or fields. The fields are
evaluated in a voxel/tile context, so they compute a value per voxel or per
tile.

One optimization is missing that will probably be key in the future: the ability
to merge multiple function nodes and execute them at the same time. Currently
the entire function evaluation is started and finished for every function node
that outputs a grid. This will add significant overhead in some situations.
Implementing this optimization requires some more changes outside of the scope
of this patch though. It's good to have something that works first.

Note: Not all function nodes are supported yet, because we don't have grid types
for all of them yet. Most notably, there are no color/float4 grids yet.
Implementing those properly is not super straight forward and may require some
more changes, because there isn't a 1-to-1 mapping between grid types and socket
types (a float4 grid may correspond to a color or vector socket later on).

Using grids with function nodes and fields can result in false positive warnings
in the UI currently. That's a limitation of our current socket type inferencing
and can be improved once we have better socket shape inferencing.

Pull Request: https://projects.blender.org/blender/blender/pulls/125110
2025-05-19 18:30:58 +02:00
Colin Basnett
39c2f01b51 Nodes: add Bit Math node
This adds a new Bit Math node which supports the following operations: `and`,
`or`, `xor`, `not`, `shift` and `rotate`.

For the `shift` and `rotate` operations, a posititive shift is a left shift and
a negative shift is a right shift.

Currently, the node always works on 32-bit integers which is what Geometry Nodes
uses internally for integers. If required, this can be extended to work on other
bit widths in the future.

The need for this came up every now and then. It can be useful when encoding
specific bits in integer attributes (for efficiency or because the geometry is
exported to other software that expects a certain format). Also, this node is
useful for some people doing crazy but fun things with Geometry Nodes like
emulating hardware. Even if the use-cases are not common, if they arise, it's
hard to work around and the cost of having this node is quite low for us.

Co-authored-by: Charlie Jolly <charliejolly@noreply.localhost>

Pull Request: https://projects.blender.org/blender/blender/pulls/138290
2025-05-19 18:03:05 +02:00
Jacques Lucke
81275eff60 Nodes: improve forward compatibility for unknown interface item types
#138747 adds a new interface item type for separators. Unfortunately, the
current code is not forward-compatible with those. This patch improves forward
compatibility by removing all unknown tree interface item types on-load.

Pull Request: https://projects.blender.org/blender/blender/pulls/139015
2025-05-19 17:52:15 +02:00
Clément Foucault
caac241c84 GPU: Make Shader Specialization Constant API Thread Safe
This allows multiple threads to request different specializations without
locking usage of all specialized shaders program when a new specialization
is being compiled.

The specialization constants are bundled in a structure that is being
passed to the `Shader::bind()` method. The structure is owned by the
calling thread and only used by the `Shader::bind()`.
Only querying for the specialized shader (Map lookup) is locking the shader
usage.

The variant compilation is now also locking and ensured that
multiple thread trying to compile the same variant will never result
in race condition.

Note that this removes the `is_dirty` optimization. This can be added
back if this becomes a bottleneck in the future. Otherwise, the
performance impact is not noticeable.

Pull Request: https://projects.blender.org/blender/blender/pulls/136991
2025-05-19 17:42:55 +02:00
Hans Goudey
6562033a4a Cleanup: Use StringRef for some UI string arguments
Instead of StringRefNull.

Pull Request: https://projects.blender.org/blender/blender/pulls/139095
2025-05-19 17:25:52 +02:00
Jacques Lucke
f3294bbd06 Nodes: improve drawing with invalid zone links
Previously, whenever the zone detection algorithm could not find a result, zones
were just not drawn at all. This can be very confusing because it's not
necessarily obvious that something is wrong in this case.

Now, invalid zones and links that made them invalid have an error.

Note, we can't generally detect the "valid part" of zones when there are invalid
links, because it's ambiguous which links are valid. However, the solution here
is to remember the last valid zones, and to look at which links would invalidate
those. Since the zone-detection results in runtime-only data currently, the
error won't show when reopening the file for now.

Implementation wise, this works by keeping a potentially outdated version of the
last valid zones around, even when the zone detection failed. For that to work,
I had to change some node pointers to node identifiers in the zone structs, so
that it is safe to access them even if the nodes have been removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/139044
2025-05-19 17:25:36 +02:00
Sean Kim
6d0c33e8e7 Cleanup: Deduplicate object space radius calculation
* Also renames the method to make the meaning more obvious

Pull Request: https://projects.blender.org/blender/blender/pulls/139038
2025-05-19 17:13:54 +02:00
Sean Kim
06306dfed6 Cleanup: Minor changes for dynamic_topology_update
* Use constexpr instead of const
* Remove unused location calculation

Pull Request: https://projects.blender.org/blender/blender/pulls/139040
2025-05-19 17:11:30 +02:00
Clément Foucault
ca88983af2 EEVEE: Reverse-Z implementation
This feature greatly increase depth buffer precision.
This is very noticeable in large view distance scenes.

This is enabled by default on GPUs that supports it (most of the hardware we
support already supports this). This makes rendering different on the GPUs
that do not support that feature (`glClipControl`).

While this give much better depth precision as before, we also have a lot of
imprecision caused by our vertex transformations. This can be improved in
another task.

Pull Request: https://projects.blender.org/blender/blender/pulls/138898
2025-05-19 16:29:26 +02:00
Philipp Oeser
cb8f0c7800 Fix #139031: Armature Edit mode can't reveal hidden bones
Caused by 9c35656766

More like a typo, in that commit, `ANIM_bonecoll_is_visible_editbone`
was swapped with `blender::animrig::bone_is_visible_editbone` (but that
was only meant to replace `ANIM_bone_is_visible_editbone`)

So to resolve, just use `ANIM_bonecoll_is_visible_editbone` again

Pull Request: https://projects.blender.org/blender/blender/pulls/139077
2025-05-19 16:26:58 +02:00
Hans Goudey
ed422eadce Fix: Assert in Set Tool Selection node with floats 2025-05-19 10:18:47 -04:00
Jacques Lucke
e87f744134 Nodes: show internal links independent of whether output is linked
Previously, internal links of node are only shown when the link is muted AND
when the corresponding output is linked to something else. I can't think of any
reason for why it's important whether the output is linked or not. It seems
showing the internal link is always useful.

This patch makes it so that all internal links are always shown when a node is
muted, regardless of whether the corresponding output socket is linked or not.

Pull Request: https://projects.blender.org/blender/blender/pulls/139086
2025-05-19 15:40:55 +02:00
Jacques Lucke
d9317046b2 Nodes: initialize node name from group name
Previously, when adding a group node it was always called `Group`. This is not
particularly useful. Also it's inconsistent with many other places like adding
modifiers where the name of the modifier depends on what modifier is added.

Now, newly added group node will have the same name as the group that it calls.
Node names still have to be unique though, so e.g. `.001` is still added.

Pull Request: https://projects.blender.org/blender/blender/pulls/139093
2025-05-19 15:39:44 +02:00
Jacques Lucke
e981345a73 Fix #139055: failing implicit conversion between different subtypes
There are separate `bNodeSocketType` for each subtype. Hence, comparing
their pointers is not enough to determine whether a conversion is necessary.

Pull Request: https://projects.blender.org/blender/blender/pulls/139083
2025-05-19 15:39:09 +02:00
YimingWu
236f401695 Grease Pencil: Allow filtering by layer groups in modifiers
Previously modifiers can only filter single layers, now filtering by
layer group is also supported.

This adds a toggle to the layer filter to switch to filtering by groups.

Resolves  #123323.

Pull Request: https://projects.blender.org/blender/blender/pulls/123353
2025-05-19 13:56:35 +02:00
Jeroen Bakker
d87e0ecb61 Fix: Vulkan: Incorrect Std430 memory layout
When using float2/int2/uint2 arrays the elements could be incorrectly
alligned. This wasn't noticable when using Blender as it isn't used,
However python addons and forks can use it.

Fixes an issue with UPBGE

Pull Request: https://projects.blender.org/blender/blender/pulls/139082
2025-05-19 13:24:19 +02:00
Miguel Pozo
239eb386ff Fix #139064: EEVEE: Resizing render region can cause a crash
Clamp the render rect to the viewport area.
2025-05-19 12:49:29 +02:00
Habib Gahbiche
cf79f19570 Compositor: support link search for filter node
Show filter types (Sobel, Diamond Sharpen, etc..) in the link search
menu.

Pull Request: https://projects.blender.org/blender/blender/pulls/139081
2025-05-19 12:39:44 +02:00
Jeroen Bakker
2143eb7a4f Refactor: Vulkan/OpenXR: Import memory handles only once
Importing memory is done to often. when memory doens't change the
previous imported memory can be used.

The idea is to keep track of the last used buffer and keep reusing
it until the view/resolution has changed. This should not happen during
a session.

Pull Request: https://projects.blender.org/blender/blender/pulls/138984
2025-05-19 12:32:08 +02:00