Commit Graph

113 Commits

Author SHA1 Message Date
Campbell Barton
43af16a4c1 Cleanup: spelling in comments, correct comment block formatting
Also use doxygen comments more consistently.
2025-05-01 11:44:33 +10:00
Christoph Lendenfeld
d2f1b6570d Anim: Separate transform snapping flags in the driver editor
With the move to the new snapping system,
the snapping flags were no longer stored on the editor but on the scene.
While that is good for all editors that deal with animation,
it also affected the Driver Editor since that is effectively a Graph Editor.
However since the driver editor doesn't deal with frames,
it is unlikely that settings should be shared with other animation editors.

With this PR the Driver Editor gets it's own snapping flag,
which means snapping can be controlled without affecting
other animation editors.

This also removes snapping options
* Snap to markers doesn't make sense, there are no markers in drivers
* Snap to seconds also makes no sense

Only snap to frames, i.e. whole numbers is kept with the option
to snap directly to whole numbers or offset the current position
by a whole number.

Pull Request: https://projects.blender.org/blender/blender/pulls/136826
2025-04-15 12:35:18 +02:00
John Kiril Swenson
a1c7f6d3e1 Fix #136513: Add cursor snapping in VSE Preview
The bug was partially caused by the fact that
`translate_snap_increment_ex` would interpret sequencer-specific
snapping bit `SEQ_SNAP_TO_FRAME_RANGE` as `SCE_SNAP_TO_INCREMENT`. Add a
check to fix this.

Technically, #122759 never added snapping for cursors in the preview,
but we can take this opportunity to also add the support, which is
relatively simple.

Pull Request: https://projects.blender.org/blender/blender/pulls/136579
2025-04-02 00:21:17 +02: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
Bastien Montagne
dd168a35c5 Refactor: Replace MEM_cnew with a type-aware template version of MEM_callocN.
The general idea is to keep the 'old', C-style MEM_callocN signature, and slowly
replace most of its usages with the new, C++-style type-safer template version.

* `MEM_cnew<T>` allocation version is renamed to `MEM_callocN<T>`.
* `MEM_cnew_array<T>` allocation version is renamed to `MEM_calloc_arrayN<T>`.
* `MEM_cnew<T>` duplicate version is renamed to `MEM_dupallocN<T>`.

Similar templates type-safe version of `MEM_mallocN` will be added soon
as well.

Following discussions in !134452.

NOTE: For now static type checking in `MEM_callocN` and related are slightly
different for Windows MSVC. This compiler seems to consider structs using the
`DNA_DEFINE_CXX_METHODS` macro as non-trivial (likely because their default
copy constructors are deleted). So using checks on trivially
constructible/destructible instead on this compiler/system.

Pull Request: https://projects.blender.org/blender/blender/pulls/134771
2025-03-05 16:35:09 +01:00
Hans Goudey
d0a6189b50 Refactor: DRW: Centralize and clean up packed normals conversion
Move the code dealing with converting float3 to GPU normals
out of the vertex format header into a separate header. Use a
proper C++ namespace and remove duplication by only using
the more recently added C++ templated conversions.

Most of the diff comes from the removal of the indirect includes
from GPU_vertex_format.hh. A lot of files ended up mistakenly
depending on that.

Pull Request: https://projects.blender.org/blender/blender/pulls/134873
2025-02-24 16:08:30 +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
789737c917 Cleanup: Refactor VSE snapping code
- 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
2025-02-13 03:17:49 +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
Richard Antalik
30f3eaa2a5 Fix #133167: Scene snapping settings confilict with VSE
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
2025-01-19 20:56:56 +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
7c775c6f57 Cleanup: Move some node editors functions to C++ namespace
Pull Request: https://projects.blender.org/blender/blender/pulls/132873
2025-01-09 19:19:06 +01:00
Campbell Barton
d2d754be3f Cleanup: spelling in comments (make check_spelling*)
- Back-tick quote math expressions so differentiate them
  from English.
