Commit Graph

23268 Commits

Author SHA1 Message Date
Jacques Lucke
4ab960b5a4 Merge branch 'blender-v4.0-release' 2023-10-31 13:47:00 +01:00
Jacques Lucke
c29857fffa Fix #113532: geometry nodes is always reevaluated after undo
The issue was that the undo system detected that node trees have been changed
even though they have not. This is because the memory dump of the node tree
changed after unrelated changes. The root issue was that
`bNodeTreeInterface::write` also wrote the struct, and the pointer of the
`bNodeTreeInterface` itself. While this pointer is generally stable, it is not
during file-write, because when IDs are written, a shallow copy is created
first (see `BLO_write_init_id_buffer_from_id`). The temporary buffer for this
shallow copy is allocated on the heap, so its pointer may change over time.

The fix is to simply not write the `bNodeTreeInterface` separately, since it's
already embedded in `bNodeTree`.

Pull Request: https://projects.blender.org/blender/blender/pulls/114322
2023-10-31 13:46:31 +01:00
Bastien Montagne
89bd460a7f Merge branch 'blender-v4.0-release' 2023-10-31 11:57:00 +01:00
Bastien Montagne
46c180015a Fix #114134: Make Local (All) operator is crashing Blender with Library Override.
Dummy mistake in own a238ab737b, forgot to do a NULL check...
2023-10-31 11:56:18 +01:00
Brecht Van Lommel
39107b3133 Revert changes from main commits that were merged into blender-v4.0-release
The last good commit was 8474716abb.

After this commits from main were pushed to blender-v4.0-release. These are
being reverted.

Commits a4880576dc from to b26f176d1a that happend afterwards were meant for
4.0, and their contents is preserved.
2023-10-30 21:40:35 +01:00
Campbell Barton
d31c61edee Cleanup: spelling in comments 2023-10-27 12:13:48 +11:00
Campbell Barton
b5a9cad252 Merge branch 'blender-v4.0-release' 2023-10-26 22:28:00 +11:00
Campbell Barton
4f0d8931f0 Fix undo crash with multiple scenes & windows
Creating a new window then a new scene would crash on undo
because the undo step loaded would not contain the new windows scene.

Regression introduced since 3.6.
2023-10-26 22:26:13 +11:00
Falk David
ab652f7b5f Fix: GPv3: Crash earsing when using modifier
This issue happend when a geometry nodes modifier wouldn't output grease
pencil geometry. In this case, we write an emtpy grease pencil
data-block to the evaluated `geometry_set`. But we don't update the
`eval_frame` that indicates on what frame the grease pencil data-block
was evaluated on.
The fix makes sure we update the `eval_frame` even if the output is
empty.

Additionally, there was a missing return in the
`get_evaluated_grease_pencil_drawing_deformation` function that lead
to an empty `deformation.positions` span.
The fix makes sure we return the correct deformation with the correct
positions.
2023-10-25 10:24:35 +02:00
Campbell Barton
5d3ce7c679 Merge branch 'blender-v4.0-release' 2023-10-25 15:43:18 +11:00
Campbell Barton
0b4dd16830 Merge branch 'blender-v4.0-release' 2023-10-25 15:43:15 +11:00
Campbell Barton
272f7637d0 Merge branch 'blender-v4.0-release' 2023-10-25 15:43:13 +11:00
Hans Goudey
692292536f Fix #113665: Sculpt mode does not unshare color attribute data
When retrieving a color attribute to paint it, the layer data needs to
be unshared so that it doesn't modify data from separate meshes.
In the past I think we've unknowingly avoided this problem by porting
code to the new attribute API. I've been refactoring `PBVH` and
`SculptSession` to make that possible (removing the long-lived
layer pointers in the two structs). But that wouldn't fit as a bug fix.
In the meantime, make sure the color attribute data is un-shared
and separate "for read" and "for write" versions of the function.

Pull Request: https://projects.blender.org/blender/blender/pulls/114119
2023-10-24 20:19:14 +02:00
Hans Goudey
7dcd777379 Fix #114077: Duplicate edges for two point evaluated curves
A curve with only two points shouldn't be considered cyclic. Otherwise
a duplicate edge is added between the points. This fixes the utility
that calculates the segment count to account for this and adjusts
other code to account for that as necessary. Curves now evaluate
correctly to a single evaluated segment in this case (in the case of
Bezier and NURBS curves, it depends on the resolution though).

Co-authored-by: Dalai Felinto <dalai@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/114095
2023-10-24 19:39:21 +02:00
Hans Goudey
5af8b839cf Fix #113988: Deformed PBVH modifies original normals
The PBVH is given the evaluated positions from the end of the modifier
stack, but then updates normals from the original mesh based on those
positions. This causes a feedback loop, even when in vertex paint mode.

