Commit Graph

113834 Commits

Author SHA1 Message Date
Bastien Montagne
48e26c3afe MEM_guardedalloc: Refactor to add more type-safety.
The main goal of these changes are to improve static (i.e. build-time)
checks on whether a given data can be allocated and freed with `malloc`
and `free` (C-style), or requires proper C++-style construction and
destruction (`new` and `delete`).

* Add new `MEM_malloc_arrayN_aligned` API.
* Make `MEM_freeN` a template function in C++, which does static assert on
  type triviality.
* Add `MEM_SAFE_DELETE`, similar to `MEM_SAFE_FREE` but calling
  `MEM_delete`.

The changes to `MEM_freeN` was painful and useful, as it allowed to fix a bunch
of invalid calls in existing codebase already.

It also highlighted a fair amount of places where it is called to free incomplete
type pointers, which is likely a sign of badly designed code (there should
rather be an API to destroy and free these data then, if the data type is not fully
publicly exposed). For now, these are 'worked around' by explicitly casting the
freed pointers to `void *` in these cases - which also makes them easy to search for.
Some of these will be addressed separately (see blender/blender!134765).

Finally, MSVC seems to consider structs defining new/delete operators (e.g. by
using the `MEM_CXX_CLASS_ALLOC_FUNCS` macro) as non-trivial. This does not
seem to follow the definition of type triviality, so for now static type checking in
`MEM_freeN` has been disabled for Windows. We'll likely have to do the same
with type-safe `MEM_[cm]allocN` API being worked on in blender/blender!134771

Based on ideas from Brecht in blender/blender!134452

Pull Request: https://projects.blender.org/blender/blender/pulls/134463
2025-02-20 10:37:10 +01:00
Dalai Felinto
6be8dd16e7 Fix (experimental) Point Cloud properties editor not showing
This was introduced on: 1584cd9aa5.
2025-02-20 09:32:21 +01:00
Omar Emara
263d9b9ccc Merge branch 'blender-v4.4-release' 2025-02-20 08:30:51 +02:00
Omar Emara
f0e92c695d Fix: File Output node crash when saving vector image
The File Output node crashes when saving a 16-bit vector image in an
RGBA image. That's because the OIIO writer assumes 4-channel buffer
while the buffer provided by the node is only 3-channel. To fix this,
the OIIO writer is extended to support all possible combination of
source and target channels.

Pull Request: https://projects.blender.org/blender/blender/pulls/134789
2025-02-20 07:29:34 +01:00
Sean Kim
0dd326592a Undo: Add explicit filtering for IDs and RNA structs marked as skippable
In the past, around the time that 2.80 was released, 4a08b974f4
introduced the idea of filtering out certain editor changes inside
the paint modes and edit mode (e.g. changing brush sizes in the editor).

This commit is the first in a series to attempt to refine this behavior
so that only certain editor settings are filtered out from the undo
stack.

In total, it does the following:
* Adds the Brush datablock to the list of IDs that do not have undo
  pushes.
* Adds support to filter out RNA structs that do not have the
  `STRUCT_UNDO` property applied (currently, just the 3D Cursor).

This has the following effects:
* Changing brush settings inside the Image Editor no longer causes
  undo pushes, becoming consistent with the other paint modes.
* Changing brush settings while in object mode in the outliner data
  block view no longer causes undo pushes.

Co-authored-by: Campbell Barton <campbell@blender.org>
2025-02-20 07:12:56 +01:00
Campbell Barton
3f6a152bf0 Cleanup: avoid redundant file-type flag calculation 2025-02-20 16:38:59 +11:00
Harley Acheson
80ae7ab04f Merge branch 'blender-v4.4-release' 2025-02-19 17:06:17 -08:00
Harley Acheson
81262b9421 Fix #134491: Adjust Text Input Offset When Deleting Selection
When a text string is longer than the available space it can be at a
scrolled offset, so that you can edit text that is wider than its
container. When selected text is deleted we don't update this offset,
so it is possible to have newly pasted text scrolled out of view. This
PR decreases the offset by the amount of the selected string that is
currently out of view.

