Commit Graph

4660 Commits

Author SHA1 Message Date
Campbell Barton
dbf86f291c Cleanup: prefer term "unreliable" over "flaky"
Avoid slang terms, also correct typo.
2025-05-22 13:51:29 +10:00
Hans Goudey
3d6ea7c075 Shape Keys: Use actual evaluated meshes in Update/Join operators
Previously this attempted to use the evaluated deform mesh (otherwise
known as the cage mesh). Because this isn't the mesh displayed in the
viewport it can be unintuitive, and it also doesn't work when the other
meshes are procedurally generated or have other "generative" modifiers.
This commit switches to just checking the evaluated mesh.

A potential downside is that modifiers like subdivision are also taken into
account and can potentially make the objects incompatible because of
mismatched vertex counts.

Part of #135095

Pull Request: https://projects.blender.org/blender/blender/pulls/138330
2025-05-20 14:19:52 +02:00
Hans Goudey
550094b018 Refactor: Attributes: Access active attribute with name
This function to get the active attribute currently returns a custom
data layer pointer. This doesn't work when we transition to the new
`AttributeStorage` system. Returning an optional string is a simple
alternative that also aligns with the idea of changing the source of
truth from an index to a string stored on the geometry.

Pull Request: https://projects.blender.org/blender/blender/pulls/139115
2025-05-19 21:29:57 +02:00
Campbell Barton
b3dfde88f3 Cleanup: spelling in comments (check_spelling_* target)
Also uppercase acronyms: API, UTF & ASCII.
2025-05-17 10:17:37 +10:00
Campbell Barton
247d8183f8 Refactor: pass the select mode to EDBM_selectmode_set
Pass the new selection mode instead of setting the value in the
BMEditMesh, then calling set.

