3999 Commits

Author SHA1 Message Date
Aras Pranckevicius
facb17b0e3 Cleanup: BLI ENUM_OPERATORS cleanup/robustness
BLI code for enums that are meant to be used as "bit flags" defined
an ENUM_OPERATORS macro in BLI_utildefines.h. This cleans up things
related to said macro:

- Move it out into a separate BLI_enum_flags.hh header, instead of
  "random bag of things" that is the current place,
- Update it to no longer need manual indication of highest individual
  bit value. This originally was added in a31a87f89 (2020 Oct), in
  order to silence some UBSan warnings that were coming
  from GPU related structures (looking at current GPU code, I don't
  think this is happening anymore). However, that caused actual
  user-visible bugs due to incorrectly specified max. enum bit value,
  and today 14% of all usages have incorrect highest individual
  bit value spelled out.
    - I have reviewed all usages of operator ~ and none of them are
      used for directly producing a DNA-serialized value; all the
      usages are for masking out other bits for which the new ~
      behavior that just flips all bits is fine.
- Make the macro define flag_is_set() function to ease check of bits
  that are set in C++ enum class cases; update existing cases to use
  that instead of three other ways that were used.

Pull Request: https://projects.blender.org/blender/blender/pulls/148230
2025-10-17 12:57:50 +02:00
Jacques Lucke
6521b448c3 Merge branch 'blender-v5.0-release' 2025-10-16 17:17:49 +02:00
Jacques Lucke
7ed85bfe17 Fix #148032: vertex/weight paint undo broken
The issue was that the data-blocks of two different undo steps were detected to
be identical, even if the attributes changed. That's because even if the
implicitly-shared data was different, they were turned into the same pointer by
cadb3fe5c5 on write.

This patch makes it so that for undo steps, implicitly shared data does not use
the pointer stability feature (in a sense, implicit-sharing itself provides
pointer stability for undo steps already).

The main tricky aspect is that we need to know if a pointer is implicitly shared
in `writestruct_at_address_nr` and oftentimes that's called before the
corresponding shared data is actually written with `BLO_write_shared`. The
solution is to enforce that the blend-write code has to know what pointers are
implicitly-shared before they are written the first time. The simplest way to
ensure that is to call `BLO_write_shared` first. However, that's not always
possible, especially when the pointer is directly embedded in an ID. Therefore,
there is a new `BLO_write_shared_tag` function that can be used in such cases.

The undo performance for the file in #141262 is still fixed with this change.

Pull Request: https://projects.blender.org/blender/blender/pulls/148144
2025-10-16 17:16:05 +02:00
Jacques Lucke
51fbcd84ce Merge branch 'blender-v5.0-release' 2025-10-13 18:25:36 +02:00
Jacques Lucke
d690ffd44f Fix #146949: Geometry Nodes: cache usage inference on modifier
This speeds up drawing of the UI of the Geometry Nodes modifier, especially for
very large node trees like in the files from #146949.

A couple previous commits and #147883 speed up the inferencing significantly
already. However, there is a certain limit to how fast this can be on large
complex node trees. While there is some more optimization potential, this patch
implements a cache on the Geometry Nodes modifier level. This means that as long
as the inputs and the node tree stays the same, the inferencing only has to
happen once, instead of on every redraw.

The main difficulty with this cache is that we don't have a good way to
invalidate it eagerly when any of the modifier inputs changes. That can
hopefully become simpler with #138117. For now, we have to check all input
values on redraw to check if anything has changed compared to the last redraw
and recompute the cache if there is any change.

Pull Request: https://projects.blender.org/blender/blender/pulls/147930
2025-10-13 18:23:50 +02:00
Hans Goudey
1d372bdc8b Refactor: Split CustomData attribute and newer attribute headers
Avoid including DNA_customdata_types.h everywhere we include the
attributes header. Over time the older attribute header should be
used less and less.

Part of #122398

Pull Request: https://projects.blender.org/blender/blender/pulls/147980
2025-10-13 15:38:26 +02:00
Sean Kim
f8c29f98c2 Cleanup: Add const to function parameters
Pull Request: https://projects.blender.org/blender/blender/pulls/147493
2025-10-09 21:15:01 +02:00
Sean Kim
167c1f0d40 Cleanup: Use C++ style casts 2025-10-09 21:14:58 +02:00
Hans Goudey
5a8d2b6624 Fix #147710: Crash binding Surface Deform modifier to faceless mesh
- Add an explicit check with a better error message than "Out of memory"
- Initialize SDefVert so the later null checks don't try to free
  uninitialized data.

