Commit Graph

4600 Commits

Author SHA1 Message Date
Christoph Lendenfeld
3792c2720d Refactor: remove ED_ prefix from autokeying functions
No functional changes

Since the functions now live in a namespace,
they no longer need the prefix

as a result there are now 2 functions named
`autokeyframe_object`
which is fine because they take different parameters

If both are needed is for a future patch to investigate

Pull Request: https://projects.blender.org/blender/blender/pulls/113612
2023-10-12 16:32:29 +02: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
Christoph Lendenfeld
4a97668db3 Refactor: remove bAction* parameter from ANIM_apply_keyingset
No functional changes
`ANIM_apply_keyingset` had a parameter
for a `bAction *` that was never passed in.
Simplify code by removing that parameter

Pull Request: https://projects.blender.org/blender/blender/pulls/113588
2023-10-12 12:57:16 +02:00
Christoph Lendenfeld
555731f8aa Refactor: Move keyframing code to animrig
No functional changes.

Move the following keyframing functions to the animrig folder
* `insert_keyframe_direct`
* `insert_keyframe`
* `delete_keyframe`
* `clear_keyframe`

In order to disentangle the code I had to move the following as well
* `delete_keyframe_fcurve`
* `visualkey_can_use`
* `visualkey_get_values`

In order to sort the functions I made 3 files (and their header counterparts)
* fcurve.cc
* keyframing.cc
* visualkey.cc

The following functions I made public so they won't get duplicated
* `update_autoflags_fcurve_direct`
* `ANIM_setting_get_rna_values`

There are public keyframing functions that
I left in the editors/animation/keyframing.cc file
I'd like to limit the scope of this refactor, and then
clean up the moved functions before moving even more over

Part of #113278

Pull Request: https://projects.blender.org/blender/blender/pulls/113503
2023-10-12 12:46:47 +02:00
Germano Cavalcante
bdb0a05de5 Fix 'Transform Extend' not identifying the correct transformation side
Caused by c59ba19c0b.

`t->mouse.imval` was being used before initialization.
2023-10-11 13:12:51 -03:00
Germano Cavalcante
02ee5a7693 Fix Snap to Face ignoring back Clip Planes
Snap to Face ignoring some clip planes is an old behavior, but it is
not desirable as the snap is made to non-visible geometry.
2023-10-10 11:30:28 -03:00
Hans Goudey
976eaae02f Cleanup: Move BKE_object.hh to C++
Simplifies the fix to #111120, where the object bounds functions
may return a C++ type instead of `BoundBox`.

Pull Request: https://projects.blender.org/blender/blender/pulls/113462
2023-10-09 23:41:53 +02:00
Hans Goudey
4eeabd274e Cleanup: Access mesh bounds more directly
Simplifies the fix to #111120, because it is clearer that the threadsafe
Mesh access is used rather than the potentially problematic object-level
bounds access.
2023-10-09 22:31:31 +02:00
Germano Cavalcante
4abd59e204 Fix #113320: 'Automatic Constraint' not working in 2D editors
Caused by 586ffcd669

The condition `(t->flag & T_2D_EDIT)` went unnoticed.
2023-10-07 12:08:06 -03:00
Germano Cavalcante
cf93c16775 Fix #112580: Limit Constraint with 'Affect Transform' not working properly in 'World Space'
The problem is observed with the "Limit Distance" and "Limit Location"
constraints.

There is an incorrect usage of `td->mtx` and `td->smtx` when converting
`TransData` space from local to global.

In this case, the code is concatenating matrices instead of converting
the location component space.

Also, these matrices only inform the global transformation components
of rotation and scale. They do not include location.

Since the "Limit Distance" and "Limit Location" constraints only require
the location component, it is not necessary to convert the rotation and
scale components.

So, the solution is to convert the location component space instead of
concatenating matrices.

Pull Request: https://projects.blender.org/blender/blender/pulls/112601
2023-10-06 12:19:53 -03:00
Germano Cavalcante
586ffcd669 Fix 'Automatic Constraint' appearing in statusbar although not supported 2023-10-03 11:10:22 -03:00
Germano Cavalcante
c706de891c Fix snap to endpoint being represented as loose point
Since different symbols are implemented, there is a distinction between
endpoint and loose point, which was partially missing in the snap code
for Mesh.
2023-10-02 16:33:05 -03:00
Campbell Barton
fc8b1411cd Cleanup: correct struct comments & help text for batch loading utility 2023-09-28 14:28:12 +10: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
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
Sybren A. Stüvel
caf46c9fbb Refactor: anim, rename flag PCHAN_HAS_TARGET to PCHAN_HAS_NO_TARGET
Rename the `bPoseChannel::flag` `PCHAN_HAS_TARGET` to `PCHAN_HAS_NO_TARGET`
as that is actually the meaning of the flag (in the majority of the code).

