Commit Graph

4698 Commits

Author SHA1 Message Date
Campbell Barton
640e70b6e8 Cleanup: various non-functional changes for C++ 2025-02-13 13:33:09 +11:00
Brecht Van Lommel
c7a33a62a2 Cleanup: Directly include DNA_userdef_types.h and BLI_listbase.h
Instead of relying on them being included indirectly.

Pull Request: https://projects.blender.org/blender/blender/pulls/134406
2025-02-12 23:01:08 +01:00
Philipp Oeser
8f45746fb9 Merge branch 'blender-v4.4-release' 2025-02-10 10:27:57 +01:00
Philipp Oeser
351aef120f Fix #134286: Weight paint mirror ignores selection in face-select mode
Since the vert selection attribute should be in sync with face masking,
we can just enter the codepath for selected vertices here.

Pull Request: https://projects.blender.org/blender/blender/pulls/134327
2025-02-10 10:27:25 +01:00
Bastien Montagne
87a4c0d3a8 Refactor: Make Library.runtime an allocated pointer.
Move `Library.runtime` to be a pointer, move the related
`LibraryRuntime` struct to `BKE_library.hh`. Similar to e.g.
Mesh.runtime, that pointer is expected to always be valid, and is
allocated at readtime or when creating a new Library ID.

Related smaller changes:
* Write code now uses standard ID writing codepath for Library IDs too.
  * Runtime pointer is reset to nullptr before writing.
* Looking up a library by its absolute path is now handled through a
  dedicated utils, `search_filepath_abs`, instead of using
  `BLI_findstring`.

Pull Request: https://projects.blender.org/blender/blender/pulls/134188
2025-02-07 17:47:16 +01:00
Falk David
445ae53c8e Merge branch 'blender-v4.4-release' 2025-02-07 12:22:59 +01:00
Falk David
8c01a59411 Fix: Grease Pencil: Use ensure_selection_attribute in vgroup_select_verts
This was implemented in the kernel but it shouldn't have been.
Since the function operates at the editor level and doesn't
only work at the low-level, it should be in the `object_vgroup.cc` file
in the `editor` context.

This also means that we can use `ensure_selection_attribute` which
fixes a crash when the selection attribute is on the wrong domain.

Pull Request: https://projects.blender.org/blender/blender/pulls/134060
2025-02-07 12:22:29 +01:00
Hans Goudey
4f833b0b5f Refactor: Add StringRef overloads to translation functions
Currently UI code always has to use char pointers when interacting with
the translation system. This makes benefiting from the use C++ strings
and StringRef more difficult. That means we're leaving some type safety
and performance on the table. This PR adds StringRef overloads to the
translation API functions and removes the few calls to `.c_str()` that
are now unnecessary.

Pull Request: https://projects.blender.org/blender/blender/pulls/133887
2025-02-06 17:47:52 +01:00
Philipp Oeser
a44b12dd6b Fix #134031: Set Parent menu lists unsupported armature options
What is (or isnt) supported here depends on object types (but we were
getting most of the options for all object types):

| **obtype** | **supports Armature modifier**  | **supports vertex groups** | **supports envelopes** | **supports automatic weights** |
| -- | -- | -- | -- | -- |
| OB_MESH | yes | yes | yes | yes |
| OB_CURVES_LEGACY | yes | no | yes | no |
| OB_CURVES | no | no | no | no |
| OB_SURF | yes | no | yes | no |
| OB_MBALL | no | no | no | no |
| OB_FONT | yes | no | yes | no |
| OB_VOLUME | no | no | no | no |
| OB_GREASE_PENCIL | yes | yes | yes | yes |
| OB_LATTICE | yes | yes (broken though) | yes | no |
| OB_EMPTY | no | no | no | no |
| OB_SPEAKER | no | no | no | no |
| OB_LIGHTPROBE | no | no | no | no |
| OB_LAMP | no | no | no | no |
| OB_ARMATURE | no | no | no | no |
| OB_POINTCLOUD | no | no | no | no |

