Commit Graph

4487 Commits

Author SHA1 Message Date
Campbell Barton
32fb40fa76 Cleanup: use function style casts for C++ 2023-07-14 12:31:00 +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
Nate Rupsis
10428bd2b4 Fix #109787: filter out non Fcurve channels from nlatrack_truncate_temporary_tracks
## Overview

Adding ANIMFILTER_FCURVESONLY  filter to  nlatrack_truncate_temporary_tracks to fix index out of bounds crash.

Pull Request: https://projects.blender.org/blender/blender/pulls/110032
2023-07-13 16:09:57 +02:00
Jacques Lucke
3f33e0c6cd Cleanup: clang format in disabled code segments
This formats code that is disabled using `#if 0`. Formatting was achieved
by temporarily changing `#if 0` to `#if 1 /*something*/`, then formatting,
and then changing it back to `#if 0`.
2023-07-12 14:18:59 +02:00
Ray molenkamp
07fe6c5a57 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any blenkernel paths from INC
- Add a dependency though LIB

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/109939
2023-07-11 19:28:01 +02:00
Ray Molenkamp
04235d0e55 Cleanup: CMake: Modernize bf_blenlib dependencies
Pretty straightforward

- Remove any blenlib paths from INC
- Add a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109934
2023-07-10 22:04:18 +02:00
Ray Molenkamp
57ad866d81 Cleanup: CMake: Modernize bf_guardedalloc dependencies
Pretty straightforward

- Removes any guardedalloc paths from INC
- Adds a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109925
2023-07-10 18:44:19 +02:00
Ray Molenkamp
7cebb61486 Cleanup: CMake: Modernize bf_dna dependencies
There's quite a few libraries that depend on dna_type_offsets.h
but had gotten to it by just adding the folder that contains it to
their includes INC section without declaring a dependency to
bf_dna in the LIB section.

which occasionally lead to the lib building before bf_dna and the
header being missing, while this generally gets fixed in CMake by
adding bf_dna to the LIB section of the lib, however until last
week all libraries in the LIB section were linked as INTERFACE so
adding it in there did not resolve the build issue.

To make things still build, we sprinkled add_dependencies wherever
we needed it to force a build order.

This diff :

Declares public include folders for the bf_dna target so there's
no more fudging the INC section required to get to them.

Removes all dna related paths from the INC section for all
libraries.

Adds an alias target bf:dna to signify it has been updated to
modern cmake

Declares a dependency on bf::dna for all libraries that require it

Removes (almost) all calls to add_dependencies for bf_dna

Future work:

Because of the manual dependency management that was done, there is
now some "clutter" with libs depending on bf_dna that realistically
don't. Example bf_intern_opencolorio itself has no dependency on
bf_dna at all, doesn't need it, doesn't use it. However the
dna include folder had been added to it in the past since bf_blenlib
uses dna headers in some of its public headers and
bf_intern_opencolorio does use those blenlib headers.

Given bf_blenlib now correctly declares the dependency on bf_dna
as public bf_intern_opencolorio will get the dna header directory
automatically from CMake, hence some cleanup could be done for
bf_intern_opencolorio

Because 99% of the changes in this diff have been automated, this diff
does not seek to address these issues as there is no easy way to
determine why a certain dependency is in place. A developer will have
to make a pass a this at some later point in time. As I'd rather not
mix automated and manual labour.

There are a few libraries that could not be automatically processed
(ie bf_blendthumb) that also will need this manual look-over.

Pull Request: https://projects.blender.org/blender/blender/pulls/109835
2023-07-10 15:07:37 +02:00
Campbell Barton
09f1844d75 Cleanup: correct doxy-groups 2023-07-09 21:40:17 +10:00
Campbell Barton
2f2facef74 Cleanup: use BKE_action prefix, position return arguments last
- BKE_action_frame_range_get  (was BKE_action_get_frame_range)
- BKE_action_frame_range_calc (was calc_action_range)
- BKE_action_has_motion       (was action_has_motion)
2023-07-09 18:17:58 +10:00
Germano Cavalcante
3f90bb6a48 Fix transform updating during some navigation operations
Navigation operations, like those of the trackpad, are not modal and
therefore are confirmed on each call.