Since the flag was so confusingly named, there were some mixups in the
armature overlay drawing code as well, which have been fixed now too.
2023-09-25 14:33:51 +02:00
Campbell Barton
e38ff7c06d Cleanup: use C++ comments for disabled code 2023-09-25 17:06:04 +10:00
Pratik Borhade
90f22739f7 Fix #112650: UI: Missing Header Status in Node Editor after Turning off Auto-offset
Caused by 42f8b49581
When auto-offset is OFF, garbage characters was displayed due to
uninitialized string.

Pull Request: https://projects.blender.org/blender/blender/pulls/112657
2023-09-23 12:37:25 +02: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
Hans Goudey
0fd0539f04 Cleanup: Rename grease pencil function to access layer at index
The plural was confusing when only one layer was returned.
2023-09-20 08:39:30 -04:00
Leon Schittek
42f8b49581 Fix: Show modal keymap for operators called inside macros
Display the modal keymap in the status bar for modal operators that
are called within macros. Most notably, the keymap for the transform
operator is displayed when it's called as part of the duplicate,
extrude, or loopcut operators or when moving nodes.

Pull Request: https://projects.blender.org/blender/blender/pulls/108027
2023-09-15 19:33:20 +02:00
Christoph Lendenfeld
bd305c8d18 Fix #110108: NLA absolute snapping
Before this patch the following snapping options were broken

* snap to markers
* snap to seconds with "Absolute Time Snap" turned on
* technically also snap to Frames with "Absolute Time Snap"
turned on (but made no real difference)

The issue was that each end of the strip would snap individually.
Potentially collapsing the strip.
This would happen e.g. when snapping to markers but with only 1 marker present.

This PR fixes the issue by finding out the closest snap offset and
shifting the strip as a whole by that amount.
That means either the start or the end of the strip will snap to the target.
By doing it that way the length of the strip is never changed by snapping.

This means when snapping to Seconds with "Absolute Time Snap" turned on,
the start of the strip might not be on a full second when the end is.

Pull Request: https://projects.blender.org/blender/blender/pulls/111984
2023-09-15 09:52:40 +02:00
Christoph Lendenfeld
8f1bd71992 Fix #112085: Not able to insert keys on subframes
When subframes were enabled, and the time cursor was at a subframe position,
the keying would still insert the key at the full frame.

This was because the value passed to the key insertion
functions was just the full frame value and not the subframe part.
Fixing it by using `BKE_scene_frame_get()` which
returns the floating point frame including the subframe part.

I've added unit tests to ensure that inserting keys at subframe values doesn't cause issues.

Pull Request: https://projects.blender.org/blender/blender/pulls/112131
2023-09-14 15:07:08 +02:00
Campbell Barton
b7f3e0d84e Cleanup: spelling & punctuation in comments
Also remove some unhelpful/redundant comments.
2023-09-14 13:25:24 +10:00
Amelie Fondevilla
127eee87ce GPv3: Duplicate keyframes
Implementation of the duplicate and move operator for grease pencil frames.

The `ACTION_OT_duplicate` operator now creates duplicates of the selected frames and stores them in the layer runtime data.
The `TRANSFORM_OT_transform` operator is updated to take care of these duplicated frames.

Pull Request: https://projects.blender.org/blender/blender/pulls/111051
2023-09-12 12:07:15 +02:00
Falk David
c0850237a1 Fix: "use_duplicated_keyframes" not found
`5ed35e` introduced the warning:
`RNA_boolean_set: TRANSFORM_OT_transform.use_duplicated_keyframes not found`

This was because the `TRANSFORM_OT_transform` did not pass
the `P_OPTIONS` flag to `Transform_Properties` to define
the `use_duplicated_keyframes` property.
2023-09-12 11:00:43 +02:00
Harley Acheson
08e63b5c26 Cleanup: Make format
Just formatting changes resulting from "make format"
2023-09-11 17:36:10 -07: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
Christoph Lendenfeld
a41da206cd Fix: Animation Editor snapping not working when using rotate or scale
This was introduced with #109015