Pull Request: https://projects.blender.org/blender/blender/pulls/134815
2025-02-20 02:05:03 +01:00
Jesse Yurkovich
c5b34ff17f Cleanup: IO: Use recently added radius accessors for USD and Alembic IO
Use recently added `radius` accessors for USD and Alembic PointClouds
and Curves.

Pull Request: https://projects.blender.org/blender/blender/pulls/134704
2025-02-20 00:23:25 +01:00
Jesse Yurkovich
de5c38e969 Merge branch 'blender-v4.4-release' 2025-02-19 14:09:48 -08:00
Jesse Yurkovich
1ef3808030 Fix: Incorrect radius values used for Alembic points and USD nurbs
These were reading in "widths" and not adjusting the values when setting
Blender's "radius" properties.

Found while cleaning up the radius API usage as part of another change.

Pull Request: https://projects.blender.org/blender/blender/pulls/134709
2025-02-19 23:09:03 +01:00
Jacques Lucke
dd28661bea Refactor: BLI: extract function to convert bytes to bits
Right now this code is only used to convert boolean arrays to bits (e.g. for
faster `IndexMask` generation). This patch extracts a more general function that
converts bytes to bits using a rule that is passed in as parameter. This may
become useful to speedup parsing e.g. CSV files to speedup detection of
delimiters and other special byte values.

This code is already covered by unit tests, so no new tests have been added.

Pull Request: https://projects.blender.org/blender/blender/pulls/134798
2025-02-19 22:52:55 +01:00
Jörg Müller
9301a0e159 Compile fix: include limits.h for INT_MIN/MAX.
Pull Request: https://projects.blender.org/blender/blender/pulls/134697
2025-02-19 22:51:07 +01:00
Sean Kim
188811feb4 Merge branch 'blender-v4.4-release' 2025-02-19 13:08:17 -08:00
Sean Kim
0acd86abca Fix: Vertex Paint average brush produces incorrect results
This commit moves the initialization of the node-sized accumulation
array out of the parallel loop to avoid odd optimization errors when
differing between debug and release builds as well as errors due to
integer overflow in both builds.

Additionally it only accumulates results from affected nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/134720
2025-02-19 22:07:34 +01:00
Sean Kim
b128f5b0d6 Merge branch 'blender-v4.4-release' 2025-02-19 13:06:16 -08:00
Sean Kim
f3377aa7e8 Fix: Set Persistent Base doesn't work for cloth brushes
The `init_positions` variable that the `ss.sculpt_persistent_co` member
gets set to was not passed into the corresponding calculation function,
resulting in a no-op.

Pull Request: https://projects.blender.org/blender/blender/pulls/134781
2025-02-19 22:05:37 +01:00
Sean Kim
875f9abe9d Merge branch 'blender-v4.4-release' 2025-02-19 13:04:40 -08:00
Sean Kim
f1fca48a4f Fix #134292: Clone brush cannot access local blendfile images
With the brush assets project, brushes were moved from being local to
the working blendfile to being linked from asset libraries. This breaks
the Image Paint 'Clone' brush, as it has a brush property that links to
other Image datablocks.

To support this functionality, this commit adds the corresponding
properties into the `ImagePaintSettings` struct so that it is stored
locally with the images that will be used by the tool, inside the main
blendfile.

The source image property is shared with the 3D version of the 'Clone'
brush instead of adding a separate field to preserve old behavior.

Notably, this has the following limitations:
* If clone brush assets have been made and shared with external packs,
  they would not work out of the box with linked image assets.
* Despite these settings being stored on the scene, they are populated
  inside the tool window under "Brush Settings" which is potentially
  misleading. However, this is already the case for the 3D version of
  the brush, so further UI refinement will happen outside of this PR.
* Users will be unable to use separate images simultaneously for the
  Image editor and the 3D viewport, unlike in pre-4.3 versions. This
  can be adjusted in the future if it is a critical workflow.

Because the intended design and functionality of this tool is currently
questionable, this commit opts to make these changes instead of doing
further design to support both accessing data on the brush and on the
scene.

