GPv3: Copy/Paste Keyframes #113110

Closed
opened 2023-10-01 11:48:22 +02:00 by Pratik Borhade · 5 comments
Member

Copy keyframes:
Aim: Identify selected frames and store them in buffer.

  • Create a class having two members (BufferItem):
    • Array of frame_number (stores frame_number of a selected keyframes per layer)
    • Layer in which keyframe belong to
  • Create static buffer which will store list of selected keyframes i.e. BufferItem (see how this is done for action_keys: copy_animedit_keys() / tAnimCopybufItem / animcopybuf. File: keyframes_general.cc )
  • Create a new function grease_pencil_copy_keyframes() in grease_pencil_frames.cc
  • In actkeys_copy_exec(), call the above function. (as of now, animation data of GPv3 is only available in ANIMCONT_GPENCIL)
  • In grease_pencil_copy_keyframes():
    • Iterate through all the visible channels
      • For every channel/layer, iterate through every frame: for (auto [frame_number, frame] : layer.frames().items()) {
      • if frame.is_selected() == true, store frame_number and layer pointer in BufferItem
    • Add BufferItem to static list

Paste Keyframes
Aim: Use static list to get all the selected keyframes and create a copy of it at playhead

  • Create grease_pencil_paste_keyframes()
  • Call above function in actkeys_paste_exec
  • In grease_pencil_paste_keyframes(): Iterate through the static list of BufferItem
    • Inside this, run for loop for frame_number array
      • Here we can get individual frame from frame_number:
        GreasePencilFrame &frame = layer.frames().lookup(frame_number[i])
      • To create a copy of this keyframe at playhead, we need to duplicate the keyframe and drawing
        Maybe we could use existing function GreasePencil::insert_duplicate_frame()

Some information about mapping of layer, drawings and frames:

Drawing done at each frame is stored at `drawing_array` in `GreasePencil` struct
These drawings and frames shares same `drawing_index`
Frames can be accessed from `Layer` class
Files to look at:

source\blender\editors\space_action\action_edit.cc
source\blender\editors\grease_pencil\intern\grease_pencil_frames.cc
source\blender\blenkernel\intern\grease_pencil.cc

Functions to look at:

actkeys_copy_exec()
ED_gpencil_anim_copybuf_copy()
copy_animedit_keys()
actkeys_paste_exec()
ED_gpencil_anim_copybuf_paste()
insert_duplicate_frame()

**Copy keyframes:** Aim: Identify selected frames and store them in buffer. - Create a class having two members (BufferItem): - Array of frame_number (stores frame_number of a selected keyframes per layer) - Layer in which keyframe belong to - Create static buffer which will store list of selected keyframes i.e. `BufferItem` (see how this is done for action_keys: `copy_animedit_keys() / tAnimCopybufItem / animcopybuf`. File: `keyframes_general.cc` ) - Create a new function `grease_pencil_copy_keyframes()` in `grease_pencil_frames.cc` - In `actkeys_copy_exec()`, call the above function. (as of now, animation data of GPv3 is only available in `ANIMCONT_GPENCIL`) - In `grease_pencil_copy_keyframes()`: - Iterate through all the visible channels - For every channel/layer, iterate through every frame: `for (auto [frame_number, frame] : layer.frames().items()) {` - if `frame.is_selected() == true`, store frame_number and layer pointer in `BufferItem` - Add `BufferItem` to static list **Paste Keyframes** Aim: Use static list to get all the selected keyframes and create a copy of it at playhead - Create `grease_pencil_paste_keyframes()` - Call above function in `actkeys_paste_exec` - In `grease_pencil_paste_keyframes()`: Iterate through the static list of `BufferItem` - Inside this, run for loop for frame_number array - Here we can get individual frame from frame_number: `GreasePencilFrame &frame = layer.frames().lookup(frame_number[i])` - To create a copy of this keyframe at playhead, we need to duplicate the keyframe and drawing Maybe we could use existing function `GreasePencil::insert_duplicate_frame()` - - - **Some information about mapping of layer, drawings and frames:** ``` Drawing done at each frame is stored at `drawing_array` in `GreasePencil` struct These drawings and frames shares same `drawing_index` Frames can be accessed from `Layer` class ``` <details> <summary> Files to look at: </summary> source\blender\editors\space_action\action_edit.cc source\blender\editors\grease_pencil\intern\grease_pencil_frames.cc source\blender\blenkernel\intern\grease_pencil.cc </details> <details> <summary> Functions to look at: </summary> actkeys_copy_exec() ED_gpencil_anim_copybuf_copy() copy_animedit_keys() actkeys_paste_exec() ED_gpencil_anim_copybuf_paste() insert_duplicate_frame() </details>
Pratik Borhade added the
Type
Report
Priority
Normal
Status
Needs Triage
labels 2023-10-01 11:48:23 +02:00
Pratik Borhade added
Type
To Do
and removed
Type
Report
labels 2023-10-01 11:51:38 +02:00
Pratik Borhade removed the
Status
Needs Triage
label 2023-10-01 12:05:59 +02:00
Iliya Katushenock removed the
Priority
Normal
label 2023-10-01 14:05:28 +02:00
Iliya Katushenock added this to the Grease Pencil project 2023-10-01 14:05:33 +02:00
Contributor

Hello. Can I take this task if it's not too emergent?

Hello. Can I take this task if it's not too emergent?
Author
Member

Hi, feel free to work on this. If you stuck somewhere, ask in this thread or in #grease-pencil-module

Hi, feel free to work on this. If you stuck somewhere, ask in this thread or in [#grease-pencil-module](https://blender.chat/channel/grease-pencil-module)
Contributor

Hello. I tried to use GreasePencil::insert_duplicate_frame() but discovered a bug in this function. I opened #114352. In the meantime I would like to discuss how to store Layer info properly. My question is is it possible that the layers of a grease pencil can also be copied to elsewhere, making the layer pointer stored in copy buffer invalid? If so we cannot store the pointer directly. What is the better identifiers for layers?

Hello. I tried to use `GreasePencil::insert_duplicate_frame()` but discovered a bug in this function. I opened #114352. In the meantime I would like to discuss how to store Layer info properly. My question is is it possible that the layers of a grease pencil can also be copied to elsewhere, making the layer pointer stored in copy buffer invalid? If so we cannot store the pointer directly. What is the better identifiers for layers?
Contributor

GPv3: Copy/Paste Keyframes #117388

GPv3: Copy/Paste Keyframes #117388
Author
Member

74b9c6a8a0
Thanks @Chao-Li 🎉

74b9c6a8a05c711df04ec97908c45382e753d4d8 Thanks @Chao-Li 🎉
Blender Bot added the
Status
Archived
label 2024-04-22 12:08:18 +02:00
Sign in to join this conversation.
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
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#113110
No description provided.