Commit Graph

120055 Commits

Author SHA1 Message Date
Campbell Barton
b385b667f7 Cleanup: keep DNA rename list sorted 2025-03-20 00:38:53 +00:00
Campbell Barton
126cfbeb82 Refactor: rename bPoseChannel::size to scale
Match the name of the RNA as well as Object::scale, also rename
associated flags.

Ref !136151
2025-03-19 22:12:47 +00:00
Sean Kim
d9a6cdb8c8 Tests: Add calc_vert_neighbors_interior unit test
Adds basic testcase for a cube with no boundary verts and no hidden
faces.

Pull Request: https://projects.blender.org/blender/blender/pulls/136150
2025-03-19 21:49:24 +01:00
Omar Emara
2bc47e1e93 Cleanup: Compositor: Remove unused function 2025-03-19 16:01:45 +02:00
Omar Emara
b5392187ba Compositor: Support conversion to and from int2 and float2
This patch adds support for converting to and from float2 and int2
result types for GPU devices, this is already supported on CPU.
2025-03-19 15:51:57 +02:00
Brecht Van Lommel
9e1d8e349d Cycles: Adaptive subdivision no longer doubles up with Blender levels
Use the mesh wrapper mechanism from GPU subdivision to get the base mesh.
This can significantly reduce memory usage and render setup time if the
level was not manually set to zero.

Pull Request: https://projects.blender.org/blender/blender/pulls/135895
2025-03-19 14:10:20 +01:00
Brecht Van Lommel
53b84851c5 Refactor: Always use subdivision mesh wrapper, even without GPU subdiv
This makes it possible for Cycles adaptive subdivision to always get the
base mesh, and will enable the same for other external renderers as well.

Metal and Vulkan now support GPU subdivision, so by default the wrapper
will be used most of the time. However this can be disabled in the
preferencesas well. For those cases, the subdiv wrapper is still created
but cached immediately as part of modifier evaluation. This way it can
take advantage of multithreaded depsgraph evaluation, which is not
guaranteed for other cases.

The draw code access the object data through a wrapper that will return
either the base mesh or subdivided mesh depending if GPU subdivision is
enabled or not. Previously Object.data would have the appropriate mesh
already, but now that Cycles may do adaptive subdivision while GPU
subdivision is disabled this is no longer possible.

Pull Request: https://projects.blender.org/blender/blender/pulls/135895
2025-03-19 14:08:37 +01:00
Brecht Van Lommel
7cc74e4078 Refactor: Access object data through accessor function in draw module
To prepare for customizing this for Meshes. Do it for everything so
copy-pasting code is more likely to do the right thing.

Pull Request: https://projects.blender.org/blender/blender/pulls/135895
2025-03-19 14:08:37 +01:00
Brecht Van Lommel
321ec72c74 Refactor: Speed up and fix some issues in mesh wrapper
* Fix mesh_copy_data setting the subd wrapper type without copying the
  associated tessellated mesh. It's unclear if this currently causes any
  issues, but with future changes it would crash.
* Use double checked lock to avoid mutex locks on every call to
  BKE_mesh_wrapper_ensure_mdata and BKE_mesh_wrapper_ensure_subdivision.
* Set wrapper type to subd also if subdivision was skipped due to bad
  topology or level set to zero. Previous it would do mutex locking and
  TBB task isolation on every function call.
* Add assert when BKE_mesh_wrapper_ensure_mdata changes the wrapper type
  from subd to mdata. This doesn't really make any sense, it just loses
  the subdivision detail. If any code relies on this we need to understand
  why and maybe change it.

Pull Request: https://projects.blender.org/blender/blender/pulls/135895
2025-03-19 14:08:37 +01:00
Brecht Van Lommel
9526fe9993 Refactor: Add BKE_mesh_new_from_object argument to ignore subdivision
Pull Request: https://projects.blender.org/blender/blender/pulls/135895
2025-03-19 14:08:37 +01:00
Omar Emara
a55eac6179 Cleanup: Compositor: Remove dead conversion code 2025-03-19 14:11:11 +02:00
Omar Emara
775df8826b Compositor: Add Image Info node
This patch adds a new Image Info node which returns information about
compositor images. The node has three sources:

