- Use new blender::transform namespace, to reduce verbosity
- Move snap_data allocation upstream, and use unified logic:
No points? Free data.
- Snap points are stored in Vector instead of Array to avoid
incrementing index.
- Point counting functions are removed. Vector size is not reserved,
since adding 10K points takes less than 1ms (AMD 5950X)
- Functions are renamed to avoid overly long names and make them as
distinct as possible.
New function naming scheme is:
`<what is done>_<sources/targets>_<timeline/preview>_<subcategory>`
for example `points_build_sources_timeline_retiming`.
Pull Request: https://projects.blender.org/blender/blender/pulls/134308
Enabling `use_snap_rotate` in 3D viewport caused rotation in sequencer
to apply snapping. Rotation snapping was using mixed snapping functions,
which aren't implemented in sequencer.
Ignore affect rotation/scale tool setting property and force increment
snapping to be used with these transform modes.
Pull Request: https://projects.blender.org/blender/blender/pulls/133272
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
This member was only really used by `transform_convert_object.cc` and
`transform_convert_object_texspace.cc`.
So instead of using a super-specialized member, use `TransData::extra`
instead.
The snap cursor internally snaps to the Face to define the occlusion of
the Grid or to calculate the "Surface" orientation set by the tool.
Even though this is not the snap point enabled by the user, this
internal Snap to Face takes precedence over the Snap to Grid that is
enabled by the user.
To solve this, the solution is to do a second snap test but now only to
Grid and using the hit point as a reference for the closest grid.
Also fixes Absolute Increment Snap not being detected as Grid by the
tool.
Pull Request: https://projects.blender.org/blender/blender/pulls/130092
This introduces partial functionality of Precision mode to 'Snap to
Grid'.
However, it behaves differently from 'Absolute Grid Snap', as it lacks
smooth mouse movement.
Precision mode is now available specifically for Transform operations.
The issue occurred because the code block that read the snap flag was
out of sync with the code block that saved the flag.
The solution was to centralize snap flag handling in the
`transform_snap_flag_from_spacetype_ptr()` function. This function
retrieves the appropriate snap flag and property based on the editor
type, eliminating the need for repetitive conditional checks and
ensuring that the correct snap flag is set for each editor.
The snap-to-grid constraint in the rotation operation should not be
limited to the grid closest to the constraint axis, as this restricts
rotational freedom.
The 'Closest' 'Snap With' option does not work well with 'Snap to Grid'
due to the unpredictable nature of this 'Snap With' option. That's why
another option is used in this case.
The option chosen in this case is the same one that was used in
'Absolute Grid Snap', that is, 'Median'.
Missed after 'Set Snap Base' commit.
Just like in 3D View, UV editing can also benefit from selecting
multiple snap target elements.
The C++ code was already done, it was only necessary to edit the
interface.
Pull Request: https://projects.blender.org/blender/blender/pulls/124986
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
The `Snap to Grid` and `Snap to Vertex` modes were being mixed if
either mode was enabled.
Support for mixed snap modes doesn't yet fully work for UVs.
Previously the bounds were accessed on the original object.
That used to implicitly get the evaluated geometry's bounds,
but now that is an explicit choice.
The functionality of snap with constraints relies on the position of
the transformed object.
Previously, snap to grid with constraints was restricted to the Move
operation.
Consequently, the 'Set Snap Base' mode, as well as other transformation
modes, failed to compute the moved position.
As a result, it lacked support for snap to grid with constraints and
would even crash under such circumstances.
The solution involves eliminating the reliance on the Move operator and
instead calculating the position based on mouse position.
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
Add two snapping increment options: a regular value
(activated with Ctrl) and a precise value (activated with Ctrl+Shift).
These values are separate for 2D and 3D views.
Ref !118760
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
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
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
The graph editor supports an Extend transformation mode, which is
essentially Move that only affects keyframes either before or
after the current frame, based on the mouse cursor position.
This fixes a bug in this mode where it doesn't respect the snap setting.
The issue was that the "Affect" options from the 3D viewport
were also used for the Graph Editor.
This was discussed in the Animation & Rigging module meeting.
https://devtalk.blender.org/t/2023-12-21-animation-rigging-module-meeting/32748
The consensus was that the Animation Editors should have their own copy of the "Affect" flags.
For this commit I opted for a more immediate solution that ignores the "Affect" flag in the animation editors.
The adding of the flag can be left for a feature PR.
Pull Request: https://projects.blender.org/blender/blender/pulls/116781
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.
Caused by 9c2e768f5b
Since above commit, drawing of the normal is not done in
`ED_view3d_cursor_snap_draw_util` anymore [that function checked the
existence of a valid target location], now add the check back.
Pull Request: https://projects.blender.org/blender/blender/pulls/116292
Implement the next phases of bounds improvement design #96968.
Mainly the following changes:
Don't use `Object.runtime.bb` for performance caching volume bounds.
This is redundant with the cache in most geometry data-block types.
Instead, this becomes `Object.runtime.bounds_eval`, and is only used
where it's actually needed: syncing the bounds from the evaluated
geometry in the active depsgraph to the original object.
Remove all redundant functions to access geometry bounds with an
Object argument. These make the whole design confusing, since they
access geometry bounds at an object level.
Use `std::optional<Bounds<float3>>` to pass and store bounds instead
of an allocated `BoundBox` struct. This uses less space, avoids
small heap allocations, and generally simplifies code, since we
usually only want the min and max anyway.
After this, to avoid performance regressions, we should also cache
bounds in volumes, and maybe the legacy curve and GP data types
(though it might not be worth the effort for those legacy types).
Pull Request: https://projects.blender.org/blender/blender/pulls/114933
Restoring the behavior while transforming keys and pressing `Ctrl`
The regular snapping code has the feature that
when you press `Ctrl` you can toggle the snapping on and off.
Prior to 4.0 the snapping for the Graph Editor used a
completely different system, including a different flag to toggle snapping.
Because of that, the flag that the regular snapping
code uses was never set by default. So the system thought it was disabled.
Now when you press `Ctrl` you would enable that
flag and the snapping code would run.
It would snap to increments because that is the mode that
is returned for the Graph Editor space type.
(Note that this is the mode of the generic snapping
system, not of the Graph Editor specific one)
However at the same time, doing that would disable the
Graph Editor specific snapping code.
So the snapped values from the original system would bubble through.
This did not occur in the Dope Sheet and NLA Editor,
because those never returned a snapping mode.
Those still have a different behavior to 3.6 where they
now snap to seconds, instead of not snapping at all.
Pull Request: https://projects.blender.org/blender/blender/pulls/114607
The last good commit was 8474716abb.
After this commits from main were pushed to blender-v4.0-release. These are
being reverted.
Commits a4880576dc from to b26f176d1a that happend afterwards were meant for
4.0, and their contents is preserved.
Caused by bd305c8d18
`snap_transform_data` adds an offset to each element being transformed.
However, this seems to only work for Move and Extend transformations.
Therefore, the solution is to make the NLA snapping system more generic.
Pull Request: https://projects.blender.org/blender/blender/pulls/113554
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
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.