Pull Request: https://projects.blender.org/blender/blender/pulls/147723
2025-10-09 16:49:42 +02:00
Damien Picard
3eb03e56b2 I18n: Translate labels using layout->prop, ->prop_search & ->op
These types of buttons do not automatically extract and translate the
label when specified specifically. This commit adds the missing
translation macros.

Some issues reported by Alexandr Fatih.
2025-10-09 12:09:03 +02:00
Christoph Lendenfeld
a09d0cfd8c Anim: Move pose bone selection state to bPoseChannel
Move the selection flag for pose bones, from the (edit)bone to the
pose bone.

Previously having multiple instances of armatures in pose mode at the
same time caused issues because selecting a pose bone on one armature
would automatically select it on all instances of it.

This is now fixed since the selection state is stored on the pose bone
(Object level) Doing so breaks API compatibility with 4.5 since the
RNA property on the Bone no longer affects the pose bone. Instead,
there is a new property on the pose bone for that.

Due to this change, some runtime flags for the transform system also
had to be moved to the pose bone. This is due to the fact that these
flags are used by the transform system to pass information between
functions. If we keep the flag at the bone level, this wouldn't work
with armature instances. See `bPoseChannelRuntimeFlag`

Fixes #117892

Pull Request: https://projects.blender.org/blender/blender/pulls/146102
2025-10-07 19:59:36 +02:00
Campbell Barton
62d72bd0b5 UV: initial implementation of UV sync select
Support sync selection in the UV editor, with face-corner selection,
so it's possible to select individual UV vertices/edges in the UV editor
without UV's attached to the same underlying edge also becoming selected.

There is limited support for maintaining the UV selection when selecting
from the 3D viewport, common operations such as picking &
box/circle/lasso select support this, however other selection operations
such as "Select Random" or "Select Similar" will clear this data,
causing all UV's connected to selected mesh elements to become selected.
We may add support for additional operators as needed.

Details:

- UV Sync Selection is now enabled by default.
- In edit-mode the UV selection is stored in BMLoop/BMFace which are
  written to custom-data layers when converted to a Mesh.
- To avoid unnecessary overhead - this data is created on demand.
  Operators may clear this data - selecting all or none do so,
  as there is no reason to store this data for a uniform selection.
- The Python API includes functions to synchronize the selection to/from
  UV's as well as flushing based on the mode.
- Python scripts that manipulate the selection will either need to clear
  this synchronized state or maintain it.

See:
- Design task: #78393.
- Implementation task: #131642.

Ref !138197
2025-10-07 01:41:16 +00:00
Hans Goudey
d3278249a8 Geometry Nodes: Volume grid Prune and Voxelize nodes
Add two common building blocks for volume-grid workflows.

- **Voxelize** turns all active tiles into fully dense voxels. For fog
  volumes, this will mean the "inside" sparse tiles will become
  individually adjustable voxel values.
- **Prune** is the opposite action as voxelize. It can be important for
  certain workflows when large regions of constant values are created.
  The node can collapsed those regions into more efficient tiles or
  inner nodes. There are a few modes which are each useful for
  different use cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/147148
2025-10-02 20:53:42 +02:00
Casey Bianco-Davis
032e983a8b Fix #130201: Grease Pencil Build modifier don't work on premade objects
This PR makes it so that when the `delta_time` attribute does not exist
or is equal to zero, the Grease Pencil Strokes will default to one
second to be drawn.
This feature existed in the legacy modifier but was not implemented in
GPv3.

Pull Request: https://projects.blender.org/blender/blender/pulls/146950
2025-10-02 19:39:19 +02:00
Hans Goudey
a68d39e9d9 Cleanup: Formatting
Run `make format` after the library update in the previous commit.
2025-10-02 12:55:42 -04:00
Jacques Lucke
9d20c8d3c8 Spreadsheet: show volume grid stats
This adds support for showing various stats of volume grids in the spreadsheet:
* Extent: Number of voxels in each direction of the bounding box of the grid.
* Voxels: Total number of active voxels in the grid. This includes all voxels
  which are stored in tiles (e.g. one leaf tile contains 512 voxels).
* Leaf Voxels: Number of active voxels stored in leaf nodes. This does not
  contain any voxels that are part of tiles.
* Tiles: Number of active tiles in the grid.
* Size: Estimated size of the volume grid in memory.

All these stats are cached on the volume grid now. A new `tag_tree_changed`
method has been added to invalidate the cache. Computing these stats is not
cheap (but not more than a few ms even for large grids). That mainly means that
we can't do it for socket inspection because that would cause too much overhead.
However, doing it just for the grids that are currently visible in the
spreadsheet seems fine and useful.