This PR does two things:
- tidy up the popup menu we get for parenting (removing non-funtional
options)
- enable "With Empty Groups" for lattices (no reason why this should not
work)

What this PR does not touch:
- the poll function for parenting (since this acts on selected objects,
checking all of them can be a costly operation which should not be part
of a poll function)

Pull Request: https://projects.blender.org/blender/blender/pulls/134037
2025-02-05 09:14:21 +01:00
Hans Goudey
fc1fe4e78c Cleanup: Rename object materials "test" functions
"test" wasn't descriptive. Rename that part to "sync_length".
Also expose documentation from the function implementation
to describe what the functions do.

Pull Request: https://projects.blender.org/blender/blender/pulls/134058
2025-02-04 17:46:08 +01:00
Campbell Barton
007d46ef6d Cleanup: rename "opengl" to "gpu" for 3D viewport utilities 2025-02-04 21:19:28 +11:00
Brecht Van Lommel
3725fad82f Cleanup: Various clang-tidy warnings in editors
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:17 +01:00
Habib Gahbiche
5eb8101efa UI: Show error if drag and drop of images fail
Adding an image object using drag and drop can fail without an apparent reason.

This patch shows an error when this happens so that the user can react accordingly (in this example switch to object mode, add the image and switch back to edit mode).

Pull Request: https://projects.blender.org/blender/blender/pulls/132994
2025-01-29 18:31:00 +01:00
Philipp Oeser
8a45c24f57 Fix: "Affect only origins" does not work for Curves
For this to work, we need to properly support `XFormObjectData` for
`Curves`.

Similar to 50770bd8f5

Part of #103680

Also fixes #133537

Pull Request: https://projects.blender.org/blender/blender/pulls/133544
2025-01-29 09:57:36 +01:00
Hans Goudey
7d6e098ca1 Cleanup: Remove unused includes in blenkernel
Pull Request: https://projects.blender.org/blender/blender/pulls/133688
2025-01-28 15:27:34 +01:00
Jacques Lucke
9e8b3e035a Fix #133633: crash because of edited Smooth by Angle node group
This adds a shallow check to see if the node group has been changed. If it has
been changed, the weak library reference is removed so that the node group will
be loaded from the source file again. This should become unnecessary once we
have asset embedding.

There are probably still ways to make Blender behave unexpectedly when editing
the Smooth by Angle node group, but this should already cover common edits. More
precise checks could be added as necessary.

Pull Request: https://projects.blender.org/blender/blender/pulls/133654
2025-01-27 15:31:22 +01:00
Bastien Montagne
9c237af041 Refactor: RNA: add discrete suffix to RNA_pointer_create.
This is a noisy preliminary step to the 'RNA ancestors' change. The
rename helps clearly tell what each `pointer_create` function does.

Pull Request: https://projects.blender.org/blender/blender/pulls/133475
2025-01-24 16:45:32 +01:00
Christoph Lendenfeld
e4f34453e3 Refactor: pass Vector instead of ListBase to motion path functions
This changes the `ListBase` argument for certain motion path functions
to `Vector<MPathTarget *>`. (and `Span`)

To better describe what the function is doing,
`animviz_get_object_motionpaths` has been renamed
to `animviz_build_motionpath_targets`.

Since `BLI_freelistN` can no longer be used, I added
`animviz_free_motionpath_targets`.

Note that the Vector is of `MPathTarget *` which
are allocated the C way. Because the `MPathTarget` struct is defined
in the .cc file, that's the only way for it to work atm.
Other refactors may mitigate that in the future, but I wanted to keep
the scope small.

Pull Request: https://projects.blender.org/blender/blender/pulls/133212
2025-01-24 12:43:20 +01:00
Jacques Lucke
619d9e4e01 Fix #98559: support applying Geometry Nodes through multires modifier
Before, it was only possible to apply modifiers through a multires modifier if
they were deform-only. The Geometry Nodes modifier is of course not deform-only.
However, often one can build a node setup, that only deforms and does nothing
else.

