63 Commits

Author SHA1 Message Date
Campbell Barton
d1b76b6554 Cleanup: only use "r_" prefix for return arguments
Ref !146253
2025-09-14 11:08:50 +00:00
Germano Cavalcante
289adf8616 Merge branch 'blender-v4.5-release' 2025-07-07 11:56:35 -03:00
Sybren A. Stüvel
d4961dac0b Fix #141341: Assert using proportional editing in object mode
Remove `BLI_assert(tc->sorted_index_map);` calls. Add one special case
in the function that investigates whether there is any selected item in
`tc->data`.

Earlier, I've been quite liberal in spreading these asserts around, to
guard against code paths that should have originally sorted `tc->data`
but by mistake didn't create `tc->sorted_index_map`.

They've been removed now, as they seem to be causing more trouble than
they're worth: the "sorting selected first" behaviour is only explicitly
there for proportional editing. With proportional editing disabled,
`tc->data` **only** contains selected items, and those are trivially
sorted first.

By now `tc->foreach_index_selected` can work without `sorted_index_map`;
if it is `nullptr`, it will assume that we're in the trivial case, and
that the array items can just be visited in index order.

Pull Request: https://projects.blender.org/blender/blender/pulls/141386
2025-07-07 15:44:12 +02:00
Campbell Barton
776dbe942c Cleanup: spelling (make check_spelling_*) 2025-06-22 11:34:32 +00:00
Sybren A. Stüvel
de22f32656 Fix #140700: Blender 4.5 Crashes When Performing Loop Cut
Correct an oversight in df6d345bb4: without proportional editing, all
the transform data is "selected" by definition. This means that the
assumption "the selected data is sorted first in the array" is
trivially true, without calling any sorting function. So instead of
using the sorted index map in these cases, just fall back to regular
iteration.

To make the code handle this nicely, I made two "foreach" functions.
The first one transparently uses the sorted index map when available,
and performs regular iteration otherwise. The second function only
visits the selected items.

This makes the usage of these functions clearer, and the fact that
selected items are expected to be sorted first (either trivially or
explicitly) can be documented in a central place.

Pull Request: https://projects.blender.org/blender/blender/pulls/140720
2025-06-22 11:54:17 +02:00
Sybren A. Stüvel
df6d345bb4 Fix #139042: use index map instead of sorting transform system data
Avoid modifying the order of transform system data. Instead, create an
index map and use that to traverse the data arrays in sorted order.

The issue observed in #139042 stems from the assumption, in _some_ of
the code, that `tc->data[i]`, `tc->data_ext[i]`, and `tc->data_2d[i]`
all contain information about the same "transformable thing". Since
`tc->data` was sorted (by selection state and, optionally for
proportional editing, by distance) but the other arrays were not, this
caused issues.

The most obvious solution, sorting all arrays the same way, turned out
to be hard to do, as some elements in one array have pointers to
elements in another array. Reordering those arrays would therefore
also make it necessary to find and update those pointers.

Instead, I decided to implement a sorted index map. The arrays can
then be kept in their original order, and the index map can be used to
visit them in sorted order.

Pull Request: https://projects.blender.org/blender/blender/pulls/140132
2025-06-19 11:20:08 +02:00
Philipp Oeser
ac3afae380 Fix: uninitialized TransData center for Curves proportional editing
When proportional editing around individual origins is used, we would
end up with uninitialized TransData center for points in curves which
have nothing selected.

