Commit Graph

3891 Commits

Author SHA1 Message Date
Campbell Barton
25279acc91 Cleanup: add SPDX copyright 2023-07-13 13:43:20 +10:00
Campbell Barton
f9316e4079 Cleanup: spelling in comments 2023-07-12 12:45:35 +10:00
Jacques Lucke
3d73b71a97 Geometry Nodes: new Repeat Zone
This adds support for running a set of nodes repeatedly. The number
of iterations can be controlled dynamically as an input of the repeat
zone. The repeat zone can be added in via the search or from the
Add > Utilities menu.

The main use case is to replace long repetitive node chains with a more
flexible alternative. Technically, repeat zones can also be used for
many other use cases. However, due to their serial nature, performance
is very  sub-optimal when they are used to solve problems that could
be processed in parallel. Better solutions for such use cases will
be worked on separately.

Repeat zones are similar to simulation zones. The major difference is
that they have no concept of time and are always evaluated entirely in
the current frame, while in simulations only a single iteration is
evaluated per frame.

Stopping the repetition early using a dynamic condition is not yet
supported. "Break" functionality can be implemented manually using
Switch nodes in the  loop for now. It's likely that this functionality
will be built into the repeat zone in the future.
For now, things are kept more simple.

Remaining Todos after this first version:
* Improve socket inspection and viewer node support. Currently, only
  the first iteration is taken into account for socket inspection
  and the viewer.
* Make loop evaluation more lazy. Currently, the evaluation is eager,
  meaning that it evaluates some nodes even though their output may not
  be required.

Pull Request: https://projects.blender.org/blender/blender/pulls/109164
2023-07-11 22:36:10 +02:00
Hans Goudey
90ba798885 Cleanup: Remove file added mistakenly in previous commit 2023-07-11 14:54:54 -04:00
Hans Goudey
be09e94f05 Cleanup: Remove unused animation channel type
Unused after f3f05daf11
2023-07-11 14:50:29 -04:00
Hans Goudey
f5ffdafea2 Fix: Node operators crash when using depsgraph
The scene time node and volume nodes crashed, since the despgraph
needs to be retrieved from the operator data instead of modifier data.
2023-07-11 13:38:25 -04:00
Ray molenkamp
07fe6c5a57 Cleanup: CMake: Modernize bf_blenkernel dependencies
Pretty straightforward

- Remove any blenkernel paths from INC
- Add a dependency though LIB

context: https://devtalk.blender.org/t/cmake-cleanup/30260

Pull Request: https://projects.blender.org/blender/blender/pulls/109939
2023-07-11 19:28:01 +02:00
Hans Goudey
424c6edc53 Geometry Nodes: Avoid geometry copies in "no cache" simulation
When we don't need to preserve a persistent cache, we can use
the geometry from the last frame directly rather than copying it.
Though implicit lets us avoid copying large data arrays when they
aren't changed, this can still give a large improvement for something
like particle simulation where the majority of the data was copied
every frame.

Pull Request: https://projects.blender.org/blender/blender/pulls/109742
2023-07-11 14:03:12 +02:00
Jacques Lucke
7ec335f995 Geometry Nodes: add run-time data to geometry nodes modifier
This adds a single run-time field and moves the existing run-time data into a new struct.
This approach makes it much easier to add new run-time data.

Pull Request: https://projects.blender.org/blender/blender/pulls/109905
2023-07-11 12:55:57 +02:00
Ray Molenkamp
04235d0e55 Cleanup: CMake: Modernize bf_blenlib dependencies
Pretty straightforward

- Remove any blenlib paths from INC
- Add a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109934
2023-07-10 22:04:18 +02:00
Iliya Katueshenock
94914d12f3 Fix #109341: Try to store single value fields as single in simulation
Sampling nodes produce fields, but can be used for
single values. If this used in simulation, this will not work
correctly, not similar as other singles. Just compute these
fields as single to store in Simulation Output node.

Pull Request: https://projects.blender.org/blender/blender/pulls/109879
2023-07-10 19:11:06 +02:00
Ray Molenkamp
57ad866d81 Cleanup: CMake: Modernize bf_guardedalloc dependencies
Pretty straightforward

- Removes any guardedalloc paths from INC
- Adds a dependency though LIB

Pull Request: https://projects.blender.org/blender/blender/pulls/109925
2023-07-10 18:44:19 +02:00
Iliya Katueshenock
a8186e1542 Fix #109885: Check if BVH tree is null in correct place
The `BKE_bvhtree_from_pointcloud_get` function have requirements for
input point cloud argument and initialization of `BVHTreeFromPointCloud`
can be skipped. Due to `BVHTreeFromPointCloud` is not initialized by
default constructor, it can contains garbage data. To check if tree is
initialized field of `BVHTreeFromPointCloud`, return argument shouldn't
be ignored. `[[nodiscard]]` attributes is added.

