Geometry Nodes: add simulation support #104924

Closed
Hans Goudey wants to merge 211 commits from geometry-nodes-simulation into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

211 Commits

Author SHA1 Message Date
Jacques Lucke 319f31b8ae Merge branch 'main' into geometry-nodes-simulation
buildbot/vexp-code-patch-coordinator Build done. Details
2023-05-03 12:55:37 +02:00
Jacques Lucke 9d65f08342 fix after merge 2023-05-03 10:46:01 +02:00
Jacques Lucke d1882427a0 Merge branch 'main' into geometry-nodes-simulation 2023-05-03 10:34:05 +02:00
Hans Goudey 05fb698608 Fix: Compile error from change in main
buildbot/vexp-code-patch-coordinator Build done. Details
2023-05-02 10:06:19 -04:00
Jacques Lucke 625865ef3c Merge branch 'geometry-nodes-simulation' of https://projects.blender.org/blender/blender into geometry-nodes-simulation 2023-05-02 16:03:30 +02:00
Jacques Lucke 9096ca5ffa Cleanup: remove dead code
Ensuring node declarations is now done at a higher level.
2023-05-02 16:03:10 +02:00
Hans Goudey ee8a24af80 Fix build error from changed function name in main 2023-05-02 10:00:06 -04:00
Hans Goudey 092b9f6bb5 Revert "Add initial non-functional "Cache" panel and checkbox"
This reverts commit 783dd65a6f.
2023-05-02 09:56:47 -04:00
Hans Goudey 7b14154ec5 Merge branch 'main' into geometry-nodes-simulation 2023-05-02 09:54:36 -04:00
Jacques Lucke 86e8100ccd only evaluate simulations used by output for now 2023-05-02 15:49:58 +02:00
Jacques Lucke 14d3be44a2 clang format 2023-05-02 14:55:32 +02:00
Jacques Lucke 6bd0606438 various cleanup 2023-05-02 14:07:23 +02:00
Jacques Lucke ed1e9ec675 Merge branch 'main' into geometry-nodes-simulation 2023-05-02 11:09:35 +02:00
Hans Goudey 1de265bddb Reorder bezier link points function declaration 2023-05-01 16:01:34 -04:00
Hans Goudey 864672a8dd Small cleanups to the three "remap_pairing" implementations 2023-05-01 16:00:40 -04:00
Hans Goudey c2f452862f Use "Simulation Nodes" label for panel as an experiment 2023-05-01 15:53:51 -04:00
Hans Goudey 783dd65a6f Add initial non-functional "Cache" panel and checkbox 2023-05-01 15:52:44 -04:00
Hans Goudey 25313429ec Don't add name button for active state item 2023-05-01 15:51:42 -04:00
Hans Goudey ed966a3fb0 Use property split for simulation state items 2023-05-01 15:51:21 -04:00
Hans Goudey 3cc9cb9dae Don't allow animating simulation item domains or types 2023-05-01 15:49:24 -04:00
Hans Goudey c0955c3b3b Cleanup: White space 2023-05-01 15:40:55 -04:00
Hans Goudey f9cd9b26a7 Cleanup: Use const pointers in simulation input node
This node isn't mean to write to the simulation state, just retrieve
from it. So it's best to make that clearer by making the context
and modifier data pointers const
2023-05-01 15:36:05 -04:00
Hans Goudey f86eda3dc1 Cleanup: Remove unused variable 2023-05-01 15:33:09 -04:00
Hans Goudey b3bea62519 Cleanup: Use shorter variable name 2023-05-01 15:28:50 -04:00
Hans Goudey 8ad27a496e Cleanup: Remove unnecessary change 2023-05-01 15:09:19 -04:00
Hans Goudey b798beabfc Cleanup: Move simulation state implementations out of header 2023-05-01 15:08:31 -04:00
Hans Goudey 236b861388 Move baking panel to physics tab in the property editor
See #107290
2023-05-01 14:47:04 -04:00
Hans Goudey 8b24da35d0 Fix: Crash deleting bake from unsaved file 2023-05-01 14:33:46 -04:00
Hans Goudey 35b3037bcd Cleanup: Fix struct/class forward declaration disagreement 2023-05-01 13:05:18 -04:00
Hans Goudey d8fa1df36f Merge branch 'main' into geometry-nodes-simulation 2023-05-01 12:55:33 -04:00
Jacques Lucke 4129e1553d fix after merge
buildbot/vexp-code-experimental-coordinator Build done. Details
2023-04-28 17:00:44 +02:00
Jacques Lucke 8c81c7de4a Merge branch 'main' into geometry-nodes-simulation 2023-04-28 16:55:44 +02:00
Hans Goudey 423694adc1 Merge branch 'main' into geometry-nodes-simulation 2023-04-28 10:24:59 -04:00
Jacques Lucke 0942871375 Merge branch 'main' into geometry-nodes-simulation 2023-04-28 16:22:24 +02:00
Jacques Lucke b7404450cf fix failing tests because sockets are added after initialization 2023-04-28 16:21:48 +02:00
Hans Goudey efc2345c70 Merge branch 'main' into geometry-nodes-simulation 2023-04-28 10:11:43 -04:00
Jacques Lucke 6c9cd34719 Fix: incorrect zone drawing after changing node order 2023-04-28 14:03:51 +02:00
Jacques Lucke 592245f440 Cleanup: compile warnings 2023-04-28 13:37:53 +02:00
Jacques Lucke d1914ba99d Merge branch 'main' into geometry-nodes-simulation 2023-04-28 13:31:25 +02:00
Jacques Lucke 2d4c449e5c cleanup 2023-04-28 13:19:42 +02:00
Jacques Lucke 8a439e7a71 cleanup 2023-04-28 13:13:12 +02:00
Jacques Lucke aa7f4ea0d6 cleanup 2023-04-28 13:01:43 +02:00
Jacques Lucke b60b1bff03 fix after merge 2023-04-28 12:46:01 +02:00
Jacques Lucke 0c713539ce Merge branch 'main' into geometry-nodes-simulation 2023-04-28 12:43:04 +02:00
Jacques Lucke 5ee94fb263 Fix: anonymous attribute relations incorrect for simulation nodes
buildbot/vexp-code-experimental-coordinator Build done. Details
2023-04-28 12:37:06 +02:00
Jacques Lucke 81317b7429 Merge branch 'main' into geometry-nodes-simulation 2023-04-28 10:26:39 +02:00
Hans Goudey 280834351e Merge branch 'main' into geometry-nodes-simulation 2023-04-27 12:44:21 -04:00
Hans Goudey 8ed250c35d Merge branch 'main' into geometry-nodes-simulation 2023-04-27 09:49:09 -04:00
Jacques Lucke c87b6fdba9 Simulation Nodes: improve simulation inputs usage
buildbot/vexp-code-patch-coordinator Build done. Details
This can improve performance by skipping computation of
some anonymous attributes that would only be used by the
simulation.
2023-04-26 20:20:34 +02:00
Jacques Lucke cf682c9b8f Simulation Nodes: support storing "anonymous" attributes in sim state
Non-geometry sockets now work properly in simulation input/output
nodes. When a field is passed into them, it is evaluated one the
preceding geometry (this aspect might need further refinement)
and is stored as attribute. The evaluation domain can be changed
in the side bar similar to modifiers.

