Commit Graph

2144 Commits

Author SHA1 Message Date
Campbell Barton d514b3b53b Cleanup: use explicit casts when assigning booleans to floats
While valid, this isn't so common and cppcheck warns about this,
use explicit casts to suppress the warning, also correct "true"
being assigned to a float value.
2024-04-01 22:20:09 +11:00
Harley Acheson 6dd0f6627e UI: Removal of Five Operator Confirmations
Removal of confirmation dialogs for the following five operators. For
each of these the UI module felt that they are all either very explicit
actions and/or are easily undone.
* ARMATURE_OT_separate (Move selected bones to a separate armature)
* CURVE_OT_separate - “Move selected points to a new object”
* OBJECT_OT_vertex_parent_set (Parent selected ob to selected vertices)
* OBJECT_OT_parent_no_inverse_set (Make Parent w/o inverse correction)
* FILE_OT_directory_new - (Create New Directory)

Pull Request: https://projects.blender.org/blender/blender/pulls/120036
2024-03-29 01:09:15 +01:00
Campbell Barton 01dceb6b89 Cleanup: remove redundant checks for known states 2024-03-29 10:30:42 +11:00
Hans Goudey c28db1f0a0 Cleanup: Use C++ namespace for object editors module
Move the public functions from the editors/object (`ED_object.hh`)
header to the `blender::ed::object` namespace, and move all of the
implementation files to the namespace too. This provides better code
completion, makes it easier to use other C++ code, removes unnecessary
redundancy and verbosity from local uses of public functions, and more
cleanly separates different modules.

See the diff in `ED_object.hh` for the main renaming changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/119947
2024-03-28 01:30:38 +01:00
Hans Goudey 436c0a773e Cleanup: Remove object vgroup functions to proper header
These functions were declared in the editors/mesh module but
defined in the editors/object module. This commit moves them to
a separate header associated with the object editors module.
2024-03-26 23:45:43 -04:00
Hans Goudey acd1b0b7f9 Refactor: Use C++ Vector for RNA/context collection retrieval
Previously retrieving a collection from the context like "selected_ids"
would give a linked list of allocated items. Now it returns a vector of
RNA pointers. Though the number of items is typically fairly small,
using contiguous memory and avoiding many small allocations are
typical performance improvements that could still be beneficial
when there are many items. Iteration also becomes much simpler.

Pull Request: https://projects.blender.org/blender/blender/pulls/119939
2024-03-27 00:47:39 +01:00
Hans Goudey efee753e8f Cleanup: Move BKE_idprop.h to C++ 2024-03-26 13:07:04 -04:00
Hans Goudey 3039ea02c6 Refactor: Simplify undo object list creation, use C++ Vector
Replace the use of the `LIB_TAG_DOIT` flag which cwas used to
only process each object data ID once with a Set. Return the objects
or bases in a Vector. Now we only iterate over the view layers bases
once instead of three times.

Pull Request: https://projects.blender.org/blender/blender/pulls/119788
2024-03-22 16:24:30 +01:00
Sybren A. Stüvel 9f0cc7fe64 Anim: Bone subdivision, ensure bone names are sequential
Ensure that subdividing "Bone" results in a chain "Bone", "Bone.001",
"Bone.002", etc.

Before this commit the order would be "Bone", "Bone.004", "Bone.003",
etc.

This might break add-ons that assume to know the bone names before the
actual subdivision happens. This would always have been fragile, as
there may, for example, already have been a "Bone.001"; in that case
subdividing "Bone" would result in "Bone", "Bone.002", etc. Instead, the
parent-child chain should be followed.

Pull Request: https://projects.blender.org/blender/blender/pulls/119775
2024-03-22 15:26:22 +01:00
Sybren A. Stüvel ce8a032ac2 Anim: fix bug in name uniqueness check for editbones
Fix the name uniqueness check for editbones. The function can receive a
"bone to ignore", which would not be properly ignored. If it was found
earlier in `armature->edbo` than another bone with the same name, the
name would incorrectly be marked as unique.

This issue only occurred when a "bone to ignore" was passed to the
uniqueness check. This never actually happens in the current code, but
that's going to change soon.
2024-03-22 15:21:36 +01:00
Hans Goudey 803c783e52 Merge branch 'blender-v4.1-release' 2024-03-19 11:59:26 -04:00
Sybren A. Stüvel cd476226d8 Fix #119402: Bone collections layers fail with pinned object or armature #119434
Don't assume armature of active object is what is displayed in the properties editor, both in C++ and Python code.

