Move `Library.runtime` to be a pointer, move the related
`LibraryRuntime` struct to `BKE_library.hh`. Similar to e.g.
Mesh.runtime, that pointer is expected to always be valid, and is
allocated at readtime or when creating a new Library ID.
Related smaller changes:
* Write code now uses standard ID writing codepath for Library IDs too.
* Runtime pointer is reset to nullptr before writing.
* Looking up a library by its absolute path is now handled through a
dedicated utils, `search_filepath_abs`, instead of using
`BLI_findstring`.
Pull Request: https://projects.blender.org/blender/blender/pulls/134188
Before, it was only possible to apply modifiers through a multires modifier if
they were deform-only. The Geometry Nodes modifier is of course not deform-only.
However, often one can build a node setup, that only deforms and does nothing
else.
To make it possible to apply the Geometry Nodes modifier in such cases the
following things had to be done:
* Update `BKE_modifier_deform_verts` to work with modifiers that implement
`modify_geometry_set` instead of `deform_verts`.
* Add error handling for the case when `modify_geometry_set` does more than just
deformation.
* Allow the Geometry Nodes modifier to be applied through a multi-res modifier.
Two new utility types (`ArrayState` and `MeshTopologyState`) have been
introduced to allow for efficient and accurate checking whether the topology has
been modified. In common cases, they can detect that the topology has not been
changed in constant time, but they fall back to linear time checking if it's not
immediately obvious that the topology has not been changed.
This works with the example files from #98559 and #97603.
Pull Request: https://projects.blender.org/blender/blender/pulls/131904
`BKE_main_ensure_invariants` was added in 1fae5fd8f6. The older
`ED_node_tree_propagate_change` was already implemented as a thin wrapper around
`BKE_main_ensure_invariants`. This patch removes the wrapper and calls the more
general function directly.
A new overload of `BKE_main_ensure_invariants` is added for the common case when
only a single data-block has been modified.
Pull Request: https://projects.blender.org/blender/blender/pulls/133048
Main goals of this refactor:
* Make it more obvious which update function should be used.
* Make it more obvious which parameters are required by using references instead
of pointers.
* Support passing in multiple modified trees instead of just a single one.
No functional changes are expected.
Pull Request: https://projects.blender.org/blender/blender/pulls/132862
The part that used the context does not seem to be necessary anymore. If the
given tree has any update tag set, the same notifiers will be sent anyway by the
`tree_changed_fn` callback.
If it turns out that we are now missing some notifier, then we have to change
the caller. It either has to call the proper `BKE_ntree_update_tag_*` function,
or create the notifier directly.
This change helps to generalize the concept of propagating changes in original
data, because the context is rarely available.
Pull Request: https://projects.blender.org/blender/blender/pulls/132810
The "use attribute" and "attribute name" IDProperties were missing
the overrideable status and the static type status. This was an oversight
from when those tags were added.
This commit fixes the flag on new modifier properties as they're created
and applies versioning to old properties. It also fixes the poll of the toggle
input attribute operator so that it isn't possible on non-editable objects.
Pull Request: https://projects.blender.org/blender/blender/pulls/131768
The poll function doesn't apply here because it just checks for object
editability and edit mode, object types, and modifier types. We shouldn't
have a poll function at all because the hovered modifier might not be
part of the context.
Resolves#90008.
Pull Request: https://projects.blender.org/blender/blender/pulls/131384
This was caused by 9a03f283e8.
The change disregarded the `orig_layers_to_apply` mask and
introduced some issues regarding clearing keyframes of deleted layers.
The fix does two things:
* Add a `orig_layers_to_apply` set that contains the pointers of the
original layers that we want to apply.
* Add a `orig_layers_to_clear` set that contains the pointers of original
layers that need their keyframe cleared.
When a layer is removed during modifier execution, we don't want
the layer to be deleted in the original geometry. Instead we clear
the keyframes by deleting all the curves geometry. A layer
can be removed by e.g. using the `Grease Pencil to Curves` node to
get curve instances, then the `Delete Geometry` node to delete
some instances, and finally `Curves to Grease Pencil` to convert back
to Grease Pencil.
Pull Request: https://projects.blender.org/blender/blender/pulls/130028
Applying a modifier on Grease Pencil objects tries to maintain the
original layer order by inserting each layer after the previous. This
ignores layer groups and all layers get move to the root group.
This patch replaces the simple `previous_node` with a per-group pointer
map, which maintains order within each group only.
The code is also creating new layers when the original node of the same
name is a group. This was creating duplicate names which are not allowed
and break various things (layer editing buttons, panel open/close
toggles, etc.). Now these new layer names are made unique to avoid a
name conflict.
One remaining issue is that mixed layer/group ordering is lost: All the
layers get pushed to the bottom of the stack, due to the way
`geometry::merge_layers` ignores layer groups. The existing groups in
the orig data are not sorted along with the evaluated layers, so they
move to the top of the stack. This requires changes to `merge_layers`
and should be handled separately.
Pull Request: https://projects.blender.org/blender/blender/pulls/129943
The input `md_eval` is invalidated when calling `BKE_scene_graph_update_for_newframe`.
The fix uses `BKE_modifier_get_original` to pass the original modifier
to `apply_grease_pencil_for_modifier_all_keyframes` then calls `BKE_modifier_get_evaluated`
after `BKE_scene_graph_update_for_newframe` to ensure the `md_eval` pointer is valid.
Pull Request: https://projects.blender.org/blender/blender/pulls/129732
This adds an option `all_keyframes` to the `object.modifier_apply` operator.
With the option enabled, the operator will iterate through all the keyframes,
then apply the modifier and merge the result back into the original
object. This is only done for Grease Pencil objects.
This is how the default `Apply` operation worked in GPv2. This adds the
functionality back but also keeps the current `Apply` behavior for consistency
with other object types.
The UI is also changed to show both options in the dropdown menu.
Again, this is only shown for Grease Pencil objects.
With Geometry Nodes it's possible to add new layers to the geometry.
When applying, this will create a single keyframe on the first frame of
evaluation. Layers with duplicated names in evaluated geometry will
be deduplicated. It's also possible to have layers with empty names.
When applying these get renamed to `Layer` (and `Layer.001` etc.
when such a layer already exists in the original geometry).
Pull Request: https://projects.blender.org/blender/blender/pulls/128487
This patch improves working with grease pencil layers in geometry nodes.
* Allow layers to have duplicate names in geometry nodes. In original data, unique names are enforced.
* This allows e.g. duplicating layers and then merging them by name in the end.
* It also resolves a big serial bottleneck when working with many grease pencil layers in geometry nodes. Enforcing unique names is inefficient.
* New `Merge Layers` node that can merge multiple layers by name or by a custom group id.
* Applying a grease pencil modifier now first merges all layers with the same name to ensure all names are unique.
Co-authored-by: Jacques Lucke <jacques@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/127873
This improve the API in multiple aspects:
* No need for an additional `lookup` call to get the current attribute. This
would internally iterate over all attributes again. This leads to O(n^2)
behavior. Note that there are still other reasons for O(n^2) behavior when
processing attributes (where n is the number of attributes).
* Remove the need to return a value from the iteration code to indicate that the
iteration should continue. This is now the default behavior. The iteration can
still be stopped by calling `iter.stop()`.
* Easier access to `is_builtin` property.
* Iterator callback only has a single parameter instead of two (of which one is
sometimes unused).
Pull Request: https://projects.blender.org/blender/blender/pulls/128128
Previously, the `AttributeIDRef` wrapper was needed because it also had to
contain a pointer to an `AnonymousAttributeID`. However, since
b279a6d703 this is not necessary anymore.
Therefore we can use "raw" `StringRef` now which reduces the mental overhead
when working with attributes and also simplifies code.
Pull Request: https://projects.blender.org/blender/blender/pulls/127140
This implements the `Apply Modifier` operator for GPv3.
Applies the modifier to the current frame. Drawings at the current frame will be updated.
If the result of the modifier creates new layers, the layers will be added and a drawing
at the current frame will be inserted.
Applying a modifier will run the following steps:
* Create a localized copy of the original Grease Pencil data and insert it into a geometry
set that owns it.
* Execute the `modifiy_geometry_set` function of the modifier with this geometry set.
* In the resulting Grease Pencil data loop over all layers:
* If the original data has a layer with the same name, overwrite its drawing data in the
current frame.
* Otherwise create a new layer in the original data and insert a resulting drawing at
the current frame.
* Remove all original layers that are not mapped to from a result layer.
* Remap the material indices for all drawings that have not been updated (e.g. the ones
that are not on the current frame).
* Copy all the layer attributes to the original Grease Pencil.
Pull Request: https://projects.blender.org/blender/blender/pulls/124543
Previously, values for `ID.flag` and `ID.tag` used the prefixes `LIB_` and
`LIB_TAG` respectively. This was somewhat confusing because it's not really
related to libraries in general. This patch changes the prefix to `ID_FLAG_` and
`ID_TAG_`. This makes it more obvious what they correspond to, simplifying code.
Pull Request: https://projects.blender.org/blender/blender/pulls/125811
The crash was caused by attempting to write-back to the original data after it
has been removed (`add_data_block_items_writeback`).
This write-back is already disabled when applying a modifier, however the
corresponding flag was only set when applying modifiers on mesh objects. This
patch fixes this issue with two small changes:
* Rename `MOD_APPLY_TO_BASE_MESH` to `MOD_APPLY_TO_ORIGINAL` to make it more
generic.
* Pass this flag into modifier evaluation for other geometry types besides
meshes in `modifier_apply_obdata`.
Pull Request: https://projects.blender.org/blender/blender/pulls/125761
This removes the legacy Grease Pencil modifiers from the code.
These should have already been inaccessible from the UI and hidden from
the user. The modifiers have been reimplemented for the new GPv3
data structure.
On top of the modifier code, some other related things have been
removed as well:
* Operators related to the legacy modifiers.
* Keymaps for the legacy modifier operators.
* Some bits of code that used modifier functions.
Some code has to be kept, because it is still used:
* The core line art code, which is used by the new line art modifier. It's
moved to `modifiers/lineart`.
* The DNA structs for the legacy modifiers. They are still needed for
conversion.
* A few kernel functions for the modifiers are kept (also for conversion).
Co-authored-by: Lukas Tönne <lukas@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/125102
This commit moves generated `RNA_blender.h`, `RNA_prototype.h` and
`RNA_blender_cpp.h` headers to become C++ header files.
It also removes the now useless `RNA_EXTERN_C` defines, and just
directly use the `extern` keyword. We do not need anymore `extern "C"`
declarations here.
Pull Request: https://projects.blender.org/blender/blender/pulls/124469
Based on the design in #120230.
* Replaces the `Shade Smooth by Angle` operator with `Shade Auto Smooth`
in the object context menu menu.
* The new operator automatically adds and removes the modifier instead
of being a destructive operation.
* The `Shade Smooth` and `Shade Flat` operators now remove the
`Smooth by Angle` modifier automatically.
* Add a pin option to modifiers, which limits dragging and keeps the
modifier after newly added modifiers in the list.
Co-authored-by: Hans Goudey <hans@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/121494
Add a menu similar to the "Object > Constraints" menu that allows adding,
copying, and clearing modifiers. The "copy all modifiers to selected" and
"clear modifiers" operators are new, to mirror the functionality we already
have for constraints.
The "Add" menu is the same that's used in the property editor. In the 3D
view, modifiers are always added to all selected objects.
Part of #120230
Pull Request: https://projects.blender.org/blender/blender/pulls/121286
There were two functions copying modifiers. The modifier operator
exposed in the property editor reported for various failures. Outliner
drag and drop did not. This commit refactors code a bit to unify the
two. Outliner drag and drop should now report why it fails too.
Issue came with the new feature of adding modifiers to selected objects
by holding alt: 9a7f4a3b58. `use_selected_objects` state should not be
remembered. Otherwise, it's possible to add/edit modifier of multiple
object without holding alt
Pull Request: https://projects.blender.org/blender/blender/pulls/120810
Support holding alt while invoking modifier operations for add, apply,
remove, and move to index in the property editor. This affects all selected
editable objects instead of just the active object.
Though the alt key is not that visible, it's consistent with the
existing multi-object property editing shortcut. If/when multi-
object editing is every made the default, the alt key could
be reversed here too.
Changes as part of #120230.
Pull Request: https://projects.blender.org/blender/blender/pulls/120695