Commit Graph

4597 Commits

Author SHA1 Message Date
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
Germano Cavalcante
9ec127bb70 Transform Snap: Deduplicate code that register the result
The `Nearest2dUserData` object is called in all cases, so move the
registration to its destructor.
2023-06-21 18:24:15 -03:00
Germano Cavalcante
3bbd99e1cb Transform Snap: Remove unnecessary member 2023-06-21 18:23:59 -03:00
Germano Cavalcante
046e5f72e6 Cleanup: Split transform_snap_object.cc into multiple files
Split into:
- transform_snap_object_armature.cc
- transform_snap_object_camera.cc
- transform_snap_object_curve.cc
tmp

tmp
2023-06-21 18:12:00 -03:00
Germano Cavalcante
f23aac659a Fix multiple snap of Vertex and Edge Perpendicular
Caused by c83e37d354.

The lambda variable is being changed to perpendicular, but the original
value needs to be used for vertex snap.
2023-06-21 17:08:38 -03:00
Germano Cavalcante
13beb4ce35 Fix snapping for Curve or Armature failing
Caused by c83e37d354
2023-06-21 14:22:39 -03:00
Germano Cavalcante
e9eb8b3cc4 Cleanup: Use BLI_timeit in C++ code
And prefer `std::cout` instead of `printf`.
2023-06-21 11:39:18 -03:00
Germano Cavalcante
c83e37d354 Cleanup: Organize snap functions into methods
The definition of `test_projected_vert_dist` has been moved to
`Nearest2dUserData::snap_point`, and the parameters accessed within the
object have been removed from the function.

Additionally, the definition of `test_projected_edge_dist` has been
moved to `Nearest2dUserData::snap_edge`, and the parameters accessed
within the object have been removed from the function.
2023-06-21 02:12:21 -03:00
Germano Cavalcante
b12ced210a Cleanup: Deduplicate transform snap code
This commit deduplicates the code for:
- Creating local projection matrix;
- Creating local clip planes;
- Testing BoundBox snap distance.

These common codes are repeated for each type of object
(Empty, Camera, Armature, Curve, Mesh, Editmesh...).

Now they have been unified in the creation of `Nearest2dUserData`.
2023-06-21 02:11:31 -03:00
Germano Cavalcante
3cfd9d8bb5 Cleanup: Reduce number of parameters in snapping functions 2023-06-21 02:09:23 -03:00
Germano Cavalcante
af63f05d17 Transform: Add utility for debug snapping time 2023-06-21 02:08:52 -03:00
Campbell Barton
472c461816 Cleanup: spelling in comments 2023-06-21 11:28:58 +10:00
Campbell Barton
25b46a5041 Cleanup: comment blocks 2023-06-21 11:28:56 +10:00
Campbell Barton
5a8d9b893c Cleanup: quiet shadow warning 2023-06-21 11:28:55 +10:00
Nate Rupsis
4268ac0ed9 Animation: NLA Vertical Reorder
Allow NLA strips to be vertically re-ordered. NLA strips can now be dragged through other strips, and locked tracks.

Co-authored-by: Sybren A. Stüvel <sybren@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/107990
2023-06-20 17:10:09 +02:00
Germano Cavalcante
cedec09d05 Fix #109130: Crash with Snap Project Individual
Caused by 3df2110abd

`dist_px` can be `nullptr`.
2023-06-19 14:26:58 -03:00
Germano Cavalcante
7764c87528 Cleanup: Transform Snap Object Code
Transform: remove unused members from 'SnapObjectHitDepth'

Also move the `short face_nearest_steps` member before the bit field.

And move 'void SnapData_EditMesh::clear()' definition to the source.

Pull Request: https://projects.blender.org/blender/blender/pulls/109132
2023-06-19 19:03:08 +02:00
Dalai Felinto
57c3c68ffb Cleanup: make format 2023-06-16 12:18:40 +02:00
Germano Cavalcante
fa31f8a0fb Fix snap being incorrectly occluded
Regression in 338c4ff03d.
2023-06-15 18:01:37 -03:00
Germano Cavalcante
338c4ff03d Fix error in 3df2110abd
Threshold was being lowered incorrectly.

