Commit Graph

65 Commits

Author SHA1 Message Date
Lukas Tönne d7c718dfd4 GPv3: Texture offset modifier
Port of the GPv2 texture modifier for transforming UVs of stroke points.

Pull Request: https://projects.blender.org/blender/blender/pulls/119050
2024-03-29 21:42:30 +01:00
Falk David 8b7d5f8587 GPv3: Simplify Modifier
Implements the GPv2 simplify modifier.

Pull Request: https://projects.blender.org/blender/blender/pulls/120018
2024-03-28 18:16:14 +01:00
Falk David 5a6a9349e0 Revert "GPv3: Simplify modifier"
This reverts commit 279b8b5748.

The PR wasn't accepted.
2024-03-28 15:23:42 +01:00
YimingWu 279b8b5748 GPv3: Simplify modifier
Implements the simplify modifier from GPv2.

Co-authored-by: Falk David <falk@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/118546
2024-03-28 15:18:33 +01:00
YimingWu 3689dfca4f GPv3: Build Modifer migration
Reimplemented build modifier using the new `CurvesGeometry` logic.

Pull Request: https://projects.blender.org/blender/blender/pulls/118739
2024-03-20 13:28:28 +01:00
Howard Trickey e3f030cce6 Geometry Nodes: Add float solver to mesh boolean node
This adds a "Solver" option to the geo boolean node, with the options
Exact and Float.
The current geo boolean node only uses the Exact solver.
This adds the ability to use the faster original floating point boolean solver.
The float solver has issues with coplanar and other coincident geometry,
but is generally much faster than the Exact solver, and users have asked
for this option (which is available in the Boolean Modifier and edit mode
boolean tool).

Like the modifier, the Float solver needs to convert the Mesh to BMesh,
do the operation, and then convert back to Mesh. It also has to do it
iteratively if more than two operands are supplied.

This is the first of a planned series of commits that will add a
new exact boolean solver, based on the Ember paper, as a solver option.
Ember will be much faster than the current exact solver, but may still not
be as fast as float, and also will not handle some non-volume-enclosing
inputs as well as Float, so it is likely that the Float solver will always remain.
We may eventually retire the old Exact Solver, however.

This commit also prepares for more sensible code in the future by
changing the internal enum names for the solvers to better reflect the
algorithms used: Fast -> Float, and Exact -> Mesh_Arr (which means
"Mesh Arrangments, the name of the paper upon which the current
exact solver is based).

Co-authored-by: Howard Trickey <trickey@google.com>
Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/119294
2024-03-14 20:49:57 +01:00
Hans Goudey 744f3b2823 Cleanup: Grammar in comments: Fix uses of "own"
"Own" (the adjective) cannot be used on its own. It should be combined
with something like "its own", "our own",  "her own", or "the object's own".
It also isn't used separately to mean something like "separate".

Also, "its own" is correct instead of "it's own" which is a misues of the verb.
2024-03-07 16:23:35 -05:00
Lukas Tönne f51e93bec7 GPv3: Shrinkwrap modifier
Port of shrinkwrap modifier from GPv2.

Adds a new API function in `BKE_shrinkwrap.hh` for the modifier.

Pull Request: https://projects.blender.org/blender/blender/pulls/119118
2024-03-06 12:05:00 +01:00
Lukas Tönne d6aadd6692 GPv3: Outline modifier
Port of GPv2 outline modifier.

Pull Request: https://projects.blender.org/blender/blender/pulls/118911
2024-03-04 16:54:07 +01:00
Lukas Tönne 68c12fe0ec GPv3: Envelope Modifier
Ports the Envelope modifier from GPv2.

Pull Request: https://projects.blender.org/blender/blender/pulls/118272
2024-03-01 10:42:41 +01:00
Lukas Tönne c6e5e62f45 GPv3: Time offset modifier
Port of the Time Offset modifier from GPv2.

