Commit Graph

4615 Commits

Author SHA1 Message Date
Hans Goudey
1cbd0f5a85 Refactor: Improve access to object data bounds
Currently object bounds (`object.runtime.bb`) are lazily initialized
when accessed. This access happens from arbitrary threads, and
is unprotected by a mutex. This can cause access to stale data at
best, and crashes at worst. Eager calculation is meant to keep this
working, but it's fragile.

Since e8f4010611, geometry bounds are cached in the geometry
itself, which makes this object-level cache redundant. So, it's clearer
to build the  `BoundBox` from those cached bounds and return it by
value, without interacting with the object's cached bounding box.

The code change is is mostly a move from `const BoundBox *` to
`std::optional<BoundBox>`. This is only one step of a larger change
described in #96968. Followup steps would include switching to
a simpler and smaller `Bounds` type, removing redundant object-
level access, and eventually removing `object.runtime.bb`.

Access of bounds from the object for mesh, curves, and point cloud
objects should now be thread-safe. Other object types still lazily
initialize the object `BoundBox` cache since they don't have
a data-level cache.

Pull Request: https://projects.blender.org/blender/blender/pulls/113465
2023-10-19 14:18:40 +02:00
Campbell Barton
e7e4e63313 Cleanup: spelling in comments, white-space in comments 2023-10-19 18:53:16 +11:00
Germano Cavalcante
6b001ea76c Merge branch 'blender-v4.0-release' into main 2023-10-17 14:53:45 -03:00
Germano Cavalcante
6bbad6c428 Fix #113801: "Snap to Same Target" don't work as expected
Introduced during snap code refactoring.

It seemed wrong to overwrite the calculated nearest distance based only
on the original distance.

But this is intentional, (the code could be improved since there are
unnecessary tests to detect the closest object).
2023-10-17 14:31:49 -03:00
Germano Cavalcante
5139a3a09f Merge branch 'blender-v4.0-release' into main 2023-10-17 11:46:45 -03:00
Germano Cavalcante
6ecef4d176 Fix crash when Transform Extend multiple NLA strips
`tdn` was being incremented even though it wasn't used, which led to
changes in memory outside the HEAP limits.
2023-10-17 11:46:10 -03:00
Christoph Lendenfeld
dcca6c2b8c Refactor: Remove nla_cache parameter from insert_keyframe
No functional changes.

The parameter was only passed in as `nullptr` or
as empty list that was immediately freed after without use.

Pull Request: https://projects.blender.org/blender/blender/pulls/113817
2023-10-17 11:48:29 +02:00
Germano Cavalcante
f20e38d422 Merge branch 'blender-v4.0-release' into main 2023-10-16 17:26:32 -03:00
Germano Cavalcante
bbf87ee78c Fix #113786: Snapping to vertex is broken, when instances are used in GN
Missed in ff4f14b21.

For GN instances, we should use `DupliObject::ob_data`.
2023-10-16 17:26:02 -03:00
Germano Cavalcante
47867549e8 Merge branch 'blender-v4.0-release' into main 2023-10-16 10:40:08 -03:00
Germano Cavalcante
6dda18269c Fix #113650: Vertex Creasing is using Mirror
`Vertex Crease`, like `Edge Crease`, is not supposed to use transform
symmetry.

So remove it.

(`Skin Resize` remains using symmetry since that case seems desirable.
See #84376)
2023-10-16 10:39:31 -03:00
Leon Schittek
d9225ac121 Merge branch 'blender-v4.0-release' 2023-10-14 10:07:09 +02:00
Germano Cavalcante
c634a15e85 Fix crash when canceling Vertex Crease with Mirror
Crash due to variables not initialized.
2023-10-13 19:14:42 -03:00
Christoph Lendenfeld
4050b0d6df Refactor: remove argument from ANIM_builtin_keyingset_get_named
No functional changes

`ANIM_builtin_keyingset_get_named` had a `KeyingSet *` argument
that was always passed as `nullptr`
This patch removes it to simplify the code.

Pull Request: https://projects.blender.org/blender/blender/pulls/113677
2023-10-13 15:40:42 +02:00
Christoph Lendenfeld
b753ef73a0 Refactor: convert ListBase of tRKS_DSource to Vector
No functional changes

The keying set code was passing around a list
of `tRKS_DSource` through a lot of functions.
It turns it this was just a ListBase wrapper around `PointerRNA`.

So to make it clearer what is passed around, I replaced the
`ListBase` with a `Vector<PointerRNA>`

To make the use of `ANIM_relative_keyingset_add_source` clearer
I made two functions out of it with different parameters.
Those can take the vector as a reference and
EITHER only an `ID *`
OR an `ID *`, `StructRNA *` and a `void *`

Pull Request: https://projects.blender.org/blender/blender/pulls/113675
2023-10-13 15:06:53 +02:00
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