Object pointer was left out from some notifiers, as this means only that object was changed. But an armature datablock can be shared by multiple objects.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/119663
2024-03-19 16:27:06 +01:00
Brecht Van Lommel 7a395e2e7f Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was f57e4c5b98.

After this one more fix was committed, this one is preserved as well:
67bd678887.
2024-03-18 15:04:12 +01:00
Harley Acheson 443ea628c5 UI: Changes to Small Operator Confirmations
Small operator confirmations get separate confirm and cancel buttons,
better descriptions and configurable confirm button text. But still
popup at cursor location and can be cancelled with mouse movement.

Pull Request: https://projects.blender.org/blender/blender/pulls/118346
2024-03-12 23:12:45 +01:00
Hans Goudey f6f767b879 Cleanup: Rename "me_eval" to "mesh_eval"
Similar to 854cdd1180
2024-03-11 11:21:18 -04:00
Harley Acheson 615edb3f3c UI: Props Dialog Default Properties
Allow activating numerical buttons upon opening of props dialogs. Set
defaults for some dialogs where appropriate.

Pull Request: https://projects.blender.org/blender/blender/pulls/119007
2024-03-05 18:54:50 +01:00
Falk David a11335d19a Cleanup: Move BKE_fcurve.h to C++
No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/119094
2024-03-05 18:39:08 +01:00
Sergey Sharybin 87a98c361c Fix: Crash when parenting mesh to armature with automatic weights
There probably are more cases where crash will happen as it is
rooting into the issue with BKE_object_workob_calc_parent() which
is used in multiple places.

The issue is caused by the access to a runtime field of workob
outside of the BKE_object_workob_calc_parent(): the runtime field
is stack-allocated in the function, and can not be accessed outside
of the function.

The easiest way to reproduce is to use ASAN, and parent mesh to an
armature with automatic weights. Although, on macOS ASAN did not
report issues, so setting workob->runtime to nullptr at the end of
of the BKE_object_workob_calc_parent() was the easiest.

The solution is simple: make the function to return the matrix,
and take care of the working object inside of it, so all tricky
parts are hidden from the API.

The patch is targeting the main branch, as in 4.1 it is not
required to do such change because all uses of the function only
access object_to_world, which is stored in the object in 4.1.

A double-check in the what_does_obaction() might be needed as it
follows the similar pattern, but it does not seem that runtime
field of the workob is accessed in usages of the what_does_obaction().

Pull Request: https://projects.blender.org/blender/blender/pulls/118847
2024-02-28 15:06:02 +01:00
Bastien Montagne de5451b112 Cleanup: Move `BKE_anim_data` header to be fully C++. 2024-02-28 11:51:03 +01:00
Hans Goudey 81a63153d0 Despgraph: Rename "copy-on-write" to "copy-on-evaluation"
The depsgraph CoW mechanism is a bit of a misnomer. It creates an
evaluated copy for data-blocks regardless of whether the copy will
actually be written to. The point is to have physical separation between
original and evaluated data. This is in contrast to the commonly used
performance improvement of keeping a user count and copying data
implicitly when it needs to be changed. In Blender code we call this
"implicit sharing" instead. Importantly, the dependency graph has no
idea about the _actual_ CoW behavior in Blender.

Renaming this functionality in the despgraph removes some of the
confusion that comes up when talking about this, and will hopefully
make the depsgraph less confusing to understand initially too. Wording
like "the evaluated copy" (as opposed to the original data-block) has
also become common anyway.

Pull Request: https://projects.blender.org/blender/blender/pulls/118338
2024-02-19 15:54:08 +01:00
Hans Goudey 1c0f374ec3 Object: Move transform matrices to runtime struct
The `object_to_world` and `world_to_object` matrices are set during
depsgraph evaluation, calculated from the object's animated location,
rotation, scale, parenting, and constraints. It's confusing and
unnecessary to store them with the original data in DNA.

This commit moves them to `ObjectRuntime` and moves the matrices to
use the C++ `float4x4` type, giving the potential for simplified code
using the C++ abstractions. The matrices are accessible with functions
on `Object` directly since they are used so commonly. Though for write
access, directly using the runtime struct is necessary.

The inverse `world_to_object` matrix is often calculated before it's
used, even though it's calculated as part of depsgraph evaluation.
Long term we might not want to store this in `ObjectRuntime` at all,
and just calculate it on demand. Or at least we should remove the
redundant calculations. That should be done separately though.