To prevent the transform operations from being updated in this case,
add a fake navigation flag.

The removal of this flag is postponed to the next call.
2023-07-07 21:27:12 -03:00
Campbell Barton
785bd13b9a Cleanup: spelling in comments 2023-07-05 14:09:33 +10:00
Germano Cavalcante
c0d230e0b8 Revert "Transform: Allow navigation by default"
This reverts commit d53862351d.

After conducting tests with artists at the studio, it was observed that
altering the Transform Modal Maps caused significant disruption due to
the heavy reliance on the "Proportional Editing" and "Automatic
Constraint" features.

Considering this, it is now deemed more beneficial to provide users
with the choice of adapting their muscle memory to the new changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/109660
2023-07-04 14:53:39 +02:00
Campbell Barton
9e26960b77 Cleanup: code-comments 2023-07-04 12:36:41 +10:00
Campbell Barton
bcdba3516b Cleanup: remove unused variable 2023-07-04 12:02:24 +10:00
Germano Cavalcante
5ea561b51c Cleanup: Use Vector and Matrices types in C++ 2023-07-03 16:20:52 -03:00
Germano Cavalcante
bc3ec100c2 Cleanup: Remove redundant code in Snap To Nearest
Result registration is already done in `SnapData::register_result`.
2023-07-03 16:20:52 -03:00
Germano Cavalcante
d0bbae8596 Fix #109641: Snapping doesn't respect Clipping Border
The clip planes in `rv3d->clip` were not being added.
2023-07-03 14:37:33 -03:00
Germano Cavalcante
6abf253689 Fix #109633: 'Project Individual Elements' for 'Vert/Edge Slide'
`Project Individual Elements` was never supported for `Vert Slide` and
`Edge Slide`, however, albeit erroneously, this option still affected
those operations.

In Blender 3.6 this situation of `Project Individual Elements`
affecting the result, has been "fixed". But users still preferred the
old behavior.

Therefore, instead of falling back to `Snap To Face`, support
`Project Individual Elements` for `Vert Slide` and `Edge Slide`.

This is more like how it worked previously.
2023-07-03 12:30:56 -03:00
Falk David
de95539ced Cleanup: Rename grease pencil modes to legacy
Renames `OB_MODE_EDIT_GPENCIL`, `OB_MODE_PAINT_GPENCIL`,  `OB_MODE_SCULPT_GPENCIL`,  `OB_MODE_WEIGHT_GPENCIL`, `OB_MODE_VERTEX_GPENCIL, and the context modes` to `*_LEGACY`.

Pull Request: https://projects.blender.org/blender/blender/pulls/109648
2023-07-03 15:15:54 +02:00
Germano Cavalcante
9d1f66c492 Fix 'optimize' directive usage on MSVC
"O" isn't an option.
2023-07-03 09:48:56 -03:00
Germano Cavalcante
1c17db7489 Fix error in debug build caused by 568fe85b94
The member `treedata_editmesh` was removed.
2023-06-30 14:24:55 -03:00
Germano Cavalcante
8cc418b6fc Fix Snap to Face Nearest not working properly if transformed
Local `init_co` and `curr_co` were being calculated incorrectly.
2023-06-30 12:44:35 -03:00
Germano Cavalcante
568fe85b94 BVH Utils: Remove member 'em' from 'BVHTreeFromEditMesh'
There is no need to pass `BVHTreeFromEditMesh` userdata if only
`BMEditMesh` is used in the callbacks.

And this code is only used in the snap system, with this change the
snap code is more simplified and organized.
2023-06-30 12:39:28 -03:00
Germano Cavalcante
efdbb57bb6 Cleanup: Hide the 'SnapCache_EditMesh' definition 2023-06-30 12:09:10 -03:00
Germano Cavalcante
6bf940d326 Cleanup: remove unnecessary callbacks
There is no need to create callback members for the snap system when
only one type of object is using them.

So remove the callbacks and inline the code.