The attributes stored in the simulation state are not actually anonymous
but normal named attributes. This makes it much more obvious how
to the disk storage works. When the simulation state is output in
geometry nodes, the attributes become anonymous attributes again.

Anonymous attributes are not stored in the simulation state anymore,
because this can lead to unreliable and hard-to-predict results when
the set of required anonymous attributes changes over time.
2023-04-26 19:58:18 +02:00
Jacques Lucke fec25c5795 Cleanup: make format 2023-04-26 19:15:52 +02:00
Hans Goudey 13e4f6be56 Merge branch 'main' into geometry-nodes-simulation 2023-04-26 12:43:05 -04:00
Hans Goudey 245380b1d3 Add node search item for simulation zone 2023-04-26 11:49:42 -04:00
Hans Goudey b850436570 Merge branch 'main' into geometry-nodes-simulation 2023-04-26 11:49:18 -04:00
Hans Goudey 52a154370d Use translation for delta time socket name 2023-04-26 11:33:42 -04:00
Hans Goudey a2602aa6a0 Disable link drag search, add empty function for add node search 2023-04-26 09:56:20 -04:00
Jacques Lucke 614eb01911 Simulation Nodes: add socket usages
There is a new `LazyFunctionForSimulationInputsUsage` the outputs
booleans that indicate whether the inputs for the Simulation Input/Output
node is used.

Also, use the existing mapping from `bNodeSocket` to lazy function socket
indices.
2023-04-26 12:50:07 +02:00
Jacques Lucke 9ab7e005e0 Merge branch 'main' into geometry-nodes-simulation 2023-04-26 10:56:38 +02:00
Jacques Lucke 61d71cc23f Merge branch 'main' into geometry-nodes-simulation 2023-04-26 10:43:15 +02:00
Jacques Lucke 60184f0b5f Merge branch 'main' into geometry-nodes-simulation 2023-04-26 10:22:39 +02:00
Jacques Lucke d010aa5e23 Simulation Nodes: support primitive values in simulation state
The simulation state can contain individual floats, vectors, ints,
booleans, colors and strings now. Note, fields/anonymous attributes
are not yet supported.

This commit also contains baking support.

Furthermore, the code now makes better use of the identifiers
stored in #NodeSimulationItem.
2023-04-25 13:44:37 +02:00
Jacques Lucke 09302ab3f0 Merge branch 'main' into geometry-nodes-simulation 2023-04-25 12:15:56 +02:00
Jacques Lucke ba7a634da5 Merge branch 'main' into geometry-nodes-simulation 2023-04-25 09:45:30 +02:00
Lukas Tönne c13005fed9 Add support for attributes storage in simulation state
Support basic geometry node socket types in the simulation zone nodes.

This allows adding items to the simulation state for float, int, bool,
vector and color sockets. ID types like Material and Object are not
supported (yet).

Item state does not include storage yet, this will be implemented
separately. Item state consists of dummy GeometryStateItem structs.

Field types of the simulation input and output node sockets need to be
synchronized because they represent the same pieces of data. This can
create a cyclic dependency which complicates the
`update_field_inferencing` function. The simple topological sorting for
propagating output field constraints (right-to-left) and input field
state (left-to-right) is not sufficient any more, because now updating
a simulation input node also modifies the paired output node, and vice
versa. To solve this issue, the two propagation functions now can
perform several passes, if changing a simulation node modifies their
counterpart. Infinite updates are prevented by checking for actual
changes: each update can only simplify the field state, until no more
changes occur. A single simulation zone can cause at most 1 additional
update, more than that may happen when simulation zones are nested.

Resolves #106218

Pull Request: #107133
2023-04-24 18:22:15 +02:00
Lukas Tönne abac119889 Fix crash on inserting links on simulation zone nodes.
When adding links to the sim zone nodes they modify the tosock/fromsock
with the socket generated for the new item. This search expects a socket
identifier rather than a name string. The identifier is now unique, so
that sockets can be reliably relinked, but the old code was using the
name instead.

Pull Request: #107303
2023-04-24 16:14:41 +02:00
Lukas Tönne 8446b2cad1 Simulation nodes: UI for simulation state items in sidebar
Selecting the input or output simulation node now shows a new panel in the node sidebar with a list of simulation state items. Items can be added, removed, or moved up and down the list. This updates the sockets on both simulation input and output nodes. This is similar to node group interfaces, except that simulation state items only have one list which generates both input and output sockets.

Resolves #105723