Pull Request: https://projects.blender.org/blender/blender/pulls/118210
2024-02-14 16:14:49 +01:00
Campbell Barton b372ebae68 Cleanup: unused headers for source/blender/editors
Remove 1317 includes from editors.
2024-02-13 10:02:53 +11:00
Bastien Montagne 5aaadebbe4 Cleanup: Make `BKE_scene.h` a full Cpp header. 2024-02-10 19:16:25 +01:00
Bastien Montagne 29fe777445 Cleanup: Make `BKE_report.h` a full Cpp header. 2024-02-10 18:34:29 +01:00
Bastien Montagne 54618dbae3 Cleanup: Make `BKE_global.h` a Cpp header. 2024-02-10 18:25:14 +01:00
Bastien Montagne 45e7827898 Clenup: Move BLT headers to Cpp.
Noisy but fairly straight forward.
2024-02-09 18:59:42 +01:00
Falk David 0a45acbe3b GPv3: Layer Parenting/Transforms
This implements layer parenting and layer transforms.

* Adds a new "Transform" panel in the object-data properties with the (local) translation, rotation and scale.
* Adds a new "Relations" panel with the parent property (and also bone name in case the parent is an armature).
* When converting from GPv2 to GPv3, the parent and transforms are converted too.
* Bone names are updated if they are renamed in the armature.

Implementation details:
* The positions in the drawings are always in layer space. During extraction, we transform the positions to object space. Note that this could be optimized further and done in the render engine itself.
* This means that e.g. the selection code (which needs to know where the positions are on screen) now takes this transform into account.
* The layer transform is calculated when accessed (from the location, rotation, scale properties).
* Code that needs to know where the positions are on screen now takes this new transform into account.

Pull Request: https://projects.blender.org/blender/blender/pulls/117247
2024-02-07 16:28:14 +01:00
Damien Picard 019eb5a35e I18n: use IFACE_ to translate status bar info & viewport statistics
Although the information displayed in the status bar is strictly
speaking reports, it makes sense to translate them using the Interface
setting instead of Reports, as the tool names and stats terms are
also translated in other UI places (toolbar, menus).

This change includes status bars statistics and keymaps, and viewport
statistics.

The change is quite extensive as it is all or nothing. Translating
keymaps using Interface means some status messages will include them
indirectly, and thus cannot use Reports without having a weird mix of
original and translated words. In turn, having only some messages
translated would be even more confusing.
The result is that all messages related to input are now translated with
Interface, which I think also makes sense.

Discussed as a followup to !116804.

-----

cc. @gtitaev

Pull Request: https://projects.blender.org/blender/blender/pulls/117234
2024-02-07 11:17:50 +01:00
Pratik Borhade 3566a9e8de UI: Tooltip when bone collections are linked
Linked bone collections are disabled in b79419914a
Include 'Disabled' tooltip for `move and assign to collection`
operation when bcol are linked.
In poll functions all other cases are already handled and also not
possible to get the index of hovered collection so just include
`poll_msg_set` in the end.

Pull Request: https://projects.blender.org/blender/blender/pulls/117715
2024-02-04 07:01:05 +01:00
Harley Acheson 311a2ec74d Anim: Properties Dialog Titles
For ARMATURE_OT_move_to_collection, when moving to a NEW collection,
title of "Move to New Collection" and confirm button that says "Move".
For POSE_OT_paths_calculate, title of "Calculate Paths for the Selected
Bones", confirm button text of "Calculate"

Pull Request: https://projects.blender.org/blender/blender/pulls/117741
2024-02-02 17:12:35 +01:00
Sybren A. Stüvel 660867fa00 Anim: bone collections, store expanded/collapsed state in DNA
Store the 'expanded/collapsed' state of the bone collection tree view in
the DNA data of the bone collections themselves. This way the tree state
is restored when loading the file.

This commit also adds some code to the abstract tree view classes, for
supporting synchronisation of the extended/collapsed state between it
and external data. It follows the same approach as the handling of the
active element.

RNA wrappers have been added to make it possible for Python code to
expand/collapse parts of the tree.

Library overrides are supported for this property, so the
expanded/collapsed state of linked armatures can be locally saved. If
there is no override, the `is_expanded` property is still editable;
changes will not be saved to file in that case, though.

Pull Request: https://projects.blender.org/blender/blender/pulls/116940
2024-02-02 12:28:22 +01:00
Hans Goudey fac27b1b6b Cleanup: Replace most used of SWAP macro with std::swap
Also remove / replace use of the math vector double swapping functions.
2024-01-31 21:12:16 -05:00
Hans Goudey 7fa5fc02b7 Cleanup: Move BLF headers to C++ 2024-01-31 14:04:56 -05:00
Hans Goudey f04bc75f8c Cleanup: Use std::string for some RNA function return values
This significantly simplifies memory management, mostly by avoiding
the need to free the memory manually. It may also improve performance,
since std::string has an inline buffer that can prevent heap
allocations and it stores the size.