This usually promotes optimization, but in this case, no change in
performance was observed.
2023-06-30 12:00:09 -03:00
Germano Cavalcante
e73a9a6a7d Fix #109519: Orbit Around Selection resets pivot if nothing is selected
Caused by 968ecf6f8b.

The value of the last pivot of the view should not be changed if there
is no selection.

The variable is static precisely because of this.
2023-06-29 21:04:51 -03:00
Germano Cavalcante
b6a534e41b Fix mouse offset of Set Snap Base returning original position
`Mouse Input::in val_unproj` was disregarded when resetting the initial
mouse position.

This caused the mouse to return to the previous position before the
`Set Snap Base` after navigating the 3D view.
2023-06-28 15:09:22 -03:00
Germano Cavalcante
ce7ee791b0 Fix Automatic Constraint using mouse position from before navigation
Axis "selection" gets messy if it doesn't use the same offset value
that is updated after navigating.
2023-06-28 14:14:58 -03:00
Germano Cavalcante
fc0e110e60 Fix #109433: Snapping occluding objects even in wireframe mode
The internal `use_occlusion_test` option was only being removed if it
was in conjunction with the `Snap to Face` option.

Both test occlusion and Snap to Face are conflicting. In wireframe mode
the objects are not occluded, but Snap to Face can prevent them from
being snapped.

The solution is to prioritize snapping to other non-Face elements but
still allow "Snap to Face" in X-Ray mode.
2023-06-28 10:34:43 -03:00
Germano Cavalcante
d53862351d Transform: Allow navigation by default
As suggested in #108669, the "Navigate during Transform" option has
been removed and this feature works by default.

Now if you press `G`, `R` or `S` to move, rotate or scale an object you
can also navigate in the viewport.

Note that this update modifies the default keymap.
Now pressing `Alt` is required for the following modals:
- `PROPORTIONAL_SIZE_UP`,
- `PROPORTIONAL_SIZE_DOWN`,
- `PROPORTIONAL_SIZE`,
- `AUTOIK_CHAIN_LEN_UP`,
- `AUTOIK_CHAIN_LEN_DOWN`,
- `AUTOCONSTRAIN`,
- `AUTOCONSTRAINPLANE`.

Pull Request: https://projects.blender.org/blender/blender/pulls/109388
2023-06-27 20:29:05 +02:00
Germano Cavalcante
597f9abcfa Snap: Refactor Face Nearest approach
- Use C++ types for matrices and vectors;
- Deduplicate code with `SnapData::register_result`;

This commit also improves the way of detecting supported snap types.
2023-06-27 12:49:55 -03:00
Germano Cavalcante
229ae63c6e Cleanup: Silence warning
```
warning: "DEBUG" is not defined
```
2023-06-27 12:49:41 -03:00
Germano Cavalcante
7d54a756b9 Snap: Optimization: Create BVHTree from loose vertices only
Since snapping to endpoints is already done when you snap to edges
together, there is no need to create a bvhtree with all the vertices.

Also use the appropriate endpoint definition for snap to armatures.
2023-06-26 14:04:03 -03:00
Germano Cavalcante
fcb2b99f2b Cleanup: Rename variables used in snap code
Many variables have been renamed to make their usage clearer in the
snap code.

- `color_line` -> `source_color`;
- `color_point` -> `target_color`;
- `loc_prev` -> `source_loc`;
- `loc_curr` -> `target_loc`;
- `normal` -> `target_normal`;
- `snap_elem_type` -> `target_type`;
- `snapElem` -> `target_type`;
- `Nearest2dUserData` -> `SnapData`;
- `SCE_SNAP_TO_VERTEX` -> `SCE_SNAP_TO_POINT` or `SCE_SNAP_TO_EDGE_ENDPOINT`;
- `SnapData_EditMesh` -> `SnapCache_EditMesh`;
- `sod` -> `em_cache`;

Also: make-format
2023-06-26 13:47:06 -03:00
Germano Cavalcante
9b1e56f013 Transform: Show Snap Base when adding multiple snap points
This is part of what was implemented in #109062

