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
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.
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.
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.
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
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
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
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
- 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
* 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
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
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
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
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
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.
- 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.
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).
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
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
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.
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.
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.
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
The paint cursor was continuously set which meant hiding the cursor
while interacting with buttons would immediately show it again.
This exposed cursor warping.
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
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
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
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.
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
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
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
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.
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.
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
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.
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.
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.
- 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.
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.
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.