- Use doxygen code blocks for TEX expressions.
2025-01-04 16:26:39 +11:00
Gerard Taulats
f7aa58dbab Fix #132062: Proper Snap to Volume memory free
Resolve MEM_new/MEM_freeN mismatch.

Pull Request: https://projects.blender.org/blender/blender/pulls/132138
2024-12-19 21:05:19 +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
1cc113dd5c Refactor: Transform - Remove the member 'TransData::ob'
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.
2024-11-18 17:13:34 -03:00
Germano Cavalcante
b4154c6a0e Fix #130078: Snap to Grid ignored if occluded in Add Object Tool
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
2024-11-11 14:26:52 +01: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
Germano Cavalcante
56c98046a5 Fix #122635: Precision mode not working with Snap to Grid
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.
2024-10-08 22:17:36 -03:00
Germano Cavalcante
ae37656478 Fix #128764: Moving keys in the animation editors enables the 3D view's snap toggle
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.
2024-10-08 19:17:51 -03:00
Germano Cavalcante
304b3e026a Fix: Snap grid point of Rotate operator is closest to the constraint axis
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.
2024-10-01 15:17:01 -03:00
Germano Cavalcante
68c3517871 Fix: 'Snap to Grid' defaults to 'Center' instead of 'Median' when 'Closest' is selected
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'.
2024-09-28 17:45:34 -03:00
Germano Cavalcante
0dad3bdfa7 Fix #123179: can't select multiple snap target elements in UV Editor
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
2024-07-26 14:59:13 +02: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
Germano Cavalcante
4690c69a65 Fix #122787: Grid snap in UV Editor also snaps to vertices
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.
2024-06-07 17:58:45 -03:00
Hans Goudey
935666a622 Fix #120104: Snap ignores evaluated geometry bounds
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.
2024-04-01 11:01:19 -04:00
Germano Cavalcante
ea3f938c07 Fix #120109: Grid snap crash when locking axis before base selection
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.
2024-04-01 11:22:03 -03: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
Hans Goudey
8b514bccd1 Cleanup: Move remaining GPU headers to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/119807
2024-03-23 01:24:18 +01:00
Germano Cavalcante
a56a975760 UV: Enable 'Set Snap Base' feature
Just like for objects in 3D View, UVs can also benefit from the
`Set Snap Base` feature (key `B`).
2024-03-12 14:35:52 -03:00
Campbell Barton
91229f0e16 Cleanup: use full sentences for comments in transform & windowmanager 2024-03-09 23:28:03 +11:00
Kyler Kelly
060174cf14 Transform: customizable rotation snap increment values
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
2024-03-09 16:57:12 +11:00
Germano Cavalcante
d37328840a Fix #119107: assert triggered when snapping with constraint in UV editor
This assertion is incorrect regardless.
2024-03-05 23:36:28 -03: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
5aaadebbe4 Cleanup: Make BKE_scene.h a full Cpp header. 2024-02-10 19:16:25 +01:00
Hans Goudey
9ab356fe6e Cleanup: Return Vector for View Layer objects and bases retrieval
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
2024-01-24 18:18:14 +01: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
Campbell Barton
6f3702740b Cleanup: order checks to skip redundant function calls 2024-01-15 22:57:28 +11:00
Alexander Gavrilov
4fe6f0b271 Fix: frame snapping for the time extend transformation mode
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.
2024-01-08 14:18:55 +01:00
Christoph Lendenfeld
86555838f1 Fix #116367: Scale snapping not working in Graph Editor
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
2024-01-04 14:03:57 +01:00
Brecht Van Lommel
d377ef2543 Clang Format: bump to version 17
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.
2024-01-03 13:38:14 +01:00
Philipp Oeser
f2cd1873ea Fix #116275: Snap (align to target) crash without valid target location
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
2023-12-18 14:18:39 +01:00
Hans Goudey
14e3523ac2 Refactor: Further improvements to geometry bounds
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
2023-11-27 16:14:49 +01: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
Brecht Van Lommel
7b26c3d517 Merge branch 'blender-v4.0-release' into main 2023-11-09 18:24:05 +01:00