When adding multiple snap points (`A` key), the 'Snap Base' location no longer corresponds to the snap target point, so it becomes invisible.

Therefore, show the resulting `Snap Base` during this operation.

Pull Request: https://projects.blender.org/blender/blender/pulls/109379
2023-06-26 17:41:15 +02:00
Germano Cavalcante
c856d29e9f Fix assert in recent commit
It was supposed to be `!=` instead of `==`.
2023-06-26 11:20:41 -03:00
Germano Cavalcante
c02333f37e Fix snap to perpendicular acting on default Snap Base
Snap to Edge Perpendicular has been disabled in Set Snap Base.
2023-06-26 11:03:47 -03:00
Germano Cavalcante
bfe4fb92f9 Fix #109346: Strange snapping behaviour
The problem was caused because the `Nearest2dUserData::obmat_` member
was deallocated in derived classes even before the main class
destructor was called.

This is strange behavior and only seen in Mac or Linux Release builds.

The solution is to not rely on the destructor to register snap values.

So create a separate function.
2023-06-26 10:52:50 -03:00
Germano Cavalcante
9cbe156d6a Fix snap to origin of objects made behind camera
The clip plane start was being ignored in this case.
2023-06-25 10:30:16 -03:00
Germano Cavalcante
9876ff183f Merge branch 'blender-v3.6-release' into main 2023-06-23 18:26:53 -03:00
Germano Cavalcante
f2fb22b94b Fix snap normal not in world-space
The algorithm that transforms space from local normal to world space was incorrect.

The problem is only observed with Align Rotation to Target on objects
with shear transformation.
2023-06-23 18:23:31 -03:00
Germano Cavalcante
1ef9c16218 Cleanup: Rename SCE_SNAP_MODE_ to SCE_SNAP_TO_
Also rename:
- `SCE_SNAP_MODE_FACE_NEAREST` to `SCE_SNAP_INDIVIDUAL_NEAREST`
- `SCE_SNAP_MODE_FACE_RAYCAST` to `SCE_SNAP_INDIVIDUAL_PROJECT`

And arrange the enums in numerical order.
2023-06-23 17:16:10 -03:00
Germano Cavalcante
f1fa2ecbf5 Fix 'Set Snap Base' not working with 'Face Project' or 'Face Nearest' 2023-06-22 22:54:47 -03:00
Germano Cavalcante
77b061f641 Transform Snap: Convert callbacks to virtual methods in subclasses
This commit converts existing callbacks into virtual methods and moves
their associated members from the base class to custom implementations
in subclasses.

These callbacks, (previously used within the main struct), have been
replaced by pure virtual methods in the `Nearest2dUserData` class.

As a result, specific subclasses can now provide their own customized
implementations for these methods.
2023-06-22 01:11:08 -03:00
Germano Cavalcante
4d1593c4ad Transform Snap: Improve snap for bones
In order to better identify which is the normal of the point
(see #108711), it is interesting to identify which is the closest bone.

So, instead of testing the snap at each point and then each bone line,
test the bone lines first and after identifying the closest one, test
its points.

With the nearest bone identified, we can use its normal instead.
2023-06-21 21:22:30 -03:00
Germano Cavalcante
48ab99f54a Cleanup: Simplify transformation from normal to global space
Just multiply the original matrix without the translation
component.
2023-06-21 21:22:30 -03:00
Germano Cavalcante
93e008dd8b Transform Snap: Support 'Align Rotation to Target' for bone points
Align with the bone that the point is part of.

Ref #108711
2023-06-21 19:59:16 -03:00
Germano Cavalcante
dea93845af Fix #108711: Snap with Align Rotation to Target do not align rotation for Empties or Bone
For now it only supports the body of the bone.

Head and tail will be supported later.
2023-06-21 19:37:02 -03:00
Germano Cavalcante
4585c8b28d Transform Snap: Remove parameter and use a more descriptive name
`sctx` can be accessed internally.

And `clip_planes_enable` makes it clearer what this method does.

Also note that this function had been accidentally removed for Cameras.
2023-06-21 18:41:08 -03:00