Pull Request: https://projects.blender.org/blender/blender/pulls/118371
2024-02-27 14:17:22 +01:00
Lukas Tönne 5599172499 GPv3: Armature Modifier
Armature deformation modifier for Grease Pencil v3.

Changes compared to GPv2:
- `multi` DNA field was unused and was removed.
- `vert_coords_prev` array is unused and was removed (gets passed to
  armature functions but never gets allocated).
- GPv3 modifier uses the common `influence` struct to store the vertex
  group name, for consistency. The
  `GREASE_PENCIL_INFLUENCE_INVERT_VERTEX_GROUP` flag is copied to
  `deformflag` as `ARM_DEF_INVERT_VGROUP` before evaluation, which is
  used internally by armature functions.
- `BKE_armature_deform_coords_with_curves` is added as another variant
  of the deform function, but uses C++ parameter types (spans instead
  of raw pointers). It gets a `Span<MDeformVert>` directly instead of
  deducing it internally from the object type. This is because we want
  to do this curve-by-curve and already use arbitrary vector spans for
  positions.

Pull Request: https://projects.blender.org/blender/blender/pulls/118752
2024-02-26 19:36:10 +01:00
YimingWu 3d1cdfe2ca GPv3: Line Art Modifier
This is a migration of the current Line Art modifier to GPv3.

Note:
- The modifier is using the exact same DNA structure as the old one, it's re-defined in a different name. At the moment all the variable names and placement after the `ModifierData` part should stay exactly the same until we do proper versioning of the modifier data and completely remove the GPv2 support.
- Vertex weight transfer feature no longer supports name initial matching ("group" used to match "group1","group2" etc). Now it will only transfer vertex weight from source vertex groups that has the exact same name as specified.

Pull Request: https://projects.blender.org/blender/blender/pulls/117028
2024-02-26 15:28:15 +01:00
YimingWu 2225ce8202 GPv3: Hook modifier
Migrates the Hook modifier to Grease Pencil v3.

Pull Request: https://projects.blender.org/blender/blender/pulls/118452
2024-02-21 14:20:47 +01:00
Lukas Tönne 2a7fcf2cfd Fix #118489: Use zero scale default since it's used as an offset. 2024-02-20 11:20:55 +01:00
YimingWu ae20873250 GPv3: Weight proximity modifier
This migrates the Weight proximity modifier to GPv3.

Pull Request: https://projects.blender.org/blender/blender/pulls/118363
2024-02-19 11:16:38 +01:00
YimingWu 975c226282 GPv3: Array Modifier
This migrates the Array modifier to Grease Pencil v3.

Pull Request: https://projects.blender.org/blender/blender/pulls/117836
2024-02-16 14:04:01 +01:00
YimingWu ace5c9af2a GPv3: Vertex Weight Angle modifier
This ports the Vertex Weight Angle modifier to Grease Pencil v3.

Pull Request: https://projects.blender.org/blender/blender/pulls/117846
2024-02-16 12:30:43 +01:00
YimingWu b661b368c4 GPv3: Length modifier
This ports the length modifier to Grease Pencil v3.

Pull Request: https://projects.blender.org/blender/blender/pulls/117124
2024-02-15 16:37:54 +01:00
YimingWu 76b0976500 GPv3: Multiple Strokes Modifier
This migrates the multiple strokes modifier to Grease Pencil v3.

Pull Request: https://projects.blender.org/blender/blender/pulls/117796
2024-02-15 14:19:50 +01:00
Lukas Tönne a4051b31d5 Fix #118135: Make sure the new active index is always valid
When deleting all the segments the active index is generally 0. Adding a
new segment increments the active index, which pushes it out of range.
The code should not expect active index to be inside the current range.

Pull Request: https://projects.blender.org/blender/blender/pulls/118143
2024-02-12 16:44:28 +01:00
Lukas Tönne 2c8de207b7 GPv3: Dash modifier
Reimplements the "Dash" (aka Dash-Dot) modifier of GPv2.