Pull Request: https://projects.blender.org/blender/blender/pulls/117695
2024-01-31 17:08:09 +01:00
Hans Goudey 961783c444 Cleanup: Move BKE_deform.h to C++ 2024-01-29 19:04:13 -05:00
Sybren A. Stüvel b79419914a Anim: avoid moving/assigning bones to a linked bone collection
In the M/Shift+M popup menus (3D viewport, armature pose/edit mode),
disable menu items for operators that are owned by a linked armature.

You can only (un)assign bones to local bone collections (so local armature
or added via local library override).
2024-01-29 14:35:53 +01:00
Sybren A. Stüvel f0aa69ff3a Fix #117620: Crash when moving bones to linked bone collection
`add_or_move_to_collection_bcoll()` already checked for linked collections,
but the caller didn't properly do a `nullptr` check. Adding that check
fixed the crash.

The next commit will actually disable the menu for such collections, so
that it's clear in the UI that it cannot work.
2024-01-29 14:35:53 +01:00
Hans Goudey fb0d6198c0 Cleanup: Move remaining asset editors code to C++ namespace 2024-01-26 18:43:13 -05:00
Hans Goudey 9ab356fe6e Cleanup: Return Vector for View Layer objects and bases retrieval
This simplifies code using these functions because of RAII,
range based for loops, and the lack of output arguments.
Also pass object pointer array as a span in more cases.

Pull Request: https://projects.blender.org/blender/blender/pulls/117482
2024-01-24 18:18:14 +01:00
Hans Goudey d02d6ec4e5 Cleanup: Remove unnecessary keywords in C++ headers 2024-01-24 11:46:39 -05:00
Hans Goudey f5bb6ac8df Cleanup: Move armature_intern.h to C++ 2024-01-24 11:46:39 -05:00
Hans Goudey 02582213de Cleanup: Move BKE_layer.hh to C++ 2024-01-24 10:55:16 -05:00
Alexander Gavrilov c478235985 Anim: copy bone collection parenting and visibility in armature join.
When joining armatures, make sure to preserve parenting relations
of bone collections. Also, copy and update the visibility flags.

Pull Request: https://projects.blender.org/blender/blender/pulls/117406
2024-01-22 15:55:39 +01:00
Sybren A. Stüvel 784ff4abc0 Anim: armature edit mode undo now also handles bone collection root count
Armature Edit mode has its own undo handling, which didn't store the
number of root bone collections in the armature. Now it does.

An alternative would be to not store this in the undo step, but rather
loop over all bone collections to find the minimum `child_index`. This
would be linear in the number of bone collections, though, so I chose to
use a few more bytes of memory to make the undo system a little faster.
2024-01-22 13:34:25 +01:00
Sybren A. Stüvel 6b8c64fc69 Anim: create new bone collections as next sibling of active one
Bone collections created via the `bpy.ops.armature.collection_new`
operator now always become the next sibling of the active bone
collection. If there is no active one, the new one is added at the end
of the list as root.

This removes the `.parent_index` property of the operator, as it is now
always created relative to the active bone collection.
2024-01-22 10:34:30 +01:00
Bastien Montagne d8d44a62f7 Cleanup: Move `BKE_appdir.h` to full Cpp header `BKE_appdir.hh`. 2024-01-21 19:42:13 +01:00
Bastien Montagne 6a9d2212e4 Cleanup: Move `BKE_blender_copybuffer.h` to full Cpp header `BKE_blender_copybuffer.hh`. 2024-01-21 19:34:20 +01:00
Jacques Lucke 4b47b46f9c Cleanup: rename PIL to BLI
The term `PIL` stands for "platform independent library." It exists since the `Initial Revision`
commit from 2002. Nowadays, we generally just use the `BLI` (blenlib) prefix for such code
and the `PIL` prefix feels more confusing then useful. Therefore, this patch renames the
`PIL` to `BLI`.

Pull Request: https://projects.blender.org/blender/blender/pulls/117325
2024-01-19 14:32:28 +01:00
Hans Goudey 3e76a1a6c2 Cleanup: Move BKE_lib_id.h to C++ 2024-01-15 12:44:14 -05:00
Hans Goudey ca560cd15e Cleanup: Move BKE_undo_system.h to C++ 2024-01-15 12:44:13 -05:00