Pull Request: https://projects.blender.org/blender/blender/pulls/134474
2025-02-19 22:00:39 +01:00
Sean Kim
5cce8cc073 Merge branch 'blender-v4.4-release' 2025-02-19 12:59:30 -08:00
Sean Kim
af8da338a0 Fix #134770: Multires persistent base doesn't work randomly
The previous attempt to restore this behavior was in
0a2d5d5801

That commit introduced clearing the related `SculptSession` variables
when the paint BVH was freed to avoid bad behaviors seen in 4.2 and
prior. However, this solution is somewhat incorrect, as the prior state
of this data is not necessarily restored when the BVH is recreated,
unlike other temporary mapping data.

This results in the persistent base data being cleared occasionally with
no indication to the user that this is happening, causing the setting to
appear to be inactive.

To fix this, this commit makes a few changes:
* Removes clearing this data in the `BKE_sculptsession_free_pbvh`
  function.
* Initializes the displacement arrays to the same size as the position
  and normal array.
* Introduce new variables to track the saved multires grid size so
  that it is not deleted, only considered invalid when the topology
  changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/134780
2025-02-19 21:58:49 +01:00
Julian Eisel
05c6446c38 Fix #128966: Update Dopesheet playhead in separate window
The playhead is redrawn as an overlay, so instead of a full region
redraw using `ARegionType.draw()`, at least an overlay only redraw using
`ARegion.draw_overlay()` needs to be triggered.

Any redrawing within a window is skipped if neither the screen, nor any
of its areas or regions are tagged for redraw. So since there are no
other areas or regions to be fully redrawn in this window, no redrawing
will happen. The screen needs to be tagged for redraw, which will skip
most drawing in this case, and just draw the overlays as wanted.

Pull Request: https://projects.blender.org/blender/blender/pulls/134579
2025-02-19 21:53:15 +01:00
Harley Acheson
2e90aace03 Fix #134796: Adjust Error Theme Color for Widget Text
When using the Error theme color for widget text color, this has to be
altered to provide sufficient contrast with other content.  This was
done with label text color, before recent changes to make these colors
themeable, by blending with text color. This PR makes similar changes
and gives similar results.

Pull Request: https://projects.blender.org/blender/blender/pulls/134807
2025-02-19 20:24:33 +01:00
Harley Acheson
9a36b800eb Merge branch 'blender-v4.4-release' 2025-02-19 11:04:59 -08:00
Harley Acheson
0425940794 Fix #134630: Do Not Set Area Subtype For Previously Stored Editors
When changing editors within an area we are currently always setting
the subtype if there are modes. This causes problems when returning to
a previous editor versus starting with the correct one. We have tried
various ways of returning to the old editor, but never quite works.
This PR only sets the subtype if we are creating a new area. If not
just leave it as it was so we naturally return to its old state.

Pull Request: https://projects.blender.org/blender/blender/pulls/134642
2025-02-19 20:03:55 +01:00
Harley Acheson
9c374fbb93 UI: Skip Internal Operators For Idle Status Bar
During idle time, just moving your mouse into an editor, the Status Bar
only shows operations attached to mouse events. Hovering into
Properties shows an item on the left mouse called "Set Active
Modifier". This is always shown because it is an internal operator
always running in that area. This PR just skips OPTYPE_INTERNAL
operators for this idle display.

Pull Request: https://projects.blender.org/blender/blender/pulls/134782
2025-02-19 19:25:14 +01:00
Clément Foucault
f8195e0bb4 Fix: Overlay: Broken shader compilation
Caused by the changes in UBO members.
This removes the duplicated lib used by overlay
and reuse the same side clip plane UBO mechanism
as workbench.
2025-02-19 17:46:47 +01:00
Dalai Felinto
9d06f32761 Point Cloud: Select Random
Move the mask_random function to BLI_index_mask.hh, so it can be shared between curves, grease pencil and point cloud.

Copied/inspired by the curves select code.