This is more or less harmless since the center is not even used in that
case (instead the center of the closest point found is used, see logic
in #set_prop_dist /#prop_dist_loc_get).

Still nicer to be clear about this, added some code comments which
hopefully make the situation clearer.

Ref. 1d0c11987f
Ref. #139101

Pull Request: https://projects.blender.org/blender/blender/pulls/139849
2025-06-06 08:09:32 +02:00
Philipp Oeser
c86f5c2a64 Fix #138545: Grease Pencil connected proportional editing wrong
It would not use topological distances.

This was the case for Grease Pencil, Curves were right though (even
though both use the same code `curve_populate_trans_data_structs` /
`calculate_curve_point_distances_for_proportional_editing`)

So that calculation is actually right, the thing that made it fail for
Grease Pencil was that `init_proportional_edit` was calling
`set_prop_dist` with the `with_dist` argument as `true` [this would
overwrite the already calculated dist with the "plain", "non-
topological" distance again... leading to wrong values being used in
`calculatePropRatio`]

So to resolve, skip the `set_prop_dist` alltogether if T_PROP_CONNECTED
is used. Done for both Curves and Grease Pencil and move into own block.
Legacy Curve get their own codeblock (with a comment where their
topological distances are calculated).

Pull Request: https://projects.blender.org/blender/blender/pulls/138588
2025-05-08 18:37:19 +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
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
Hans Goudey
1332c21581 Point Cloud: Implement proportional editing for transform operator
This is very simple since there is no connectivity between points.
2025-04-15 13:24:32 -04:00
Richard Antalik
a08246a1a2 Refactor: Move VSE code to namespaces
This PR creates 2 namespaces for VSE code:
- `blender::seq` for sequencer core code
- `blender::ed::vse` for editor code

These names are chosen to not be in conflict with each other.
No namespace was used for RNA.

Finally, file `BKE_sequencer_offscreen.h` was moved from BKE to sequencer.

Pull Request: https://projects.blender.org/blender/blender/pulls/135500
2025-03-06 06:22:14 +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
Hans Goudey
b4c9b3e87f Cleanup: Move transform editors module to C++ namespace
Pull Request: https://projects.blender.org/blender/blender/pulls/134701
2025-02-18 01:27:04 +01:00
Hans Goudey
cd04584412 Point Cloud: Implement transform operator
This ends up being very simple because point cloud has
no connectivity information and each element is just one
position.

Also implement the 3D transform gizmo.

The geometry deformation system isn't implemented in this
commit. That can be tacked later.
2025-02-16 23:36:04 -05: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
Campbell Barton
b9f055459a Cleanup: ensure trailing space around comment blocks 2024-11-27 19:01:00 +11:00
Hans Goudey
a8f41a618c Cleanup: Remove unused GP V2 transform, curve edit code
See #123468.

Pull Request: https://projects.blender.org/blender/blender/pulls/129731
2024-11-02 22:24:59 +01:00
Sybren A. Stüvel
61bda71083 Anim: Support slotted Actions in 'Push Down' NLA operator
Instead of calling `BKE_nlastrip_new()` (which, due to backward compat
reasons automatically picks a slot), the Push Down operator now calls
`BKE_nlastrip_new_for_slot()`, which explicitly assigns the given slot.

On top of that, the frame range of the slot is used to set the strip's
frame range (instead of the range of the entire Action).

Pull Request: https://projects.blender.org/blender/blender/pulls/128444
2024-10-04 16:20:43 +02:00
Sybren A. Stüvel
fff6e59dde Anim: when assigning Action, check its ID type and NLA tweak mode
When assigning an Action with the new API:

- check the Actions ID type (if it is a legacy Action), and
- check whether the ID is in NLA tweak mode.

This means that action assignment can fail, so the
`animrig::assign_action()` and `animrig::unassign_action()` functions
now return a `[[nodiscard]] bool`.

Part of `generic_assign_action()` has now also been shielded with an
`#ifdef WITH_ANIM_BAKLAVA` just to be sure.

This also includes a change in `BKE_animdata_free()`. That function now
first exits NLA tweak mode (if enabled) before freeing the Actions. This
makes it possible to simply un-assign the assigned Action, as all the
NLA tweakmode stuff has already been taken care of by the responsible
function.

Pull Request: https://projects.blender.org/blender/blender/pulls/128199
2024-09-27 15:43:02 +02:00
Sybren A. Stüvel
b952782a44 Refactor: Anim, move Action queries from BKE to the animrig::Action class
Move the following BKE functions to the `animrig::Action` class. Some of
those will be extended to support slots in a future commit; for now they
still operate on all F-Curves in the Action.

| Old                             | New                                 |
|---------------------------------|-------------------------------------|
| `BKE_action_frame_range_calc()` | `Action::get_frame_range_of_keys()` |
| `BKE_action_frame_range_get()`  | `Action::get_frame_range()`         |
| `BKE_action_has_motion()`       | `Action::has_keyframes()`           |
| `BKE_action_has_single_frame()` | `Action::has_single_frame()`        |
| `BKE_action_is_cyclic()`        | `Action::is_cyclic()`               |

Implementations have been copied from the BKE functions. The frame range
functions now return `float2` instead of requiring two `float *r_…`
return parameters.

The `has_motion` function is now renamed to `has_keyframes`, as that is
what the implementation was actually testing for.

The functions now no longer are null-safe. The BKE functions handled a
null action pointer, but IMO that doesn't make sense, and in none of the
call sites I could find where this would actually be valid.

No functional changes.

Ref: #127489

Pull Request: https://projects.blender.org/blender/blender/pulls/127512
2024-09-13 15:04:47 +02:00
Sybren A. Stüvel
3417934eff Anim: add Action Slot assignment to NLA strip
For an NLA strip to use a slotted Action, it needs to specify which slot
to use in that action. This is now handled by two new properties on the
strip in DNA & RNA: `action_slot_handle` and `action_slot_name`.

These serve the same purpose as their counterparts on the `AnimData`
struct.

Note that this commit does NOT add NLA evaluation support for slotted
Actions. It merely allows assigning them. Evaluation, tweak mode
support, etc. will be implemented in future commits.

Pull Request: https://projects.blender.org/blender/blender/pulls/127359
2024-09-12 14:08:16 +02:00
Sybren A. Stüvel
3fdc9e9637 Refactor: convert BKE_action.h to C++
Move the contents of `BKE_action.h` into `BKE_action.hh` and remove
C-isms.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/127407
2024-09-10 14:55:47 +02:00
Sybren A. Stüvel
636d83fbea Refactor: convert BKE_nla.h to C++
Rename `BKE_nla.h` to `BKE_nla.hh` and remove C-isms.

No functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/127395
2024-09-10 13:41:01 +02:00
Jacques Lucke
5861b078f7 Core: rename ID.flag and ID.tag values
Previously, values for `ID.flag` and `ID.tag` used the prefixes `LIB_` and
`LIB_TAG` respectively. This was somewhat confusing because it's not really
related to libraries in general. This patch changes the prefix to `ID_FLAG_` and
`ID_TAG_`. This makes it more obvious what they correspond to, simplifying code.

Pull Request: https://projects.blender.org/blender/blender/pulls/125811
2024-08-07 12:12:17 +02:00
Campbell Barton
91229f0e16 Cleanup: use full sentences for comments in transform & windowmanager 2024-03-09 23:28:03 +11:00
Bastien Montagne
de5451b112 Cleanup: Move BKE_anim_data header to be fully C++. 2024-02-28 11:51:03 +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
54618dbae3 Cleanup: Make BKE_global.h a Cpp header. 2024-02-10 18:25:14 +01:00
Philipp Oeser
568c99d191 Fix #117989: GPv3: Cannot move Node(s) in Geo Node Editor in 'Edit Mode'
The transform system reacts to `CTX_GPENCIL_STROKES` in a special way
that is only useful in `SPACE_VIEW3D`.
There was a similar case fixed in 23e9ebfdbd, but there would be
multiple other places to also check the spacetype.

So now do this more generalized and only ever set `CTX_GPENCIL_STROKES`
if we are in editmode (that check existed before) **and** in
`SPACE_VIEW3D`.

Pull Request: https://projects.blender.org/blender/blender/pulls/118042
2024-02-09 15:11:32 +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
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
02582213de Cleanup: Move BKE_layer.hh to C++ 2024-01-24 10:55:16 -05:00
Christoph Lendenfeld
5e28601d69 Anim: Separate keying flags
Splits the flag `..._FLAG_INSERTNEEDED` between autokey and
manual keying. The fact that this flag was shared between the two
systems has been the cause of issues in the past. It wouldn't
let you insert a keyframe even though you explicitly used an operator
to do so.

In order to be clearer what options are used where, the user preferences
have been reordered.

By default "Only Insert Needed" will be enabled for auto-keying, but not for manual keying.
The versioning code will enable both if it was enabled previously.

# Code side changes

The keying system has flags that define the behavior
when keys are inserted. Some of those flags were shared
between keying and auto-keying. Some were only used for
auto-keying.
To clarify that, prefix flags that used exclusively in one or the other
system with `AUTOKEY`/`MANUALKEY`

Also the flag name on the user preferences and the tool settings was renamed.
Previously it was called `autokey_flag`. To indicated that it is not only used
for autokeying, rename it `keying_flag`.

Fixes: #73773

Pull Request: https://projects.blender.org/blender/blender/pulls/115525
2024-01-19 16:26:10 +01:00
Hans Goudey
3e76a1a6c2 Cleanup: Move BKE_lib_id.h to C++ 2024-01-15 12:44:14 -05:00
Brecht Van Lommel
d377ef2543 Clang Format: bump to version 17
Along with the 4.1 libraries upgrade, we are bumping the clang-format
version from 8-12 to 17. This affects quite a few files.

If not already the case, you may consider pointing your IDE to the
clang-format binary bundled with the Blender precompiled libraries.
2024-01-03 13:38:14 +01:00
Bastien Montagne
3acb64e7ac BKE_main: move header to be a fully CPP one.
Pull Request: https://projects.blender.org/blender/blender/pulls/115681
2023-12-01 20:38:54 +01:00
Christoph Lendenfeld
1905667967 Refactor: Rename eAutokey_Flag enum
No functional changes.

Rename the `eAutokey_Flag` to `eKeyInsert_Flag`
to indicate that it is not only used for auto keying.
Also rename the enum items to better reflect what they are used for.

Pull Request: https://projects.blender.org/blender/blender/pulls/115295
2023-11-23 12:09:23 +01:00
Germano Cavalcante
e581dde40f Transform: remove restricted assert
`t-val` and `t->loc` can share same pointer, as long as `t->loc` is 3D.

This partially reverts 9dcf73c715
2023-11-17 08:55:27 -03:00
Hans Goudey
3d57bc4397 Cleanup: Move several blenkernel headers to C++
Mostly focus on areas where we're already using C++ features,
where combining C and C++ APIs is getting in the way.

Pull Request: https://projects.blender.org/blender/blender/pulls/114972
2023-11-16 11:41:55 +01:00
Hans Goudey
7b51d32dd9 Cleanup: Move BKE_modifier.h to C++ 2023-11-14 09:30:40 +01:00
Germano Cavalcante
9dcf73c715 Fix #114787: VSE: canceling move does not reset strip channel
Probably caused by ad01cdd7fc.

Once again, problems resetting values due to `td->val` and `td->loc`
sharing the same pointer.

This needs to be avoided, as when resetting it is always expected that
one will be 1D and the other 3D.
2023-11-13 19:30:12 -03:00
Falk David
23e9ebfdbd Fix: GPv3: Crash when transforming keyframes
Blender would crash when trying to move/duplicate, etc. some keyframes.
This was because the `convert_type_get` function in the transform code
would return the wrong transform type `TransConvertType_GreasePencil`
instead of `TransConvertType_Action`.
The fix makes sure that we only return the
`TransConvertType_GreasePencil` in the 3d viewport.
2023-10-25 10:24:35 +02:00
casey bianco-davis
e266b142f6 GPv3: Transform operators
This adds the keybindings, menu, and functionally for the edit mode transform operators to grease pencil v3.

The transform operation include:
 * translate, rotate, scale, change opacity, change radius

Pull Request: https://projects.blender.org/blender/blender/pulls/111836
2023-10-21 15:12:47 +02:00
Germano Cavalcante
fc66502e7a Cleanup: Deduplicate code
And prefer C++ vector types.
2023-10-20 10:13:58 -03:00
Christoph Lendenfeld
1f995917a9 Refactor: Replace autokey macros with functions
No functional changes

The following macros have been replaced with identically named functions
* IS_AUTOKEY_ON
* IS_AUTOKEY_MODE
* IS_AUTOKEY_FLAG

Pull Request: https://projects.blender.org/blender/blender/pulls/113610
2023-10-12 16:20:18 +02:00
Christoph Lendenfeld
a3831fe7af Refactor: Move autokeyframing functions to animrig
No functional changes

The following functions have been moved
`autokeyframe_cfra_can_key`
`autokeyframe_object`
`ED_autokeyframe_object`
`ED_autokeyframe_pchan`
`ED_autokeyframe_property`

they are all in a new file
keyframing_auto.cc
while the declarations are in
ANIM_keyframing.cc

The autokeyframe makros also have been moved

Pull Request: https://projects.blender.org/blender/blender/pulls/113607
2023-10-12 15:44:58 +02:00
Richard Antalik
86a0d0015a VSE: Improve retiming UI
Currently retiming is quite awkward, when you need to retime multiple
strips strips in sync. It is possible to use meta strips, but this is
still not great. This is resolved by implementing selection.

General changes:
Gizmos are removed, since they are designed to operate only on active
strip and don't support selection.
Transform operator code is implemented for retiming data, which allows
more sophisticated manipulation.
Instead of drawing marker-like symbols, keyframes are drawn to
represent retiming data. Retiming handles are now called keys. To have
consistent names, DNA structures have been renamed.
Retiming data is drawn on strip as overlay.

UI changes:
Retiming tool is removed. To edit retiming data, press Ctrl + R, select
a key and move it. When retiming is edited, retiming menu and
context menu shows more relevant features, like making transitions.
Strip and retiming key selection can not be combined. It is possible to
use box select operator to select keys, if any key is selected.
Otherwise strips are selected.
Adding retiming keys is possible with I shortcut or from menu.
Retiming keys are always drawn at strip left and right boundary. These
keys do not really exist until they are selected. This is to simplify
retiming of strips that are resized. These keys are called "fake keys"
in code.

API changes:
Functions, properties and types related to retiming handles are renamed
to retiming keys:
retiming_handle_add() -> retiming_key_add()
retiming_handle_move() -> retiming_key_move()
retiming_handle_remove() -> retiming_key_remove()
retiming_handles -> retiming_keys
RetimingHandle -> RetimingKey

Retiming editing "mode" is activated by setting `Sequence.show_retiming_keys`.

Pull Request: https://projects.blender.org/blender/blender/pulls/109044
2023-09-27 01:45:59 +02:00