Commit Graph

39 Commits

Author SHA1 Message Date
Campbell Barton
84694bf635 Cleanup: add inline array size comments and minor corrections 2025-05-23 14:03:20 +10:00
Jacques Lucke
578f935170 Nodes: support changing attached frame while transforming nodes
Currently, removing a node frame a frame is rather annoying. The `alt+P`
shortcut is hard to reach and probably not very intuitive. Furthermore, often
one only notices that one wants to remove a node from a frame after starting to
move the node. So one would have to put the node back down, detach it from the
frame and then start moving again.

This patch simplifies this entire process by adding a new shortcut that can be
used while dragging nodes. When `F` is pressed, the selected nodes are detached
from their parents. Alternatively, if the nodes are detached already, they may
be attached to the frame under the cursor.

Pull Request: https://projects.blender.org/blender/blender/pulls/138650
2025-05-15 20:54:29 +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
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
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
Hans Goudey
16fff2e49c Cleanup: Transform: Use C++ parallel_for to remove boilerplate
threading::parallel_for implements its own check to avoid
threading when the data length is below the grain size, and
its overhead is lower anyway, since it doesn't use a function
call for every element.

Pull Request: https://projects.blender.org/blender/blender/pulls/135316
2025-03-03 16:16:41 +01:00
Harley Acheson
46ddd76609 Merge branch 'blender-v4.4-release' 2025-02-28 12:38:10 -08:00
John Kiril Swenson
f874d46589 Fix: UI: Transform Feedback for Invalid Trackball
Patch #132957 added helpful UI feedback when attempting to rotate or
scale an object whose transforms are set to "only affect locations."
But it neglected to check for invalid trackpad rotations that are
affected the same way. This patch renames the original `HLP_ERROR` to
`HLP_ERROR_DASH` to distinguish it from a `HLP_ERROR` transform cursor
with no dashed line present, which matches trackball's normal state.

