65 Commits

Author SHA1 Message Date
Campbell Barton
7c52aa1250 Fix #147530: Proportional factor from transform may exceed 1.0
The factor for transform data must be in the 0..1 range however
float imprecision could cause values above 1.0 to be set.

Resolve by clamping.
2025-10-07 22:40:34 +11:00
Philipp Oeser
23fcfa3e4c Fix #147070: Proportional editing even when disabled in object mode
This happened if proportional editing was enabled in editmode, not
having an active object plus being in object mode.

The transform system `convert_type_get` assumes
`TransConvertType_Object` if we dont have an active view layer object.

Corresponding code for proportional editing detection [in
`initTransInfo` & `saveTransform`] wasnt though (it used `toolsettings`
`proportional_edit` -- not `proportional_objects` -- in that case).

This is now corrected.

Probably caused by e91d581167

Pull Request: https://projects.blender.org/blender/blender/pulls/147193
2025-10-06 10:57:49 +02:00
Falk David
1122a05cb6 VSE: Scene Selector & Scene Time Synchronization
Implements the proposed design (with some modifications) in #135058.

## Sequencer Scene

This adds a new property called `sequencer_scene` to workspaces. This scene is used
by the video sequence editors in the current workspace for their context.
This is a first step towards "detaching" the VSE from the active scene in the window.

Each sequencer timeline editor shows the sequencer scene that is being used.
By default, when no sequencer scene is selected, the timeline and preview are empty.

Pressing the "new" button will add a new scene and assign it to the sequencer
scene for the current workspace.

## Contextual Playback

Pressing `Space` (by default) for starting the animation playback is now contextual:
depending on the context (where your mouse cursor is), the scene that is played back
might be different. E.g. with a 3D Viewport and a Sequencer open, pressing "play"
in the 3D Viewport will play the _active scene_ of the window, while pressing "play"
in the sequencer will play the _sequencer scene_.

## Time & Scene Synchronization

Additionally, this adds a toggle called "Sync Active Scene".
With the property turned on, the active scene & scene time in the window will be
synced with the time & scene of the current scene strip in the sequencer.

Note that this is _not_ bi-directional. The sequencer can change the active scene
and map time, but it's not possible the other way around since it one can have
multiple strips using the same scene (+camera, and even time!).

Currently this setting is exposed in the footer of the sequencer timeline as well
as in the workspace settings.

This allows for one of the core concepts that the story tools projects aims at: Working
in a scene (e.g. in the 3D viewport) while also working with the edit
(in the sequencer timeline).

## Some technical notes

* Undoing while playback is running will now cancel playback. This is to avoid the timer,
   that points to the scene and viewlayer that are playing, to get de-synced after loading
   the memfile undo step.
* When the sequencer scene is not the same as the active scene, we ensure it has
   a depsgraph.
* Normally, when a `NC_SCENE` notifier points to a specific scene, the notifier is dropped
   if that scene doesn't match the active one in the window. We now also check that it
   doesn't match the sequencer scene in the active workspace.
* When loading older files, we need to make sure that the active workspace in a window
   uses the active scene as the sequencer scene. This is to make sure that the file opens with
   the same sequences open.
* Tool settings are stored per scene. To make sure the sequencer uses the tool settings for
   the sequencer scene, the "context.tool_settings" and `CTX_data_tool_settings` members
   are overridden in the sequence editors.

Pull Request: https://projects.blender.org/blender/blender/pulls/140271
2025-08-25 11:58:17 +02:00
Campbell Barton
96b47a12fc Merge branch 'blender-v4.5-release' 2025-07-10 15:32:48 +10:00
Campbell Barton
68f559db5d Fix #141663: Wrong help-line displayed when rotating the camera
When transforming a camera show a helper line from the frame center.
2025-07-10 05:29:47 +00:00
Germano Cavalcante
ff9cc9c170 Refactor: Transform, reduce array bit size by removing TransData::ext
Now that the `t->data` and `t->data_ext` arrays have the same ordering,
it is no longer necessary to include each member of `t->data_ext` in
`t->data`. Access can be done using the same index.

Pull Request: https://projects.blender.org/blender/blender/pulls/141563
2025-07-08 20:47:56 +02:00
Germano Cavalcante
58af30f9b9 Refactor: Transform: Unify logic of "orient_axis" and "constraint_axis"
In rotation-based transform operations, the rotation axis can be
determined in two ways:
1. Through "orient_axis" (X, Y or Z)
2. Through "constraint_axis"

When the axis is obtained through the constraint, "orient_axis" is
ignored, and the angle may be negated depending on the view orientation
to match the mouse movement.