This could cause occlusion errors.
2023-06-15 17:31:27 -03:00
Hans Goudey
f4124ee02d Cleanup: Move GeometrySet and components to proper namespace
Move `GeometrySet` and `GeometryComponent` and subclasses
to the `blender::bke` namespace. This wasn't done earlier since
these were one of the first C++ classes used throughout Blender,
but now it is common.

Also remove the now-unnecessary C-header, since all users of
the geometry set header are now in C++.

Pull Request: https://projects.blender.org/blender/blender/pulls/109020
2023-06-15 22:18:28 +02:00
Germano Cavalcante
3df2110abd Cleanup: various tweaks to the transform_snap_object code
This commit implements several changes aimed at enhancing the
readability of the transform snap object code.

The changes are:
- Reduce number of parameters in functions;
- Unify functions;
- Replace enum `eViewProj` with a bool;
- Remove unused members;
- Deduplicate code;

Pull Request: https://projects.blender.org/blender/blender/pulls/109012
2023-06-15 17:29:50 +02:00
Germano Cavalcante
e918cf343c Fix isolated Snap to Edge Perpendicular not working
Caused by 5621154185.

The Perpendicular Snap needs a `prev_co` to work.
But in `Snap With` `Closest` mode the `prev_co` is not calculated.
Thus, when isolated, the snap to Perpendicular is never done.

So this commit puts the `center_global` fallback back to `prev_co`.

Also, if `Snap Base Edit` is used when only the snap to
`Edge Perpendicular` is enabled. `Snap To` will be temporarily set to
`Vert`, `Edge`, `Face` and `Edge Midpoint`.
2023-06-15 11:30:16 -03:00
Iliya Katueshenock
1571be0a47 Cleanup: Use float2 in nodeToView and nodeFromView
Use 2D float to represent node positions.

Pull Request: https://projects.blender.org/blender/blender/pulls/108956
2023-06-15 16:04:23 +02:00
Jeroen Bakker
0809377789 Cleanup: Make format 2023-06-15 10:01:53 +02:00
Philipp Oeser
1097e33032 Merge branch 'blender-v3.6-release' 2023-06-15 09:46:27 +02:00
Philipp Oeser
d61d2e5f59 Fix #108911: Fcurve Proportional editing circle draws wrong
Since we scale the GPU matrix a certain way (in order to draw a round
circle even for different UI x/y scaling), we have to also compensate
with GPU matrix translation (instead of drawing the raw
frame/value as coords untranslated).

There might be ways to solve this differently (e.g. manipulating the passed
coords instead of the GPU matrix or having a version of imm_drawcircball
that can do this in a way that compensates UI view scaling), but this seems
to be the most straightforward.

Thx @mano-wii hinting at the way to do this with GPU matrix alone.

Should probably go into 3.3 LTS as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/108979
2023-06-15 09:45:22 +02:00
Germano Cavalcante
9265fa1eed Cleanup: Split 'transform_snap_object.cc' into smaller files
This commit splits the `transform_snap_object.cc` file into 4 files:
- `transform_snap_object.hh`
- `transform_snap_object.cc`
- `transform_snap_object_editmesh.cc`
- `transform_snap_object_mesh.cc`

The `transform_snap_object.hh` header, in addition to sharing common
types, allows functions defined in each of these files to be shared
between them.

This makes the code easier to read and simplifies maintenance.