Pull Request: https://projects.blender.org/blender/blender/pulls/109892
2023-07-10 18:12:41 +02:00
Ray Molenkamp
7cebb61486 Cleanup: CMake: Modernize bf_dna dependencies
There's quite a few libraries that depend on dna_type_offsets.h
but had gotten to it by just adding the folder that contains it to
their includes INC section without declaring a dependency to
bf_dna in the LIB section.

which occasionally lead to the lib building before bf_dna and the
header being missing, while this generally gets fixed in CMake by
adding bf_dna to the LIB section of the lib, however until last
week all libraries in the LIB section were linked as INTERFACE so
adding it in there did not resolve the build issue.

To make things still build, we sprinkled add_dependencies wherever
we needed it to force a build order.

This diff :

Declares public include folders for the bf_dna target so there's
no more fudging the INC section required to get to them.

Removes all dna related paths from the INC section for all
libraries.

Adds an alias target bf:dna to signify it has been updated to
modern cmake

Declares a dependency on bf::dna for all libraries that require it

Removes (almost) all calls to add_dependencies for bf_dna

Future work:

Because of the manual dependency management that was done, there is
now some "clutter" with libs depending on bf_dna that realistically
don't. Example bf_intern_opencolorio itself has no dependency on
bf_dna at all, doesn't need it, doesn't use it. However the
dna include folder had been added to it in the past since bf_blenlib
uses dna headers in some of its public headers and
bf_intern_opencolorio does use those blenlib headers.

Given bf_blenlib now correctly declares the dependency on bf_dna
as public bf_intern_opencolorio will get the dna header directory
automatically from CMake, hence some cleanup could be done for
bf_intern_opencolorio

Because 99% of the changes in this diff have been automated, this diff
does not seek to address these issues as there is no easy way to
determine why a certain dependency is in place. A developer will have
to make a pass a this at some later point in time. As I'd rather not
mix automated and manual labour.

There are a few libraries that could not be automatically processed
(ie bf_blendthumb) that also will need this manual look-over.

Pull Request: https://projects.blender.org/blender/blender/pulls/109835
2023-07-10 15:07:37 +02:00
Iliya Katueshenock
c78b6e9954 Geometry Nodes: Improve Blur node face domain performance
Slight speed up of face topology building for blur node.
Avoid using increment and replacing by adding size.
Multi-threading for accumulating offsets. Early returns
in one place places. In a test with a large grid, the node
became 36% faster, with 13 out of 40 ms saved from
the topology building.

Pull Request: https://projects.blender.org/blender/blender/pulls/109764
2023-07-10 13:47:29 +02:00
Brecht Van Lommel
f2705dd913 Fix #109683: Cycles and Eevee missing AOVs when no closure connected
No reason to skip these, and this will be useful for faster shader node
preview rendering based on AOVs.

Pull Request: https://projects.blender.org/blender/blender/pulls/109709
2023-07-10 12:41:44 +02:00
Campbell Barton
6290451712 Cleanup: spelling in comments 2023-07-09 21:22:45 +10:00
Hoshinova
c9fbbea261 Cleanup: Assign corresponding expressions to variable params.max_distance
Pull Request: https://projects.blender.org/blender/blender/pulls/109328
2023-07-06 18:13:22 +02:00
Hans Goudey
2b4666b17b Geometry Nodes: Fill new quad poly offsets in parallel
Add an offset indices utility to do fill constant size new offsets in
parallel, which was already done in the duplicate elements node.

For example, filling poly offsets for a new part of a mesh that is only
quads. In the extrude node this was single-threaded before, so the
new poly offsets is about 10x faster, saving about 10 out of 157 ms
when extruding 2 million faces.
2023-07-05 15:39:33 -04:00
Campbell Barton
785bd13b9a Cleanup: spelling in comments 2023-07-05 14:09:33 +10:00
Sergey Sharybin
e1b60fdb91 Remove Z Buffer from ImBuf
It was only used by OpenEXR and Iris images, and saving the Z Buffer
in those formats was disabled by default. This option comes from the
times prior to the addition of the Multilayer EXR.

It also worth noting that it was not possible to save Iris with Depth
pass from Blender as internally it is called IRIZ format and it was
not exposed. But even after exposing this format option something still
was missing as saving and loading ITIZ did not show up the Depth pass.