Pull Request: https://projects.blender.org/blender/blender/pulls/134624
2025-02-19 17:23:37 +01:00
Dalai Felinto
1584cd9aa5 Cleanup: Rename point cloud to pointcloud / POINT_CLOUD to POINTCLOUD
Though "Point Cloud" written as two words is technically correct and should be used in the UI, as one word it's typically easier to write and parse when reading. We had a mix of both before this patch, so better to unify this as well.

This commit also renames the editor/intern/ files to remove pointcloud_ prefix.
point_cloud was only preserved on the user facing strings:

* is_type_point_cloud
* use_new_point_cloud_type

Pull Request: https://projects.blender.org/blender/blender/pulls/134803
2025-02-19 17:11:08 +01:00
Jacques Lucke
234810f01d Fix: Geometry Nodes: support relative paths in import nodes
Previously, the code would assert in `BLI_fopen` when the path is relative.

There are two main options to make the path absolute:
1. Always use the path of the current .blend file as base.
2. Is the path of the .blend file "owns" the current node as base. So when
  the Import node is part of a linked node tree, the path of the linked .blend
  file is used as base.

Both options are useful depending on the specific use-case, but the latter
seems more consistent with other places in Blender. For more advanced
functionality, we might need nodes that give the current .blend file path
and one node to join paths.

Pull Request: https://projects.blender.org/blender/blender/pulls/134794
2025-02-19 15:33:37 +01:00
Hans Goudey
0fd79c3613 Point Cloud: Implement join operator
Similar to !134691.

Pull Request: https://projects.blender.org/blender/blender/pulls/134702
2025-02-19 15:30:12 +01:00
Hans Goudey
5a6d2e1ce2 Curves: Implement join operator
Previously the object join operator wasn't implemented for the new
curves type. This commit implements the joining by passing the selected
curves geometry as instances to the realize instances function. That way
the complexity of the new code just relates to dealing with objects.

Pull Request: https://projects.blender.org/blender/blender/pulls/134691
2025-02-19 15:24:29 +01:00
Hans Goudey
2f01da564d Fix: Point Cloud: Properly handle caches in undo step decode
Previously the bounds and BVH caches could be incorrect after redo.
2025-02-19 09:14:33 -05:00
Hans Goudey
cc2d85ae7c Point Cloud: Support view selected operator in edit mode 2025-02-19 09:14:33 -05:00
Philipp Oeser
7847df4686 Pointcloud: Integration with transverts (cursor snapping)
This adds:
- support for snapping for the pointcloud object (selection to cursor/
grid, cursor to selection)
- as usual, "Warp" an "Randomize" operators come along "for free" with
this

Pull Request: https://projects.blender.org/blender/blender/pulls/134799
2025-02-19 15:06:06 +01:00
Philipp Oeser
57ed1e9632 Merge branch 'blender-v4.4-release' 2025-02-19 14:28:38 +01:00
Philipp Oeser
3dc9211b8f Fix #134662: Video Sequencer: reset transforms ignores auto keyframing
Just call the appropriate autokeyframe functions when this operator
changes StripTransform properties.

Pull Request: https://projects.blender.org/blender/blender/pulls/134667
2025-02-19 14:28:14 +01:00
Omar Emara
6946108678 Merge branch 'blender-v4.4-release' 2025-02-19 15:07:23 +02:00
Omar Emara
d5c662a305 Fix #134436: Compositor is much slower on Windows
The new CPU compositor in v4.4 is much slower than the old CPU
compositor in v4.3 on Windows. This is because MSVC does not inline many
of the core methods in the Result class of the compositor. To fix this,
we force inline those methods, adding a new macro for inlining methods
in the process, since the existing macro has the static keyword, which
only works for functions, not methods.

Pull Request: https://projects.blender.org/blender/blender/pulls/134748
2025-02-19 13:56:06 +01:00
илья _
119fc054f8 Cleanup: BKE: Nodes: Pass-by-reference
Restriction of the nodes api to clearly define never-null function arguments.
Side effects: some assertions and null-check (with early return) were removed.
On the caller side is ensured to never derefer null to pass argument (mainly in RNA).
In addition, one pointer argument now actually a return type.