Pull Request: https://projects.blender.org/blender/blender/pulls/108949
2023-06-14 20:08:08 +02:00
Hans Goudey
68c6402666 Cleanup: Use C++ accessor for mesh position attribute 2023-06-14 12:37:52 -04:00
Germano Cavalcante
23f4fe4af1 Merge branch 'blender-v3.6-release' into main 2023-06-14 11:50:37 -03:00
Germano Cavalcante
5b39f39695 Clenaup: Remove unreferenced formal parameters
This silences warnings.
2023-06-14 11:45:46 -03:00
Campbell Barton
ffdce441ee License headers: use SPDX-FileCopyrightText for source/
There are still some files that need to be manually updated due to
missing copyright dates.
2023-06-14 23:36:23 +10:00
Germano Cavalcante
cfede90082 Merge branch 'blender-v3.6-release' into main 2023-06-14 10:27:36 -03:00
Germano Cavalcante
c2ed9c39cd Fix #108958: Crash in edit mode when snapping is enabled
Caused by cad897de16

The crash happens because the `SnapData_EditMesh` is removed from the
map but still accessed afterwards.

However, after cad897de16, invalidating an object's unique snap date is
no longer required.
2023-06-14 10:25:34 -03:00
Hans Goudey
7d935f94f3 Cleanup: Grammar: it's vs its 2023-06-13 14:51:49 -04:00
Hans Goudey
e5ec04d73c Mesh: Move vertex/edge crease to generic attributes
Store subdivision surface creases in two new named float attributes:
- `crease_vert`
- `crease_edge`
This is similar to 2a56403cb0.

The attributes are naming conventions, so their data type and domain
aren't enforced, and may be interpolated when necessary. Editing tools
and the subdivision surface modifier use the hard-coded name. It might
be best if these were edited as generic attributes in the future, but
in the meantime using generic attributes helps.

The attributes are visible in the list, which is how they're now meant
to be removed. They are now interchangeable with any tool that works
with the generic attribute system-- even tools like vertex paint can
affect creases now.

This is a breaking change. Forward compatibility isn't preserved for
versions before 3.6, and the `crease` property in RNA is removed in
favor of making a smaller API surface area with just the attribute API.
`Mesh.vertex_creases` and `Mesh.edge_creases` now just return the
matching attribute if possible, and are now implemented in Python.
New functions `*ensure` and `*remove` also replace the operators to
add and remove the layers for Python.

A few extrude node test files have to be updated because of different
(now generic) attribute interpolation behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/108089
2023-06-13 20:23:39 +02:00
Philipp Oeser
2beb1bc38f Merge branch 'blender-v3.6-release' 2023-06-12 10:00:07 +02:00
Philipp Oeser
d75aeb03e5 Fix #108707: Parent space Transform ignores armature objects rotation
Seems like an oversight in 5c4b0c98d3.

Child bones would calculate their orientation from the parent bone local
alone, now multiply take the armature objects world transform into account as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/108755
2023-06-12 09:59:14 +02:00
Germano Cavalcante
5621154185 Transform: Remove current 'Snap Base' in 'Set Snap Base' mode
The current `Snap Base` was available and displayed to allow snapping
to `Edge Perpendicular`.

However, the usefulness of perpendicular snapping in `Set Snap Base`
mode is questionable and can sometimes cause inconvenience.

Also, removing the current `Snap Base` indicator (the `X` drawing)
makes the intention of the operation more apparent.

Therefore, this commit removes both the indicator and the effect of the
current `Snap Base` in `Set Snap Base` mode.

Pull Request: https://projects.blender.org/blender/blender/pulls/108776
2023-06-09 14:12:15 +02:00
Germano Cavalcante
0ed8195486 Fix assert failing after 4d6da30d16
Assert can be triggered if only `SCE_SNAP_MODE_FACE_NEAREST` is used.
2023-06-08 22:08:02 -03:00
YimingWu
116cbcbc86 Fix #108229: Wider tolerance shuffling NLA strips
In `transdata_get_time_shuffle_offset_side`, the tolerance for
terminating the loop is too tight, sometimes it will lead to a infinite
loop due to non-integral start/end values. Now fixed.

Pull Request: https://projects.blender.org/blender/blender/pulls/108257
2023-06-08 04:15:45 +02:00