The reason of removal is to make it a more clear match of the ImBuf
with a render pass, and use it instead of a custom type in the render
result and render pass API. This will simplify the API and also avoid
stealing buffers and making shallow copies when showing the render
result.

For the cases when Depth is needed a Multilayer EXR is to be used,
as most likely more than just the Depth will be needed.

On a user level this change:

- Removes the "Z Buffer" option from the interface.

- It preserves existing sockets in compositor nodes, but it will
  output black image. Also changing the image data-block will
  remove the socket unless a Multilayer EXR with Depth pass image
  is selected.

- Removes "Depth" socket of the Viewer and Composite nodes.

Ref #108618

Pull Request: https://projects.blender.org/blender/blender/pulls/109687
2023-07-04 17:03:02 +02:00
Campbell Barton
9753e70e37 Cleanup: move BLI_str_replace into BLI_string_utils.h
String search & replace is a higher level function (unlike BLI_string.h)
which handlers lower level replacements for printing and string copying.

Also use BLI_string_* prefix (matching other utilities).

This makes it possible to use BLI_string in Blender's internal utilities
without depending on DynStr, MemArena... etc.
2023-07-04 12:02:25 +10:00
Hans Goudey
a3bfd6e20d Cleanup: Extract utility for counting indices
This utility counts the number of occurrences of each index in an array.
This is used for building mesh topology maps offsets, or for counting
the number of connected elements. Some users are geometry nodes,
the subdivision draw cache, and mesh to curve conversion.

See #109628
2023-07-03 18:47:03 -04:00
Damien Picard
11ecfaa6b0 I18n: use proper name for the Convert Colorspace node
The Convert Colorspace node uses "Convert Colorspace" as a name on
registration, but it uses "Color Space" as a `DefNode()` in
NOD_static_types.h.

As a result, the node name is not extracted to the .po files, and thus
not translated.

This commit uses the same name in all definitions of the node.

Pull Request: https://projects.blender.org/blender/blender/pulls/109419
2023-07-03 12:16:43 +02:00
Hans Goudey
7be0d1481c Cleanup: Simplify topology node deduplication comparisons
And add deduplication to the corners of edge count field input.
2023-07-02 18:31:20 -04:00
Hans Goudey
4369429101 Cleanup: Move NOD_socket.h to C++
See #103343

Pull Request: https://projects.blender.org/blender/blender/pulls/109623
2023-07-02 21:01:57 +02:00
Hans Goudey
4f90504def Fix: Node group operator crash with group node
`modifier_data` is null when geometry nodes executes as an operator.
2023-07-02 11:40:31 -04:00
Iliya Katueshenock
6777c0c98e Fix: Assert creating offsets in duplicate elements node
Fix of assert for debug build. Offsets have one last extra
element, used to contain offset for last real element. When
copying values to offsets, the last element has to be ignored.

Pull Request: https://projects.blender.org/blender/blender/pulls/109476
2023-07-02 17:22:51 +02:00
Campbell Barton
69aee8ba6b Cleanup: remove redundant (void) for functions with no args in C++ 2023-07-02 19:54:27 +10:00
Jacques Lucke
db7b2ef386 Cleanup: remove unnecessary "struct" in declaration 2023-07-02 11:37:56 +02:00
Jacques Lucke
f33d7bb598 Nodes: add nested node ids and use them for simulation state
The simulation state used by simulation nodes is owned by the modifier. Since a
geometry nodes setup can contain an arbitrary number of simulations, the modifier
has a mapping from `SimulationZoneID` to `SimulationZoneState`. This patch changes
what is used as `SimulationZoneID`.

Previously, the `SimulationZoneID` contained a list of `bNode::identifier` that described
the path from the root node tree to the simulation output node. This works ok in many
cases, but also has a significant problem: The `SimulationZoneID` changes when moving
the simulation zone into or out of a node group. This implies that any of these operations
loses the mapping from zone to simulation state, invalidating the cache or even baked data.

The goal of this patch is to introduce a single-integer ID that identifies a (nested) simulation
zone and is stable even when grouping and un-grouping. The ID should be stable even if the
node group containing the (nested) simulation zone is in a separate linked .blend file and
that linked file is changed.

In the future, the same kind of ID can be used to store e.g. checkpoint/baked/frozen data
in the modifier.

To achieve the described goal, node trees can now store an arbitrary number of nested node
references (an array of `bNestedNodeRef`). Each nested node reference has an ID that is
unique within the current node tree. The node tree does not store the entire path to the
nested node. Instead it only know which group node the nested node is in, and what the
nested node ID of the node is within that group. Grouping and un-grouping operations
have to update the nested node references to keep the IDs stable. Importantly though,
these operations only have to care about the two node groups that are affected. IDs in
higher level node groups remain unchanged by design.

