Commit Graph

118369 Commits

Author SHA1 Message Date
Omar Emara
8b418a63c4 Cleanup: Use socket type in single input value operation
This patch uses the socket type as opposed to the result type in the
switch case that initialize the values of the single input value
results, since that makes more sense as we are retrieving the values
from the sockets. This also matches the implementation in pixel
operations.
2025-03-20 12:19:43 +02:00
Omar Emara
776810aec9 Cleanup: Remove outdated comments
Float2 and Int2 are no longer internal types, so removes some outdated
comments in the result types enum.
2025-03-20 12:18:35 +02:00
Omar Emara
38446399f4 Cleanup: Use fixed width integer for int results
We use fixed width integers in the variant definition, so retrieve using
fixed width as well.
2025-03-20 12:16:46 +02:00
Omar Emara
1589b1e444 Compositor: Support all single value types in File Output
This patch adds support for all types of single values for the File
Output node, image types are not yet supported. This involves converting
integer types to float since image saving code does not support integer
images.
2025-03-20 11:06:43 +02:00
Omar Emara
ff4237d713 Compositor: Support Int2 and Float2 types in shader operations
This patch adds support for Int2 and Float2 types in shader operations.
They are already supported for multi-function procedures. They are not
used in practice, but implementing them makes adding new types easier
since we don't have to think about types that are supported and those
that aren't. They are both encoded as vec3 due to limited supported for
those types in the GPUMaterial implementation.
2025-03-20 09:52:54 +02:00
Pratik Borhade
4cd7e335a9 Fix #136156: Grease Pencil: Crash calling active layer operator with out-of-bounds index
Exit early from the operator when `layer_index > total layers`.

Pull Request: https://projects.blender.org/blender/blender/pulls/136172
2025-03-20 08:03:36 +01:00
Campbell Barton
90b6235d1c Cleanup: use common suffix's for operator callbacks 2025-03-20 16:05:34 +11:00
Campbell Barton
0dce94c20b Cleanup: clarify ED_undo_operator_repeat return value
This returned a 0/1 using a function signature typically used for
operator exec. Avoid confusion by returning a bool.
2025-03-20 16:00:51 +11:00
Campbell Barton
e4ca31f6dd Fix: incorrect return flags from Image Copy to Clipboard 2025-03-20 15:19:03 +11:00
Campbell Barton
613623e992 Cleanup: use "exec" suffix for operator execute callbacks 2025-03-20 03:56:25 +00:00
Campbell Barton
b5d0b6cf6b Fix: incorrect return flags for marker box select 2025-03-20 03:56:24 +00:00
Sean Kim
cdfb65a5a8 Fix: Potential stack use after free with Plane brush
The `Plane` brush type calculates its own node mask. The
`IndexMaskMemory` for the corresponding `IndexMask` goes out of scope
inside the inner method, resulting in an ASAN crash. To fix this, use
the `IndexMaskMemory` declared in the larger `do_brush_action` scope and
pass it in by reference to ensure its lifetime lasts appropriately.

Pull Request: https://projects.blender.org/blender/blender/pulls/136209
2025-03-20 03:26:49 +01:00
Nicola
51c8986106 Fix #136204: Inversion strength of Plane brush is weaker than expected
Flatten/Fill/Scrape use a different formula for the strength when
inverted, but for Fill and Scrape this is only applied when Invert to
Fill/Scrape is off.

The equivalent logic for the Plane brush is to lower the inversion
strength only when the inversion mode is set to Invert Displacement.

Fill and Scrape don't need an explicit check in `brush_strength`
because `flip` is set to `1.0` in `brush_flip` when
`BRUSH_INVERT_TO_SCRAPE_FILL` is on.

Pull Request: https://projects.blender.org/blender/blender/pulls/136211
2025-03-20 03:03:27 +01:00
Campbell Barton
4c88c929c6 Fix: invalid return value from sequencer "Add Speed Transition" operator 2025-03-20 12:59:42 +11:00
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