This also adds some general improvements to the spreadsheet:
* Support `int64_t` and `int3` columns.
* Draw ints with thousand separators.
* Support showing ints as number of bytes such as `23 MB`.

Pull Request: https://projects.blender.org/blender/blender/pulls/147191
2025-10-02 13:50:25 +02:00
Campbell Barton
b78c5fadf3 Cleanup: various non functional changes for C++ 2025-10-01 23:22:44 +00:00
Sean Kim
0f3c6da272 UI: Add preset curve buttons for curve mapping template
To support setting the custom `CurveMapping` to a well defined preset,
there exist a number of operators that are hardcoded to apply a
particular preset to a particular curve.

This commit begins to replace this functionality and make it part of the
template itself, allowing the preset to be applied to any curve. For
now, it only supports either positive or negative slopes, primarily for
the brush usecases.

The `brush.curve_preset` and `brush.sculpt_curves_falloff_preset`
operators are unneeded after this change and have been removed.

Notably, these preset controls have not been added elsewhere, they can
be added on a case by case basis in future commits by interested
modules.

Pull Request: https://projects.blender.org/blender/blender/pulls/146847
2025-09-29 20:11:29 +02:00
Brecht Van Lommel
689f182792 Cycles: Make adaptive subdivision a non-experimental feature
* Add adaptive subdivision properties natively on the subdivision surface
  modifier, so that other engines may reuse them in the future. This also
  resolve issues where they would not get copied properly.
* Remove "Feature Set" option in the render properties, this was the last
  experimental one.
* Add space choice between "Pixel" and "Object". The latter is new and can
  be used for object space dicing that works with instances. Instead of
  a pixel size an object space edge length is specified.
* Add object space subdivision test.

Ref #53901

Pull Request: https://projects.blender.org/blender/blender/pulls/146723
2025-09-25 16:18:50 +02:00
Hans Goudey
fc4fc2d16c Geometry Nodes: Make displaying "Manage" panel optional
Often displaying the "Manage" panel is not very useful, or at least it
isn't worth taking up the screen real-estate. This commit adds an option
for showing the panel in the modifier, and adds an option to the node
group which is used to initialize the modifier option when creating a
modifier for a node group asset.

Pull Request: https://projects.blender.org/blender/blender/pulls/146775
2025-09-25 16:00:07 +02:00
Campbell Barton
2f3e6e69df Cleanup: rename BM_mesh_{validate=>is_valid}
The term validate is often used to make the data valid
(e.g. BKE_mesh_validate) where is this only checks the mesh is valid.
2025-09-25 11:22:23 +10:00
Jesse Yurkovich
858254aca4 Cleanup: Unused variable when WITH_ALEMBIC is off
Pull Request: https://projects.blender.org/blender/blender/pulls/146389
2025-09-17 01:41:00 +02:00
Jacques Lucke
ad27211b77 Refactor: Geometry Nodes: use faster IDProperty group lookup instead of custom VectorSet
Geometry Nodes used a `PropertiesVectorSet` in some places to allow
constant-time `IDProperty` access by name in a group. This used to be a
bottleneck in node groups with hundreds of inputs. Now this separate hash table
is not necessary anymore, because it's `IDProperty` groups now support this
directly since 6cb2226f13.

This also adds a `IDP_GetPropertyFromGroup_null` utility function to be able to
do this refactor more safely. Null pointers were allowed before.

Pull Request: https://projects.blender.org/blender/blender/pulls/146152
2025-09-12 15:43:14 +02:00
Campbell Barton
1f80345242 Cleanup: quiet some array-bounds warnings with GCC 15
Warnings remain but suppression is not as simple, see: !146150.
2025-09-12 21:48:43 +10:00
Campbell Barton
84511b8509 Core: add type checks to ID property accessors
Since moving the C++ ID property access macros cast "const" away,
replace with get/set accessors and add asserts that correct types
are used.
2025-09-12 06:29:42 +00:00
Hans Goudey
a08cd68f1e Modifiers: Use implicit sharing for some bind data
Addresses #145680.

In one (relatively extreme) test file with the surface deform modifier,
memory usage goes from 14 GB to 4 GB, and an annoying freeze
from preparing an undo step after every operation is gone.

Pull Request: https://projects.blender.org/blender/blender/pulls/145705
2025-09-11 20:00:01 +02:00
Brecht Van Lommel
1439b11de9 Fix: Build error in lite build without USD and Alembic 2025-09-10 19:37:30 +02:00
Brecht Van Lommel
6d25aad41f Cycles: Remove Alembic procedural
This was added for a fairly specialezed use case and is no longer being used
as far as we know. A future replacement would be to add a USD/Hydra procedural,
for which most of the groundwork already exists.