As mentioned in a comment, calculating these normals and duplicating
the arrays is quite wasteful. But it's necessary since the PBVH always
assumes we are interested in modifying the positions, and also always
retrieves the normals from the original mesh too. Those things would
be good to untangle at some point too, but for now this change is small
and helps to clarify the situation as well.

Caused by: b339e3937d

Pull Request: https://projects.blender.org/blender/blender/pulls/114118
2023-10-24 18:56:15 +02:00
Sergey Sharybin
92a19747f0 Sculpt: Add timing information for BMesh PBVH
The goal is to make it possible to have more or less reliable way
to perform performance comparisons of changes in algorithms used
in dynamic topology.

This change allows to run Blender with the following arguments:

  blender --log "sculpt.detail,pbvh.bmesh" --log-level 2

and see timing of dynamic topology flood-fill operation, as well as
individual timings of edge subdivision/collapsing.

Pull Request: https://projects.blender.org/blender/blender/pulls/114099
2023-10-24 14:37:54 +02:00
Hans Goudey
7ba92a2a2f Fix #114081: Auto smooth versioning node group missing UI data
Fix the missing min and max and correc the interface socket's subtype.
2023-10-24 11:28:10 +02:00
Christoph Lendenfeld
265858525e Refactor: ANIM_setting_get_rna_values to return a Vector
No functional changes.

Changing old C code to C++ by returning a `Vector` from `ANIM_setting_get_rna_values`.
This reduces the argument count for that function and simplifies the code.

Pull Request: https://projects.blender.org/blender/blender/pulls/113931
2023-10-24 09:01:38 +02:00
Jacques Lucke
7254caa267 Merge branch 'blender-v4.0-release' 2023-10-23 21:29:25 +02:00
Jacques Lucke
312d8b1d66 Fix #114041: freeze connecting capture attribute to repeat output node
The issue was that a node was supposed to propagate an anonymous
attribute that is only created further to the right in the tree. This does not
during inferencing, where uses of fields can only come to the right of its
creation. Note, all fields coming out of the repeat input/output node are
new field sources during inferencing.

Now, only field sources that are passed from the outside into the repeat zone
can be propagated from the repeat output to the repeat input node.

Solving this also showed another issue where anonymous attributes are
not properly propagated through a repeat zone where there is no link between
the repeat input and output node. In such cases, data is still propagated between
those two nodes when the number of iterations is zero.
2023-10-23 21:29:00 +02:00
Dalai Felinto
6b7d0fe425 GPv3: Layer Selection modifier input
Known limitations to be addressed separately:

* We are not warning/keeping track of the named layers.
* There is no lookup for layers (groups) yet.

Ref !113908.
2023-10-23 15:49:34 +02:00
Dalai Felinto
f312be62ea GPv3: Named Layer Selection field
This field supports either a Layer, or a Layer Group name as input,
and outputs a selection.

The nodes that use this should add the name to the list of Named
Dependencies of the node-tree.

Ref !113908.
2023-10-23 15:49:34 +02:00
Pratik Borhade
357c213cde Fix #114010: Can't duplicate object data
This is due to missing switch case for new Grease pencil object.

Pull Request: https://projects.blender.org/blender/blender/pulls/114057
2023-10-23 13:10:22 +02:00
Bastien Montagne
65a6350250 Merge branch 'blender-v4.0-release' 2023-10-23 12:13:57 +02:00
Damien Picard
c7a6ede996 Fix #113981: ID plural names using spaces instead of underscores
Translation markers `N_()` were added to IDs' plural names in !113912.
I also renamed some of those because I thought there were only display
names.

This commit reverts the renaming, leaving only the addition of the
markers.

Pull Request: https://projects.blender.org/blender/blender/pulls/114030
2023-10-23 12:05:28 +02:00
Campbell Barton
c8c2343b4b Cleanup: spelling in comments 2023-10-23 10:09:05 +11:00
Douglas Paul
f5c9acc154 GPv3: Reimplement how customdata is updated when layers are re-ordered
Instead of calculating the expected insertion index for a customdata entry being moved, this implementation just records the initial layer indices so that it can compare them with the final indices to determine how the customdata entries need to be re-arranged.

Also simplifies the `add_layer` function and adds an implementation that just takes a `name` and adds a new layer with that name to the root group.

Pull Request: https://projects.blender.org/blender/blender/pulls/113962
2023-10-21 16:47:17 +02:00
casey bianco-davis
e266b142f6 GPv3: Transform operators
This adds the keybindings, menu, and functionally for the edit mode transform operators to grease pencil v3.

The transform operation include:
 * translate, rotate, scale, change opacity, change radius