Pull Request: https://projects.blender.org/blender/blender/pulls/117758
2024-02-08 15:35:20 +01:00
Lukas Tönne da2d3be202 GPv3: Lattice modifier
Ported lattice modifier from GPv2.

The `LatticeDeformData` is no longer stored in the modifier data, but calculated on-the-fly like in the mesh deform modifier. This is quite trivial data and only stores deformed positions of the lattice, so not really worth the effort and complexity of caching it.

Pull Request: https://projects.blender.org/blender/blender/pulls/117955
2024-02-08 14:09:11 +01:00
Campbell Barton c4a2858975 Cleanup: strip trailing space 2024-02-02 10:43:17 +11:00
Falk David 898ff6ceee Revert "GPv3: Array modifier"
This reverts commit e1ce3c3cc7.
2024-02-01 16:18:13 +01:00
YimingWu e1ce3c3cc7 GPv3: Array modifier
Grease Pencil Array modifier migrated to GPv3.

All features now working as expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/117722
2024-02-01 15:58:53 +01:00
YimingWu 4722c801c5 GPv3: Thickness modifier
Thickness modifier ported to Grease Pencil v3.

Note: Uniform thickness range and UI step changed to better
match new thickness of blender unit.

![image](/attachments/2e9c9bfa-d869-4bec-a529-c3833390a201)

Pull Request: https://projects.blender.org/blender/blender/pulls/117631
2024-01-30 13:04:30 +01:00
Lukas Tönne 0daa426739 GPv3: Mirror modifier
Implements the mirror modifier from GPv2.

Pull Request: https://projects.blender.org/blender/blender/pulls/117637
2024-01-30 12:10:33 +01:00
YimingWu 56439d88f5 GPv3: Noise modifier
This ports the noise modifier to GPv3.
There should be no functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/117057
2024-01-29 16:49:16 +01:00
Lukas Tönne 7e87513368 GPv3: Offset modifier
Ported the Offset modifier from GPv2.

Pull Request: https://projects.blender.org/blender/blender/pulls/117446
2024-01-24 16:57:58 +01:00
YimingWu f54348edc9 GPv3: Smooth modifier
Smooth modifier ported to Grease Pencil 3.0

Exposed `smooth_curve_attribute()` from `grease_pencil_edit.cc`
to achieve the smoothing effect. It will not be the exact same result
as the old algorithm.

Pull Request: https://projects.blender.org/blender/blender/pulls/116975
2024-01-24 04:36:36 +01:00
Lukas Tönne baeb4d7753 GPv3: Tint and Color modifiers
Implements the Tint and Color (aka. "Hue/Saturation") modifiers.

Pull Request: https://projects.blender.org/blender/blender/pulls/117297
2024-01-19 16:59:39 +01:00
YimingWu 4d387843e9 GPv3: Subdivide Modifier
This ports the Subdivide modifier from GPv2.

Pull Request: https://projects.blender.org/blender/blender/pulls/117056
2024-01-18 13:02:53 +01:00
Lukas Tönne c02f3c94d9 GPv3: Opacity modifier
Opacity modifier implementation based on GP2.
Functionality is largely unchanged.

_Color Mode_ is either `Stroke` or `Fill` for modifying color opacity or
`Hardness`.
_Uniform Opacity_ does two things at once (!):
- Sets the same opacity value for every point in a stroke.
- Sets opacity as an absolute value rather than a factor.

_Weight as Factor_ (button to the right of Opacity Factor): Use the
vertex group as opacity __factor__ rather than an overall __influence__.
This is confusing and hard to convey, but copies behavior from GP2.

The _Influence_ panel contains the same filter settings as the GP2
modifier, with some small changes:
- _Layer_ selects only strokes in the respective layer (with an _Invert_
  option)
- _Material_ selects only points with the respective material (with an
  _Invert_ option)
- _Layer Pass_ and _Material Pass_ select only strokes/points which are
  rendered in the respective pass.
  _Note 1: Layers don't have UI for setting a pass yet, this will be a
  generic layer attribute. This can be set through the API for testing._
  _Note 2: In GP2 a pass value of zero was used to disable pass filters.
  Since zero is a valid pass ID an explicit flag has been added for the
  purpose of turning pass filters on and off._