Pull Request: https://projects.blender.org/blender/blender/pulls/146021
2025-09-10 16:39:01 +02:00
Campbell Barton
3c7f4edd92 Cleanup: spelling in comments & string
Also back-tick quote literals in CMakeLists files.
2025-09-06 09:27:54 +10:00
Brecht Van Lommel
a4e9e4869d Refactor: Add foreach_working_space_color to ID type
Left for future work:
* Freestyle modifiers, dynamic paint, legacy texture mapping
* Editor colors: should be changed to sRGB?
* Studio light preferences: also sRGB, though less clear

Pull Request: https://projects.blender.org/blender/blender/pulls/145476
2025-09-05 19:03:32 +02:00
Brecht Van Lommel
ffa4f8c7ad Refactor: Split off lighter BLI_color_types.hh from BLI_color.hh
Functions for convert between the color types and ostream support are
now outside the classes.

Many files were changed to fix cases where direct includes for headers
were missing.

Pull Request: https://projects.blender.org/blender/blender/pulls/145756
2025-09-05 11:11:32 +02:00
YimingWu
02737c7b93 LineArt: Allow curves objects to be loaded into calculation
When line art is first developed, curves objects does not exist yet, now
it is added to line art so it will be read and take part in feature line
generation and occlusion tests.

This patch also adds "Line Art" panel for curves object, just like other
objects supported by line art.

Pull Request: https://projects.blender.org/blender/blender/pulls/145296
2025-08-28 17:28:47 +02:00
Hans Goudey
18fc19b4fe Cleanup: Rename "mloopuv" to "uv_map"
The old name refers to the `MLoopUV` struct which isn't use anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/145251
2025-08-27 17:44:08 +02:00
Sean Kim
fee064e524 Multires: Add 'Conform Base' functionality
This commit modifies the `OBJECT_OT_multires_base_apply` operator to
take in a new parameter which determines whether the final heuristic of
adjusting for a subdivision surface modifier applies.

Resolves #124553

Pull Request: https://projects.blender.org/blender/blender/pulls/145055
2025-08-27 01:39:23 +02:00
Hans Goudey
715cff1299 Cleanup: Use attribute API in weighted normal modifier
Use the attribute API instead of CustomData to access
the face strength integer attribute.

Ref #122398

Pull Request: https://projects.blender.org/blender/blender/pulls/145205
2025-08-27 00:57:33 +02:00
Hans Goudey
dce7626b6b Cleanup: Remove unused CustomData interpolation "subweights" argument
This argument is always passed as null. Removing it simplifies the
transition to `AttributeStorage`. Nowadays it seems that most more
complicated interpolation needs are not handled directly by the
CustomData system.

Pull Request: https://projects.blender.org/blender/blender/pulls/145197
2025-08-27 00:02:20 +02:00
Sergey Sharybin
e0154de320 Rework Bake from Multires
The main idea is to switch Bake from Multires from legacy DerivedMesh
to Subdiv. On the development side of things this change removes a lot
of code, also making it easier easier to rework CustomData and related
topics, without being pulled down by the DerivedMesh.

On the user level switch to Subdiv means:

- Much more closer handling of the multi-resolution data: the derived
  mesh code was close, but not exactly the same when it comes to the
  final look of mesh.

  Other than less obvious cases (like old DerivedMesh approach doing
  recursive subdivision instead of pushing subdivided vertices on the
  limit surface) there are more obvious ones like difference in edge
  creases, and non-supported vertex creases by the DerivedMesh.

- UV interpolation is done correctly now when baking to non-base level
  (baking to multi-resolution level >= 1).

  Previously in this case the old derived mesh interpolation was used
  to interpolate face-varying data, which gives different results from
  the OpenSubdiv interpolation.

- Ngon faces are properly supported now.

A possible remaining issue is the fact that getting normal from CCG
always uses smooth interpolation. Based on the code it always has been
the case, so while it is something to look into it might be considered
a separate topic to dig into.
2025-08-22 17:59:27 +02:00
Casey Bianco-Davis
18da9cc777 Fix #142644: Grease Pencil: Subdivide Modifier not smoothing first point when cyclical
The problem was that the `Subdivide Modifier` would not apply catmull clark
smoothing to the first and last points when a curve was cyclical.

This also fixes a mistake were the smoothing would read from the same data
as writing, leading to the shape to be skewed.

