GPv3: Refactor: replace remove_frame_at
function #110957
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#110957
Loading…
Reference in New Issue
No description provided.
Delete Branch "filedescriptor/blender:gpv3-refactor-remove-frames-function"
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?
Instead of removing frames one by one, the
GreasePencil::remove_frames
function now expects a span of frame numbers, replacing the
GreasePencil::remove_frame_at
function.Now, when drawings need to be deleted, we shrink the array only once.
@blender-bot build
Hey, I just have a few comments on the PR.
@ -1503,0 +1500,4 @@
changed = true;
GreasePencilDrawingBase *drawing_base = this->drawings(drawing_index_to_remove);
if (drawing_base->type != GP_DRAWING) {
Maybe we should check for null frames here, before accessing the drawing with the drawing index. I guess we cannot remove them with this function, right ?
@ -1531,0 +1523,4 @@
return;
}
const int drawings_to_remove = sorted_indices_to_remove.size();
blender::IndexRange last_drawings_range(grease_pencil.drawings().size() - drawings_to_remove,
I guess this can be const
@ -1531,0 +1530,4 @@
* skipping over drawings that are already in the range to be removed. */
auto next_available_index = last_drawings_range.last();
auto greatest_index_to_remove_it = std::rbegin(sorted_indices_to_remove);
auto get_next_availible_index = [&]() {
typo
get_next_availible_index
>get_next_available_index
@ -1540,2 +1557,3 @@
}
std::swap(this->drawings()[index_to_remove], this->drawings()[last_drawing_index]);
/* Swap the pointers to the drawings in the drawing array. */
std::swap(grease_pencil.drawings()[index_to_remove], grease_pencil.drawings()[swap_index]);
Maybe you can use the API here ?
std::swap(grease_pencil.drawings(index_to_remove), grease_pencil.drawings(swap_index));
I tried this, but for some reason
std::swap
complains if I do this. My best guess is that in this case we get the return value of a function which can't be used in the swap?Okay, maybe because from the function you get the value of the pointer and not a reference to the pointer in the array ?
@ -36,2 +37,3 @@
changed |= grease_pencil.remove_frame_at(layer, frame_number);
frames_to_remove.append(frame_number);
}
grease_pencil.remove_frames(layer, frames_to_remove.as_span());
This is always going to return false.
Maybe now we can get rid of
changed
and just return the result ofremove_frames
.@ -498,1 +496,3 @@
void remove_drawing(int index);
/**
* Removes all the frames with \a frame_numbers in the \a layer.
* \retruns true if any frame was removed.
Small typo
\retruns
>\returns
.Also, maybe we can specify in the comment that this functions also deletes the drawings that no longer have users after this operation.
Looks good.