Pull Request: https://projects.blender.org/blender/blender/pulls/134653
2025-02-28 21:14:36 +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
Harley Acheson
40eadc75be UI: Transform Feedback for Invalid States
This adds support for Transform MouseInputMode INPUT_ERROR using a new
transform cursor HLP_ERROR (dashed line ending with WM_CURSOR_STOP.
This is shown when attempting an object rotation or scale when
transforms are set to "Affect Only Locations". At this time the status
bar is also cleared and an warning message is shown.

Pull Request: https://projects.blender.org/blender/blender/pulls/132957
2025-01-30 17:11:14 +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
Brecht Van Lommel
920e709069 Refactor: Make header files more clangd and clang-tidy friendly
When using clangd or running clang-tidy on headers there are
currently many errors. These are noisy in IDEs, make auto fixes
impossible, and break features like code completion, refactoring
and navigation.

This makes source/blender headers work by themselves, which is
generally the goal anyway. But #includes and forward declarations
were often incomplete.

* Add #includes and forward declarations
* Add IWYU pragma: export in a few places
* Remove some unused #includes (but there are many more)
* Tweak ShaderCreateInfo macros to work better with clangd

Some types of headers still have errors, these could be fixed or
worked around with more investigation. Mostly preprocessor
template headers like NOD_static_types.h.

Note that that disabling WITH_UNITY_BUILD is required for clangd to
work properly, otherwise compile_commands.json does not contain
the information for the relevant source files.

For more details see the developer docs:
https://developer.blender.org/docs/handbook/tooling/clangd/

Pull Request: https://projects.blender.org/blender/blender/pulls/132608
2025-01-07 12:39:13 +01:00
Hans Goudey
3d0988a719 Cleanup: Move some math C-API usage to C++ API
Mostly part of an attempt to remove some of the lesser-used
parts of the C math API.
2024-12-20 21:46:59 +01:00
Habib Gahbiche
35ea495bb6 UI: Nodes: Remove some snapping options
Compositor: UI: remove snapping to nodes.

Snapping nodes to other nodes behaves in a very unpredictable way, which makes most snapping options useless.

The patch removes the following:
- Snapping options `Node X`, `Node Y` and `Node XY`
- Menu `Snap Node Element`
- Menu `Snap Target`

New behavior:
- Activating `Snap` always acts as 'Snap to Grid'

Part of https://projects.blender.org/blender/blender/issues/128612

Pull Request: https://projects.blender.org/blender/blender/pulls/127667
2024-11-24 14:30:22 +01:00
Germano Cavalcante
dc653b94cc Cleanup: merge transform_data.hh into transform.hh
What's in one ends up mixing with the other. There's no need to keep
the two headers separate.
2024-11-18 17:13:35 -03:00
Campbell Barton
4df285ccd5 Cleanup: move function comments into headers or implementation notes
For C/C++ doc-strings should be located in headers,
move function comments into the headers, in some cases merging
with existing doc-strings, in other cases, moving implementation
notes into the function body.
2024-11-02 17:27:09 +11:00
Germano Cavalcante
97816b3936 Fix #129161: Snap Toggle turning on after confirming with 'Set Snap Base'
A smaller enum value was passed to ENUM_OPERATORS, causing bitwise-not
issues.
2024-10-18 14:29:11 -03: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
Campbell Barton
004c247670 Cleanup: different declaration names, use r_ prefix for return args 2024-07-29 13:01:10 +10:00
John Kiril Swenson
406554c11e VSE: Add snapping in preview area
Adds snapping in the VSE preview area.

Source points are the four corners and origins of all selected, visible
image quads. Targets can be preview borders, preview center, or
corners/origins of other strips.

Pull Request: https://projects.blender.org/blender/blender/pulls/122759
2024-07-06 15:24:52 +02:00
Harley Acheson
03cd8b359b UI: Edge Slide Status Display
While using Edge Slide show only changing values in the area header and
only keymap entries on the Status Bar

Pull Request: https://projects.blender.org/blender/blender/pulls/121585
2024-05-09 00:06:31 +02:00
Germano Cavalcante
f0479e915f Transform: Implement Snap to Grid mode
Addresses two improvements to `Snap to Grid` as suggested in #73993:
- Make 'Absolute Grid Snapping' a new Snap Mode
- Snap to Grid in Non-Side View performed at ground level

Implementation details:

- Snap to Grid has no cursor symbol, unless we are in `Set Snap Base`
  mode. Similar to the previous 'Absolute Grid Snap' behavior.
- In Non-Side view, Snap to Grid is performed at ground level.
- If `Snap Base` is `Closest`, Snap to Grid uses the transform pivot
  point instead. Similar to the previous 'Absolute Grid Snap' behavior.
- The "Absolute Grid Snap" option has been removed.

Pull Request: https://projects.blender.org/blender/blender/pulls/116109
2024-03-27 13:17:24 +01:00
Campbell Barton
91229f0e16 Cleanup: use full sentences for comments in transform & windowmanager 2024-03-09 23:28:03 +11:00
Germano Cavalcante
b4f1d15af6 Cleanup: generalize Vert Slide data with common C++ and transform types
Changes:
- Use C++ for Array e Vector types.
- Create methods to access or edit struct parameters.
- Use `TransData` to access the initial position of the vertex.

These changes will allow Vert Slide to be compatible with other
transform "convert_types".
2024-03-06 15:18:28 -03:00
Germano Cavalcante
2d50a41d77 Edge Slide: use snap system to check sliding vertex visibility
This is a different solution to #32068

The sliding edge occlusion test is done to prevent a non-visible
reference vertex from being used to calculate the factor direction.

This commit changes the behavior, but the difference is difficult to
notice.

The changes in behavior are:
- Other objects affect occlusion.
- Slide direction is used to test occlusion instead of edge.
- The reference point is now the point whose direction is visible and
  is closest to the mouse cursor.
2024-03-06 13:50:27 -03: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
9097f1c62d Cleanup: unhyphenate track-pad & thumb-stick
Both are typically written without hyphenation, add to local dictionary.
2023-12-15 22:57:34 +11: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
Campbell Barton
e7e4e63313 Cleanup: spelling in comments, white-space in comments 2023-10-19 18:53:16 +11:00
Germano Cavalcante
fb556c75df Snap: New icons
For Blender 4.0 we decided to support individual icons for different
snap elements.

This was originally contributed by Erik Abrahamsson as !107054 with
some contributions by myself (Germano).

This set of icons being simple geometric symbols, that should be
familiar to CAD artists.

Note that Face and Volume share the same icon (circle). This is
deliberate since they communicate a similar functionality - are not
aimed at precision snapping the same way the vertex or perpendicular
are.

Also note that later we should also try to change the icons shown in
the snap menu to match the symbols that the artists see in the preview
window.

———

On the decision process:

The version currently in main (and rolled back here) was an initial
attempt of aggregating more information to the icons (e.g., by aligning
the icons to the target edges) while making them more suitable to
Blender. After presenting both options to (parts of the) community,
there was nothing fundamentally broken found with either option, though
options diverged over personal preference.

With that in mind, in the latest UI module meeting it was agreed to use
the original proposal then.

This final call was proposed by Dalai Felinto on his role of
commissioner (stakeholder) for the snap polishing tasks (#73993) and
designer for the related Snap Base design #66484.

———

This commit reverts commit 9c2e768f5b.

The reverted icons (referred originally as minimalistic icons) may be
proposed later as a separate theme option.
2023-09-27 16:59:16 -03:00
Hans Goudey
867f99c2af Cleanup: Move depsgraph headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/110816
2023-09-22 03:18:17 +02:00
Falk David
5ed35e5665 Cleanup: Anim: Replace use of T_AUTOMERGE
In the animation transform code, `T_AUTOMERGE` was used
to indicate that the duplicated keys need to be merged.

In perparation of #111051, this no longer makes much sense because
in grease pencil we cannot have two keys in the same channel at the same
frame.

This PR replaces the `T_AUTOMERGE` flag in the animation code to
`T_DUPLICATED_KEYS` to indicate that the transform is being called
with duplicated keyframes.

Pull Request: https://projects.blender.org/blender/blender/pulls/111268
2023-09-11 14:43:35 +02:00
Hans Goudey
ffe4fbe832 Cleanup: Move editors headers to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/110820
2023-08-05 02:57:52 +02:00
Germano Cavalcante
2786680ad8 Cleanup: Remove unused struct
`TransCenterData` is no longer used since be60b3b239
2023-08-03 13:55:59 -03:00
Germano Cavalcante
f1d44dd64a Transform: Refactor: Use float vector type for 'TransInfo::mval'
In most cases float access is required for this member.
2023-08-02 15:35:09 -03:00
Germano Cavalcante
5ed14e9269 Transform: use screen mouse offset position for navigation
In the 3D View, after navigating, the initial cursor position was
updated based on the relative position of the cursor in 3D space.

Now the initial relative position is maintained but moved closer to or
further from the 2d center based on zoom.
2023-07-31 11:03:45 -03:00
Campbell Barton
52acf6a6ec Cleanup: correct file names in comments after C -> C++ renaming
Use back-tick quotes to differentiate these from plain text.
2023-07-31 13:02:30 +10:00
Campbell Barton
d82322f616 Cleanup: spelling in comments 2023-07-16 15:50:02 +10:00
Jacques Lucke
3a2f5fb9db Editors: move transform code to C++
Also see #103343.

Co-authored-by: Germano Cavalcante <germano.costa@ig.com.br>
Pull Request: https://projects.blender.org/blender/blender/pulls/110049
2023-07-13 17:59:52 +02:00