However, "orient_axis" never has its angle negated. Since the default
orientation is "View", the Z axis is inverted by default, aligning with
the mouse movement but not with the constraint axis.

This causes problems in the Redo Panel because the constraint fields
are hidden in the Rotation operation, so they need to be unset for the
Axis field to work. However, if you change the value of the Rotation
field, the object may have its rotation negated unexpectedly.

This issue was partially shown in #93078. Commit c30e6a37b0 attempted
to fix it by unsetting the constraint property when the Axis was
changed. However, this solution is incomplete: if the Axis is changed
and then reverted, the negative rotation issue reappears. In addition,
it has not been implemented in all operations.

This commit resolves the issue by reverting c30e6a37b0, aligning the
behavior of "orient_axis" and "constraint_axis", and unsetting
"constraint_axis" in `saveTranform`.

A downside of this solution is that it may break operators invoked from
Python that rely on "orient_axis" as the rotation axis, as the rotation
value now needs to be negated.

Pull Request: https://projects.blender.org/blender/blender/pulls/141101
2025-07-04 20:47:25 +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
Richard Antalik
4a11be2656 VSE: Add option to translate pivot point
This feature allows you to change postion of origin/pivot for images
without changing their position.

It is implemented as property of transform operator. It is activated
by pressing `Ctrl + .` shortcut.
Move Origin item was also added to transform menu.

Origin can be snapped to 3x3 grid on strip image. This represents
most usual anchor points.

Ref: #134251
Pull Request: https://projects.blender.org/blender/blender/pulls/134206
2025-05-06 05:16:56 +02:00
Campbell Barton
d616c87d03 Cleanup: spelling in comments (make check_spelling_*) 2025-03-21 11:51:50 +11:00
Campbell Barton
c690255184 Cleanup: rename "size" to "scale" in transform code
This value is mainly used for scale values, not an absolute "size".
2025-03-19 10:37:45 +11:00
Campbell Barton
9b9bddb3fd Merge branch 'blender-v4.4-release' 2025-03-07 20:12:48 +11:00
Campbell Barton
5849d9aec3 Fix crash using transform with grease pencil without an "area" 2025-03-07 20:11:51 +11:00
Richard Antalik
68abed543b Refactor: Remove module prefix form symbols in sequnecer namespaces
Remove
SEQ_ prefix for blender::seq namespace and
ED_sequencer for blender::ed::vse namespace

Pull Request: https://projects.blender.org/blender/blender/pulls/135560
2025-03-06 13:04:39 +01: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
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
Richard Antalik
2a44bdfbd0 Refactor: Use C++ types for vectors strip image transform code
All 2D vectors related to image transform code were changed to float2.
Previously, it was decided, that 4x4 matrix should be used for 2D
affine transform, but this is changed to 3x3 now.

Texture painting code did rely on `IMB_transform` with 4x4 matrix.
To avoid large changes, I have added function
`BLI_rctf_transform_calc_m3_pivot_min`.

Main motivation is cleaner code - ease of use of c++ API, and avoiding
returning values by arguments.

Pull Request: https://projects.blender.org/blender/blender/pulls/133692
2025-02-17 11:23:00 +01: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
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
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
Hans Goudey
129a2aa0f4 Refactor: Move region runtime data out of DNA
Pull Request: https://projects.blender.org/blender/blender/pulls/130303
2024-11-21 19:34:53 +01:00
Hans Goudey
75ab1c2daf Cleanup: Grease Pencil: Remove unused code and indirect include in header
- Remove now-unused runtime data from the legacy GP structs.
- Remove the `DNA_brush_types.h` include from the GP header.

Pull Request: https://projects.blender.org/blender/blender/pulls/130280
2024-11-14 16:59:55 +01:00
Hans Goudey
a804320138 Cleanup: Remove unused grease pencil legacy handling in some operators
See #123468.
2024-11-02 23:14:41 +01:00
Julian Eisel
d177388979 Sculpt/Paint: Tag brushes for unsaved changes for UI indication
Part of the brush assets project followups, see #116337.

Based on feedback, it seems important to indicate to the user when a brush has
unsaved changes.

There's no reliable updating mechanism we can use or hook into here, except for
RNA "update" callbacks. Brush data gets changed in many places in code, the only
way to do this seems manual tagging every time a brush property gets changed.
This PR introduces `BKE_brush_tag_unsaved_changes()` for this. I spent some time
going through all brush properties to ensure changes call the tagging function.

A known limitation with this will be that changes to dependencies won't be
indicated in the brush. E.g. Changing the texture attached to a brush won't make
the brush be indicated as changed.

The UI to indicate the changed brushes is being discussed still, see #128846.