By-reference return types instead of pointers going to be separate kind of
change since also imply of cleaning up variables created from reference.

Also good future improvement would be to mark a copy-constructor as
explicit for DNA node types.

Pull Request: https://projects.blender.org/blender/blender/pulls/134627
2025-02-19 13:44:11 +01:00
Jacques Lucke
3263dd6333 Fix: Geometry Nodes: unescape column names after csv import 2025-02-19 12:36:19 +01:00
Brecht Van Lommel
e166c25c0b Merge branch 'blender-v4.4-release' 2025-02-19 11:47:19 +01:00
Brecht Van Lommel
3004848372 Fix #134756: Internal text datablock filepath considered missing
When the text datablock was marked as external at one point and the
filepath was allocated, it would be considered missing.
2025-02-19 11:26:57 +01:00
Jacques Lucke
ac2cd6c1ef Geometry Nodes: make CSV parser more reliable and faster
This reimplements the CSV parser used by the (still experimental) Import CSV
node.

Reliability is improved by:
* Properly handling quoted fields.
* Unit tests.
* Generalizing the parser to be able to handle customized delimiter, quote and
  escape characters (those are not exposed in the node yet though).
* More accurate detection of column types by actually taking all values of a
  column into account instead of only the first row.

Performance is improved by designing the parser in a way that supports
multi-threaded parsing. I'm measuring about 5x performance improvement which
mainly comes from multi-threading. Some files I wanted to use for benchmarking
didn't load in the version that's in `main` but do load fine with this new
version.

The implementation is now split up into two parts:
1. A general CSV parser in `blenlib` that manages splitting a buffer into
   records and their fields.
2. Application specific parsing of fields into e.g. floats and integers which
   remains in `io/csv/importer`.

This separation simplifies unit testing and makes the core code more reusable.

Pull Request: https://projects.blender.org/blender/blender/pulls/134715
2025-02-19 11:10:59 +01:00
Bastien Montagne
4ec5d600cd Refactor: Core: Make BKE_libblock_alloc_notest return ID pointer. 2025-02-19 10:55:05 +01:00
Campbell Barton
8cad69a138 Merge branch 'blender-v4.4-release' 2025-02-19 11:51:46 +11:00
Campbell Barton
efe02a9943 Cleanup: function argument flags for UIList.draw_item
Correct two mistakes in [0] which accidentally assigned
flags to the previously declared parameter as well as assigning an
argument to `prop`, then setting the flags on `parm`.

While it seems that "active_property" only became optional by accident
leave this as-is to avoid breaking scripts.

[0]: 113997a03c

Ref #134379.
2025-02-19 11:47:44 +11:00
Campbell Barton
e1a4269ee1 Merge branch 'blender-v4.4-release' 2025-02-19 11:14:13 +11:00
Harley Acheson
e850a09762 UI: Add Icons to Represent Error Conditions
This PR adds three SVG Icons. One to represent that an icon is not
found - ICON_NOT_FOUND - so represent when an out-of-range value was
used to specify an icon. The second - ICON_CHAR_NOTDEF - is to
represent that a text character is not found in the specified font or
font stack. The third - ICON_CHAR_REPLACEMENT - is to indicate the
portion of a text string that contains invalid bytes.

Pull Request: https://projects.blender.org/blender/blender/pulls/134008
2025-02-19 01:11:24 +01:00
Campbell Barton
9e0c8a41cd Object Mode: conversion no longer depends on the active object
Conversion was only possible if the active object was editable &
selected, this complicated overriding the operator from Python
since it wasn't enough to override the selection & active-object.

Now it's possible to use bpy.ops.object.convert() from Python
overriding the selected_editable_objects only.

For users the difference isn't so significant:

- Having an active object is no longer required.

- It's possible there are no objects to operate on,
  as previously the active object was used to check at least one
  object could be converted, although this check wasn't fool-proof
  as it didn't check the objects data-type.

Resolves #100664.

Ref !134728.
2025-02-19 11:06:31 +11:00