The node returns the following information:

- Pixel Coordinates: The coordinates of the centers of the pixels in the
  image. Those are essentially the integer coordinates with half pixels
  offsets added.
- Texture Coordinates: Zero centered pixel coordinates normalized along
  the greater dimension. Somewhat analogous to Object coordinates in
  shader nodes.
- Resolution: The resolution of the image.
- Location: The location of the image in the virtual compositing space.
- Rotation: The rotation of the image in the virtual compositing space.
- Scale: The scale of the image in the virtual compositing space.

This node is very useful to allow greater flexibility and procedural
creations. For instance, coordinates can be used to create procedural
effects like vignette using very simple math nodes. And size can be used
to compute size-relative parameters for pixel-parameter nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/135104
2025-03-19 11:38:29 +01:00
Omar Emara
0a80f470f8 Compositor: Add common nodes to compositor
This patch adds common nodes that are used in Geometry Nodes and Shader
Nodes to the compositor. The following new nodes were added:

- Vector Math.
- Vector Rotate.
- Vector Mix.
- Value Mix.
- Clamp.
- Float Curve.
- Blackbody.

The follow nodes were replaced by common counterparts:

- Value.
- Color Ramp.
- Mix Color.
- Map Range.
- Math.
- Combine XYZ.
- Separate XYZ.
- Vector Curves.

Some new features were gained in the process:

- Mix Color can now clamp both factor and result.
- Map Range can map different types and interpolations.
- Vector Curves gained a new Factor input.

Some behaviors were changed:

- Map Range previously forcibly clamped values whose magnitude is larger
  than the arbitrary value of 10000. This is no longer the case.

Some nodes were removed:

- Map Value. This was Map Range without the maximum 10000 limitation
  followed by a Clamp node. Both are now available as nodes.

Some common nodes remain separate:

- Separate/Combine Color. Shader counterpart does not yet support all
  color modes, and does not support alpha.
- RGB Curves. Shader variant does not support Film-Like curves or
  Black/White balancing.

Texture nodes will also be added soon in a separate patch. Nodes that
were replaced are now deprecated but still exist and will later be
removed in v5.0. Backward compatibility code was introduced to convert
from the deprecated nodes to the new nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/135300
2025-03-19 10:54:36 +01:00
Mohamed Gad
95eee272fe Fix #133173: Van Vliet does not converge at some values
Increasing the error tolerance from 1e-8 to 1e-7 guarantees convergence
before reaching oscillatory behavior. Additionally, using double
precision for all variables involved in the operation prevents
truncation errors, ensuring numerical stability.

Introducing a damping factor might fix oscillatory behavior but will
come at the cost of much more iterations, which does not seem worth it
considering that the suggested error tolerance of 1e-7 for the scale
factor translates to, at most, an error tolerance of 1e-3 for the
standard deviation in practice as can be seen by investigating the
derivative of the variance as a function of the scale factor. Such an
error will be almost impossible to notice in the context of blurring.

Pull Request: https://projects.blender.org/blender/blender/pulls/136149
2025-03-19 10:19:26 +01:00
Campbell Barton
44e45e8606 Fix: crash in background mode calling operators using ED_slider_create 2025-03-19 18:39:56 +11:00
Campbell Barton
7ecbe51522 Fix: crash in transform.create_orientation on curves without a 3D view 2025-03-19 03:32:34 +00:00
Campbell Barton
484aed26d6 Fix: crash in the weight paint poll function
The poll function didn't account for there being
no active region.
2025-03-19 14:01:28 +11:00
Campbell Barton
38ca9b0b87 Cleanup: improvements ED_markers_find_nearest_marker & it's doc-string
- Remove reference to variable in the function from the doc-string,
- Note that a non-empty marker list always returns a marker.
  Some callers assumed but wasn't the case until recently, see #136059.
