WIP: GreasePencilFrame API #116045 #118439
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#118439
Loading…
Reference in New Issue
No description provided.
Delete Branch "mews6/blender:grease-pencil-frame-api"
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?
WIP for the GreasePencilFrame API described in issue #116045 . I'm pretty new to this codebase and this code Does not compile yet, so please, if you notice any problem on this patch, let me know so i can correct it. The initial patch has a few of the definitions required for this project, but also some things missing. I'll be working on it as we figure out what works and what doesn't. I'll keep updating this description as we figure out goals and limitations.
@filedescriptor
Added some comments that should help.
@ -158,0 +163,4 @@
// TODO
// blender::Span<Frame *> frame = grease_pencil
blender::Span<Frames *> frames = grease_pencil->frames();
What you want here are the frames in the layer.
Note: Because the callback has been defined on a property that's a "GreasePencilLayer", the
ptr->data
points to this type. That's how you get the layer.@ -158,0 +168,4 @@
}
static void rna_iterator_grease_pencil_frames_end(CollectionPropertyIterator *iter,
PointerRNA *ptr)
PointerRNA *ptr
->PointerRNA * /*ptr*/
(because it's unused)@ -158,0 +171,4 @@
PointerRNA *ptr)
{
using namespace blender::bke::greasepencil;
// TODO
@ -158,0 +179,4 @@
{
// TODO
GreasePencil *grease_pencil = rna_grease_pencil(ptr);
return grease_pencil->frames().size();
@ -158,0 +186,4 @@
PointerRNA *ptr)
{
using namespace blender::bke::greasepencil;
// TODO
We're iterating over the keys, so get the key from the iterator but then lookup the frame in the frames and return that.
@ -178,0 +216,4 @@
srna = RNA_def_struct(brna, "GreasePencilFrame", nullptr);
RNA_def_struct_sdna(srna, "GreasePencilFrame");
RNA_def_struct_ui_text(srna, "Grease Pencil Frame", "Collection of frames");
"Collection of frames"
->"A Grease Pencil keyframe"
@ -178,0 +217,4 @@
srna = RNA_def_struct(brna, "GreasePencilFrame", nullptr);
RNA_def_struct_sdna(srna, "GreasePencilFrame");
RNA_def_struct_ui_text(srna, "Grease Pencil Frame", "Collection of frames");
RNA_def_struct_path_func(srna, "rna_GreasePencilFrame_path");
This is not needed AFAIK
@ -178,0 +221,4 @@
// GreasePencilDrawing stub. TODO
RNA_def_property(prop, "drawing", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "GreasePencilDrawing");
The
GreasePencilDrawing
type is not defined.You need to add a function
rna_def_grease_pencil_drawing
that defines it:Make sure to call this function to define the type in
RNA_def_grease_pencil
(same forrna_def_grease_pencil_frame
)@ -227,6 +290,21 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna)
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_update");
}
static void rna_def_grease_pencil_frames_api(BlenderRNA *brna, PropertyRNA *cprop)
This is not needed for this PR.
Just implemented your suggestions. I'll be on the lookout for any more problems. Also, for the properties required of GreasePencilFrame (a selection status and the keyframe time), if I get the structure correctly, I'm imagining that we should put them in
rna_def_grease_pencil_drawing
, Are they going to be defined throughRNA_def_property
in the same vein asGreasePencilDrawing
? I'm looking at a few other places in this file where we seem to reference whether or not something is selected, such as in this line:9be14b3bce/source/blender/makesrna/intern/rna_grease_pencil.cc (L322)
but there is no attribute defined for selection, would this suffice for GreasePencilFrame?
No, they should go in
rna_def_grease_pencil_frame
since that's where everything on the frame goes.Another little question, what do we mean for
a property for the keyframe time
on this issue? looking into the way stuff is organized onDNA_grease_pencil_types.h
i see that for GreasePencilFrameint drawing_index
is defined as an "Index into the GreasePencil->drawings array.". Do you refer to this property when referring to keyframe time? Also could this be implemented like howFrame Number
is defined inrna_gpencil_legacy.cc
or is there any other considerations for it?@mews6 Ah I see, in the current API, the
frame_number
was a property on the frame that indicates the start time of that keyframe. With the new data model, the frame doesn't actually know about what its start time is. The layer now holds that information. So I think we shouldn't add this property to the frame.@ -158,0 +163,4 @@
// TODO
Layer &layer = static_cast<GreasePencilLayer *>(ptr->data)->wrap();
blender::Span<FramesMapKey> sorted_keys = layer.sorted_keys();
Don't forget the
rna_iterator_array_begin(iter, sorted_keys.data(), sizeof(FramesMapKey), sorted_keys.size(), false, nullptr);
@ -178,0 +229,4 @@
RNA_def_struct_ui_text(srna, "Grease Pencil Frame", "A Grease Pencil keyframe");
RNA_def_struct_path_func(srna, "rna_GreasePencilFrame_path");
// GreasePencilDrawing stub. TODO
Comment can be removed now.
@ -188,0 +256,4 @@
prop = RNA_def_property(srna, "frames", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "GreasePencilFrame");
RNA_def_property_collection_funcs(prop,
"rna_iterator_grease_pencil_frames_begin", // TODO
// TODO
can be removed now it looks like.Hi @mews6 .
Glad to see you here! 🦊
Just added the call you told me to, also removed TODO comments .
Got a comment about
rna_iterator_grease_pencil_frames_end
.Have you tested this with all the changes yet? Does it compile for you?
@ -158,0 +169,4 @@
iter, sorted_keys.data(), sizeof(FramesMapKey), sorted_keys.size(), false, nullptr);
}
static void rna_iterator_grease_pencil_frames_end(CollectionPropertyIterator *iter,
Since this function doesn't do anything but call
rna_iterator_array_end
, you don't need it.For
RNA_def_property_collection_funcs
, just use the"rna_iterator_array_end"
callback directly.Checkout
From your project repository, check out a new branch and test the changes.