This makes it possible to compare with the current selection mode
(needed for UV sync select #131642).
2025-05-14 11:26:58 +10:00
Guillermo Venegas
3b1e123361 Refactor: UI: Replace uiItemS and uiItemS_ex with uiLayout::separator
This merges the public `uiItemS` and `uiItemS_ex` functions into an
object oriented API (`uiLayout::separator`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code
(or vice-versa), making it almost seamless.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138826
2025-05-13 17:54:26 +02:00
Guillermo Venegas
dafdced6ab Refactor: UI: Replace uiItemR with class method uiLayout::prop
This converts the public `uiItemR` function to an object oriented
API (`uiLayout::prop`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138617
2025-05-08 20:45:37 +02:00
Campbell Barton
63cdb7eae4 Cleanup: pass SelectPick_Params by reference instead of pointer
Also use a return value from ED_select_pick_params_from_operator.
2025-05-08 13:50:14 +10:00
Pratik Borhade
ea439fdf0c Fix #91188: Change identifier prefix for some sculpt mode operations
With `MESH_OT` prefix, the shortcut was added to wrong
keymap ("object mode", see: `WM_keymap_guess_opname`).
idname of following operations has been changed, they are
only exposed in sculpt mode UI (also see their poll function:
`geometry_extract_poll`):
- `face_set_extract`
- `paint_mask_extract`
- `paint_mask_slice`

Pull Request: https://projects.blender.org/blender/blender/pulls/133852
2025-05-07 10:30:58 +02:00
Campbell Barton
8cc63c6848 Refactor: add a version of EDBM_selectmode_set_multi that takes objects
Support setting the select mode when the object array has already
been created, needed for #131642.
2025-05-07 17:03:29 +10:00
Jacques Lucke
e8d1491e62 Refactor: Depsgraph: simplify query API further
* Remove `DEG_get_evaluated_object` in favor of `DEG_get_evaluated`.
* Remove `DEG_is_original_object` in favor of `DEG_is_original`.
* Remove `DEG_is_evaluated_object` in favor of `DEG_is_evaluated`.

Pull Request: https://projects.blender.org/blender/blender/pulls/138317
2025-05-02 15:08:29 +02:00
Campbell Barton
43af16a4c1 Cleanup: spelling in comments, correct comment block formatting
Also use doxygen comments more consistently.
2025-05-01 11:44:33 +10:00
Hans Goudey
12e626f31f Shape Keys: Add operator to update keys from selected objects
This operator is very similar to the existing "Join as Shapes" operator,
which updates or adds shape key array values with the positions of
objects with the same name, but instead of creating new shape keys,
it just updates existing ones. The new operator is called "Update from
Objects" in the UI.

Internally, some logic was moved to a poll function shared between the
two operators, and a new argument for whether to ensure keys exist was
added to their shared implementation.

Part of #135095.

Pull Request: https://projects.blender.org/blender/blender/pulls/136853
2025-04-30 20:07:25 +02:00
Germano Cavalcante
9a4ee099e6 Fix #137680: Knife constraints not accurate in orthographic view
The code that updated the ray based on the constraint point was
incorrect in orthographic view. In this view, it's the ray origin that
changes, not the direction. This has now been fixed.

Additionally, as a further improvement, when snapping is not available,
a fallback point is now used as the constraint point.

Pull Request: https://projects.blender.org/blender/blender/pulls/137776
2025-04-29 22:43:34 +02:00
Guillermo Venegas
8e499caded Refactor: UI: Replace uiLayoutColumnWithHeading with class method uiLayout::column
This converts the public `uiLayoutColumnWithHeading` function to an
object oriented API (an `uiLayout::column` overloaded version), matching
the python API.

Like the original `uiLayout::column`, this overloaded version now also
returns an `uiLayout` reference instead of a pointer. New calls to this
method should use references too.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138056
2025-04-27 17:09:52 +02:00
Guillermo Venegas
2d896877d1 Refactor: UI: Replace uiLayoutColumn with class method uiLayout::column
This converts the public `uiLayoutColumn` function to an object oriented
API (`uiLayout::column`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

`uiLayout::column` now returns an `uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Pull Request: https://projects.blender.org/blender/blender/pulls/138034
2025-04-26 21:07:34 +02:00
Campbell Barton
c90e8bae0b Cleanup: spelling in comments & replace some use of single quotes
Previously spell checker ignored text in single quotes however this
meant incorrect spelling was ignored in text where it shouldn't have
been.

In cases single quotes were used for literal strings
(such as variables, code & compiler flags),
replace these with back-ticks.

In cases they were used for UI labels,
replace these with double quotes.

In cases they were used to reference symbols,
replace them with doxygens symbol link syntax (leading hash).

Apply some spelling corrections & tweaks (for check_spelling_* targets).
2025-04-26 11:17:13 +00:00
Guillermo Venegas
f0f0361254 Refactor: UI: Replace uiLayoutRowWithHeading with class method uiLayout::row
This converts the public `uiLayoutRowWithHeading` function to an object oriented
API (an `uiLayout::row` overloaded version), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

Same as the original `uiLayout::row`, this overloaded version also now returns an
`uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/138014
2025-04-26 02:17:31 +02:00
Guillermo Venegas
90644b30b2 Refactor: UI: Replace uiLayoutRow with class method uiLayout::row
This converts the public `uiLayoutRow` function to an object oriented
API (`uiLayout::row`), matching the python API.
This reduces the difference between the C++ API with the python version,
its also helps while converting code from python to C++ code (or vice-versa),
making it almost seamless.

`uiLayout::row` now returns an `uiLayout` reference instead of a pointer.
New calls to this method should use references too.

Part of: #117604

Pull Request: https://projects.blender.org/blender/blender/pulls/137979
2025-04-25 19:45:25 +02:00
Pablo Vazquez
f4c31b75ba UI: Rename "Tris to Quads" to "Triangles to Quads"
Rename the operator label to `Triangles to Quads`. This way, when
searching it will show up both when looking for `Triangles` or `Tris`.
Instead of having to always search for `Tris` which is less intuitive.

This also matches the manual, which has been calling this operator
`Triangles to Quads` for several years now.

This does not rename any API or operator name.
2025-04-24 19:00:48 +02:00
Hans Goudey
0f72fffac3 UI: Clarify Boolean solver descriptions/names and make consistent
Use the same solver names and descriptions for the geometry node,
the modifier, the sculpt trim tool, and the edit mesh intersect operator.
Also clarify the descriptions, some of which used to say that the float
solver had the best performance which isn't true anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/137922
2025-04-24 15:06:26 +02:00
Campbell Barton
c1de05aa3b Refactor: don't pass in mesh & object data to edit-mesh undo functions
Avoid confusion from having multiple meshes declared in undo conversion
logic by passing in the meshes vertex group members as arguments.
2025-04-23 03:16:21 +00:00
Brecht Van Lommel
fb2ba20b67 Refactor: Use more typed MEM_calloc<> and MEM_malloc<>
Pull Request: https://projects.blender.org/blender/blender/pulls/137822
2025-04-22 11:22:18 +02:00
Brecht Van Lommel
388a21e260 Refactor: Eliminate various void pointers passed to MEM_freeN
It's safer to pass a type so that it can be checked if delete should be
used instead. Also changes a few void pointer casts to const_cast so that
if the data becomes typed it's an error.

Pull Request: https://projects.blender.org/blender/blender/pulls/137404
2025-04-21 17:59:41 +02:00
Brecht Van Lommel
637c6497e9 Refactor: Use more typed MEM_calloc<>, avoid unnecessary size_t cast
Handle some cases that were missed in previous refactor. And eliminate
unnecessary size_t casts as these could hide issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/137404
2025-04-21 17:59:41 +02:00
Jacques Lucke
f442c86197 Depsgraph: improve type safety when getting evaluated or original ID
The goal here is to avoid having to cast to and from `ID` when getting the
evaluated or original ID using the depsgraph API, which is often verbose and not
type safe. To solve this, there are now `DEG_get_original` and
`DEG_get_evaluated` methods which are templated on the type and use a new
`is_ID_v` static type check to make sure it's only used with valid types.

This allows removing quite some verbosity on all the call sites. I also removed
`DEG_get_original_object`, because that does not have to be a special case
anymore.

Pull Request: https://projects.blender.org/blender/blender/pulls/137629
2025-04-17 13:09:20 +02:00
Campbell Barton
cc83a7dbef Cleanup: assign variables in edit-mesh picking
Avoid having to use `vc.em->bm` for each BMesh reference.
2025-04-17 16:16:28 +10:00
Hans Goudey
b52554b475 Cleanup: Simplify ID management in edit mesh undo
Currently this code uses the `Mesh` struct as a value embedded in the
undo step struct. This causes the need for various hacky workarounds and
abstraction leaks. It's simpler to just allocate it in the regular way
The Shape Key ID can also be freed with the regular ID free function,
avoiding the need to expose the internal free function.

Pull Request: https://projects.blender.org/blender/blender/pulls/137613
2025-04-17 01:09:23 +02:00
Hans Goudey
ce8bfd6f8f Cleanup: Add comment with reasoning for edit mode object update tag 2025-04-16 11:53:02 -04:00
Hans Goudey
d6e8c4c124 Fix #63434: Edit mesh undo does not handle vertex group removal
Seems that this was a fundamental design problem that was resolved
with 3b6ee8cee7.

Since the vertex group names are stored on the mesh now, we can
just store their state in the undo mesh, and restore it when decoding
an undo step.

Pull Request: https://projects.blender.org/blender/blender/pulls/137225
2025-04-15 13:58:37 +02:00
Jason C. Wenger
702efd6846 BMesh: add a BM_faces_join() to return a duplicate face (if found)
Every call to BM_faces_join and BM_faces_join_pair has been adjusted to
provide the new face pointer, and a BLI_assert_msg has been added so
that doubles are now consistently identified and flagged as a problem.
BM_faces_join is now also capable of automatically reusing a double
when it is found. This new behavior is currently unused at this point.
Future patch-sets will begin to use it, allowing simplification of
calling functions.

Ref: !137406
2025-04-15 11:03:15 +00:00
Campbell Barton
d6825c863f Cleanup: remove redundant PropertyFlag casts which can hide errors 2025-04-11 12:02:07 +10:00
Campbell Barton
92fe84374d Cleanup: remove redundant calls to object & ID material resize
BKE_id_material_clear is already syncing other objects material length.
2025-04-08 14:03:28 +10:00
Zyq-XDz
cebffdfdfa Fix #136384: Separate by Material leaves objects without material slots
`BKE_id_material_clear` removes all materials for each linked objects.
However, the code doesn't sync the materials after resize.

Ref: !136863
2025-04-08 14:02:00 +10:00
Hans Goudey
f3aa425d81 Fix #136873: Edit mesh knife crash with no valid evaluated edit mesh
When the evaluated mesh doesn't have an edit mesh that corresponds
to the original edit mesh, don't use evaluated deformed positions, just
use the mesh's original positions instead.
2025-04-02 12:45:47 -04:00
YimingWu
79c1bb67d9 Fix #136867: Modeling: Knife cut through toggle should refresh cuts
Previously pressing `c` to cut through mesh will only update knife cuts
when mouse is moved again, this means if you press `c` at the end of
mouse stroke, it will not update cuts and you end up still only cutting
front faces. This fix makes it that the toggle refreshes knife cuts
immediately.

Pull Request: https://projects.blender.org/blender/blender/pulls/136870
2025-04-02 14:44:36 +02:00
Hans Goudey
c7dd2131f6 Cleanup: Pass ReportList to shape key function instead of operator
The operator should be a separate abstraction level than this sort of function.
2025-04-01 15:05:41 -04:00
Hans Goudey
b811282fda Cleanup: Replace weird update tag in Join as Shape Keys implementation
The scene isn't being changed here, especially object selection. The mesh
is being changed though (or rather its shape key data-block, but that really
means the objects using it need to be reevaluated). For some reason this
doesn't make a functional difference currently though.
2025-04-01 15:05:41 -04:00
Hans Goudey
e818a52926 Refactor: Various cleanups to ED_mesh_shapes_join_objects_exec
- Remove useless wrapper function that checked redundant invariants
- Use Vector instead of looping over context variable twice
- Use references instead of pointers
- Make variable names non-cryptic
- Remove useless comment
- Use continue instead of indenting the rest of loops
- Fix grammar and improve text in comment
2025-04-01 15:05:41 -04:00
Campbell Barton
bcdcc3dbde Refactor: use enum types for event modifiers & types
Use enum types for event modifier and types,
`wmEventModifierFlag` & `wmEventType` respectively.

This helps with readability and avoids unintended mixing with other
types. To quiet GCC's `-Wswitch` warnings many `default` cases needed
to be added to switch statements on event types.

Ref !136759
2025-03-31 23:48:29 +00:00
Hans Goudey
ef86d9fe86 Cleanup: Remove ED_ prefix from private functions 2025-03-31 11:21:24 -04:00
Campbell Barton
b252a6c7fb Cleanup: various non-functional changes for C++ 2025-03-28 00:59:15 +00:00
Campbell Barton
12e17e2477 Cleanup: use const arguments, variables 2025-03-28 00:59:11 +00:00
Philipp Oeser
a062b334a9 Fix #136491: crash 'Select Linked' after 'Select Boundary Loop'
...  when in multiobject editmode

We had a similar issue in #95752, so the fix here is similar to
cc0c4c17f0

The reason here is that `edbm_region_to_loop_exec` switches to edge
select mode but was only doing this on objects that actually had faces
selected, all other participating meshes would keep their selectmode
which would now be out of sync with both the objects that had faces
selected and scene settings for these.

This causes problems later in 'Select Linked'. Here, a mixture of
objects are used. First the viewcontext is set up with the active
object, then all participating objects are iterated (changing the
viewcontext to another object), then `unified_findnearest` would use
that changed viewcontext which would now contain the last object
iterated. To repeat: this could now have a different selectmode than the
active object which is later **again** used to get the nearest `BMElem`
from in `EDBM_elem_from_selectmode`. So in the failing case, we could
get an edge (but no face because of edge selectmode) from
`unified_findnearest`, `EDBM_elem_from_selectmode` would return NULL
though (edge provided, but in face selectmode), leading to the crash.

To solve this it is best to change selectmode on all
participating meshes in multi-object editmode if necessary so
these are always in sync for following operations.

Pull Request: https://projects.blender.org/blender/blender/pulls/136497
2025-03-25 13:54:01 +01:00
Campbell Barton
818a1a6a35 Cleanup: replace int with wmOperatorStatus 2025-03-22 16:35:59 +11:00
Campbell Barton
10233e95dd Cleanup: use a typed enum for operator & gizmo callbacks
Callbacks: exec invoke & modal now use a typed enum wmOperatorStatus.

This helps avoid mistakes returning incompatible booleans or other
values which don't make sense for operators to return.

It also makes it more obvious functions in the WM API are intended
to be used to calculate return values for operator callbacks.

Operator enums have been moved into DNA_windowmanager_enums.h
so this can be used in other headers without loading other includes
indirectly.

No functional changes expected.

Ref !136227
2025-03-20 21:11:06 +00: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
ff8baa6791 Cleanup: pass BMUVOffsets by const reference 2025-03-13 17:06:32 +11:00
Campbell Barton
78c3f6a1ee Cleanup: adjust order of terms for BMesh UV map function calls
Order more generic terms first for better ordering, more useful
completion.
2025-03-13 15:23:46 +11:00
Campbell Barton
6ef7dae8ef Cleanup: spelling in comments (make check_spelling_*) 2025-03-13 13:41:17 +11:00