GPv3: Insert grease pencil keyframe from the dopesheet #110649
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#110649
Loading…
Reference in New Issue
No description provided.
Delete Branch "amelief/blender:gpv3-insert-keyframe"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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, andinsert_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.Note: There is a TODO left in
insert_duplicate_frame
, because we need to add a user to the drawing if the function is called with thedo_instance
option. We need #110579 to do so.However, this option is never called for this insert keyframe operator. Thus, I don't think it is needed to land this PR.
I we want to land this PR before 110579, we could remove the option in this function for clarity.
First pass.
@ -1344,2 +1344,4 @@
}
void GreasePencil::add_duplicate_drawings(
const int add_num, const blender::bke::greasepencil::Drawing &duplicated_drawing)
add_num
->duplicate_num
duplicated_drawing
->drawing
(since this is the drawing to be duplicated not the actually duplicated one)@ -1359,2 +1373,4 @@
}
bool GreasePencil::insert_duplicate_frame(blender::bke::greasepencil::Layer &layer,
const GreasePencilFrame &duplicated_frame,
duplicated_frame
->frame
@ -1361,0 +1381,4 @@
const int drawing_index = do_instance ? duplicated_frame.drawing_index :
int(this->drawings().size());
const int duration = 0;
Shouldn't this get the duration from the
duplicate_frame
?Agree. I had to change the function so that it takes an index instead of directly the frame to be duplicated. I think now it works, though.
@ -1361,0 +1390,4 @@
frame->type = duplicated_frame.type;
const GreasePencilDrawingBase *drawing_base = this->drawings()[duplicated_frame.drawing_index];
Can use a new API here
this->drawings(duplicated_frame.drawing_index)
. Tiny bit nicer.@ -1361,0 +1391,4 @@
frame->type = duplicated_frame.type;
const GreasePencilDrawingBase *drawing_base = this->drawings()[duplicated_frame.drawing_index];
BLI_assert_msg((drawing_base->type == GP_DRAWING),
I think instead of the
assert
here I would prefer aswitch
that has aTODO
comment for theGP_DRAWING_REFERENCE
case and does nothing.@ -768,0 +777,4 @@
using namespace blender::bke::greasepencil;
Layer *layer = static_cast<Layer *>(ale->data);
GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(ale->id);
const int frame_number = ac->scene->r.cfra;
Even if it's a bit longer, I would prefer this to be
current_frame_number
. Makes the rest more readable imho.@ -768,0 +780,4 @@
const int frame_number = ac->scene->r.cfra;
if (layer->frames().contains(frame_number)) {
/* A frame already exists at the current frame number. */
This comment can be removed with the change suggested above.
@ -768,0 +788,4 @@
if (hold_previous) {
const GreasePencilFrame *active_frame = layer->frame_at(frame_number);
if ((active_frame == nullptr) || (active_frame->is_null())) {
/* There is no active frame to hold to, or it's a null frame. */
/* There is no active frame to hold to, or it's a null frame. Therefore just insert a blank frame. */
898eaec510
tof6a49de5fc
One more thing I noticed.
@ -768,0 +805,4 @@
}
if (changed) {
layer->tag_frames_map_keys_changed();
the
layer.add_frame
function will do the tagging already. I think this is not needed.One more thing I noticed.
Second pass :)
@ -1406,0 +1436,4 @@
const int duplicate_frame_number,
const bool do_instance)
{
using namespace blender;
using namespace blender::bke::greasepencil;
here so we can useDrawing
below.@ -1406,0 +1438,4 @@
{
using namespace blender;
BLI_assert(layer.frames().contains(frame_number));
Rather than asserting here, I think we can return
false
. I don't think we should crash here if theframe_number
isn't found.@ -1406,0 +1454,4 @@
const GreasePencilDrawingBase *drawing_base = this->drawings(frame.drawing_index);
switch (drawing_base->type) {
case GP_DRAWING: {
const GreasePencilDrawing *drawing = reinterpret_cast<const GreasePencilDrawing *>(
Can be directly
Drawing &drawing = reinterpret_cast<const GreasePencilDrawing *>(drawing_base)->wrap();
@ -1406,0 +1457,4 @@
const GreasePencilDrawing *drawing = reinterpret_cast<const GreasePencilDrawing *>(
drawing_base);
if (do_instance) {
/* TODO : add user to the drawing. */
drawing.add_user();
(needs a rebase withmain
)@ -1406,0 +1460,4 @@
/* TODO : add user to the drawing. */
}
else {
this->add_duplicate_drawings(1, drawing->wrap());
This should have a comment saying that the inserted frame already points to this duplicated drawing, because the index was set to
int(this->drawings().size())
.0c6313e538
to44523a27e1
Some final small comments, but otherwise this looks good.
@ -34,6 +37,8 @@
#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_gpencil_legacy.h"
#include "BKE_grease_pencil.h"
Don't think this header needs to be included.
@ -481,10 +481,17 @@ typedef struct GreasePencil {
void remove_layer(blender::bke::greasepencil::Layer &layer);
void add_empty_drawings(int add_num);
void add_duplicate_drawings(int add_num,
duplicate_num
andDrawing &drawing
61fcbdcb00
to33fc703589