Pull Request: https://projects.blender.org/blender/blender/pulls/144529
2025-08-15 12:19:41 +02:00
Jesse Yurkovich
0240a1f32f Cleanup: CMake: Modernize bf_intern_openvdb dependencies
This follows the other CMake "modernization" commits, this time for
`bf_intern_openvdb` and the OpenVDB dependency itself.

The difference with this one is that `intern/openvdb` becomes an
"optional" dependency itself. This is because downstream consumers often
want to include this dependency rather than openvdb directly, so this
target must also be optional. Optional, in this case, means the target
always exists but may be entirely empty.

Summary
- If you are using BKE APIs to access openvdb features, then use the
  `bf::blenkernel` target
- If you are only using `intern/openvdb` APIs then use the
  `bf::intern::optional::openvdb` target (rare)
- For all other cases, use the `bf::dependencies::optional::openvdb`
  target (rare)

context: https://devtalk.blender.org/t/cmake-cleanup/30260
Pull Request: https://projects.blender.org/blender/blender/pulls/137071
2025-08-12 21:26:38 +02:00
Falk David
8873dff159 Fix: Grease Pencil: Assert in length modifier due to wrong argument
Discovered in #144048.

The `evaluated_length_total_for_curve` function expects the correct
cyclic value of the curve to be passed in.
2025-08-08 13:45:36 +02:00
Campbell Barton
cccc2c77c5 Cleanup: consistent for C-style comment blocks 2025-08-08 07:37:33 +10:00
YimingWu
6f57268e9a LineArt: Use "Radius" instead of "Thickness" for generating strokes
Previously line art uses the same thickness value as found in grease
pencil before blender v4.3 for generating strokes, now everything is
migrated to using "radius", so it makes more sense to change that it to
using "radius" so it's consistent with everywhere else.

Pull Request: https://projects.blender.org/blender/blender/pulls/144121
2025-08-07 15:40:17 +02:00
Falk David
4a013194dd Cleanup: Core: Replace FPS scene macro with member function
Replaces the `FPS` macro with `scene->frames_per_second()`.

The macro has two major issues:
* It hides that it depends on a `Scene *` variable named `scene`.
* It makes debugging harder.

This is now replaced with a member function on the scene.

Pull Request: https://projects.blender.org/blender/blender/pulls/144127
2025-08-07 11:30:25 +02:00
Jacques Lucke
54bfc11f68 Cleanup: avoid indenting entire geometry nodes modifier blend-write function 2025-08-04 06:39:16 +02:00
YimingWu
250e809d6f Fix #143870: Grease Pencil: Fix typo in dash modifier
Previously modified by e7a3f0758e, should be `!joined_geo.has_curves()`.

Pull Request: https://projects.blender.org/blender/blender/pulls/143889
2025-08-03 14:09:08 +02:00
Campbell Barton
2c27d2be54 Cleanup: grammar corrections, minor improvements to wording 2025-08-01 21:41:24 +10:00
Jacques Lucke
3905cdd89a Fix #143455: crash in Grease Pencil Shrinkwrap modifier when there is a dependency cycle
The case when no mesh can be retrieved from the shrinkwrap target object can be
retrieved was not handled. It was handled by `ensure_shrinkwrap_cache_data` but
the calling function didn't check if the cache was actually created.
`BKE_modifier_get_evaluated_mesh_from_evaluated_object` can return null for an
object that would usually have a mesh but the object has not been evaluated yet,
as can be the case when there is a depsgraph cycle.

From my current understanding, the issue existed without 83325d1fd. Changing the
hash just made the depsgraph do different scheduling decisions so that now the
shrinkwrap was evaluated before the target object. The order in which these two
things are evaluated is arbitrary when there is a depsgraph cycle.

Pull Request: https://projects.blender.org/blender/blender/pulls/143757
2025-08-01 12:58:31 +02:00
Campbell Barton
f281f5a500 Cleanup: header grouping
Group includes, this is mostly being done already but had become mixed
up in some areas.
2025-07-30 14:22:06 +10:00
YimingWu
272178d001 Fix #143420: Grease Pencil: Handle empty result in dash modifier
The dash modifier creates final result by combining filtered/processed
and unfiltered strokes, but this result could be empty. The code assumes
valid joined geometry when it's sometimes not the case. This patch did
a null check and it worked as it should.

Pull Request: https://projects.blender.org/blender/blender/pulls/143424
2025-07-28 13:38:08 +02:00
Campbell Barton
e8f9e2d1d1 Cleanup: use UTF8 string functions in editors & related logic
Use UTF8 aware functions unless raw bytes are expected.
2025-07-27 16:41:19 +10:00