Pull Request: https://projects.blender.org/blender/blender/pulls/128845
2024-10-11 22:08:14 +02:00
Germano Cavalcante
0ac66493c0 Fix: Error in previous commit: Snap to grid not updating size while navigating
`t->snap` varies per operator and does not update.
2024-10-08 23:29:57 -03:00
Lukas Tönne
a57206dd59 GPv3: Remove unused legacy editor functions for GPv2
Removes all unused functions in ED_gpencil_legacy.hh

Pull Request: https://projects.blender.org/blender/blender/pulls/128597
2024-10-07 18:21:28 +02:00
John Kiril Swenson
9dd2d7bd75 Fix: VSE snapping with edge panning
Ever since it was added to the VSE in e49fef45ce, edge panning would
break snapping -- edge panning a strip and then bringing it back would
cause snap code to trigger at incorrect locations. This is because the
edge pan system would update the `View2D` in `t->region->v2d.cur`, but
not mouse values, and so `t->values` would end up unchanged even while
the strip was moving.

e6a557952e fixed the issue for the node editor by recalculating mouse
input values when the view changed with `transformViewUpdate()`, but
since the code was separate from VSE, that fix did not get also get
applied here.

Although the code in `view2d_edge_pan_loc_compensate()` is mostly
identical between the two and so one possibility is to move it to
`transform_generics.cc`, adapting it to allow it to be used by both
spaces, custom transform data in the node editor additionally stores and
updates a `viewrect_prev` as mentioned in e040aea7bf, which VSE custom
data does not have. Since the fix is small enough and I don't want to
risk messing with other module code, I've opted to just copy the fix
over to VSE. If further bugs crop up in the future, we can consider
combining the code.

Also fix typo in `tranformViewUpdate()`.

Pull Request: https://projects.blender.org/blender/blender/pulls/126471
2024-08-20 07:11:45 +02:00
Hans Goudey
729bfe7800 Cleanup: Rename more paint variables
Avoid the one letter variable names and rename "tar" to "dst".
2024-06-10 09:04:35 -04: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
Brecht Van Lommel
b0b0510dbf Refactor: Access paint brush through accessor function
This will be used for brush assets in the future.

Ref #119801
2024-03-22 20:54:09 +01:00
Philipp Oeser
dbce0c3183 Cleanup: format 2024-03-11 11:40:04 +01:00
Philipp Oeser
7394a4042b Merge branch 'blender-v4.1-release' 2024-03-11 09:33:15 +01:00
Philipp Oeser
a8b9a58608 Fix #54468: crash calling transform operators with incomplete regiondata
If we run into NULL `RegionView3D` `regiondata` [which e.g. happens if
we just set `bpy.context.area.type = 'VIEW_3D'` without further actions
in the text editor prior to calling the transform operator], we can make
it gracefully work just by using `t->spacetype = SPACE_EMPTY` in
`initTransInfo`.

Similar check is already done in ba229e3859 (marked /* running in the
text editor */).

Transform code is smart enough to have fallback code in place that sets
matrices etc.

Pull Request: https://projects.blender.org/blender/blender/pulls/119205
2024-03-11 09:27:32 +01:00
Campbell Barton
91229f0e16 Cleanup: use full sentences for comments in transform & windowmanager 2024-03-09 23:28:03 +11:00
Brecht Van Lommel
0f2064bc3b Revert changes from main commits that were merged into blender-v4.1-release
The last good commit was 4bf6a2e564.
2024-02-19 15:59:59 +01:00
Campbell Barton
5c87dfd269 Cleanup: use BLI_time_ prefix for time functions
Also use the term "now" instead of "check" for clarity.
2024-02-15 13:15:56 +11: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
45e7827898 Clenup: Move BLT headers to Cpp.
Noisy but fairly straight forward.
2024-02-09 18:59:42 +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
Campbell Barton
be7f89a9f5 Cleanup: spelling in comments 2024-01-29 11:47:42 +11:00
Hans Goudey
02582213de Cleanup: Move BKE_layer.hh to C++ 2024-01-24 10:55:16 -05: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
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
Germano Cavalcante
78943edc5d Transform: Custom modifier to navigate while transforming
Discussed in #114646.

This commit transforms the "alt_navigation" option of the transform
operators into a new modal key item. "PASSTHROUGH_NAVIGATE"

In addition to cleaning up a lot of the code, it allows you to
customize the key chosen to navigate while transforming.
2023-11-09 21:33:34 -03:00
Richard Antalik
4d37fb80b1 Cleanup: Convert VSE headers from .h to .hh 2023-11-03 01:33:54 +01: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