Commit Graph

3595 Commits

Author SHA1 Message Date
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
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
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
Brecht Van Lommel
15b9ae5436 Refactor: Use typed functions for blend file data reading
This makes the read and write API functions match more closely, and adds
asserts to check that the data size is as expected.

There are still a few places remaining that use BLO_read_data_address
and similar generic functions, these should eventually be replaced as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/120994
2024-04-24 17:01:22 +02:00
Campbell Barton
1865776767 Cleanup: doxygen syntax, use colons after "param" arguments, not "note" 2024-04-24 10:55:44 +10:00
Campbell Barton
fd589fdca4 Cleanup: various non functional C++ changes 2024-04-20 13:46:14 +10:00
Hans Goudey
11f0d88d13 Subdiv: Move most blenkernel subdiv code to C++ namespace
Move most code to `blender::bke::subdiv`. That helps organization
and makes using C++ in subdiv code easier, which will be useful for
removing the unnecessary opensubdiv C-API wrapper.
2024-04-19 09:03:31 -04:00
Hans Goudey
40b7bf30c8 Cleanup: Remove unused variable 2024-04-18 15:17:28 -04:00
Jesse Yurkovich
3f8ec963e3 Fix: Use correct datatype in MSC modify_geometry_set for the frame time
The recently added `modify_geometry_set` code path [1] inside the Mesh
Sequence Cache was meant to follow what was done inside `modify_mesh`
but failed to use the correct data type for the time offset. Double is
used throughout Blender when dealing with the frame time and this was
simply missed.

This results in rounding errors and downstream consumers like USD would
re-read the wrong frames. e.g. it would read frame 4 twice because the
values provided when switching from frame 4 to frame 5 were
`4.000000119209290` and `4.999999880790710` instead of
`4.000000000000000` and `5.000000000000000` with this patch.

[1] ea256346a8

Pull Request: https://projects.blender.org/blender/blender/pulls/120790
2024-04-18 20:55:13 +02:00
Hans Goudey
9a7f4a3b58 Modifiers: Affect all selected objects when holding alt
Support holding alt while invoking modifier operations for add, apply,
remove, and move to index in the property editor. This affects all selected
editable objects instead of just the active object.

Though the alt key is not that visible, it's consistent with the
existing multi-object property editing shortcut. If/when multi-
object editing is every made the default, the alt key could
be reversed here too.

Changes as part of #120230.

Pull Request: https://projects.blender.org/blender/blender/pulls/120695
2024-04-18 17:40:50 +02:00
Hans Goudey
fda57f8e84 Fix: Vertex normal calculation broken in array modifier
Mistake in 6023a6a423
2024-04-16 09:14:50 -04:00
Hans Goudey
75804f2dd0 Fix #120575: GPU subdivision ignores split normals from sharp edges
Fall back to CPU subdivision when there are split edges and the mesh
normals domain is face corners. This is required because splitting the
normals on faces adjacent to sharp edges doesn't work well with the
performance requirements of GPU subdivision.

This is related to 1111903416

Pull Request: https://projects.blender.org/blender/blender/pulls/120674
2024-04-15 21:19:54 +02:00
Damien Picard
abc0bf814f UI: Fix and improve a few messages
- "Log Encoding with Chroma inset and rotation": add "of primaries" in
  the description of the AgX Log color space to better explain the
  operation, based on wording in !106355.
- Remove a few double spaces.
- Make Line Art title case everywhere, to convey it's the system /
  brand / product name and not the generic concept.
- "Copy Absolute coordinates or Normal vector" -> "of Normal Vector":
typo.
- "Makes a link between selected output in input sockets" ->
  "Make...", "output and input": typo.
- "Purge Unused Data From This File" -> "from this": title case as per
  HIGs.
- GPencil -> Grease Pencil: no reason to use an abbreviation here.
- "Around Current Frame" -> "Around Frame": actual name of the
  onion-skinning method.
- "... (layer height for layer tool, i.e.)" -> "(i.e. the layer height
  for the layer tool)": put "i.e." at the start of the sentence.
- Expand description of toe-in stereo camera option.
- "Children collections their parent-collection-specific settings" ->
  "Children collections with their...": typo.
- "Generate vertex weights base on..." -> "based on" : typo, lower
  case.
- Expand description of GP modifier properties, based on their mesh
  counterparts.
- "AEnvelope" -> "Envelope": typo.
- "Falloff type the feather" -> "of the feather": typo.
- "usually make transition as long as effect strip": rephrase.
- "When disabled a users extensions directory is created" -> "a
  user's": typo.
- "successfull" -> "successful": typo.
- "Remove all attributes... a single wildcard (*).": remove trailing
  ".".
- "..., use "Save Preferences."": remove trailing ".".

Some issues reported by Marina Veselkova and Tamar Mebonia.

Pull Request: https://projects.blender.org/blender/blender/pulls/120649
2024-04-15 20:02:38 +02:00
Campbell Barton
49bf7ebbdd Cleanup: use const args & variables, remove redundant checks
- Declare const variables & arguments.
- Remove redundant null checks.
- Remove break after return.
- Replace suspicious "&" with "&&".
2024-04-15 09:50:47 +10:00
Hans Goudey
c91449836a Cleanup: Move BKE_workspace.h to C++ 2024-04-12 17:03:18 -04:00
Falk David
089a435376 Fix: GPv3: Default value for fill opacity in opacity modifier
Make sure the default value for the fill opacity is 1 instead of 0.
2024-04-12 17:42:42 +02:00
Hans Goudey
3d1bf4eb74 Fix: Properly free/allocate non-trivial shrinkwrap cache struct
Mistake in 0b80d5e755

Pull Request: https://projects.blender.org/blender/blender/pulls/120527
2024-04-11 16:15:18 +02:00
Lukas Tönne
68060a9ccf GPv3: Implement UV rotation mode for the noise modifier
UV rotation in the noise modifier was a todo since UVs were not
supported yet at the time the modifier was added. This patch adds the
missing UV rotation feature.

Pull Request: https://projects.blender.org/blender/blender/pulls/120336
2024-04-06 14:25:18 +02:00
Pablo Vazquez
4e90501377 UI: Fix label in Particle System modifier
Fix two issues with the current label:
1. "particle tab" should be "Particles tab" since that's the actual name
    of the tab.
2. "Settings are in..." is inconsistent with similar labels where the
   word used is "inside" instead of "in".

Pull Request: https://projects.blender.org/blender/blender/pulls/120319
2024-04-05 18:50:57 +02:00