Implements the GPv2 onion skinning functionality.
There are no functional changes exept for the `use_ghosts_always`
option, which has been removed. This was used to show onion
skinning in the final render.
Pull Request: https://projects.blender.org/blender/blender/pulls/119792
This fixes an issue where the `use_masks` functions on layers
and groups returned the wrong value.
The issue was that the root group doesn't have this flag set
which then propagates to all the layers and groups.
To fix this we invert the `GP_LAYER_TREE_NODE_USE_MASKS` flag (now called `GP_LAYER_TREE_NODE_HIDE_MASKS`).
The API still uses the `use_masks` function.
Layer masks were partly already there. This PR completes the implementation and expose them through the UI.
This also adds three operators to:
- add a layer mask
- remove a layer mask
- reorder layer masks
Note: These are not used by the renderer yet. Will be done in a following PR.
Pull Request: https://projects.blender.org/blender/blender/pulls/119433
This adds the `viewlayername` property to grease pencil v3 layers.
It's exposed as `viewlayer_render` in python.
Note: this is not used in the renderer yet. Will be used in a following PR.
Pull Request: https://projects.blender.org/blender/blender/pulls/119422
This implements layer parenting and layer transforms.
* Adds a new "Transform" panel in the object-data properties with the (local) translation, rotation and scale.
* Adds a new "Relations" panel with the parent property (and also bone name in case the parent is an armature).
* When converting from GPv2 to GPv3, the parent and transforms are converted too.
* Bone names are updated if they are renamed in the armature.
Implementation details:
* The positions in the drawings are always in layer space. During extraction, we transform the positions to object space. Note that this could be optimized further and done in the render engine itself.
* This means that e.g. the selection code (which needs to know where the positions are on screen) now takes this transform into account.
* The layer transform is calculated when accessed (from the location, rotation, scale properties).
* Code that needs to know where the positions are on screen now takes this new transform into account.
Pull Request: https://projects.blender.org/blender/blender/pulls/117247
Adds vertex groups and basic operator support to the `GreasePencil` data
block.
Vertex groups in the `GreasePencil` ID are used as the source of truth
for vertex groups names and ordering in the UI. Individual drawings also
have vertex group lists, but they should not be modified directly by
users or the API. The main purpose of storing vertex group names in in a
drawing's `CurveGeometry` is to make it self-contained, so that vertex
weights can be associated with names without requiring the
`GreasePencil` parent data.
Vertex group operators are implemented generically for some ID types.
Grease Pencil needs its own handling in these operators. After
manipulating `vertex_group_names` the `validate_drawing_vertex_groups`
utility function should be called to ensure that drawings only contain a
true subset of the `GreasePencil` data block.
Operators for assigning/removing/selecting/deselecting vertices are also
implemented here. To avoid putting grease pencil logic into the generic
`object_deform.cc` file a number of utility functions have been added in
`BKE_grease_pencil_vgroup.hh`.
Fixes#117337
Pull Request: https://projects.blender.org/blender/blender/pulls/117476
This cleanup changes the `layer` parameter in `get_drawing_at` and `get_editable_drawing_at` to a reference.
This makes it clear that the layer is required for this function.
Each value is now out of the global namespace, so they can be shorter
and easier to read. Most of this commit just adds the necessary casting
and namespace specification. `enum class` can be forward declared since
it has a specified size. We will make use of that in the next commit.
The `paint_init_pivot` calculates the `location` based
on the midpoint of the bounds of the object. For grease pencil
the bounds depend on the current frame (for original data).
This fixes the issue by making the `bounds_min_max` function
dependent on the `frame` and by introducing a `bounds_min_max_eval`
for evaluated data.
Adds a new scene tool setting `use_grease_pencil_multi_frame_editing`.
The `foreach_*_drawing` functions are moved to the `ed::greasepencil` namespace in the editor, since they are now context sensitive and depend on the toolsetting. They are now named `retrieve_editable_drawings` and `retrieve_visible_drawings` and return
an array of drawings instead of calling a callback function.
Pull Request: https://projects.blender.org/blender/blender/pulls/114283
This field supports either a Layer, or a Layer Group name as input,
and outputs a selection.
The nodes that use this should add the name to the list of Named
Dependencies of the node-tree.
Ref !113908.
Instead of calculating the expected insertion index for a customdata entry being moved, this implementation just records the initial layer indices so that it can compare them with the final indices to determine how the customdata entries need to be re-arranged.
Also simplifies the `add_layer` function and adds an implementation that just takes a `name` and adds a new layer with that name to the root group.
Pull Request: https://projects.blender.org/blender/blender/pulls/113962
Instead of having two APIs (`find_layer_by_name` +
`find_layer_group_by_name`) replace them with a single API
`find_node_by_name`.
This returns a `TreeNode` but the caller can easily check if it's a
layer or a group.
This adds `GreasePencilEditHints` and correctly implements
`crazyspace::get_evaluated_grease_pencil_drawing_deformation`
to support querying the deformation of points after evaluation.
This is needed for users to properly select points in edit mode while
seeing the effects of the modifiers.
Pull Request: https://projects.blender.org/blender/blender/pulls/113586
We had a short discussion on this change. "Grease Pencil Layer" is
just a bit too long, especially in the UI. Even though "Layer" might be
ambiguous, it shouldn't be in the context of geometry nodes. There are
currently no other "Layers" and if there were, using the same domain
name could be fine (just like we reuse the point domain for e.g. vertices
in meshes and control points in curves).
This also renames the internal enum to `ATTR_DOMAIN_LAYER`
Pull Request: https://projects.blender.org/blender/blender/pulls/113589
This implements the core changes for this design: https://devtalk.blender.org/t/grease-pencil-integration-into-geometry-nodes/31220
The changes include:
* Add `CustomData` for layer attributes
* Add attribute support for the `GreasePencilComponent` to read/write layer attributes. Also introduces a `Layer` domain.
* Implement a `GreasePencilLayerFieldContext` and make `GeometryFieldContext` work with grease pencil layers.
* Implement `Set Position` node for `Grease Pencil`.
Note: These changes are only accessible/visible with the `Grease Pencil 3.0` experimental flag enabled.
Co-authored-by: Jacques Lucke <jacques@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/112535
This PR implements an initial drawing tool that can already be used for testing.
While this is not fully feature complete (compared to the current grease pencil draw tool) the following is already implemented:
* Pressure support for radius and opacity.
* Material color and vertex color support.
* New active smoothing algorithm based on curve fitting.
* Simplify algorithm as a post-process step.
Some deliberate limitations include:
* The drawing plane is always the front plane. Drawing on surfaces is also not supported.
*
The current approach has not been optimized for performance yet. The goal was to have a straightforward implementation
first and then focus on performance later.
There are numerous parameters in the code that are hard-coded for now. These should be exposed at some point, potentially as user settings.
Pull Request: https://projects.blender.org/blender/blender/pulls/110093
In preparation of https://projects.blender.org/blender/blender/pulls/112535, we need to make sure all layer tree manipulations are in functions on the `GreasePencil` struct so we can keep the `CustomData` for layers in sync with the layer tree.
This PR makes sure that all the functions that change the layer tree in any way are `protected` on the `LayerGroup` class. The `GreasePencil` struct is declared `friend` with `LayerGroup`.
We also cleanup and remove a lot of code duplication between layers and layer groups and try to write functions in a generic way for `TreeNode` (both layers and layer groups are tree nodes).
Pull Request: https://projects.blender.org/blender/blender/pulls/112837
It was possible to access a mutable drawing from a const GreasePencil
object. This sort of mistake is possible because DNA requires using raw
pointers.
Implementation of the duplicate and move operator for grease pencil frames.
The `ACTION_OT_duplicate` operator now creates duplicates of the selected frames and stores them in the layer runtime data.
The `TRANSFORM_OT_transform` operator is updated to take care of these duplicated frames.
Pull Request: https://projects.blender.org/blender/blender/pulls/111051
`extern "C"` did not actually have an effect here since it only impacts
name mangling of functions, not structs (or other class types). Now this
can get in the way when we add C++ blocks with functions , e.g.
templates are not allowed in code with C-linkage.
Most of these were added in ad4b7741db, even though it was known that
this doesn't have any impact. Reason was because developers thought they
would have to add that to all direct and indirect includes to be able to
use a header in C++ (a common misconception). Now with most files
compiled in C++, it's obvious that this isn't the case.
Pull Request: https://projects.blender.org/blender/blender/pulls/111926
Partially reverts b14a0ee57e.
Instead of renaming the DNA field, use namespaces in C++ to resolve
name collisions (which is the reason this change was done
in the first place).
Some functionality of `Layer`s and `LayerGroup`s can be shared. This is why the `TreeNode` class exists. It encapsulates all the common methods both `Layer`s and `LayerGroup`s should have.
Up until now, the usage of `TreeNode` was not consistent and often the layers would just access the base c-struct directly.
This refactor makes it so that all of the functions affecting only the `TreeNode` are moved to the `TreeNode` class and only implemented there.
For example, renaming a layer is really just renaming the node. Therefor there shouldn't even be a `rename_layer` and `rename_layer_group` function. These were combined into a `rename_node` function.
Pull Request: https://projects.blender.org/blender/blender/pulls/111177
This makes it so the `GreasePencil` geometry gets updated on a time
change.
The frame at which the object gets evaluated is stored in runtime as
`eval_frame`. This is for example used to calculate the bounding box
of the geometry as well as invalidating the batch cache for different
frames.
Pull Request: https://projects.blender.org/blender/blender/pulls/111137
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.
While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.
Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.
Some directories in `./intern/` have also been excluded:
- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.
An "AUTHORS" file has been added, using the chromium projects authors
file as a template.
Design task: #110784
Ref !110783.
Implementation of the transform action for grease pencil frames, which enables translating and scaling grease pencil frames in the dopesheet.
This patch adds the following in the grease pencil API :
- `move_frames` to move a set of frames given a map of key transformations (with overwrite), and
- the structure `LayerTransformData` that stores in the layer runtime some useful data for the frames transformation.
Co-authored-by: Falk David <falk@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/110743
Instead of removing frames one by one, the `GreasePencil::remove_frames`
function now expects a span of frame numbers, replacing the
`GreasePencil::remove_frame_at` function.
Now, when drawings need to be deleted, we shrink the array only once.
Pull Request: https://projects.blender.org/blender/blender/pulls/110957
Adaptation of the operator `ACTION_OT_keyframe_insert` to take into account grease pencil channels.
Grease pencil keyframes can now be inserted in blank mode, or in additive mode (duplicate the current frame in the new keyframe).
Two API functions were added :
* `add_duplicate_drawings` which copies the data of a drawing to creates a duplicate, and
* `insert_duplicate_frame` which creates a duplicate frame of an existing one either by copy or instance.
The additive mode option is also added to the UI.
The Layer method `frame_key_at` previously private was set to public.
Pull Request: https://projects.blender.org/blender/blender/pulls/110649
Adds a user count to drawings to track how many frames use the drawing.
If the user count hits `0` the drawing should be deleted.
Also adds a function to delete a frame in a layer. This will
decrement the user count of the drawing and delete it if there are no
users left. This is consistent with the way GPv2 worked.
Pull Request: https://projects.blender.org/blender/blender/pulls/110579
Implementation of the click-selection operator of keyframes in the dopesheet, along with its alternatives : deselect all when no frames is hit, extend selection with shift, column selection with alt, select all keyframes on current channel with ctrl+alt.
Includes the new following API functions :
* `select_frame_at` : selects a frame in a layer at a specific time (if such frame exists),
* `select_all_frames` : selects all frames of a layer,
* `select_layer_channel` : selects a layer, and sets it as active (if layer is not null, otherwise the active layer is set null),
* `layer_has_frame_selected` : checks if any of the frames in the layer is selected.
Pull Request: https://projects.blender.org/blender/blender/pulls/110492
This turns the embedded group into a pointer.
Note: Older files will not load the grease pencil v3 object properly after this.
The objects will not have any layers in them.
Pull Request: https://projects.blender.org/blender/blender/pulls/110007