GPv3: Python API: GreasePencilFrame #116045
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#116045
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
We need a Python API for the
GreasePencilFrame
. SeeGreasePencilFrame
inDNA_grease_pencil_types.h
andclass Layer
inBKE_grease_pencil.hh
The layer needs a collection property:
frames
inrna_def_grease_pencil_layer
.layer.frames()
. Use thesorted_keys()
cache so that the collection returns the elements sorted by the scene time.The
GreasePencilFrame
should havedrawing
to aGreasePencilDrawing
(which can just be a stub for now).Given what we talked, could i take care of this as a first step?
@mewslore Yes :)
Alright, I'm forking the repository and I'll work from there. Is there anything else i should take into account?
@mews6 If you haven't already, then this is good to read https://wiki.blender.org/wiki/Tools/Pull_Requests
Alright, it's been a while, and i took a break to celebrate the holidays with my family (which is why i've been so silent as of late, sorry for that). However, i already took a look into the documentation of the existing Python API and i've been reading the files you suggested. And there's a few questions i have before coding anything:
Where would we locate the class? classes inside of files with other information is a thing that happens in Blender's souce code, so i'm not sure if there is already a place where this class should be. Would it share a file with other classes?
When you mention "a pointer
drawing
to aGreasePencilDrawing
" are we talking about an actual pointer from C/C++?Given the fact that we're making a pointer towards an instance of
GreasePencilDrawing
, could this code be merged without that class existing? If not, then coulddrawing
be a null? (which i'd imagine could be the case if this code can be merged without it)I'll probably keep asking either here or in the chat when i run into trouble. But for now, those are my main questions.
@mews6 Welcome back :) (no need to apologize!)
Layer
class then the location isblender/source/blender/blenkernel/BKE_grease_pencil.hh:333
(here).RNA_def_property_struct_type
is the name of the RNA struct defined withRNA_def_struct_sdna
(here).GreasePencilDrawing
inblender/source/blender/makesdna/DNA_grease_pencil_types.h
(here). But what I mean with "this can be a stub for now" is that you just defineGreasePencilDrawing
usingRNA_def_struct_sdna
(see how it's done for the RNA for layers) but not add any props etc. to it. It can just be an empty container for now.I already have a few things coded, but i'm hesitant to commit them because they don't compile as of now. One of the things i've noticed is that the functions that manage iterations in
rna_def_grease_pencil.cc
generally recieve a parameter by reference calledCollectionPropertyIterator *iter
. I'm a bit confused over this structure, and i'm not sure where this variable is coming from. An example of this structure being asked for can be seen here. As my code currently stands, I'm trying to define this kind of function for the collection property that is being defined forGreasePencilFrame
, but I'm not sure where could i find the values being asked for there, this might affect our code in this specific project given we need a custom collection iterator and this might interact with it. How does this specific piece of code work?@mews6 Hello!
First, let me point out that it's OK to create a PR that doesn't compile yet :) Just make sure to prepend
WIP:
to the title. Makes it easier to see where the issue might be. It also makes it clear to others that there is work being done on this task!Now to answer the question about the collection property. When using
RNA_def_property_collection_funcs
, we're defining the callbacks that can be found in theCollectionPropertyRNA
struct.PropCollectionBeginFunc
,PropCollectionNextFunc
etc. These callbacks are called with theCollectionPropertyIterator
as the first argument. It's basically the struct that manages the iteration. It keeps track of what the current item is, etc. etc.Now in our case, I think we can mostly use the
rna_iterator_array_*
functions that exist already. Because we want to iterate over thesorted_keys
array. So e.g. ourbegin
callback would first callrna_iterator_array_begin
with all the array information ofsorted_keys
. Then it would userna_iterator_array_get
to get the current item. This would be theFramesMapKey
that we can pass into theframes()
map to get theGreasePencilFrame
. The other callbacks would works similarly. Calling therna_iterator_array_*
callback, get the key, return the frame.Hope that helps!
EDIT: I realized that the
begin
callback doesn't need to return anything, so just callingrna_iterator_array_begin
will be enough. But theget
callback will need to get the frame. Anyway, you get the idea.