The issue manifested in two ways.
* snapping did not work with rotate and scale
* the scale and rotate value would increment in steps instead of fluidly

This was caused because the snapping code would force the
mode to `SCE_SNAP_TO_INCREMENT` if the snapping
wasn't enabled for the given transform mode.

This snapping mode is not supported in the Animation Editors though,
causing the snapping `switch` to fall back to `default` which is to do no snapping.
My assumption is that this mode also causes the increments in the transform.

It would be good to support that in the future,
but for now this is just a fix to get the 3.6 behavior back.

Pull Request: https://projects.blender.org/blender/blender/pulls/112088
2023-09-08 11:34:17 +02:00
Campbell Barton
9e41eccc6e Cleanup: spelling in comments 2023-09-08 17:12:29 +10:00
Hans Goudey
c4cec77b91 Fix: Debug build error after previous commit
Remove debug asserts that don't serve a clear purpose besides testing
something that's clear from the called code, and require accessing mesh
data just for asserts.
2023-09-06 22:57:59 -04:00
Campbell Barton
90864d3fb8 Curve: operate on handles when the knot is selected
Change the behavior of transform and set-handle-type to operate on both
handles when the knot is selected.

This was an oversight in [0] which changed selection to select the knot
without the handles.

This makes curve bezier handles picking & transform match the Graph
Editor & grease pencil bezier curves.

This fixes issues transforming a bezier knot:

- Auto handles would be converted to "Aligned".
- Vector handles would be converted to "Free"
  with the vector handles being left in-place.

Resolves #111840.

Details:

Selecting only the knot vertex was done because the tweak tool no longer
de-selects when picking an already selected vertex to allow tweak to be
used to transform the selection (instead of always de-selecting all
before tweaking). Without this change, dragging a single handle required
manually de-selecting the knot and the opposite handle (3 clicks to
select a handle before dragging). Selecting only the knot solves this
but means transform needs to support tweaking a vertex (& it's handles)
without it's handles selected.

See design #96544.

[0]: 618f39fca2
2023-09-06 22:03:16 +10:00
Campbell Barton
8c85fd90cb Fix transforming a gpencil bezier vertex changing it's handle type
Selecting a gpencil bezier vertex and move it would change the handle
type when set to "Auto".

This happened because of a mismatch between transform flag use
and BKE_nurb_bezt_handle_test which would change the handle type
when only the vertex (knot) was selected.

Resolve by treating both handles as selected when the knot is selected.
2023-09-06 22:03:16 +10:00
Campbell Barton
78b6ed19f3 Curve: extend BKE_nurb_bezt_handle_test & BKE_nurb_handles_test
Replace use_handles with an enum that optionally uses handles
except when the vertex (knot) is selected in which case it behaves
as if both handles are selected.

Needed for nurb curves not to change handle type when only the
center point is selected (as is done in the graph editor).

No functional changes.
2023-09-06 22:03:16 +10:00
Campbell Barton
ccaafa318d Cleanup: negate handles_visible & name hide_handles
Match naming of curve transform conversion to avoid confusion.
2023-09-06 22:03:16 +10:00
Campbell Barton
1f01a64403 Cleanup: spelling in comments 2023-09-06 14:23:01 +10:00
Jacques Lucke
b5c89822ac RNA: return PointerRNA from rna create functions
There are a couple of functions that create rna pointers. For example
`RNA_main_pointer_create` and `RNA_pointer_create`. Currently, those
take an output parameter `r_ptr` as last argument. This patch changes
it so that the functions actually return a` PointerRNA` instead of using
the output parameters.

This has a few benefits:
* Output parameters should only be used when there is an actual benefit.
  Otherwise, one should default to returning the value.
* It's simpler to use the API in the large majority of cases (note that this
  patch reduces the number of lines of code).
* It allows the `PointerRNA` to be const on the call-site, if that is desired.

No performance regression has been measured in production files.
If one of these functions happened to be called in a hot loop where
there is a regression, the solution should be to use an inline function
there which allows the compiler to optimize it even better.