A consequence of this design is that every `bNodeTree` now has a `bNestedNodeRef`
for every (nested) simulation zone. Two instances of the same simulation zone (because
a node group is reused) are referenced by two separate `bNestedNodeRef`. This is
important to keep in mind, because it also means that this solution doesn't scale well if
we wanted to use it to keep stable references to *all* nested nodes. I can't think of a
solution that fulfills the described requirements but scales better with more nodes. For
that reason, this solution should only be used when we want to store data for each
referenced nested node at the top level (like we do for simulations).

This is not a replacement for `ViewerPath` which can store a path to data in a node tree
without changing the node tree. Also `ViewerPath` can contain information like the loop
iteration that should be viewed (#109164). `bNestedNodeRef` can't differentiate between
different iterations of a loop. This also means that simulations can't be used inside of a
loop (loops inside of a simulation work fine though).

When baking, the new stable ID is now written to disk, which means that baked data is
not invalidated by grouping/un-grouping operations. Backward compatibility for baked
data is provided, but only works as long as the simulation zone has not been moved to
a different node group yet. Forward compatibility for the baked data is not provided
(so older versions can't load the data baked with a newer version of Blender).

Pull Request: https://projects.blender.org/blender/blender/pulls/109444
2023-07-01 11:54:32 +02:00
Jacques Lucke
422e0c02e9 Cleanup: move more rna files to C++
Also see #103343.

There was one unusual complication due to `openvdb` here. The `BKE_volume.h`
header included `openvdb` but that would not link correctly in rna code. I'm not entirely
sure why any of the openvdb code is actually instantiated, may be an issue in the
`openvdb` headers. The solution is to create a new header that gives access to the
underlying `openvdb` data structure for a `Volume` geometry. This header can't be
included in rna for now, until the linking issues are resolved.

Pull Request: https://projects.blender.org/blender/blender/pulls/109508
2023-06-30 08:49:53 +02:00
Hans Goudey
e4cc91a611 Geometry Nodes: Node group operators initial phase
This PR adds a new operator to run a node group on object geometry.
Only curves sculpt mode is supported for now, to simplify the design.

A new geometry node editor context to edit operator groups is also
added. This allows changing any node group, rather than only node
groups that are part of the active modifier context.

3D viewport menus are added with any geometry node group
asset in a catalog that contains the `Operator` tag. Currently Blender
must be restarted to refresh the list of available operators.

This is only the first phase of the node group operator feature.
Many more features will be added in next steps.

See #101778

Pull Request: https://projects.blender.org/blender/blender/pulls/108947
2023-06-29 13:57:54 +02:00
Chris Blackbourn
dee737d64b Cleanup: use c++ constructor and destructor for paramhandle in uv unwrap 2023-06-29 17:19:09 +12:00
Iliya Katueshenock
ffb0517e6e Cleanup: fix debug lazy function name for Switch node
Pull Request: https://projects.blender.org/blender/blender/pulls/109437
2023-06-28 17:26:31 +02:00
Hans Goudey
a1cc621e1e Cleanup: Remove unused custom data type
`CD_HAIRLENGTH` is not really a custom data type, it was just used to
specify the hair particle "length" attribute to pass it to EEVEE and
material preview. Because of the "typemap" array in `CustomData`,
it's better not to have this unnecessary type. Instead, use the same
mechanism used to request the active color attribute.

Pull Request: https://projects.blender.org/blender/blender/pulls/109449
2023-06-28 17:17:31 +02:00
Iliya Katueshenock
fde8e6ce65 Fix #109406: Ignore unsupported socket in shader
In 3957a1ad03 was
added the new Rotation socket to a Mix node.
Mix node can be used in shaders node tree. This cause problem,
rotation socket is not supported in shader currently. This fix
just add check to ignore any unsupported sockets in shader and
to fix any related problem.

Pull Request: https://projects.blender.org/blender/blender/pulls/109410
2023-06-27 16:46:18 +02:00
Iliya Katueshenock
3957a1ad03 Geometry Nodes: Mix Rotations
Add support a new Rotation socket/data type to a Mix node.

Rotation socket avala ible only in Geometry Nodes right now,
list of supported types for node depend on own node tree type.

Mixing kind is slerp (interpolation) of a quaternion. As initial
phase this is enough. In a future, other modes of interpolation
can be added (Euler for XY+Z, YZ+X, ZX+Y, ...). Clamping for
factor work the same as for all other data types.

Drag and drop should take care avoiding create links between
Rotation sockets and all other socket types, this requires chages
is mix node callback for drag & drop system.

See: https://projects.blender.org/blender/blender/issues/92967

Pull Request: https://projects.blender.org/blender/blender/pulls/109084
2023-06-27 00:50:53 +02:00
Damien Picard
44d012ce1d I18n: disambiguate a few messages
- "Front"/"Back": 'put something at the front/back' or 'the front/back
  face of something'. (e. g. the Empty Image options, Depth and Side
  option, both use the same strings as enum, which should be avoided
  in some languages).
- "Flip": invert, as in normals, or mirror, as in an image.
- "Path": a path to a resource, in general a file but sometimes a
  datablock, as opposed to a trajectory in space.
- "Join": disambiguate for the Grease Pencil operator, which may use a
  different word as that for meshes.
- "Wave": an ondulating motion, as opposed to a fluid dynamics motion.
- "Step": can mean the distance between two things, or a number of
  times to do something. In this case it is better to use the plural.
- "Edge": generally the edges of a mesh, but can also mean edge
  detection. Additionally, it was used for the option to enable
  Freestyle. This was changed to "Use Freestyle".
- "Boundary": the limit of a grease pencil drawing for filling
  purposes, as opposed to the external limit of a (non-manifold) mesh.
- "Rotations": can be translated to something like "Turns", in the
  context of a spiral.

Pull Request: https://projects.blender.org/blender/blender/pulls/108213
2023-06-26 15:07:06 +02:00
Jacques Lucke
af476f6a62 Nodes: fix zone detection for some special cases
This fixes crashes in the cases when:
* Two zones have a cyclic parent relationship.
* A node has more than one direct parent zone.
2023-06-26 14:33:37 +02:00
Bastien Montagne
21f5c7c45f Merge branch 'blender-v3.6-release' 2023-06-26 12:37:11 +02:00
Iliya Katueshenock
5f2368753a Fix #109307: memory leak changing simulation item name
Pull Request: https://projects.blender.org/blender/blender/pulls/109324
2023-06-26 12:33:13 +02:00
Iliya Katueshenock
39386175e1 Fix: Incorrect rotation socket hiding in raycast node
The typo was made in 63dae2a105.

Pull Request: https://projects.blender.org/blender/blender/pulls/109352
2023-06-26 03:27:34 +02:00
Campbell Barton
f4a65cfe5d BLI_string: remove potentially unsafe BLI_sprintf
Replace by BLI_snprintf or string joining.

See #108917.
2023-06-25 13:34:31 +10:00
Hans Goudey
c1292b4a80 Revert "Fix: Revert changes in Mesh to Volume node and modifier to Blender 3.6"
This reverts commit 537fdbbfa2.

Somehow the revert in 9b708c8650
was undone by the next merge from the 3.6 branch,
9876ff183f.
2023-06-24 14:11:17 -04:00
Omar Emara
c9e6399fe1 Realtime Compositor: Implement Keying node
This patch implements the Keying node for the realtime compositor. To
ease the implementation, some morphological operators were moved into
algorithms and a mechanism to steal data between results was added to
the Result class.

Pull Request: https://projects.blender.org/blender/blender/pulls/108393
2023-06-24 13:02:33 +02:00
Germano Cavalcante
9876ff183f Merge branch 'blender-v3.6-release' into main 2023-06-23 18:26:53 -03:00
Hans Goudey
e570f13616 Cleanup: Move NOD_geometry.h to C++
Pull Request: https://projects.blender.org/blender/blender/pulls/109306
2023-06-23 22:15:42 +02:00
Hans Goudey
9b708c8650 Revert "Fix: Revert changes in Mesh to Volume node and modifier to Blender 3.6"
This reverts commit 0b0a5d21ac.

The breaking changes in that commit have been postponed to 4.0.
2023-06-23 14:14:17 -04:00
Jacques Lucke
537fdbbfa2 Fix: Revert changes in Mesh to Volume node and modifier to Blender 3.6
This brings back the `Fill Volume` and `Exterior Bandwidth` inputs in
the Mesh to Volume node and modifier. Those existed in Blender 3.5 but
were removed in 700d168a5c because the way they were
implemented did not use the openvdb api in the right way.

While it's rare that people turned off the `Fill Volume` option, the
exterior bandwidth was used more and can have significant impact on
the result. Furthermore, there is no clear replacement for the
functionality.

Therefore, we decided to roll back the changes in 3.6 to avoid breaking
compatibility. We intend to keep the changes in 4.0 for now, but need
to work on a more clear short term replacement for the removed
functionality.

Pull Request: https://projects.blender.org/blender/blender/pulls/109297
2023-06-23 14:14:17 -04:00