- Replace null check in the look with an initial assignment to ensure
  a marker is always returned.
- Rename argument `x` to `frame`.
2025-03-19 01:16:20 +00:00
Campbell Barton
c37455acac Fix: crash in transform.from_gizmo from a missing poll function
In practice it's unlikely users would trigger this crash.
2025-03-19 00:51:15 +00:00
Harley Acheson
3f65f700e5 UI: Typographical and Path Wrapping for Tooltips
For tooltips, use typographical line breaking with hard limit for uses
of the regular font, path wrapping with hard limit for uses of the
monospaced font. Small correction to wrapping code so that hard limit
is not taken if there are optional breaking points.

Pull Request: https://projects.blender.org/blender/blender/pulls/136148
2025-03-19 00:44:44 +01:00
Campbell Barton
c690255184 Cleanup: rename "size" to "scale" in transform code
This value is mainly used for scale values, not an absolute "size".
2025-03-19 10:37:45 +11:00
Guillermo Venegas
cb11e23605 Fix #93504: Text moving in status bar
When flexiable spacing clamp the floating point widths to whole pixels
in ui_update_flexible_spacing to remove the random jiggling that can
occur, notable seen on the status bar at the right edge.

Pull Request: https://projects.blender.org/blender/blender/pulls/135899
2025-03-18 23:57:47 +01:00
Sean Kim
96869d03d4 Weight Paint: Allow property changes in the editor to create undo steps
Currently, no change to an RNA property invoked from the UI while inside
Weight Paint mode creates an undo step. This includes both tool
properties (e.g. brush size, tool settings) as well as mesh properties
(symmetry, active vertex group, selection mode).

This behavior was initially introduced to avoid creating extra undo
steps when painting or sculpting and changing tool settings, however,
it applied to all property changes performed while in any paint mode,
including changes to mesh datablock properties.

To fix this behavior, this commit simply removes Weight Paint from the
list of modes that have their own (legacy) undo system. This means it's
now covered by the regular memfile / global undo system.

This builds on !134548 and !134836.

Ref: #134220, #69760, and many others

Pull Request: https://projects.blender.org/blender/blender/pulls/135758
2025-03-18 22:05:54 +01:00
Sean Kim
d6f88c757e Cleanup: Remove unnecessary const in mesh_brush_common.hh
Pull Request: https://projects.blender.org/blender/blender/pulls/136113
2025-03-18 22:01:17 +01:00
Sean Kim
054f8719ce Fix #136105: Unable to sample un-merged color in Texture Paint
Introduced with 9dddef9581

Code incorrectly checked for if the face was hidden instead of checking
if the face was not hidden when picking the face.

Pull Request: https://projects.blender.org/blender/blender/pulls/136107
2025-03-18 21:55:22 +01:00
Brecht Van Lommel
bb878234a7 Fix #136137: Crash with subdivision modifier and search
After recent changes. Use uiLayoutPanel like other modifiers.
2025-03-18 20:17:06 +01:00
Clément Foucault
17eadcabc8 Fix: EEVEE: Broken lightprobe baking with hair particle system
Would result in a crash after 2892b494bd
2025-03-18 19:27:54 +01:00
Bastien Montagne
7bf17d83ab Cleanup: blenfont & blentranslation: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.

This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.

MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.

NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.

Pull Request: https://projects.blender.org/blender/blender/pulls/136126
2025-03-18 18:25:50 +01:00
Harley Acheson
4894c888ee BLF: Configurable Line Breaking Behavior
The PR allows specifying the method of line breaking. Current functions
gain an optional argument that defaults to "Minimal" which breaks as it
does now, only on space and line feed. "Typographical" breaks on
different types of spaces, backslashes, underscore, forward slash if
not following a number, dashes if not following a space, Chinese,
Japanese, and Korean Ideograms, and Tibetan intersyllabic marks. "Path"
breaks on space, underscore, and per-platform path separators. There is
also a "HardLimit" flag that forces breaking at character boundary at
the wrapping limit.

