Commit Graph

3611 Commits

Author SHA1 Message Date
Jacques Lucke
549f567743 Merge branch 'blender-v4.2-release' 2024-07-11 17:27:42 +02:00
Jacques Lucke
85760b6a13 Fix #123974: handle corrupted file missing baked data more gracefully 2024-07-11 17:25:29 +02:00
Jacques Lucke
24dc9a21b1 Geometry Nodes: support attaching gizmos to input values
This adds support for attaching gizmos for input values. The goal is to make it
easier for users to set input values intuitively in the 3D viewport.

We went through multiple different possible designs until we settled on the one
implemented here. We picked it for it's flexibility and ease of use when using
geometry node assets. The core principle in the design is that **gizmos are
attached to existing input values instead of being the input value themselves**.
This actually fits the existing concept of gizmos in Blender well, but may be a
bit unintutitive in a node setup at first. The attachment is done using links in
the node editor.

The most basic usage of the node is to link a Value node to the new Linear Gizmo
node. This attaches the gizmo to the input value and allows you to change it
from the 3D view. The attachment is indicated by the gizmo icon in the sockets
which are controlled by a gizmo as well as the back-link (notice the double
link) when the gizmo is active.

The core principle makes it straight forward to control the same node setup from
the 3D view with gizmos, or by manually changing input values, or by driving the
input values procedurally.

If the input value is controlled indirectly by other inputs, it's often possible
to **automatically propagate** the gizmo to the actual input.

Backpropagation does not work for all nodes, although more nodes can be
supported over time.

This patch adds the first three gizmo nodes which cover common use cases:
* **Linear Gizmo**: Creates a gizmo that controls a float or integer value using
  a linear movement of e.g. an arrow in the 3D viewport.
* **Dial Gizmo**: Creates a circular gizmo in the 3D viewport that can be
  rotated to change the attached angle input.
* **Transform Gizmo**: Creates a simple gizmo for location, rotation and scale.

In the future, more built-in gizmos and potentially the ability for custom
gizmos could be added.

All gizmo nodes have a **Transform** geometry output. Using it is optional but
it is recommended when the gizmo is used to control inputs that affect a
geometry. When it is used, Blender will automatically transform the gizmos
together with the geometry that they control. To achieve this, the output should
be merged with the generated geometry using the *Join Geometry* node. The data
contained in *Transform* output is not visible geometry, but just internal
information that helps Blender to give a better user experience when using
gizmos.

The gizmo nodes have a multi-input socket. This allows **controlling multiple
values** with the same gizmo.

Only a small set of **gizmo shapes** is supported initially. It might be
extended in the future but one goal is to give the gizmos used by different node
group assets a familiar look and feel. A similar constraint exists for
**colors**. Currently, one can choose from a fixed set of colors which can be
modified in the theme settings.

The set of **visible gizmos** is determined by a multiple factors because it's
not really feasible to show all possible gizmos at all times. To see any of the
geometry nodes gizmos, the "Active Modifier" option has to be enabled in the
"Viewport Gizmos" popover. Then all gizmos are drawn for which at least one of
the following is true:
* The gizmo controls an input of the active modifier of the active object.
* The gizmo controls a value in a selected node in an open node editor.
* The gizmo controls a pinned value in an open node editor. Pinning works by
  clicking the gizmo icon next to the value.

Pull Request: https://projects.blender.org/blender/blender/pulls/112677
2024-07-10 16:18:47 +02:00
Pratik Borhade
1ca8dce9cc Fix: Assert when calling node tool
similar to f4ef3de32b

Pull Request: https://projects.blender.org/blender/blender/pulls/124220
2024-07-05 16:41:46 +02:00
Philipp Oeser
74c4b41f1a Merge branch 'blender-v4.2-release' 2024-06-28 14:35:13 +02:00
Philipp Oeser
33ca4daf8f Fix #123882: Ocean Modifier not updating normals in "Displace" mode
Exposed by 383a145a19