Pull Request: #106919
2023-04-24 14:26:22 +02:00
Jacques Lucke a1c3bb62be Cleanup: add debug names to simulation input/output 2023-04-24 12:53:40 +02:00
Jacques Lucke 8fdd7211b1 Merge branch 'main' into geometry-nodes-simulation 2023-04-24 12:45:00 +02:00
Jacques Lucke c396f41e14 Merge branch 'main' into geometry-nodes-simulation 2023-04-22 16:15:41 +02:00
Jacques Lucke 05ddbc20b8 Simulation Nodes: bake simulation states to disk
This adds baking support to simulation nodes.

The following features are supported:
* Bake simulation nodes of selected objects from the new "Baking" panel in the
  object properties.
* Free baked/cached simulation data.
* The bake is stored on disk in a folder next to the .blend file (so it's necessary
  to save before baking works).
* Baked data is detected automatically when reloading the file.
* The data stored on disk is partially deduplicated. Only duplicates that can be
  detected using implicit-sharing are taken into account.
* The baked data can contain meshes, curves, pointclouds and instances.
* The simulation state is written using a combination raw binary files for the
  data arrays and `.json` for meta data. Other formats besides `.json` could be
  used (most code is agnostic to that), but json is the easiest to use right now and
  seems to be good enough the common use cases (note that the size of the `.json`
  files do not depend on how large e.g. the baked mesh is).
* During baking, there is a progress bar and it can be interrupted using escape.

Limitations:
* Volumes are not written to disk yet.
* Currently it always bakes the entire scene frame range.
* Baking subframes is supported internally, but is not exposed in the UI.
* Currently, all attributes are written, but that is likely not necessary in most
  cases (e.g. selection attributes are written as well).

Pull Request: #106937
2023-04-22 14:48:43 +02:00
Jacques Lucke f307b5ae65 Merge branch 'main' into geometry-nodes-simulation 2023-04-22 13:13:16 +02:00
Hans Goudey a04b39faf4 Merge branch 'main' into geometry-nodes-simulation 2023-04-21 15:26:21 -04:00
Jacques Lucke 0865f80591 Merge branch 'main' into geometry-nodes-simulation 2023-04-21 09:26:59 +02:00
Jacques Lucke 4d34028ce9 use BitArrayVector instead of MultiValueMap for attribute propagation detection
This simplifies the code and also makes it more efficient in many cases
(although not by much in my simple tests).
2023-04-20 14:31:21 +02:00
Hans Goudey 80fdf4a88d Merge branch 'main' into geometry-nodes-simulation 2023-04-19 23:25:50 -04:00
Hans Goudey 945d71b56b Merge branch 'main' into geometry-nodes-simulation 2023-04-19 22:52:35 -04:00
Jacques Lucke a5140712cc Merge branch 'main' into geometry-nodes-simulation 2023-04-19 11:25:26 +02:00
Jacques Lucke 40c76a1945 Merge branch 'main' into geometry-nodes-simulation 2023-04-19 08:57:35 +02:00
Hans Goudey 95bc1dd0e5 Cleanup: MIssing definition 2023-04-18 16:56:26 -04:00
Jacques Lucke 6f26bb6841 add missing immUnbindProgram()
buildbot/vexp-code-experimental-coordinator Build done. Details
2023-04-18 14:27:54 +02:00
Hans Goudey e41cd795a6 Small cleanups to zone drawing
- Avoid unnecessary topology tag
- Copy from offsets in one line
- Comment formatting
- Avoid describing future changes in comment, let the code stand on its own
2023-04-18 07:24:06 -04:00
Dalai Felinto 01c6824eaf Cleanup: make format 2023-04-18 12:12:51 +02:00
Dalai Felinto 8981bb4ac6 Geometry Nodes: Simulation Zone drawing updates
* Make the drawing smoother/anti-aliased.
* We use the alpha to blend between the background and the zone color.
* If alpha is 100% we then get to see the dotted background again
* Change zone corner radius to match nodes/layout.

If we want to set the background transparent again we need to do:
```
-    immUniformThemeColorBlend(TH_BACK, TH_NODE_ZONE_SIMULATION, zone_color[3]);
+    immUniformThemeColor(TH_NODE_ZONE_SIMULATION);
```

For the design behind some of those change see #106810
Pull Request: #107043
2023-04-18 12:08:27 +02:00
Jacques Lucke e4926b4b2a Merge branch 'main' into geometry-nodes-simulation 2023-04-18 11:15:23 +02:00
Lukas Tönne 315cc66bd8 Fix #106732: Support for simulation zones in copy operators
Copying a simulation zone should keep the 1:1 pairing intact (see `remap_pairing` functions)
- When copying a simulation input node on its own, unpair it to avoid ambiguity. Only the old simulation input node is paired to the output.
- When copying a simulation output node on its own, no special action is needed - the node gets a new ID and nothing is paired with it.
- When copying both input and output, remap the `output_node_id` property of the simulation input node, so that it is paired with the output copy.

There are a couple of places where copies happen:
* Node tree copy
* Duplicate nodes
* Group Separate (copies nodes from the group tree into another tree)
* Clipboard (both copy to clipboard and paste into node tree)
* Shader node tree branch copy for execution

These copy operators do mostly the same thing, but in slightly different ways, which makes the code incompatible (e.g. using a `Map<const bNode *, bNode *> node_map` vs. `Map<bNode *, bNode *> node_map`). That's why there are 3 `remap_pairing` implementations.