- _Vertex Group_: This can be used as an additional influence filter on
  points. If _Weight as Factor_ is enable the vertex group instead
  replaces the opacity factor. In _Fill_ mode the vertex group weight of
  the stroke's first point is used as influence for the entire stroke.
- _Custom Curve_ is another possible influence factor per point. The
  curve input value is the relative position of a point along its
  stroke.

The Influence settings have been moved into a separate DNA struct, which
should help with reusability in various modifiers. Various utility
functions can be found int `MOD_grease_pencil_util.hh` for handling
influence settings and generating `IndexMasks` for modernized C++ code.

Pull Request: https://projects.blender.org/blender/blender/pulls/116946
2024-01-16 16:56:14 +01:00
Hans Goudey 7132c7a53c Cleanup: Replace MVertTri type with C++ vector
Similar to 7c69c8827b. Remove more unused includes.
2023-12-20 20:59:11 -05:00
Campbell Barton e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Campbell Barton cc892efcd4 Cleanup: use snake case, especially for structs that define callbacks
Use snake case for ShaderFxTypeInfo, ModifierTypeInfo,
GpencilModifierTypeInfo & bConstraintTypeInfo.
2023-07-27 12:21:06 +10:00
Sergey Sharybin c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Campbell Barton b7f5e4b1b6 Fix building on MSVC
Empty struct introduced in dad9f45561.
2023-01-10 19:04:07 +11:00
Campbell Barton dad9f45561 Cleanup: move run-time members of SurfaceModifierData into a struct
Using run-time members in the surface modifier complicated code-review
and caused an unnecessary renaming in `dna_rename_defs.h`.

Also rename:
- `x` -> `vert_positions_prev`.
- `v` -> `vert_velocities`.
- `cfra` -> `cfra_prev`.
2023-01-10 17:19:30 +11:00
Sergey Sharybin 5f8f436dca Allow surface deform when target mesh increases number of vertices
A studio request actually.

The goal is to cover rather typical situation: when the mesh was
bound to target when the target was on subdivision level 0 but
uses a higher subdivision level for rendering. Example of such
setup is a facial hair bound to the face.

The idea of this change is to use first N vertices from the target
where N is the number of vertices on target during binding process.
While this sounds a bit arbitrary it covers typical modifier setup
used for rigging. Arguably, it is not more arbitrary than using a
number of polygons (which is how the modifier was checking for
changes on target before this change).

Quite straightforward change. A bit tricky part was to not break
the behavior since before this change we did not track number of
vertices sued when binding. The naming I'm also not super happy
with and just followed the existing one. Ideally the variables in
DNA will be prefixed with `target_` but doing it for an existing
field would mean compatibility change, and only using prefix for
the new field will introduce weird semantic where the polygons
count will be even more easily confused with a count on the
deforming mesh.

Differential Revision: https://developer.blender.org/D14830
2022-05-04 10:56:33 +02:00
Sergey Sharybin aa1fb4204d Cleanup: More clear name in surface deform modifier
Make it explicit that counter is about target mesh.

Use DNA rename for it so that the files stay compatible.

Also renamed some purely runtime fields to replace `t`
prefix with `target` as the short `t` is super easy
to miss.

Differential Revision: https://developer.blender.org/D14835
2022-05-04 10:56:33 +02:00
Campbell Barton 6f305577b3 Cleanup: use "num" as a suffix in: source/blender/modifiers
Also rename DNA struct members.
2022-03-28 14:41:31 +11:00
Hallam Roberts 3da84d8b08 Cleanup: use M_PI_2 and M_PI_4 where possible
The constant M_PI_4 is added to GLSL to ensure it works there too.