To make it possible to apply the Geometry Nodes modifier in such cases the
following things had to be done:
* Update `BKE_modifier_deform_verts` to work with modifiers that implement
  `modify_geometry_set` instead of `deform_verts`.
* Add error handling for the case when `modify_geometry_set` does more than just
  deformation.
* Allow the Geometry Nodes modifier to be applied through a multi-res modifier.

Two new utility types (`ArrayState` and `MeshTopologyState`) have been
introduced to allow for efficient and accurate checking whether the topology has
been modified. In common cases, they can detect that the topology has not been
changed in constant time, but they fall back to linear time checking if it's not
immediately obvious that the topology has not been changed.

This works with the example files from #98559 and #97603.

Pull Request: https://projects.blender.org/blender/blender/pulls/131904
2025-01-23 17:34:30 +01:00
Brecht Van Lommel
be67a07cae Fix #133411: Texture baking changes object visibility
The recent addition of DEG_disable_visibility_optimization in #133358
almost fixed this, but it was not fully working. By ensuring objects
are evaluated we avoid modifying original objects.

If for some reason (like a Python handler) the object is still missing,
report an error in the bake operator.

Pull Request: https://projects.blender.org/blender/blender/pulls/133439
2025-01-23 10:35:41 +01:00
Campbell Barton
ecdeeca5b3 Cleanup: re-order baking highpoly break-on-error
Avoid breaking with a partially initialized `highpoly` as this
could cause complications when freeing members in the future.
Also use variables for brevity.
2025-01-22 12:45:03 +11:00
Campbell Barton
0f0bc1a940 Fix #107426: error when texture bake cannot access evaluated mesh data
Changes in [0] broke baking to objects with animated render visibility,
causing render visibility override not to work.

Resolve by disabling visibility optimizations.

Ref !133358

