GPv3: Add user count to drawings #110579

Merged
Falk David merged 7 commits from filedescriptor/blender:gpv3-drawing-user-count into main 2023-08-01 17:04:45 +02:00
Member

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.

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.
Falk David requested review from Amélie Fondevilla 2023-07-28 15:24:48 +02:00
Amélie Fondevilla approved these changes 2023-07-28 15:39:44 +02:00
Amélie Fondevilla left a comment
Member

Looks good.
Tiny comment on const argument.

Looks good. Tiny comment on const argument.
@ -1282,6 +1279,29 @@ bool GreasePencil::insert_blank_frame(blender::bke::greasepencil::Layer &layer,
return true;
}
void GreasePencil::remove_frame_at(blender::bke::greasepencil::Layer &layer, int frame_number)

const int frame_number

`const int frame_number`
filedescriptor marked this conversation as resolved
Amélie Fondevilla requested changes 2023-07-28 15:57:58 +02:00
Amélie Fondevilla left a comment
Member

Actually, the remove function should also take care of frames with fixed duration.

Actually, the remove function should also take care of frames with fixed duration.
Jacques Lucke reviewed 2023-07-28 16:20:33 +02:00
@ -64,1 +66,4 @@
mutable SharedCache<Vector<uint3>> triangles_cache;
/**
* Number of users for this drawing.
Member

Here you are only concerned with how many frames reference this drawing, right? Maybe the variable naming or comment can become a bit more concrete. Also add information for why this is necessary in the first place (to remove the drawing when it's not used anymore).

Here you are only concerned with how many frames reference this drawing, right? Maybe the variable naming or comment can become a bit more concrete. Also add information for why this is necessary in the first place (to remove the drawing when it's not used anymore).
filedescriptor marked this conversation as resolved
@ -95,0 +114,4 @@
* Returns true for when this drawing has more than one user.
*/
bool is_instanced() const;
bool has_no_users() const;
Member

avoid no in name, so just call it has_users.

avoid `no` in name, so just call it `has_users`.
filedescriptor marked this conversation as resolved
Falk David force-pushed gpv3-drawing-user-count from cb6cd90b90 to 49c6a62bdb 2023-07-28 16:53:57 +02:00 Compare
Falk David force-pushed gpv3-drawing-user-count from 77e5fea813 to 1626696f51 2023-08-01 12:21:23 +02:00 Compare
Falk David requested review from Amélie Fondevilla 2023-08-01 12:21:35 +02:00
Falk David force-pushed gpv3-drawing-user-count from 1626696f51 to b01fecbc68 2023-08-01 14:35:20 +02:00 Compare
Author
Member

This PR now only adds the user count and GreasePencil::remove_frame_at function.

This PR now only adds the user count and `GreasePencil::remove_frame_at` function.
Amélie Fondevilla approved these changes 2023-08-01 14:47:23 +02:00
Amélie Fondevilla left a comment
Member

Looks good to me.
Just one remark

Looks good to me. Just one remark
@ -1406,0 +1414,4 @@
return;
}
GreasePencilDrawingBase *drawing_base = this->drawings(drawing_index_to_remove);
if (base->type != GP_DRAWING) {

Shouldn't this be drawing_base->type ?

Shouldn't this be `drawing_base->type` ?
filedescriptor marked this conversation as resolved
Amélie Fondevilla reviewed 2023-08-01 14:48:52 +02:00
@ -1406,0 +1407,4 @@
if (!layer.frames().contains(frame_number)) {
return;
}
GreasePencilFrame &frame_to_remove = layer.frames().lookup(frame_number);

Oh, something else. This should be frames_for_write() I think.
Or return a const result.

Oh, something else. This should be `frames_for_write()` I think. Or return a const result.
filedescriptor marked this conversation as resolved
Falk David added 1 commit 2023-08-01 15:00:41 +02:00
Falk David merged commit de8ce4e34b into main 2023-08-01 17:04:45 +02:00
Falk David deleted branch gpv3-drawing-user-count 2023-08-01 17:04:47 +02:00
Falk David added this to the Grease Pencil project 2023-08-01 17:05:22 +02:00
Sign in to join this conversation.
No reviewers
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
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#110579
No description provided.