Age | Commit message (Collapse) | Author |
|
|
|
This was a regression introduced in rB0ff3f96a1b0193d69dae5ca69e7c93d6cdf34558.
|
|
A virtual array is a data structure that is similar to a normal array
in that its elements can be accessed by an index. However, a virtual
array does not have to be a contiguous array internally. Instead, its
elements can be layed out arbitrarily while element access happens
through a virtual function call. However, the virtual array data
structures are designed so that the virtual function call can be avoided
in cases where it could become a bottleneck.
Most commonly, a virtual array is backed by an actual array/span or
is a single value internally, that is the same for every index.
Besides those, there are many more specialized virtual arrays like the
ones that provides vertex positions based on the `MVert` struct or
vertex group weights.
Not all attributes used by geometry nodes are stored in simple contiguous
arrays. To provide uniform access to all kinds of attributes, the attribute
API has to provide virtual array functionality that hides the implementation
details of attributes.
Before this refactor, the attribute API provided its own virtual array
implementation as part of the `ReadAttribute` and `WriteAttribute` types.
That resulted in unnecessary code duplication with the virtual array system.
Even worse, it bound many algorithms used by geometry nodes to the specifics
of the attribute API, even though they could also use different data sources
(such as data from sockets, default values, later results of expressions, ...).
This refactor removes the `ReadAttribute` and `WriteAttribute` types and
replaces them with `GVArray` and `GVMutableArray` respectively. The `GV`
stands for "generic virtual". The "generic" means that the data type contained
in those virtual arrays is only known at run-time. There are the corresponding
statically typed types `VArray<T>` and `VMutableArray<T>` as well.
No regressions are expected from this refactor. It does come with one
improvement for users. The attribute API can convert the data type
on write now. This is especially useful when writing to builtin attributes
like `material_index` with e.g. the Attribute Math node (which usually
just writes to float attributes, while `material_index` is an integer attribute).
Differential Revision: https://developer.blender.org/D10994
|
|
This refactor simplifies having standalone function pointer that
does a single conversion. It also speeds up implicit type conversion
of attributes.
|
|
|
|
This is especially useful when trying to add a node group instance, e.g. via
drag & drop from the Outliner or Asset Browser.
Previously this would just silently fail, with no information why. This is a
source of confusion, e.g. earlier, it took me a moment to realize I was
dragging a node group into itself, which failed of course.
Blender should always try to help the user with useful error messages.
Adds error messages like: "Nesting a node group inside of itself is not
allowed", "Not a compositor node tree", etc.
Adds a disabled hint return argument to node and node tree polling functions.
On error the hint is reported, or could even be shown in advance (e.g. if
checked via an operator poll option).
Differential Revision: https://developer.blender.org/D10422
Reviewed by: Jacques Lucke
|
|
|
|
The default insert link callback for nodes was trying to move the
existing link away, since it didn't properly handle multi-input sockets
(though the problem wasn't exposed for the join node). We can basically
skip all of this "moving existing links" for multi-input sockets, unless
we are at the link limit.
|
|
Use LISTBASE_FOREACH macro, rename variables, comment formatting,
simplification of logic, etc.
|
|
Differential Revision: https://developer.blender.org/D10857
|
|
|
|
Doing this, because it might make it easier to replace the implementation
of `bNodeInstanceHash`.
|
|
The node tree evaluator now calls a callback for every used socket with
its corresponding value(s). Right now the callback does nothing.
However, we can use it to collect attribute name hints, socket values
for debugging or data that will be displayed in the spreadsheet.
The main difficulty here was to also call the callback for sockets in
nodes that are not directly executed (such as group nodes, muted
nodes and reroutes).
No functional changes are expected.
|
|
|
|
Change `float to boolean` and `int32 to boolean` to return false for zero and negative values.
This aligns with how artists would expect these values to work. This is in contrast to what a coder would expect. It was determined on blender.chat that this was a better default. This means that a negative float value would give a boolean false.
Change `Color4f to boolean` to return false for zero and negative grayscale values.
Likewise, for color to boolean, to account for negative value colors, the grayscale value would be used for determining if a colour was false or not.
See {T86454}
Reviewed By: JacquesLucke
Differential Revision: https://developer.blender.org/D10685
|
|
|
|
Cycles, Eevee, OSL, Geo, Attribute
Based on outdated refract patch D6619 by @cubic_sloth
`refract` and `faceforward` are standard functions in GLSL, OSL and Godot shader languages.
Adding these functions provides Blender shader artists access to these standard functions.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D10622
|
|
Previously, the signature of a `MultiFunction` was always embedded into the function.
There are two issues with that. First, `MFSignature` is relatively large, because it contains
multiple strings and vectors. Secondly, constructing it can add overhead that should not
be necessary, because often the same signature can be reused.
The solution is to only keep a pointer to a signature in `MultiFunction` that is set during
construction. Child classes are responsible for making sure that the signature lives
long enough. In most cases, the signature is either embedded into the child class or
it is allocated statically (and is only created once).
|
|
This does not need to be included everywhere, because it is only
needed in very few translation units that actually define CPPType's.
|
|
|
|
This visualization of nested node groups makes it easier to debug
some issues. Muted nodes, muted links, reroute nodes and unavailable
sockets are removed from the visualization to keep it clean.
Nested node groups are visualized using colored clusters.
|
|
This also moves the handling of muted nodes from derived node tree to
node tree ref.
|
|
`NodeTreeRef` is a thin wrapper on top of `bNodeTree`. By default it
should not hide anything from the underlying `bNodeTree` (before this
it was hiding muted links).
For convenience some "derived" data is cached on sockets. For example
all the connected sockets when reroutes and muted links are ignored.
A nice side benefit of this refactor is that `NodeTreeRef` requires
less memory than before.
|
|
This patch adds the ability to mute individual wires in the node editor.
This is invoked like the cut links operator but with a new shortcut.
Mute = Ctrl + Alt
Cut = Ctrl
Dragging over wires will toggle the mute state for that wire.
The muted wires are drawn in red with a bar across the center.
Red is used in the nodes context to indicate invalid links, muted links and internal links.
When a wire is muted it exposes the original node buttons which are normally hidden when a wire is connected.
Downstream and upstream links connected using reroute nodes are also muted.
Outside scope of patch:
- Add support for pynodes e.g. Animation Nodes
- Requires minor change to check for muted links using the `is_muted` link property or the `is_linked` socket property.
Maniphest Tasks: T52659
Differential Revision: https://developer.blender.org/D2807
|
|
Add implicit `int32 to Color4f` conversion. Matches `int32 to float3` conversion logic.
This may not be the most useful conversion but prevents an error in the Attribute Convert node.
Reviewed By: JacquesLucke
Differential Revision: https://developer.blender.org/D10686
|
|
Use average instead of distance when converting from float3/float2 to float. This matches behaviour of shader nodes.
See: https://developer.blender.org/T86454
Reviewed By: JacquesLucke
Differential Revision: https://developer.blender.org/D10684
|
|
This is necessary to make float sockets display a value with the unit
system. `PROP_DISTANCE` will be used quite a lot by the mesh primitives
geometry nodes patch.
Differential Revision: https://developer.blender.org/D10711
|
|
The result value should be true if the input values are not zero.
Note that there is ongoing conversation about these conversions
in D10685. This is simply a fix though.
|
|
The multi-input-socket cannot be connected to the same socket twice currently.
However, it is still possible to achieve this using an intermediate reroute node.
In this case the origin socket should be listed twice in the `linked_sockets_` list.
Higher level functions can still deduplicate the list of they want.
|
|
This conversion works the same way as a combination of the existing
color to float3 to boolean conversions, so the boolean result will be
false if the color is black, otherwise true, and the alpha is ignored.
|
|
This Patch removes the auto sorting from Multi-Input Sockets and allows
the links to be sorted by drag and drop instead.
As a minor related change, it fixes the drawing of the mute line to
connect to the first input instead of the socket's center.
|
|
Otherwise muting a Join Geometry node has no effect, when there
are multiple Join Geometry nodes in a row.
|
|
|
|
|
|
|
|
This is a complete rewrite of the derived node tree data structure.
It is a much thinner abstraction about `NodeTreeRef` than before.
This gives the user of the derived node tree more control and allows
for greater introspection capabilities (e.g. before muted nodes were
completely abstracted away; this was convenient, but came with
limitations).
Another nice benefit of the new structure is that it is much cheaper
to build, because it does not inline all nodes and sockets in nested
node groups.
Differential Revision: https://developer.blender.org/D10620
|
|
Use _fn as a suffix for callbacks.
|
|
This adds a couple more utility methods to various node tree ref types.
Also `InternalLinkRef` has been added to get simpler access to internal links.
|
|
Note that this still does not work when in the node group directly referenced
by the modifier, only in sub-node-groups. This limitation will be removed
at some point.
|
|
This commit exposes the strings used in the node error messages for
localization. It also changes the message tooltip creation to
automatically add the period at the end, to be more consistent with
the (arguably bad) design of other tooltips in Blender.
Calling `TIP_` directly in the node implementation files allows us to
continue using `std::string` concatenation instead of passing variadic
arguments. It's also more explicit about which part of the message is
translated and which isn't. The files already include the translation
header anyway.
|
|
Sometimes it is useful to have this information available to be able
to read information from links.
|
|
An error doesn't make sense in these situations because we don't expect
to find attributes on empty geometry, and an empty geometry set is a
valid situation.
Note that we can't use `component.is_empty` here, because often the
component is visually "empty" but still has a point cloud with no
points or a mesh with no vertices.
|
|
This makes it easier to use the api.
|
|
This patch adds icons to the right side of nodes when they encounter a
a problem. When hovered, a tooltip displays describing the encountered
while evaluating the node.
Some examples are: attribute doesn't exist, mesh has no faces,
incorrect attribute type, etc. Exposing more messages to the system
will be an ongoing process. Multiple warnings per node are supported.
The system is implemented somewhat generically so that the basic
structure can also be used to store more information from evaluation
for the interface, like a list of available attributes.
Currently the messages are just button tooltips. They could be styled
differently in the future. Another limitation is that every instance of
a node group in a parent node tree will have the same error messages,
the "evaluation context" used to decide when to display the tooltips
must be extended to support node tree paths.
Differential Revision: https://developer.blender.org/D10290
|
|
Since the derived node tree is already build for the evaluation system,
it's simpler to pass a derived node to the params struct. This will also
allow context lookups in nested node groups for node error messages,
since the derived node has that information readily accessible.
|
|
I need to access these utilities from modifier code as well.
Therefore, they should not live in the nodes module.
|
|
Currently every attribute node assumes that the attribute exists on the
"points" domain, so it generally isn't possible to work with attributes
on other domains like edges, polygons, and corners.
This commit adds a heuristic to each attribute node to determine the
correct domain for the result attribute. In general, it works like this:
- If the output attribute already exists, use that domain.
- Otherwise, use the highest priority domain of the input attributes.
- If none of the inputs are attributes, use the default domain (points).
For the implementation I abstracted the check a bit, but in each
node has a slightly different situation, so we end up with slightly
different `get_result_domain` functions in each node. I think this makes
sense, it keeps the code flexible and more easily understandable.
Note that we might eventually want to expose a domain drop-down to some
of the nodes. But that will be a separate discussion; this commit focuses
on making a more useful choice automatically.
Differential Revision: https://developer.blender.org/D10389
|
|
Normally sockets only have one input link. This commit adds the back-end
changes needed to use multiple input links per socket.
Multi-input sockets can be defined with a new flag in `bNodeSocketType`.
The changes necessary to make the sockets work in the geometry nodes
evaluator are generalizing input socket values as a vector of values,
and supporting this in the derived node tree structure.
This patch should contain no functional changes. Two upcoming patches
will use this system for the "Join Geometry" node and expose link picking
and updated display in the UI: D10069 and D10181.
Reviewed By: Jacques Lucke, Hans Goudey
Differential Revision: https://developer.blender.org/D10067
|
|
Previously float2 was converted to float3 by implicitly converting to a
float pointer first, which was then passed to the float3 constructor.
This leads to uninitialized memory in the z component of the new float3.
Ideally this should be solved in float2/float3 itself, but my first fix for
that resulted in a compile error: rB6ac0a3d83c8e5a39bd5356aa0d68e3166bd91e82
This is an alternative fix that can be used for now. Will have to look
into the conversion in more detail again.
|
|
Some of these conversions are arbitrary to some degree.
However, the user experience is better when at least something
happens when converting between types, instead of just getting
zeros. I left out a few conversions that I wasn't sure about yet.
I also added conversions for float2.
|