Pull Request: https://projects.blender.org/blender/blender/pulls/111836
2023-10-21 15:12:47 +02:00
Jacques Lucke
b18810d2aa Merge branch 'blender-v4.0-release' 2023-10-20 21:22:11 +02:00
Jacques Lucke
0e9f472726 Fix #113773: repeat zone does not propagate anonymous attributes sometimes
The repeat zone needs some special treatment during anonymous attribute
inferencing, because it propagates those attributes directly  from the repeat
input to the repeat output node and vice versa.

Now the algorithm uses multiple passes if necessary to reach a stable
inferencing result.

Pull Request: https://projects.blender.org/blender/blender/pulls/113970
2023-10-20 21:21:40 +02:00
Hans Goudey
7b09983423 Cleanup: Consistent const usage in headers, use std::move
Avoid const for variables stored by value in structs/classes,
since that is redundant with the constness of the owner itself.
std::move a few strings that were missed before.
2023-10-20 19:32:26 +02:00
Falk David
e433a8eaaf GPv3: Replace find API with find_node_by_name
Instead of having two APIs (`find_layer_by_name` +
`find_layer_group_by_name`) replace them with a single API
`find_node_by_name`.
This returns a `TreeNode` but the caller can easily check if it's a
layer or a group.
2023-10-20 19:05:31 +02:00
Falk David
f6c8ddda26 GPv3: Add is_child_of function
Adds a new API to check if a node is a child of a group.
2023-10-20 18:51:22 +02:00
Hans Goudey
89e3ba4e25 Mesh: Replace auto smooth with node group
Design task: #93551

This PR replaces the auto smooth option with a geometry nodes modifier
that sets the sharp edge attribute. This solves a fair number of long-
standing problems related to auto smooth, simplifies the process of
normal computation, and allows Blender to automatically choose between
face, vertex, and face corner normals based on the sharp edge and face
attributes.

Versioning adds a geometry node group to objects with meshes that had
auto-smooth enabled. The modifier can be applied, which also improves
performance.

Auto smooth is now unnecessary to get a combination of sharp and smooth
edges. In general workflows are changed a bit. Separate procedural and
destructive workflows are available. Custom normals can be used
immediately without turning on the removed auto smooth option.

**Procedural**

The node group asset "Smooth by Angle" is the main way to set sharp
normals based on the edge angle. It can be accessed directly in the add
modifier menu. Of course the modifier can be reordered, muted, or
applied like any other, or changed internally like any geometry nodes
modifier.

**Destructive**
Often the sharp edges don't need to be dynamic. This can give better
performance since edge angles don't need to be recalculated. In edit
mode the two operators "Select Sharp Edges" and "Mark Sharp" can be
used. In other modes, the "Shade Smooth by Angle" controls the edge
sharpness directly.

### Breaking API Changes
- `use_auto_smooth` is removed. Face corner normals are now used
  automatically   if there are mixed smooth vs. not smooth tags. Meshes
  now always use custom normals if they exist.
- In Cycles, the lack of the separate auto smooth state makes normals look
  triangulated when all faces are shaded smooth.
- `auto_smooth_angle` is removed. Replaced by a modifier (or operator)
  controlling the sharp edge attribute. This means the mesh itself
  (without an object) doesn't know anything about automatically smoothing
  by angle anymore.
- `create_normals_split`, `calc_normals_split`, and `free_normals_split`
  are removed, and are replaced by the simpler `Mesh.corner_normals`
  collection property. Since it gives access to the normals cache, it
  is automatically updated when relevant data changes.

Addons are updated here: https://projects.blender.org/blender/blender-addons/pulls/104609

### Tests
- `geo_node_curves_test_deform_curves_on_surface` has slightly different
   results because face corner normals are used instead of interpolated
   vertex normals.
- `bf_wavefront_obj_tests` has different export results for one file
  which mixed sharp and smooth faces without turning on auto smooth.
- `cycles_mesh_cpu` has one object which is completely flat shaded.
  Previously every edge was split before rendering, now it looks triangulated.

Pull Request: https://projects.blender.org/blender/blender/pulls/108014
2023-10-20 16:54:08 +02:00
Jacques Lucke
65d4ae7445 Merge branch 'blender-v4.0-release' 2023-10-20 16:48:16 +02:00
Jacques Lucke
051b02ed11 Fix #113851: viscoelastic springs do not work
Caused by 425b871607.

The root issue was that these two states of the hash table were
mixed up in 425b871607: (1) the hash table exists and (2) the hash
table is empty.

The use of `std::optional` restores these two different states again.
2023-10-20 16:47:41 +02:00
Sergey Sharybin
15ab734faf Fix: Dyntopo sculpt on plane destroys the mesh
The issue is probably deeper and affects more cases. The plane with an
edge loop in the center added was the case which shown the error.

Caused by a mistake in the refactor in 062169698a which left an array
size uninitialized before filling it in.

