WIP: all of my pending patches. #104456

Draft
Alexander Gavrilov wants to merge 7 commits from angavrilov/blender:pending-combined into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

7 Commits

Author SHA1 Message Date
Alexander Gavrilov 390349fa1c Merge branches 'dev-shapekey-locking-gproject', 'pr-shapekey-smoothing', 'pr-shrinkwrap-tproj' and 'pr-undo-fixes' into pending-combined
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
2024-02-05 21:13:04 +02:00
Alexander Gavrilov 65221d6e63 Bone Overlay: support bone wireframe opacity depth fade.
Add an option that allows fade based on the depth from the camera,
using exponential decay with the slider specifying the 'half-life'
depth. This is intended as a way to automatically hide bones
in distant parts of the mesh while focused on a specific part.
2024-02-05 21:13:01 +02:00
Alexander Gavrilov 8ca49d2e3a Fix undo overreach in various paint modes for #69760 and related.
This tries to fix undo overreach on selection of vertex groups,
shape keys, uv maps, colors and attributes in various modes.

- The Vertex Paint mode is now a subtype of Sculpt, so it should
  use a sculpt undo step on entering the mode, and property changes
  shouldn't write undo steps.
- Sculpt undo modes were deliberately over-undoing color attribute
  selection changes for some reason.
- The Weight Paint mode uses memfile, so it should save steps
  for property changes, except for those excluded from undo,
  e.g. by bc0a6b0400.
- If a memfile undo step happens anyway for some reason in sculpt
  and vertex paint modes, immediately following property changes
  to object and mesh datablocks should also push to avoid over-undo
  if the immediately following scuplt step is reverted (unrelated
  ones like materials or scene seem safe).
2024-01-30 18:18:18 +02:00
Alexander Gavrilov a13c2f9e50 Mesh Edit: implement an operator to smooth shape key deformation.
Similar to the difference between Corrective Smooth and simple Smooth
modifiers, when editing shape keys it sometimes makes sense to smooth
the deformation defined by the key rather than the final shape.

This implements a simple shape key smoothing operator, accessible
via the Vertex menu next to Blend From Shape. The operator applies
a simple iterative smoothing process (identical to the one implemented
by the Smooth tool) to the offsets of vertices from the relative basis
key rather than their positions.

In order to provide more flexibility for dealing with shape keys
intended to be used in conjunction with other ones, the operator
provides an option to modify the relative basis used for smoothing
via selecting another key. The following modes are supported:

Only Active Key:
  The default mode smoothes the deformation of the key itself.
  The additional reference key is not used.

Include Key:
  Includes the deformation of the reference key into the smoothing.

  This can be used when the key currently being edited is intended to
  be applied on top of another one to smooth their combined deformation.

Exclude Key:
  This excludes the deformation of the reference key from smoothing.

  Intended for the opposite case of smoothing the difference between
  two keys being intended to be used alternatively to each other.

Relative To Key:
  This effectively overrides the Relative To setting of the active key,
  simply replacing the basis key for the purpose of this operator only.

  If both keys have the same Relative To basis, this mode behaves
  the same as Exclude Key.

Like ordinary Smooth, the operator supports locking smoothing of certain
axis directions. In addition, it supports restricting direction based on
the vertex normal to allow separately smoothing volume and topology.
2024-01-30 12:21:34 +02:00
Alexander Gavrilov 87217dfbe1 Sculpt: check shape key locks in the gesture project operation. 2024-01-19 17:06:56 +02:00
Alexander Gavrilov 228a176371 Sculpt: refactor gesture operations to allow cancelling.
The sculpt gesture project operation fulfills the criteria for
checking shape key locks, which implies being able to cancel
the operation if the check fails.

Implementing this requires splitting the gesture begin callback
into two parts that are called before and after the undo push
begin call, and supporting a return value to allow the callback
to signal that the operation should be cancelled.
2024-01-19 17:06:56 +02:00
Alexander Gavrilov 2ee7bba933 Shrinkwrap: fix stability of the Target Normal Project mode.
This mode works by using an iterative process to solve a system
of equations for each triangle to find a point on its surface that
has the smooth normal pointing at the original point. If a point
within the triangle is not found, the next triangle is searched.

All instability with vertices jumping to the opposite side of
the mesh is caused by incorrectly discarding triangles for various
reasons when the solution is close to the triangle edge.

In order to optimize performance the old code was aggressively
aborting iteration when the local gradient at the edge was
pointing outside domain. However, it is wrong because it can be
caused by a sharp valley diagonal to the domain boundary with
the bottom gently sloping towards a minimum within the domain.

Now iteration is only aborted if the solution deviates
nonsensically far from the domain. Otherwise, the iteration
proceeds as usual, and the final result is checked against
domain borders with epsilon.

In addition, iterations can now be aborted based on the value
of the Jacobian determinant, or the number of linear search
correction steps. Both can signify a singularity, which can
be caused by the lack of a real solution to the equation.

Finally, custom correction clearly has to be done after
the linear search phase of the iterative solver, because the
linear correction math assumes running after a normal Newton
method step, not some kind of custom clamping.

Differential Revision: https://developer.blender.org/D15892
2023-11-20 12:36:13 +02:00