Pull Request: https://projects.blender.org/blender/blender/pulls/135203
2025-03-18 18:02:36 +01:00
Clément Foucault
2892b494bd Cleanup: DRW: Remove some global access to DRWContext
Rel #136090
2025-03-18 17:48:54 +01:00
Clément Foucault
8c7cb9d3c7 Cleanup: DRW: Flatten global access to DRWContext
Rel #136090
2025-03-18 17:28:00 +01:00
Harley Acheson
745509a0ab Fix #136119: Remove Warning Message With Save As
Regular "Save As" does not set "incremental" property, either true or
false, which results in a warning message. This PR just handles the
reading of this optional property properly by checking existence first.

Pull Request: https://projects.blender.org/blender/blender/pulls/136127
2025-03-18 17:23:35 +01:00
Bastien Montagne
9fcec54c93 Cleanup: blenloader: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.

This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.

MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.

NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.

Pull Request: https://projects.blender.org/blender/blender/pulls/136121
2025-03-18 16:14:26 +01:00
Omar Emara
781dea8442 Cleanup: Compositor: Use default case for blur types
Use a default case for blur type switch case, that's because adding all
types is not necessary, and I am trying to differentiate between switch
cases that need full type enumeration and those that do not.
2025-03-18 16:15:27 +02:00
Pratik Borhade
ba2e567efb Grease Pencil: Drawing API functions to assign/remove vertex group data
Currently there is no python api function to assign/remove vertices to specific
vertex group. Traditional `object.vertex_groups[0].add/rna_VertexGroup_vertex_add`
didn't work, because Grease Pencil stores deform verts and vertex group
on individual drawings. Now intorduced a new function
`vertex_group_assign` and `vertex_group_remove` on `Drawing`.

Resolves #135281.
Resolves #134678.

Example (just add GP Suzanne):
```
import bpy

C = bpy.context

drawing = C.active_object.data.layers['Lines'].current_frame().drawing
drawing.vertex_group_assign(vgroup_name="Group", indices_ptr=[2, 6, 10, 18, 19, 20], weight = 0.9)
drawing.vertex_group_remove(vgroup_name="Group", indices_ptr=[2, 6, 10])
```

Pull Request: https://projects.blender.org/blender/blender/pulls/135283
2025-03-18 15:11:09 +01:00
Omar Emara
0a57002469 Cleanup: Compositor: Remove redundant SMAA types
This patch removes code that handles types other than Float and Color,
that's because SMAA is practically only used for those types only.
2025-03-18 15:51:51 +02:00
Omar Emara
383a6ce654 Refactor: Compositor: Formalize single value data update
This patch formalizes the process of data updates of single values.
Previously, this was done internally in the set_single_value method, but
there was a hack in multi-function procedure code to do the same. This
patch adds a new method for single value data updates and uses it
internally in set_single_value.
2025-03-18 15:03:55 +02:00
Bastien Montagne
24e3010e50 Cleanup: freestyle: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.

This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.

MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.

NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.

Pull Request: https://projects.blender.org/blender/blender/pulls/136118
2025-03-18 13:57:00 +01:00
Germano Cavalcante
015b7483e7 Fix #136061: Shear and Edge Slide not displaying custom keys in statusbar
Since 40eadc75be, `ED_workspace_status_text` is now called at the
beginning of the modal function.

This clears any custom keymap and redraws the status bar.

The `Edge Slide` and `Shear` operations only update the status bar if a
modal key is pressed (not on mouse move).

The solution to avoid losing custom modal keys, and not having to
update the status bar more often is: call `ED_workspace_status_text`
only when an operation that requires redraw is performed.

Pull Request: https://projects.blender.org/blender/blender/pulls/136101
2025-03-18 12:46:56 +01:00
Germano Cavalcante
94a8b5f607 Revert "Fix #136061: Modeling: Always update status bar on shear/edge slide."
This reverts commit b02c83386b.

The problem has not been fully resolved (there is a glitch in the
status bar when changing operations).