Pull Request: https://projects.blender.org/blender/blender/pulls/113972
2023-10-20 16:09:36 +02:00
Philipp Oeser
9e7fd16c19 Merge branch 'blender-v4.0-release' 2023-10-20 14:23:42 +02:00
Philipp Oeser
bb8cb4e56f Fix #113810: Frame Range Metadata missing when burned into image
Probably an oversight in 6c3110a661 ?

Now added the necessary bits to make it work in `BKE_image_stamp_buf` as
well.

Pull Request: https://projects.blender.org/blender/blender/pulls/113840
2023-10-20 14:22:57 +02:00
Sergey Sharybin
21c8af467d Cleanup: Convert winfunc and utfconv to C++
Basically, the intern/utfconv directory, as well as users of
these headers.

Pull Request: https://projects.blender.org/blender/blender/pulls/113901
2023-10-20 10:27:31 +02:00
Sergey Sharybin
85c557ffa2 Cleanup: Rename BLI_string_utils.h to BLI_string_utils.hh
All users of it are now C++, which opens doors to add C++ to the
public API.
2023-10-20 10:27:26 +02:00
Bastien Montagne
3aa5644751 Merge branch 'blender-v4.0-release' 2023-10-19 21:42:26 +02:00
Damien Picard
e3fc935349 I18n: disambiguate and extract a few messages
Extract:
- Sculpt filter types from the Sculpt menu. Some of these types use a
  custom label, different  from those defined in the operator RNA,
  which was never extracted.
- "Today" and "Yesterday" from the file browser modification date.
- All name_plural from IDs, as these are used in the UI to list which
  data block is to be removed, when calling outliner.orphans_purge.

Disambiguate:
- "Area", meaning the measurement of a surface as opposed to a place.

Some messages reported by Satoshi Yamasaki in #43295.

Pull Request: https://projects.blender.org/blender/blender/pulls/113912
2023-10-19 21:39:58 +02:00
Sergey Sharybin
687e58bb77 Cleanup: Simplify public API of unique name functions
Their return value was only used in one place.

Change it to comparison with a stored name, and make the functions
to return void instead.

Removing the return boolean makes it possible to change underlying
functions to work with std::string and return unique name by value.

Pull Request: https://projects.blender.org/blender/blender/pulls/113934
2023-10-19 15:07:57 +02:00
Hans Goudey
fba7671205 Cleanup: Const correctness, unused variable warning in GP draw code 2023-10-19 15:03:32 +02:00
Hans Goudey
1cbd0f5a85 Refactor: Improve access to object data bounds
Currently object bounds (`object.runtime.bb`) are lazily initialized
when accessed. This access happens from arbitrary threads, and
is unprotected by a mutex. This can cause access to stale data at
best, and crashes at worst. Eager calculation is meant to keep this
working, but it's fragile.

Since e8f4010611, geometry bounds are cached in the geometry
itself, which makes this object-level cache redundant. So, it's clearer
to build the  `BoundBox` from those cached bounds and return it by
value, without interacting with the object's cached bounding box.

The code change is is mostly a move from `const BoundBox *` to
`std::optional<BoundBox>`. This is only one step of a larger change
described in #96968. Followup steps would include switching to
a simpler and smaller `Bounds` type, removing redundant object-
level access, and eventually removing `object.runtime.bb`.

Access of bounds from the object for mesh, curves, and point cloud
objects should now be thread-safe. Other object types still lazily
initialize the object `BoundBox` cache since they don't have
a data-level cache.

Pull Request: https://projects.blender.org/blender/blender/pulls/113465
2023-10-19 14:18:40 +02:00
Hans Goudey
40080f618c Sculpt: Use C++ Set to store PBVH Node BMesh elements
Mainly to simplify code and also add some add type safety, replace
`GSet` with `blender::Set` for the storage of BMesh triangles and
vertices on each PBVH node. Some initial tests point to better
performance too, but the numbers are hard to verify so far.

Because of the larger `PBVHNode`, memory usage slightly increases
(observed a 2% increase with a 1M face grid) for regular Mesh sculpting,
but it seems `Set` is more memory efficient than `GSet`, because I also
observed a 10% decrease in memory usage for dynamic topology.
In the future nodes can be split in a more data-oriented fashion to
reduce memory usage overall.

This also makes it simpler to switch to another type in the future.

Pull Request: https://projects.blender.org/blender/blender/pulls/113907
2023-10-19 14:18:15 +02:00
Campbell Barton
0488117548 Unbreak debug build 2023-10-19 22:43:26 +11:00
Falk David
26816931c4 Fix: GPv3: Remap materials
Also fixes a crash when moving the first material of the default Grease Pencil Suzanne down by one.

Pull Request: https://projects.blender.org/blender/blender/pulls/113855
2023-10-19 13:19:41 +02:00
Lukas Tönne
367320a0f5 Merge branch 'blender-v4.0-release' 2023-10-19 11:48:54 +02:00