[0]: 0dcee6a386
2025-01-22 12:43:23 +11:00
Campbell Barton
db6cbcef5b Fix crash when texture bake cannot access evaluated mesh data
Baking could fail to access an objects evaluated mesh data (see #107426),
while the error remains, prefer an error instead of crashing.

Since the depsgraph runs Python callbacks I don't think we can
provide a guarantee the mesh data will available, so even if #107426
is fixed, it's reasonable to have a check here.
2025-01-21 17:56:01 +11:00
Campbell Barton
d1e3db71a6 Cleanup: use "_num" suffix instead of "tot_" prefix
Also group array with its length argument.
2025-01-21 16:51:41 +11:00
Hans Goudey
c6f5c44350 Cleanup: Remove unused includes in editors modules
Pull Request: https://projects.blender.org/blender/blender/pulls/133166
2025-01-16 23:17:51 +01:00
YimingWu
43492a8278 Fix #133035: Grease Pencil: Convert mesh materials to fill materials
When converting mesh to grease pencil, different face materials should
also be converted to grease pencil ones. This now works by converting
viewport display color diffuse_color from the mesh material to grease
pencil material fill color. Notes:

- If there are empty material slots in the mesh, faces assgined to these
  material slots will be assgined to a new fallback white material in
  the converted grease pencil fills.
- If original mesh does not have any material slots, a white material
  will be created in the grease pencil object for the fills.
- If original mesh has multiple material slots of the same material,
  they would be reduced to one material slot in the converted fills.

Pull Request: https://projects.blender.org/blender/blender/pulls/133087
2025-01-16 15:12:50 +01:00
Campbell Barton
e3e8c154fa Docs: correct collection.objects_add_active name & description
The name was incorrect as it doesn't add to the "Active Collection"
the description, was also incorrect referencing "the object" instead
of the selection.

Use a longer description to clarify the purpose of the operator.

Resolves #64313.
2025-01-16 13:04:17 +11:00
YimingWu
1bacb0de62 Fix #132987: Grease Pencil: Ensure selection domain when switching modes
Grease Pencil tool settings could have different selection modes for
different object modes (like edit mode and sculpt mode). This fix
ensures when switching object modes, the selection domain is updated to
match the selection mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/133030
2025-01-14 16:46:23 +01:00
Jacques Lucke
684fd4643a Nodes: use BKE_main_ensure_invariants directly instead of ED_node_tree_propagate_change
`BKE_main_ensure_invariants` was added in 1fae5fd8f6. The older
`ED_node_tree_propagate_change` was already implemented as a thin wrapper around
`BKE_main_ensure_invariants`. This patch removes the wrapper and calls the more
general function directly.

A new overload of `BKE_main_ensure_invariants` is added for the common case when
only a single data-block has been modified.

Pull Request: https://projects.blender.org/blender/blender/pulls/133048
2025-01-14 16:26:54 +01:00
YimingWu
e18011fddc Fix #133034: Grease Pencil: Reset ob->actcol when converting from mesh
When converting object to grease pencil from mesh, the material counters
need to be set to the the value that matches
`GreasePencil::material_array_num` to avoid index issues in adding
grease pencil materials downstream.

Pull Request: https://projects.blender.org/blender/blender/pulls/133038
2025-01-14 12:15:31 +01:00
YimingWu
9d509de52a Grease Pencil: Convert from mesh to Grease Pencil
Convert mesh objects to grease pencil, optionally preserve mesh faces as
filled shapes, and convert crease edges into strokes. Following options
are available:

- Whether to convert faces to filled strokes.
- Stroke thickness.
- Stroke offset (Using normal direction to lift strokes out of mesh
  surfaces).

Note that "Crease Angle" option from legacy grease pencil is not ported
to this implementation. This option is deemed more suitable for using
geometry nodes to achieve.

Resolves #126480

Pull Request: https://projects.blender.org/blender/blender/pulls/131854
2025-01-14 08:28:52 +01:00
Hans Goudey
73ff099405 Cleanup: Remove unnecessary casts for PropertyFlag enum type 2025-01-10 15:18:40 -05:00
Hans Goudey
f2c9fccee0 Cleanup: Move legacy node integer types defines to separate header
Moving these defines to a separate header makes their "legacy" status
more obvious. This commit just adds the include wherever necessary.

Followup to 971c96a92c.

Pull Request: https://projects.blender.org/blender/blender/pulls/132875
2025-01-09 20:03:08 +01:00
Falk David
d413b0064f Cleanup: Move BKE_material.h to C++
The `BKE_material.h` is only renamed to `.hh` to preserve
the history of the file. Changes to the file are done in
the following commit.
2025-01-09 18:11:46 +01:00
Jacques Lucke
038159e96b Refactor: Nodes: improve node tree update API
Main goals of this refactor:
* Make it more obvious which update function should be used.
* Make it more obvious which parameters are required by using references instead
  of pointers.
* Support passing in multiple modified trees instead of just a single one.

No functional changes are expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/132862
2025-01-09 17:00:05 +01:00
Jacques Lucke
971c96a92c Nodes: rename integer type of nodes to type_legacy
The new description for `bNode.type_legacy`:
```
  /**
   * Legacy integer type for nodes. It does not uniquely identify a node type, only the `idname`
   * does that. For example, all custom nodes use #NODE_CUSTOM but do have different idnames.
   * This is mainly kept for compatibility reasons.
   *
   * Currently, this type is also used in many parts of Blender, but that should slowly be phased
   * out by either relying on idnames, accessor methods like `node.is_reroute()`.
   *
   * A main benefit of this integer type over using idnames currently is that integer comparison is
   * much cheaper than string comparison, especially if many idnames have the same prefix (e.g.
   * "GeometryNode"). Eventually, we could introduce cheap-to-compare runtime identifier for node
   * types. That could mean e.g. using `ustring` for idnames (where string comparison is just
   * pointer comparison), or using a run-time generated integer that is automatically assigned when
   * node types are registered.
   */
```

Pull Request: https://projects.blender.org/blender/blender/pulls/132858
2025-01-09 15:28:57 +01:00
Jacques Lucke
db7ff834c9 Refactor: Nodes: remove context argument from propagation function
The part that used the context does not seem to be necessary anymore. If the
given tree has any update tag set, the same notifiers will be sent anyway by the
`tree_changed_fn` callback.

If it turns out that we are now missing some notifier, then we have to change
the caller. It either has to call the proper `BKE_ntree_update_tag_*` function,
or create the notifier directly.

This change helps to generalize the concept of propagating changes in original
data, because the context is rarely available.

Pull Request: https://projects.blender.org/blender/blender/pulls/132810
2025-01-08 19:45:50 +01:00
Campbell Barton
7e8dcf77db Cleanup: pass UnitSettings as a const reference 2025-01-08 21:22:45 +11:00
Campbell Barton
e949ff7334 Fix unit scale use when when units were disabled
UnitSettings::scale_length was used to scale reported
values for operators (translate, shrink-fatten, voxel-size).

This isn't expected as the value isn't editable when the unit-system
is set to None.

Add BKE_unit_value_as_string_scaled utility function for clarity &
to ensure scaling is only applied when it should be.
2025-01-08 21:07:23 +11:00
Brecht Van Lommel
0c2ec3dcf9 Fix #132716: Selected to active bake broken after recent bugfix
Consistently pass evaluated bake target objects to Cycles, instead
of using the original for this case. This way it can be matched with
evaluated objects being rendered.

Pull Request: https://projects.blender.org/blender/blender/pulls/132722
2025-01-07 10:57:46 +01:00
Campbell Barton
d2d754be3f Cleanup: spelling in comments (make check_spelling*)
- Back-tick quote math expressions so differentiate them
  from English.
- Use doxygen code blocks for TEX expressions.
2025-01-04 16:26:39 +11:00
Ray Molenkamp
5783950ac5 Revert: 0dc484f9cc bf_rna modernisation
This caused build errors on the docs builder, I can't seem to reproduce
locally, so revert for now and have another look at some point in the
future.

Sadly as these changes usually go, this took 5c515e26bb and
2f0fc7fc9f with it as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/132559
2025-01-02 19:56:24 +01:00
Campbell Barton
5c515e26bb Cleanup: remove trailing space, ensure a newline at EOF 2025-01-02 15:11:18 +11:00
Ray Molenkamp
0dc484f9cc Cleanup: CMake: Modernize bf_rna dependencies
Pretty straightforward

- Remove any bf_rna paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132413
2024-12-31 18:23:25 +01:00
Hans Goudey
645624130d Cleanup: Simplify creation of mesh for particle system conversion 2024-12-30 11:13:47 -05:00
Ray molenkamp
10c5493746 Cleanup: CMake: Modernize bf_geometry dependencies
Pretty straightforward

- Remove any bf_geometry paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132375
2024-12-28 19:58:14 +01:00
Ray Molenkamp
43d47d272a Cleanup: CMake: Modernize bf_asset_system dependencies
Pretty straightforward

- Remove any bf_asset_system paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132357
2024-12-26 20:47:53 +01:00
Ray Molenkamp
16eb4430f5 Cleanup: CMake: Modernize bf_render dependencies
Pretty straightforward

- Remove any bf_render paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132355
2024-12-26 18:50:53 +01:00
Ray Molenkamp
a0d9826b3c Cleanup: CMake: Modernize bf_imbuf dependencies
Pretty straightforward

- Remove any bf_imbuf paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132336
2024-12-25 23:32:15 +01:00
Ray Molenkamp
4dcef4421c Cleanup: CMake: Modernize bf_functions dependencies
Pretty straightforward

- Remove any bf_functions paths from INC
- Add a dependency though LIB when missing

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/132335
2024-12-25 19:46:31 +01:00