A newer, even more efficient solution is on the way.
2025-03-18 08:42:10 -03:00
Campbell Barton
3f9c08d960 Docs: add a doc-string for rotation_mode
Based on the report #135332, it's not obvious that rotation modes that
aren't selected aren't used, note this in the doc-string.

Ref !136103
2025-03-18 22:39:30 +11:00
Campbell Barton
5fc3303a35 Fix assert drawing the knife tool points with the Vulkan backend
Using the knife tool with Vulkan failed because using
GPU_PRIM_POINTS isn't supported with the GPU_SHADER_3D_UNIFORM_COLOR
shader.

Resolve using a shader intended for drawing points.

Ref !136109
2025-03-18 22:36:13 +11:00
Campbell Barton
c3320a1082 Fix crash starting with only the Vulkan backend enabled
When built with only the Vulkan back-end this wasn't being checked for
causing Blender to start with no GPU backend which crashed.

Ref !136110
2025-03-18 22:23:15 +11:00
Bastien Montagne
015f8150a2 Cleanup: geometry: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.

This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.

MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.

NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.

Pull Request: https://projects.blender.org/blender/blender/pulls/136116
2025-03-18 11:58:05 +01:00
Jeroen Bakker
4429cc7e84 Fix: Vulkan: Incorrect framebuffer selection
When swap chain is updated the logic could select an incorrect
framebuffer. This isn't actually the case during normal usage, but has
been detected during the development of OpenXR support. Here it did
matter.

Pull Request: https://projects.blender.org/blender/blender/pulls/136115
2025-03-18 11:49:52 +01:00
Omar Emara
ebaa12af6c Refactor: Compositor: Use data sharing for SMAA
Use data sharing instead of copying in the SMAA algorithm. This reduces
redundant copies and code duplication.
2025-03-18 12:38:48 +02:00
Bastien Montagne
9139005e82 Fix building on Clang19 on Linux.
Commit e9a21cf14c seems to have removed a bit too many includes, this
reverts one change, which seems to be enough to get it working again.

Will let @deadpin decide whether we keep this 'include all' header
include here, or go more refined in our includes.
2025-03-18 11:23:39 +01:00
Campbell Barton
b77d77af40 Refactor: add utility object & pchan setters, respecting protected flags
Add "set" functions for location, scale & rotation that leave
protected channels untouched.

Ref !136104
2025-03-18 20:36:57 +11:00
Omar Emara
a345c4597e Refactor: Compositor: Use GPU setter nodes for unlinked sockets
This patch refactors how values of unlinked sockets are provided to
nodes. Previously, the GPU node stack values were initialized at
construction time and linked by the node's compile methods. This meant
that we needed to handle implicit conversion if the socket is linked to
an unlinked node group input.

Alternatively, we now insert a GPU setter node for each unlinked socket
that carries the value and type of the origin socket, and let the GPU
code generator do implicit conversion at the shader level. This has
three advantages:

- It makes it easier to add new types since we no longer have to handle
  those types in shader node code and it reduces code duplication.
- It makes the code more inline with how we implement multi-function
  procedures. So refactoring is easier.
- It opens the door to implement things like implicit inputs, which will
  be needed later for things like texture nodes.
2025-03-18 11:23:43 +02:00
Bastien Montagne
1ff24efa02 Cleanup: ikplugin: Replace 'void' MEM_[cm]allocN with templated, type-safe MEM_[cm]allocN<T>.
The main issue of 'type-less' standard C allocations is that there is no check on
allocated type possible.

This is a serious source of annoyance (and crashes) when making some
low-level structs non-trivial, as tracking down all usages of these
structs in higher-level other structs and their allocation is... really
painful.

MEM_[cm]allocN<T> templates on the other hand do check that the
given type is trivial, at build time (static assert), which makes such issue...
trivial to catch.

NOTE: New code should strive to use MEM_new (i.e. allocation and
construction) as much as possible, even for trivial PoD types.

Pull Request: https://projects.blender.org/blender/blender/pulls/136095
2025-03-18 10:14:53 +01:00