Dynamic node declarations are problematic:
Copying nodes invokes `nodeDeclarationEnsure` to generate declarations for new nodes. It does not, however, change the socket lists. If a dynamic declaration for a node copy alters the sockets (in this case: remove all because the node is unpaired), the subsequent `update_socket_declarations` will crash because it expects sockets to match the declaration.
At the end of operators there is usually a `BKE_ntree_update_main` or similar, which invokes `update_node_declaration_and_sockets`. This method _does_ update the socket lists as well (see #106732), but only if a node is tagged for a respective update.

The solution here is to use `update_node_declaration_and_sockets` for dynamic declarations instead of just `build_node_declaration_dynamic`.

Pull Request: #106812
2023-04-17 16:10:55 +02:00
Jacques Lucke 8f3796e90a Merge branch 'main' into geometry-nodes-simulation 2023-04-17 06:34:09 +02:00
Hans Goudey cbc5b17c1a Cleanup: Use const int cast 2023-04-13 22:20:47 -04:00
Hans Goudey a76c714c26 Cleanup: Whitespace 2023-04-13 22:20:35 -04:00
Hans Goudey c22fed5c01 Cleanup: Unnecessary null check
See comment on MEM_delete
2023-04-13 22:20:26 -04:00
Hans Goudey c38d259779 Cleanup: Use const pointers 2023-04-13 22:17:06 -04:00
Hans Goudey 8497737d92 Cleanup: Use reference 2023-04-13 22:16:42 -04:00
Hans Goudey c385369e07 Cleanup: Fix typo in function name 2023-04-13 22:12:47 -04:00
Hans Goudey 4ebe696e85 Cleanup: Comment formatting and const casts 2023-04-13 22:12:09 -04:00
Hans Goudey b180fea69e Cleanup: Proper doxygen section 2023-04-13 22:08:57 -04:00
Hans Goudey a066d62798 Cleanup: Function and variable naming 2023-04-13 22:08:02 -04:00
Hans Goudey c226954d03 Cleanup: Proper doxygen syntax 2023-04-13 22:06:43 -04:00
Hans Goudey 9e4f58a8eb Merge branch 'main' into geometry-nodes-simulation 2023-04-13 22:06:08 -04:00
Jacques Lucke baeb386410 Merge branch 'main' into geometry-nodes-simulation 2023-04-13 16:41:16 +02:00
Jacques Lucke a277117b3e Merge branch 'main' into geometry-nodes-simulation 2023-04-11 09:19:12 +02:00
Jacques Lucke e665a50fb6 Cleanup: rename region to zone in theme settings 2023-04-07 16:53:21 +02:00
Lukas Tönne c6d8da0e97 Remove simulation inputs when deleting outputs and vice versa
buildbot/vexp-code-experimental-coordinator Build done. Details
To avoid unpaired simulation inputs or outputs, whenever deleting such
nodes the respective paired node should be deleted as well. A simple
utility function selects paired nodes before the delete operator removes
them.

This does not affect API methods, which still remove only individual
nodes. The feature is primarily a workflow improvement.

Resolves #105728

Pull Request: #106597
2023-04-05 18:28:36 +02:00
Lukas Tönne 98bc439e47 Add simulation input and output node as a pair
Simulation input and output nodes are currently added individually, but they always need to exist as pair. This PR modifies the _Add Node_ menu so that a single menu entry adds and input and output node together.

The `NODE_OT_add_node` operator currently adds just a single node type. A new variant of this operator is added which adds a _simulation zone_ with origin + target node instead. This requires some modification of the `NodeAddOperator` base class, moving the `node_type` property into the final implementation. Unlike the `NODE_OT_add_node` operator, the `NODE_OT_add_simulation_zone` adds 2 different node types.

After adding the two nodes, a reference needs to be added to "pair" them: Input node ("origin") stores the UID of the output node ("target") in its `output_node_id` property. So far this was detected automatically when adding an input, but this method is not very robust (e.g. it depends on order of adding nodes and adding multiple pairs can be tricky).

Now the pairing is done explicitly through an API function `node_geo_simulation_input_pair_with_output`. The `NODE_OT_add_simulation_zone` operator performs pairing of the input/output nodes after adding them. The function is accessible through RNA, so an operator may be added if necessary to allow users to fix unpaired nodes.

In addition to pairing the two nodes, the operator also positions them at a comfortable distance, as well as adding a default link between the two Geometry sockets for convenience.

Resolves #105727

Pull Request: #106557
2023-04-05 16:20:41 +02:00
Lukas Tönne 3d8d142205 Check if output node exists before creating a sim input lazy function.
Avoid creating a lazy function for the `Simulation Input` node if the `output_node_id` is invalid. This can happen when e.g. the output node is deleted without also deleting the input node. The lazy function assumes a valid output ID and will crash if the output node does not exist.

Pull Request: #106585
2023-04-05 14:28:58 +02:00
Jacques Lucke d98988d872 Simulation Nodes: indicate which frames are cached in timeline
buildbot/vexp-code-patch-coordinator Build done. Details
2023-03-28 13:37:57 +02:00
Jacques Lucke b14668ae03 Simulation Nodes: refactor automatic caching
The most important part of this change is that the simulation
state at a specific point in time is more self contained now.
This way, only the modifier has to deal with finding the old/new
simulation states and not every simulation individually.

Furthermore, this also includes some simple cache invalidation
when the user changes something that might affect the result.
2023-03-28 13:37:30 +02:00
Jacques Lucke f04787e87b Merge branch 'main' into geometry-nodes-simulation 2023-03-28 11:48:25 +02:00
Jacques Lucke 0351ce9769 Merge branch 'main' into geometry-nodes-simulation 2023-03-22 11:35:08 +01:00
Jacques Lucke c4b3e0e0bb Merge branch 'main' into geometry-nodes-simulation 2023-03-21 17:56:34 +01:00
Jacques Lucke 2ddddf6e36 fix simulation zone background color 2023-03-21 16:02:37 +01:00
Jacques Lucke b652bcbe92 remove use_persistent_cache from simulation output node 2023-03-21 12:38:47 +01:00
Jacques Lucke 8b47a252b1 Merge branch 'main' into geometry-nodes-simulation 2023-03-21 12:25:13 +01:00
Jacques Lucke d9fb08133a Geometry Nodes: improve simulation zone discovery 2023-03-20 16:59:44 +01:00
Jacques Lucke 753af18573 BLI: improve bit data structures and processing 2023-03-20 16:59:16 +01:00
Jacques Lucke 7b62cc943d fix 2023-03-20 16:25:02 +01:00
Jacques Lucke e5c63abece Merge branch 'main' into geometry-nodes-simulation 2023-03-20 16:15:08 +01:00
Jacques Lucke e21afd2f2f Merge branch 'main' into geometry-nodes-simulation 2023-03-16 12:47:11 +01:00
Hans Goudey 3bad7a51cb Implement simulation nodes as lazy functions directly
Support for multiple sockets will be slightly more complete now too,
but that part hasn't been tested.
2023-03-13 17:29:06 -04:00
Hans Goudey ecb91d46a8 Merge branch 'main' into geometry-nodes-simulation 2023-03-13 13:45:05 -04:00
Hans Goudey f36dd06609 Add initial infrastructure for multiple simulation state items
- Use dynamic declarations to build simulation node sockets
- Fixes in some node code for futher use of dynamic declarations
- Copying, freeing, reading, and writing of simulation state array
- Add simulation state items with link drag operator

The new sockets won't do anything yet, only geometry sockets are
supported, and there is no way to remove sockets yet.
2023-03-10 16:17:24 -05:00
Hans Goudey b2e508f7af Merge branch 'main' into geometry-nodes-simulation
buildbot/vexp-code-patch-coordinator Build done. Details
2023-03-10 12:31:50 -05:00
Hans Goudey a90f02d5f4 Merge branch 'main' into geometry-nodes-simulation 2023-03-10 11:33:03 -05:00
Hans Goudey 9241ab1d7c Merge branch 'main' into geometry-nodes-simulation
buildbot/vexp-code-patch-coordinator Build done. Details
2023-02-28 11:48:47 -05:00
Hans Goudey 6f56fee3bb Fixes after merge
buildbot/vexp-code-experimental-coordinator Build done. Details
2023-02-17 17:44:56 -05:00
Hans Goudey 9393c2aba9 Merge branch 'main' into geometry-nodes-simulation 2023-02-17 17:09:21 -05:00
Hans Goudey 508fd044b4 Revert "Fix simulation"
This reverts commit 468f43c7a6.

Revert "Add initial dynamic declarations"

This reverts commit 50a2c77c4e.

Revert "Add initial simulation state items array to output node"

This reverts commit 3f1027567d.
2022-12-19 12:04:46 -06:00
Hans Goudey 38567bc023 Cleanup: Slightly refactor cancelling link drag operator
Clarify that the dragged links aren't stored in the tree, use a
separate function for cancelling vs. applying the links to the tree.
2022-12-19 12:04:46 -06:00
Hans Goudey 8fa664fd33 Cleanup: Return early in node link operator, remove useless comments 2022-12-19 12:04:46 -06:00
Hans Goudey 1b24140d9f Cleanup: Remove redundant information from node link drag struct 2022-12-19 12:04:46 -06:00
Hans Goudey aeea690e00 Cleanup: Remove unnecessary node link flag
Links that are currently being dragged are now stored outside
of the node tree, so we don't need a flag to distinguish them
from "proper" links.
2022-12-19 12:04:46 -06:00
Jacques Lucke 6ecb1cb780 Fix: socket tooltip not showing when there was no type conversion 2022-12-19 12:04:46 -06:00
Jacques Lucke 988241e23e Geometry Nodes: simplify handling of invalid group interface sockets
Previously, the code tried to keep node groups working even if some of
their input/output sockets had undefined type. This caused some
complexity with no benefit because not all places outside of this file
would handle the case correctly. Now node groups with undefined
interface sockets are disabled and have to be fixed manually before
they work again.

Undefined interface sockets are mostly caused by invalid Python
API usage and incomplete forward compatibility (e.g. when newer
versions introduce new socket types that the older version does
not know).
2022-12-19 12:04:46 -06:00
Hans Goudey a2cee52617 Fix std::optional value() build error on older macOS SDK
Patch from @dupoxy

Differential Revision: https://developer.blender.org/D16796
2022-12-19 12:04:46 -06:00
Julian Eisel a0ed3601c9 Fix T103187: Opening node search menu is slow because of assets.
Avoid utility function call that would query the file system, this was a
bottleneck. The path joining was also problematic. See patch for more
details.

Differential Revision: https://developer.blender.org/D16768

Reviewed by: Jacques Lucke
2022-12-19 12:04:46 -06:00
Hans Goudey 8226abc111 Cleanup: Remove duplicate UV islands header
This code was duplicated from `pbvh_uv_islands.hh`,
which was the version that was actually used.
2022-12-19 12:04:46 -06:00
Christophe Hery 807be888a5 Fix: Crash after mesh color attribute name commit
6514bb05ea missed a null check when accessing the active
and default color attribute names, since the CustomData API does not
do that check itself.
2022-12-19 12:04:46 -06:00
Charlie Jolly f92a85d7d2 Nodes: Add Exclusion color mix mode
Expands Color Mix nodes with new Exclusion mode.

Similar to Difference but produces less contrast.

Requested by Pierre Schiller @3D_director and
@OmarSquircleArt on twitter.

Differential Revision: https://developer.blender.org/D16543
2022-12-19 12:04:46 -06:00
Patrick Mours 6bd6d7aec7 Fix T103258: Deleting a shader with OptiX OSL results in an illegal address error
Materials without connections to the output node would crash with OSL
in OptiX, since the Cycles `OSLCompiler` generates an empty shader
group reference for them, which resulted in the OptiX device
implementation setting an empty SBT entry for the corresponding direct
callables, which then crashed when calling those direct callables was
attempted in `osl_eval_nodes`. This fixes that by setting the SBT entries
for empty shader groups to a dummy direct callable that does nothing.
2022-12-19 12:04:46 -06:00
Patrick Mours cfb77c54b0 Fix T103257: Enabling or disabling viewport denoising while using OptiX OSL results in an error
Switching viewport denoising causes kernels to be reloaded with a new
feature mask, which would destroy the existing OptiX pipelines. But OSL
kernels were not reloaded as well, leaving the shading pipeline
uninitialized and therefore causing an error when it is later attempted to
execute it. This fixes that by ensuring OSL kernels are always reloaded
when the normal kernels are too.
2022-12-19 12:04:46 -06:00
Campbell Barton 0d18005d2b Cleanup: indentation in CMake files 2022-12-19 12:04:46 -06:00
Campbell Barton 06525747c0 Build: resolve failure to copy indirect dependencies for USD on Linux
Even when building without OpenImageIO and OpenVDB, USD depends on these
libraries.

Ensure these libraries are copied when building with USD.
2022-12-19 12:04:46 -06:00
Campbell Barton 74171ff3b0 CMake: warn Linux references old linux_centos7_x86_64 paths
When the centos7 library dir is found, warn when the values of cached
variables reference it, listing the variables and their values.
2022-12-19 12:04:46 -06:00
Jacques Lucke 32a7384c0b Geometry Nodes: improve dot graph export of lazy function graph
* Dim default input values.
* Print default input values instead of type name.
* Add node/socket names to group input/output nodes.
2022-12-19 12:04:46 -06:00
Campbell Barton 54942e5ea6 Fix T102792: Sculpt cursor jumps to random place
Restrict the condition under which paint cursors read use the cursor
location from the the operating-system.

This caused a glitch when dragging UI elements in painting context
popup. Since the paint cursor would display using mouse motion
which was clamped to the window center - an internal detail of hidden
cursor grabbing.

Now only read the cursor coordinates when clamped to a region which
is used for the transform cursor to stay visible even when the cursor
wraps around.
2022-12-19 12:04:46 -06:00
Campbell Barton 5d1ed47d6c Fix T103253: Infinite drag of number buttons is broken on WIN32
Recent reverting of changes to cursor grabbing intended to match
Blender 3.3 release. This is the case for 3.4x branch, however there is
an additional change to grabbing on WIN32 by Germano [0] which is a
significant improvement on old grabbing logic for Windows.
So instead of matching 3.3x behavior, restore logic that keeps
the cursor centered while grabbing & hidden.

This re-introduces T102792 issue displaying the paint-brush while
dragging buttons, this will have to be solved separately.

Re-apply [1] & [2], revert [3] & [4].

[4]: a3a9459050
[0]: 9fd6dae793
[1]: 4cac8025f0
[2]: 230744d6fd
[3]: 0240b89599
2022-12-19 12:04:46 -06:00
Campbell Barton bb8cbf0c10 UI: don't change mouse cursor while it's grabbed
The paint cursor was continuously set which meant hiding the cursor
while interacting with buttons would immediately show it again.

This exposed cursor warping.
2022-12-19 12:04:22 -06:00
Campbell Barton b3386868fe Build: correct extension type for SNDFILE 2022-12-19 12:04:22 -06:00
Campbell Barton c9bd78890a Build: remove opus workaround for sndfile
For some reason SNDFILE now builds without this workaround,
which broke building FFMPEG.
2022-12-19 12:04:22 -06:00
Chris Blackbourn a12614d166 Fix T102923: replace zero check with epsilons with uv constrain to bounds
Small roundoff errors during UV editing can sometimes occur, most likely
due to so-called "catastrophic cancellation".

Here we set a tolerance around zero when using Constrain-To-Bounds and UV Scaling.

The tolerance is set at one quarter of a texel, on a 65536 x 65536 texture.

TODO: If this fix holds, we should formalize the tolerance into the UV editing
subsystem, perhaps as a helper function, and investigate where else it needs
to be applied.

Differential Revision: https://developer.blender.org/D16702
2022-12-19 12:04:22 -06:00
Chris Blackbourn 0403d77a0f Fix T103237: Prevent UV Unwrap from packing hidden UV islands
When migrating to the new packing API, pin_unselected was not
implemented correctly.

Regression from rB143e74c0b8eb, rBe3075f3cf7ce, rB0ce18561bc82.

Differential Revision: https://developer.blender.org/D16788

Reviewed By: Campbell Barton

Duplicated in blender-v3.4-release as rB3dcd9992676a
2022-12-19 12:04:22 -06:00
Chris Blackbourn fe7a0ebce4 Cleanup: format 2022-12-19 12:04:22 -06:00
Campbell Barton af7c34716b Fix active/default color names not being editable
Revert [0] and enable the editable flag as the intent for [1] was that
these values would be editable.

[0]: e58f5422c3
[1]: 6514bb05ea
2022-12-19 12:04:22 -06:00
Damien Picard 34f307547b Fix T103183: UV map name of mesh converted from curve is untranslated
Upon conversion, the newly-created UV map with default name "UVMap"
should be translated.

Reviewed By: mont29

Maniphest Tasks: T103183

Differential Revision: https://developer.blender.org/D16775
2022-12-19 12:04:22 -06:00
Campbell Barton bb9b2b556f Cleanup: remove unused active name set callback functions 2022-12-19 12:04:22 -06:00
Campbell Barton a3a132ea74 Build: upgrade pre-built libraries for Linux
Replace ../lib/linux_centos7_x86_64 with ../lib/linux_x86_64_glibc_228,
built with Rocky8 Linux, compatible with the VFX platform CY2023,
see: T99618.

- Update build-bot configuration.
- Remove unnecessary check for Blosc, this is part of OpenVDB lib now.
- Remove WITH_CXX11_ABI, always use new C++11 ABI now
- Replace centos7 by glibc_228 everywhere

Note that existing builds with cached paths pointing to
"../lib/linux_centos7_x86_64" will need to be updated.

Includes contributions by Brecht.
2022-12-19 12:04:21 -06:00
Brecht Van Lommel ac59dfeffd Fix T103049: Cycles specular light leak regression
The logic here is not ideal but was unintentionally changed in refactoring
for path guiding, now restore it back to 3.3 behavior again.
2022-12-19 12:04:21 -06:00
Hans Goudey 24523726d7 Mesh: Store active & default color attributes with strings
Attributes are unifying around a name-based API, and we would like to
be able to move away from CustomData in the future. This patch moves
the identification of active and fallback (render) color attributes
to strings on the mesh from flags on CustomDataLayer. This also
removes some ugliness used to retrieve these attributes and maintain
the active status.

The design is described more here: T98366

The patch keeps forward compatibility working until 4.0 with
the same method as the mesh struct of array refactors (T95965).

The strings are allowed to not correspond to an attribute, to allow
setting the active/default attribute independently of actually filling
its data. When applying a modifier, if the strings don't match an
attribute, they will be removed.

The realize instances / join node and join operator take the names from
the first / active input mesh. While other heuristics may be helpful
(and could be a future improvement), just using the first is simple
and predictable.

Differential Revision: https://developer.blender.org/D15169
2022-12-19 12:04:21 -06:00
Hans Goudey 20cab8f8f2 Geometry Nodes: Add error message when applying modifier with no mesh
If the resulting geometry from applying a geometry nodes modifier
contains no mesh, give an error message. This gives people something to
search and makes the behavior more purposeful.

Also remove the `modifyMesh` implementation from the geometry nodes
modifier, since it isn't necessary anymore. And remove the existing
"Modifier returned error, skipping apply" message which was cryptic
and redundant if applying returns an actual error message.

Resolves T103229

Differential Revision: https://developer.blender.org/D16782
2022-12-19 12:04:21 -06:00
Hans Goudey f9b621a9d9 Nodes: Allow skipping node attachment after dragging
This patch allows skipping the automatic insertion of nodes on top of
links when the transform operator ends. When putting nodes into small
spaces this often gets in the way and wastes time. Now, when holding
`alt`, this is turned off.

The header text is also improved to add this shortcut and to remove
the Dx and Dy values and improve the formatting a bit.

Making this functionality optional might allow us to use it in more
places in the future, like for the nodes added by link-drag-search.

Differential Revision: https://developer.blender.org/D16230
2022-12-19 12:04:21 -06:00
Iliya Katueshenock f1b16f3ceb Fix: ignore unavailable sockets linked to multi-input socket
Differential Revision: https://developer.blender.org/D16784
2022-12-19 12:04:21 -06:00
Brecht Van Lommel cc9d9c7724 Fix make deps harvest error on Linux, due to macOS specific folder in Vulkan 2022-12-19 12:04:21 -06:00
Brecht Van Lommel f1f2ff1116 Fix T103170: missing Cycles viewport light threshold update after exposure edit 2022-12-19 12:04:21 -06:00
Brecht Van Lommel 6b26b0db21 Fix build issue with NanoVDB and HIP on Linux
This patch was already accepted upstream, so this is temporary until we update
to a new OpenVDB release that includes it.
2022-12-19 12:04:21 -06:00
Jacques Lucke 8848cfdf4b Cleanup: fix warning 2022-12-19 12:04:21 -06:00
Hans Goudey e50d567c97 Cleanup: Various improvements to modifier apply operator
Use C++ casts, decrease variable scope, use references, use const.
2022-12-19 12:04:21 -06:00
Hans Goudey 496e344015 Cleanup: Move mesh modifier apply function to editors module
The function was highly related to the apply modifier operator,
and only used once. This was too specific to be in the blenkernel,
especially in a mesh conversion file.
2022-12-19 12:04:21 -06:00
Ray molenkamp c30718ded9 cmake/win: Allow running blender_test from the VS debugger
This was missing some paths setup in the environment, ctest
normally sets this up before running the tests from the CLI
but that does not help the IDE all that much.
2022-12-19 12:04:21 -06:00
Nate Rupsis 1965e31d17 Fix T101130: Scaling of NLA Strip Via S Hotkey Not Working
After switching over to using start_frame / end_frame, scaling an NLA strip didn't scale the strip, it just repeated the action.

Now withing the NLA transform code, we look for TFM_TIME_EXTEND / TFM_TIME_SCALE transform mode, and handle the update to strip scale accordingly
2022-12-19 12:04:21 -06:00
Jacques Lucke 5e384860a6 Merge branch 'master' into geometry-nodes-simulation 2022-12-15 13:29:14 +01:00
Hans Goudey 468f43c7a6 Fix simulation 2022-12-14 16:42:48 -06:00
Hans Goudey 50a2c77c4e Add initial dynamic declarations 2022-12-14 16:02:43 -06:00
Hans Goudey c82b1aa1c0 Merge branch 'master' into geometry-nodes-simulation 2022-12-14 14:41:42 -06:00
Hans Goudey 3f1027567d Add initial simulation state items array to output node 2022-12-14 14:34:20 -06:00
Hans Goudey ab8d77359b Merge branch 'master' into geometry-nodes-simulation 2022-12-14 14:02:15 -06:00
Jacques Lucke 3ef95d7f19 add theme color for simulation region 2022-12-13 11:44:14 +01:00
Jacques Lucke 02a264f5ab Merge branch 'master' into geometry-nodes-simulation 2022-12-13 11:15:20 +01:00
Hans Goudey 2525c1c023 Add initial "Extend" socket. Doesn't do anything yet 2022-12-10 15:12:17 -06:00
Hans Goudey 620b190e52 Fix delta time output
Output time in seconds rather than frame units
2022-12-10 14:07:09 -06:00
Hans Goudey 657ffe9aa7 Fix: Simulation resets when playback stops 2022-12-10 14:06:32 -06:00
Hans Goudey 3fcf50d37a Make the simulation always run, remove run socket
Note: Still unstable. Simulation resets when playback stops bug.

Since the "Run" behavior can basically be implemented with the switch
node already, it's just adding unnecessary complexity to the interface
now, when it's use case isn't clear. We decided to remove it for now,
and only consider it later as a possible convenience feature, rather
than an essential part of the design.

Also, the simulation nodes are now considered "side effect nodes"
for the evaluator, meaning they are *always* evaluated, even if they
aren't needed because of switch nodes, etc. This was the best way
we thought of to make simulations run consistently even through
situations like that.
2022-12-10 00:01:20 -06:00
Hans Goudey 49e8218edf Remove Started and Ended booleans
These aren't theoretically necessary, since you can just created them
as regular outputs. Maybe we will eventually add them back for
convenience, but that's not clear.
2022-12-09 18:31:07 -06:00
Hans Goudey 94e6f87ebc Remove "Persistent Cache" option from the UI
I will keep it internally, but for the simulation MVP we want to focus
on the most basic "last frame's cache" features at first.
2022-12-09 17:12:12 -06:00
Hans Goudey 3dcb437d5c Remove elapsed time sockets
Since this is theoretically redundant with simulating a float
with the delta time value, we decided to remove it for now to
make the whole interface simpler.
2022-12-09 17:11:05 -06:00
Hans Goudey ffe0db184a Merge branch 'master' into geometry-nodes-simulation 2022-12-09 17:05:29 -06:00
Hans Goudey 8648cf4717 Merge branch 'master' into geometry-nodes-simulation 2022-12-09 15:23:58 -06:00
Hans Goudey c9958c8e9f Basics of temporary and persistent cache working again
Edge cases not really tested still though
2022-12-08 00:06:35 -06:00
Hans Goudey 24e2d08b49 Merge branch 'master' into geometry-nodes-simulation 2022-12-07 16:29:07 -06:00
Hans Goudey bb732c240d Half finished refactoring to simulation cache
- Cache is accessed with a string identifier, allowing multiple sockets in the future
- Cache is meant to be stored in a simple array, not sparsely like before
- Persistent cache and temporary "last run" cache are separated more clearly
- Use a "Time Point" class instead of integers, to maybe clarify adding subframe support in the future
- Use a different "sim" namespace (not sure if that will last)
- The value from the last frame is moved, to avoid a copy when no persistent cache is used

I don't think this works now, at least I haven't tested it.
2022-12-04 15:06:28 -06:00
Hans Goudey 850aa3d26a Allow multiple caches in the same node group
The caches now hash the identifier of the output node as well.
2022-12-02 16:13:18 -06:00
Hans Goudey 1ba264d5f0 Be more forgiving when simulation nodes lost their storage 2022-12-02 16:06:03 -06:00
Hans Goudey 92a1234830 Add hint to add simulation output node first
Until we can add both nodes at the same time, or we find
an improve simulation to link the two nodes
2022-12-02 15:49:11 -06:00
Hans Goudey afe5d0b9f2 Merge branch 'master' into geometry-nodes-simulation 2022-12-02 14:48:03 -06:00
Hans Goudey cff291d1f3 Merge branch 'master' into geometry-nodes-simulation 2022-12-02 14:32:09 -06:00
Hans Goudey bbcdca1378 Merge branch 'master' into geometry-nodes-simulation 2022-12-02 11:24:32 -06:00
Hans Goudey a0caa03942 Merge branch 'master' into geometry-nodes-simulation 2022-12-02 09:17:54 -06:00
Hans Goudey 7469e19446 Add basic UI support for multiple simulations in a group
Just allows multiple simulation "frames"/regions/contexts to be drawn
in the editor, doesn't include any changes to caching yet.
2022-12-01 19:49:05 -06:00
Hans Goudey 0019d6cc8f Fix property name for node UI 2022-12-01 18:11:11 -06:00
Hans Goudey e9c3e4f14e Merge branch 'master' into geometry-nodes-simulation 2022-12-01 17:57:14 -06:00
Hans Goudey bdd71c129c Set "Run" input default to true 2022-12-01 16:34:50 -06:00
Hans Goudey 18b2ec1963 Rename "Use Cache" to "Persistent Cache"
This is a temporary option anyway, the caches will be controlled in a
more unified place at the object or scene level. But for now the name
can be a bit better anyway.
2022-12-01 16:32:01 -06:00
Hans Goudey 97df619be7 Move "Run" input to simulation output node
It's the output node that decides whether to requiest the values
from the nodes inside the simulation, so it makes more sense
for it to be there. This is part of a general effort to have less
redundancy in the options.
2022-12-01 16:30:46 -06:00
Hans Goudey 3059f1743e Merge branch 'master' into geometry-nodes-simulation 2022-12-01 15:45:46 -06:00
Erik Abrahamsson 4726803e85 Fixed typo in Simulation Input node
"Delta Time" was set instead of "Elapsed Time" output.
2022-11-30 23:35:48 +01:00
Jacques Lucke fa277178e8 Merge branch 'master' into geometry-nodes-simulation 2022-11-26 13:51:16 +01:00
Jacques Lucke 7cf192956b Move simulation input/output node a bit more into the convex frame 2022-11-25 12:04:04 +01:00
Jacques Lucke f7cf6e957d Merge branch 'master' into geometry-nodes-simulation 2022-11-25 11:20:53 +01:00
Jacques Lucke b5ea0d2f41 Add frame around nodes in simulation 2022-11-24 16:35:40 +01:00
Hans Goudey c2a632cd41 Basic working simulation and in-memory caching 2022-11-23 17:19:25 -06:00
Hans Goudey 7ad2b93ec4 More semi-working sockets, lazyness, more TODOs, RNA 2022-11-23 16:02:39 -06:00
Hans Goudey 6d930d0b4a Merge branch 'master' into geometry-nodes-simulation 2022-11-23 12:04:46 -06:00
Hans Goudey f55f2b5ff4 Add some input sockets 2022-11-22 21:57:06 -06:00
Hans Goudey 5aaa435ac7 Simulation output and input nodes 2022-11-22 18:23:26 -06:00