Differential Revision: https://developer.blender.org/D14288
2022-03-11 18:27:58 +01:00
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00
Bastien Montagne a0acb9bd0c Fix T91444: Edge Loop Preview fails with two Mirror Modifiers
The mirror modifiers merge option caused unnecessary re-ordering
to the vertex array with original vertices merging into their copies.

While this wasn't an error, it meant creating a 1:1 mapping from input
vertices to their final output wasn't reliable (when looping over
vertices first to last) as is done in
BKE_editmesh_vert_coords_when_deformed.

As merging in either direction is supported, keep the source meshes
vertices in-order since it allows the vertex coordinates to be extracted.

NOTE: Since this change introduce issues for some cases (e.g. bound
modifiers like SurfaceDeform), this change is only applied to newly
created modifiers, existing ones will still use the old incorrect merge
behavior.

Reviewed By: @brecht

Maniphest Tasks: T93321, T91444

Differential Revision: https://developer.blender.org/D13355
2021-11-25 10:21:49 +01:00
Brecht Van Lommel 128eb6cbe9 Modifiers: export motion blur velocity through attribute
Previously fluid simulation and Alembic modifiers had a dedicated function
to query the velocity for motion blur. Now use a more generic system where
those modifiers output a velocity attribute.

Advantages:
* Geometry and particle nodes can output velocity through the same mechanism,
  or read the attribute coming from earlier modifiers.
* The velocity can be preserved through modifiers like subdivision surface or
  auto smooth.
* USD and Alembic previously only output velocity from fluid simulation, now
  they work with velocity from other sources too.
* Simplifies the code for renderers like Cycles and exporters like
  Alembic and USD.

This breaks compatibility:
* External renderers and exporters accessing these velocities through the
  Python API now need to use the attribute instead.
* Existing modifier node setups that create an attribute named "velocity"
  will render differently with motion blur.

Differential Revision: https://developer.blender.org/D12305
2021-09-10 16:48:30 +02:00
Alexander Gavrilov 1ab6d5c1dc Surface Deform: support sparse binding mode for improving performance.
When a vertex group is used to limit the influence of the modifier
to a subset of vertices, binding data for vertices with zero weight
is not needed. This wastes memory, disk space and CPU cycles.

If the vertex group contents is known to be final and constant,
it is reasonable to optimize by only storing data group vertices.
This has to be an option in case the group can change.

Supporting this requires adding a vertex index field and spliting
the vertex count into mesh and bind variants, but both happen to
fit in available padding. The old numverts field is renamed to the
new bound vertex count field to maintain the array length invariant.
Versioning is used to initialize the other new fields.

If a file with sparse binding is opened in an old blender version,
it is corrupted into a non-sparse bind with vertex count mismatch,
preventing the modifier from working until rebind.

Differential Revision: https://developer.blender.org/D11924
2021-07-16 16:12:00 +03:00
Falk David 00ec99050e Fix T85051: Add bisect distance as a parameter to the mirror modifier
The `bisect_distance` in the mirror modifier was hard-coded to `0.001`.
This would result in some unexpected behavior like vertices close
to the mirror plane being deleted or merged.

The fix now adds a parameter to the mirror modifier to expose the
bisect distance to the user. The default is set to the previous
hard-coded value to not "change" previous files.

Ref D10201
2021-04-22 16:31:41 +10:00
Philipp Oeser fcc3227efd Fix T86654: wrong Vertex Interpolation option default when importing alembic caches
This resulted in bad motion blur from alembic animation when imported
after rB83980506957c (because it was now OFF by default).
When imported in a version prior to rB83980506957c and saved, this was
still working fine.

Vertex interpolation option introduced in rBbab2260b59c7 was defaulting
to ON (correct) in that commit, but was lost in rB83980506957c.

Now switch this to ON by default again.

Note: if you have a file that was (incorrectly) imported with a version
after rB83980506957c you'll have to enable Vertex Interpolation option
on every MeshSequenceCache modifier by hand.

Maniphest Tasks: T86654

Differential Revision: https://developer.blender.org/D10876
2021-04-02 21:18:34 +02:00