The real culprit was in 6a3c3c77b3 though (where the original meshes
normals were tagged dirty instead of the result's).

So to resolve, now tag the result (not the original).

Pull Request: https://projects.blender.org/blender/blender/pulls/123893
2024-06-28 14:34:26 +02:00
Bastien Montagne
f6358f6e71 Merge branch 'blender-v4.2-release' 2024-06-26 19:28:22 +02:00
Damien Picard
26cdf7e340 I18n: Extract many custom labels defined in uiItem*
Those labels needed a manual translation with IFACE_() or RPT_():
  - "Add Item",
  - "Blend",
  - "Cached from the first line art modifier.",
  - "Custom Curve",
  - "Custom Path",
  - "Custom Range",
  - "End",
  - "Enter a Unicode codepoint hex value",
  - "Forward Axis",
  - "Insert Unicode Character",
  - "Mid Level",
  - "Min",
  - "Mode",
  - "No Items",
  - "Object",
  - "Path",
  - "Probability",
  - "Sample Radius",
  - "Sharp edges or custom normals detected, disabling GPU subdivision",
  - "Start",
  - "Texture Mapping",
  - "Up Axis",
  - "Using both CPU and GPU subdivision",
2024-06-26 19:25:20 +02:00
Lukas Tönne
a606f2fd09 Merge branch 'blender-v4.2-release' 2024-06-24 10:28:50 +02:00
Lukas Tönne
37e2a27bdd Fix #80876: Ocean modifier "Delete Bake" button does not work
The ocean modifier uses its Bake operator for both baking and freeing
the cache, based on the `free` operator property.

There are two bugs here:
1. The "Delete Bake" variant of the button was created using the
   `WM_OP_EXEC_DEFAULT` operator context. This skips the `invoke`
   callback which is crucial for setting the operator `modifier`
   property. Without that the modifier will just exit early.
   The "Bake" button is drawn using the `uiItemO` function which uses
   the invoke context automatically, so it does not have this issue.
2. The `free` property is set for the "Delete Bake" variant, but was
   never reset to its initial `false` value. The "Bake" variant has to
   also set this property, otherwise it will always execute the "free"
   code path.

Pull Request: https://projects.blender.org/blender/blender/pulls/123506
2024-06-24 10:27:28 +02:00
Falk David
6d301c12af Fix #123489: GPv3: Outline modifier outputs wrong radii
This was introduced by 6ad04beff8.
It replaced a multiplication by a division by mistake.
2024-06-20 16:22:54 +02:00
Lukas Tönne
c714aa64e8 Fix #123352: Time offset chain mode inserts wrong keys
The time offset modifier inserts keys sequentially, overwriting earlier
frames with later ones, and only the last relevant frame remains used.

In chain mode this process is repeated for every chain segment and then
all segments are repeated to fill the entire timeline. However, because
all keyframes are inserted for every repetition, they can overwrite
keyframes from earlier repetitions as well.

Clamping the insert keyframe makes sure that no keys are inserted
outside of the target range for a give repetition.

Pull Request: https://projects.blender.org/blender/blender/pulls/123423
2024-06-19 12:42:21 +02:00
Falk David
6ad04beff8 Cleanup: GPv3: Move create_curves_outline into grease_pencil_geom.cc
Moves the `create_curves_outline` into the editor file `grease_pencil_geom.cc`
in preperation to use it in other places (draw tool).

Pull Request: https://projects.blender.org/blender/blender/pulls/123383
2024-06-18 18:12:45 +02:00
Bastien Montagne
de713122f3 Merge branch 'blender-v4.2-release' 2024-06-13 12:17:10 +02:00
Damien Picard
f87d4e4e40 I18n: Extract and disambiguate a few messages
Extract
- Cycles denoiser enum.
- Extensions user preferences UI.
- Node operator poll message from new node function.

Improve
- Split "(Enabled|Disabled) on startup, overriding the preference."
into two messages.

Disambiguate
- "Add" when describing the action of adding something should use the
  Operator context.
- "Dimensions", in noise textures.
- "Transform" as a noun, the matrix transform type of Geometry Nodes,
  as opposed to the verb to move things in space.
- "Parent" as a noun or verb (the parent of an object, to parent an
  object to another).

Some issues reported by Satoshi Yamasaki, deathblood, and Gabriel Gazzán.

Pull Request: https://projects.blender.org/blender/blender/pulls/122969
2024-06-13 12:15:55 +02:00
Pratik Borhade
52121edd96 Fix #123106: Custom panel name can't auto translate in GN modifier
Add `IFACE_` macro to translate the custom subpanel header.

Pull Request: https://projects.blender.org/blender/blender/pulls/123124
2024-06-12 14:37:18 +02:00
Lukas Tönne
1e237da1db Fix #123076: Remove UI line for removed property
The `keep_custom_normals` property was removed in
f3c32a36bc.

Pull Request: https://projects.blender.org/blender/blender/pulls/123079
2024-06-11 15:29:01 +02:00
Falk David
0089a90625 Refactor: Attribute API: Remove ID owner dependency
The attribute API defined in `attribute.cc` was dependent on
the assumption that `ID`s are always the "direct" owners of attributes.

For Grease Pencil drawings, this is not the case. The Grease Pencil ID
stores the attributes for layers, and the attributes for drawings are stored
in `CurvesGeometry` on the drawings themselves.

In order to make use of  `rna_attribute.cc`, we need that API to handle
other types of attribute owners.

This adds an `AttributeOwner` which is basically just a type and a
pointer. We replace the `ID` pointers and pass `AttributeOwner`s instead.

For cases where we have to do a switch based on the type, all the
types are handled and the `default` statment is left out. This ensures
that we get a compiler warning when a new `AttributeOwnerType`
is added.

No functional changes expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/122765
2024-06-07 16:42:41 +02:00
Jacques Lucke
10984c1461 Geometry Nodes: resimulate current frame if it's the last cached one
The goal is to simplify debugging the "current" simulation step. Previously, when a frame
was cached already, one would have to go back to the beginning to cache everything again.
Now, the last cached simulation step is discarded and simulated again if any property that
affects it is changed.

Pull Request: https://projects.blender.org/blender/blender/pulls/122736
2024-06-06 20:47:17 +02:00
Jacques Lucke
7d77691a83 Fix: avoid trying to load bake while baking
This could cause issues when rebaking a simulation without freeing
the old bake first.
2024-06-03 18:46:41 +02:00
Falk David
94b4542afe GPv3: Refactor: Use GPv2 point times as is
During the conversion of GPv3 to GPv2, we computed the
time difference between the points. So we we're keeping track
of the time a point was created relative to the previous point.

There doesn't seem to be a good reason to do this.
It can also go very wrong in case the times of two points are
very close to one another (which can result in catastrophic
cancellation).

With this change, the time delta values are now the time
a point was created, relative to the first point.

Pull Request: https://projects.blender.org/blender/blender/pulls/122367
2024-05-30 14:12:26 +02:00
Jacques Lucke
05820ae1cc Cleanup: remove unnecessary assert
It doesn't make sense to check if an unsigned integer is >= 0.
2024-05-29 14:55:14 +02:00
Iliya Katueshenock
bea8825446 Cleanup: BLI: Remove Span::get method
Unlike to `lookup_or_default` accessor methods of `Map` or attribute provider class,
`Span::get` is not so explicit and self described to be used with default value.
Other one issue was is that result is by value. But this is not the main reason to
delete this method. And although this can be fixed by reference, this is still not
such good to just have method to check index and return something.

Pull Request: https://projects.blender.org/blender/blender/pulls/122425
2024-05-29 14:26:21 +02:00
Falk David
d8c5f9a8ba Fix: GPv3: Build modifier maximum gap not working
The "Maximum Gap" setting for the "Natural Drawing Speed"
mode was not working.
This was because the code used `math::max` to try and clamp the value
to a maximum when it should have used `math::min`.
This fixes this issue.
2024-05-28 12:27:36 +02:00
Falk David
e4c0055591 Fix #122355: Opacity modifier hardness mode not working
This was introduced by 944be3d619.

In order to keep the behavior the same at the user level,
we can't invert the factor. We have to invert the values, then
apply the factor and convert back.

Pull Request: https://projects.blender.org/blender/blender/pulls/122360
2024-05-28 12:12:31 +02:00
Falk David
489bb2e29a Cleanup: GPv3: Use dereference operator instead of .varray 2024-05-28 11:19:54 +02:00
Hans Goudey
e77c2d77e4 Cleanup: Remove unused function argument 2024-05-23 14:06:56 -04:00
Philipp Oeser
f3c32a36bc Fix #103562: preserve custom normals in BM_mesh_triangulate
`BM_mesh_triangulate` is used in exporters (when the "Triangulate"
option is ON), the `Triangulate` modifier and currently also in the
`Triangulate` geometry node (even though there are plans to change this,
see !112264)

So in practice, exporters (Alembic/FBX/OBJ/Collada) were breaking
custom normals for game pipelines (unless everything was triangulated
beforehand).

This change builds upon 93c8955a72 (uses the use
`BM_custom_loop_normals_to_vector_layer` /
`BM_custom_loop_normals_from_vector_layer` pair of calls).

In the case of the `Triangulate` modifier, this had its own try at
preserving custom normals in 7d0fcaa69a  -- doing very similar
things but as an option -- this is now removed (so it is always done,
which fits into "interpolate custom data if it's there" design that we have
nowadays).

NOTE: the "Triangulate Faces" operator already did the same
Pull Request: https://projects.blender.org/blender/blender/pulls/121871
2024-05-23 17:33:40 +02:00
Falk David
125617dc82 GPv3: Replace uses of Layer::frame_key_at
There were multiple places in the GPv3 code that assumed that the
frame key is equivalent to the start frame of the frame with that key.
But this is not the case. The `FramesMapKeyT` is either the start frame
*or* the end frame (for frames with fixed duration).

This adds a new function `start_frame_at` that returns the start frame
number of the frame at `frame_number` or -1 if no such frame exists.

One place needed the index into sorted keys (for onion skinning) so
this was replaced with a new function `sorted_keys_index_at`.

With these changes, `Layer::frame_key_at` is now a private method.

Pull Request: https://projects.blender.org/blender/blender/pulls/122045
2024-05-21 14:25:41 +02:00
Falk David
ba1356e339 Cleanup: GPv3: Rename FramesMapKey to FramesMapKeyT
Other code also uses the suffix `T` to indicate that this is a type.
Note that `FramesMapKeyT` is just an `int` but with a very specific
meaning. Hence the alias to avoid confusions.
2024-05-21 13:16:53 +02:00
Hans Goudey
c4fc19f064 Cleanup: Use reference argument for BKE_mesh_copy_for_eval 2024-05-20 13:18:24 -04:00
Hans Goudey
a6ecfe2f79 Cleanup: Rename DerivedMesh.cc and header
After recent commits, the .cc file is only used for actual object data
evaluation in the depsgraph, and the header is only used for the old
DerivedMesh data structure that's still being phased out.
2024-05-20 13:11:18 -04:00
Hans Goudey
9b1c6fb04b Cleanup: Use const for edit mesh deformation arguments 2024-05-20 10:14:41 -04:00
Brecht Van Lommel
a926f5b67d Refactor: Replace ID_IS_LINKED by !ID_IS_EDITABLE
Add new ID_IS_EDITABLE macro that checks if the ID can be edited in the
user interface. Replace usage of ID_IS_LINKED where it is used with this
meaning.

Also add a corresponding ID.is_editable property for Python.

This prepares for the ability to edit some linked datablocks for brush
assets.

Pull Request: https://projects.blender.org/blender/blender/pulls/121838
2024-05-16 14:53:09 +02:00
YimingWu
401401b7f2 GPv3: LinArt: Handle shared cache for v3.
Shared cache in GPv3 line art is created before
`MOD_lineart_compute_feature_lines_v3`, the function will create its own
cache and overwrite the old one, causing memory leak. Now all code paths
have been fixed.
2024-05-16 12:30:03 +08:00
YimingWu
66a338741e GPv3: LinArt: Missing walk() for target_material
In `foreach_ID_link` of LineArt v3, the `walk()` call for
`target_material` is missing, causing crash on reopening. Now fixed.
2024-05-16 11:51:25 +08:00
Hans Goudey
944be3d619 Refactor: GPv3: Store inverted hardness value
To simplify propagation of the attribute with joined geometry
(0.0 defaults are generally easier to handle with attributes, and
even more performant), store the inverse of the current "hardness"
attribute as "softness" instead. This change involves adding a few
`1.0f - value` operations, though in the future as the renderer is
replaced that mostly should become unnecessary.

Updated version of #118007.

Pull Request: https://projects.blender.org/blender/blender/pulls/121578
2024-05-15 17:51:35 +02:00
Chao Li
4b59c1bcbf GPv3: Merge by distance Operator
The algorithm to merge points based on distance thresholdhas been
implemented in 8b7d5f8587. This patch moves the function to
`blender::ed::greasepencil` namespace and use it to implement
merge by distance operator.

There are two parameters for the operator:
`threshold`: Distance threshold used for merging.
`use_unselected`: Use whole stroke or only selected points

Resolves: #113917
Pull Request: https://projects.blender.org/blender/blender/pulls/120385
2024-05-15 16:25:41 +02:00
Iliya Katueshenock
75d17b1db5 Cleanup: Move BKE_node to namespace
Move all header file into namespace.
Unnecessary namespaces was removed from implementations file.
Part of forward declarations in header was moved in the top part
of file just to do not have a lot of separate namespaces.

Pull Request: https://projects.blender.org/blender/blender/pulls/121637
2024-05-13 16:07:12 +02:00
Falk David
281bbe198d Cleanup: GPv3: Use get_drawing_at in modifier util functions
Part of #121565.

Instead of accessing the drawing indices directly, use
`get_drawing_at` in the utility functions.

Pull Request: https://projects.blender.org/blender/blender/pulls/121732
2024-05-13 15:40:36 +02:00
Jacques Lucke
2f289857af Object: add Shade Auto Smooth operator
Based on the design in #120230.
* Replaces the `Shade Smooth by Angle` operator with `Shade Auto Smooth`
  in the object context menu menu.
* The new operator automatically adds and removes the modifier instead
  of being a destructive operation.
* The `Shade Smooth` and `Shade Flat` operators now remove the
  `Smooth by Angle` modifier automatically.
* Add a pin option to modifiers, which limits dragging and keeps the
  modifier after newly added modifiers in the list.

Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/121494
2024-05-08 20:24:10 +02:00
Falk David
fea091e18e Refactor: GPv3: insert_blank_frame
This is part of #121565.

Renames the `insert_blank_frame` function to `insert_frame`.

Instead of returning a boolean for if the keyframe was created,
return a pointer to the drawing. This aligns more with how
we're using this API. After inserting a keyframe, it's common
to then e.g. write to the newly created drawing.

Also use sensible default parameter values for the duration
(default = implicit hold) and the keyframe type
(dafault = `BEZT_KEYTYPE_KEYFRAME`).

With this change, we're moving closer to the goal of
only allowing to create drawings by creating keyframes.
2024-05-08 16:47:46 +02:00
Falk David
737572ed88 Cleanup: GPv3: Use GreasePencil::layer function instead of GreasePencil::layers
This also ensures that there is an assert that checks
for valid indices before accessing the span of layers.
2024-05-08 12:35:06 +02:00
YimingWu
3be6dbb02a Fix #121366: Invalid mat_nr after exact boolean
Material index of faces could be a invalid value after booleaning in
exact boolean in "Index Based" mode against objects with no material
slots, this is caused by the lack of initilization material remapping
array. Now all initilized to 0.

Assigning 0 explicitly in Fast mode as well for consistency.

Pull Request: https://projects.blender.org/blender/blender/pulls/121380
2024-05-04 13:29:35 +02:00
Campbell Barton
9918488bb1 Cleanup: use uppercase tags, following own style guide 2024-05-03 11:33:21 +10:00
Sergey Sharybin
1b0012d51c Refactor: Require C++ for users of BLI_simd.h
This is because sse2neon.h might be used to emulate SSE intrinsics
on ARM64 architecture, and it uses some preprocessor which is not
available for C language when using MSVC.

The old-style math file math_matrix.c uses this header, so needed
to become C++. Simple rename did not work since there is a new math
utility math_matrix.cc exists. Following some existing convention
the math_matrix.c is renamed to math_matrix_c.cc. Eventually all the
code should switch to use C++ style math, and the C style removed,
so it seems reasonable to not mix old and new style of API in the
same file.

There should be no functional changes.

Pull Request: https://projects.blender.org/blender/blender/pulls/121335
2024-05-02 16:22:19 +02:00
Jacques Lucke
ebd2762239 Fix: crash when applying geometry nodes with bake node 2024-05-01 23:11:58 +02:00
Hans Goudey
a83e695c0a Cleanup: Use utility for safe division 2024-04-30 09:08:46 -04:00
Falk David
5ebce2c72c Fix: GPv3: Division by zero for single point curves
Makes sure to map curves with a single point to 0.0f in the
custom curve mapping.
2024-04-30 13:17:36 +02:00
Campbell Barton
08b3db500f Cleanup: correct asserts
Also remove redundant assert.
2024-04-25 12:02:14 +10:00