Pull Request: https://projects.blender.org/blender/blender/pulls/111976
2023-09-06 00:48:50 +02:00
Christoph Lendenfeld
93bf17f333 Fix: Warnings in transform_convert_nla.cc
No functional changes
The recent refactor patch introduced warnings on flag checks
2023-09-05 14:16:10 +02:00
Christoph Lendenfeld
4033f3bcc3 Refactor: Code indentation in transform_convert_nla.cc
No functional changes

`transform_convert_nla.cc` had a few `if`s within
for loops that could be inverted to remove the indentation.

In addition to that I extracted the snapping functionality
so the `if`s there can also be inverted and return.

Pull Request: https://projects.blender.org/blender/blender/pulls/111968
2023-09-05 13:01:51 +02:00
Christoph Lendenfeld
11fe57cab8 Animation: Move Snapping to Scene
Part of #91973

Moving the snapping code for the
* Graph Editor
* Action Editor
* and NLA editor

into the common system that lives on the scene.
This includes the Magnet icon for turning
snapping on and off.

The old settings translate to the new in the following way:
* `Frame Step` -> `Frame`
* `Second Step` -> `Second`
* `Nearest Frame` -> `Frame` + `Absolute Time Snap`
* `Nearest Second` -> `Second` + `Absolute Time Snap`
* `Nearest Marker` -> `Nearest Marker`

Since this moves the location of the snapping settings
from the editor to the scene, it changes the behavior.
Previously each editor could have different snapping
settings, where now they are all synced.

Pull Request: https://projects.blender.org/blender/blender/pulls/109015
2023-09-05 10:06:55 +02:00
Campbell Barton
0c26c84704 Cleanup: spelling in comments 2023-09-05 11:04:27 +10:00
Germano Cavalcante
2cead79747 Snap: Support occlusion of 'In Front' objects
This fixes #111767

`In Front` objects remain visible even if they are behind non
`In Front` objects.

It is to be expected then that the snap for them is not occluded as if
they were not `In Front`.
2023-09-04 19:05:48 -03:00
Campbell Barton
e8c812a307 Cleanup: spelling in comments, update dictionary 2023-09-03 21:35:07 +10:00
Harley Acheson
8779f92e67 Cleanup: Make format
Just changes resulting from Make format.
2023-09-01 11:09:12 -07:00
Germano Cavalcante
9c2e768f5b Snap: Show different symbols for different types
Add a set of symbols to improve visualization of different snap types.

- Circle: Represents snapping to a vertex.
- Two Aligned Lines: Represent snapping to an edge.
- Closed Aligned Square: Represents snapping to a specific part of an edge (center or perpendicular).
- Face-Aligned Circle with Midline: Represents snapping to a face.

Pull Request: https://projects.blender.org/blender/blender/pulls/109387
2023-09-01 17:08:07 +02:00
Germano Cavalcante
37bb00b245 Fix snap failing if target vertex is on same edge as the transformed one
7d54a756b9 did with only loose verties participating in the snap.
However, edges with a transformed vertices are ignored as well.
So some vertices may end up not participating in the snap.

Therefore, add then the vertices whose connected edge is being
transformed.
2023-09-01 11:40:33 -03:00
Germano Cavalcante
14a9c2b1aa Fix #111715: VSE: "Bounding Box Center" pivot point is the same as "Median Point"
The logic to calculate the bounds was missing.

Also add a notifier with `NC_SPACE | ND_SPACE_SEQUENCER` to update the
space.
2023-08-31 15:41:29 -03:00
Philipp Oeser
e46b87f4b1 Node Editor: show auto-attach status while moving
This was just giving the shortcut to toggle, but not giving the actual
status ("ON"/"OFF").

This was especially confusing in the following scenario:
- Alt-drag a node (to detach links)
- try to drop on a link (with Alt still held down) was not working
because the modal keymap would have actually toggled auto-attach to OFF

Pull Request: https://projects.blender.org/blender/blender/pulls/111739
2023-08-31 14:59:21 +02:00
Germano Cavalcante
a0b232c80d Fix #111548: Snap only working on some surface curve control points
The loop was ignoring ` nu->pntsv` in this case, resulting in only the
first point of each row being used for snapping.

This commit also simplifies the code by removing the no-snap limitation
when the curve only has 1 point.

This limitation existed because the curve is not visible in this case.

But this is contradictory for when the curve has loose points (which
are also not visible).
2023-08-30 14:49:51 -03:00