Fix #118509: GPv3: fix broken drawing array compression function #120433

Merged
Lukas Tönne merged 4 commits from LukasTonne/blender:gp3-fix-remove-unused-drawings into main 2024-04-10 18:23:43 +02:00
Member

The remove_drawings_with_no_users did not work properly when removing
more than one drawing at a time. It created incorrect drawing indices
that were larger than the drawings array, causing crashes down the line.

The new implementation should be both cleaner and more efficient,
avoiding a loop over all frames for every drawing removed.

This complements #119337 which fixes disappearing keyframes during
transform.

The `remove_drawings_with_no_users` did not work properly when removing more than one drawing at a time. It created incorrect drawing indices that were larger than the drawings array, causing crashes down the line. The new implementation should be both cleaner and more efficient, avoiding a loop over all frames for every drawing removed. This complements #119337 which fixes disappearing keyframes during transform.
Lukas Tönne added 1 commit 2024-04-09 16:10:56 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
e298ef0cfc
Fix #118509: Refactored the GPv3 drawing array compression function.
The `remove_drawings_with_no_users` did not work properly when removing
more than one drawing at a time. It created incorrect drawing indices
that were larger than the drawings array, causing crashes down the line.

The new implementation should be both cleaner and more efficient,
avoiding a loop over all frames for every drawing removed.
Lukas Tönne added this to the Grease Pencil project 2024-04-09 16:11:00 +02:00
Lukas Tönne requested review from Falk David 2024-04-09 16:15:43 +02:00
Author
Member

@blender-bot build

@blender-bot build
Falk David requested changes 2024-04-10 12:48:14 +02:00
Dismissed
Falk David left a comment
Member

Thanks, got some comments.

Thanks, got some comments.
@ -2310,0 +2255,4 @@
};
/* Index map to remap drawing indices in frame data. */
Array<int> drawing_index_map(drawings.size(), -1);
Member

I'd like to see a comment here that documents that negative indices are "unmapped" and ignored.

I'd like to see a comment here that documents that negative indices are "unmapped" and ignored.

Usually i create constexpr const int is_non_check = -1 varibles for that reason.

Usually i create `constexpr const int is_non_check = -1` varibles for that reason.
LukasTonne marked this conversation as resolved
@ -2310,0 +2259,4 @@
int first_unused_drawing = -1;
int last_used_drawing = drawings.size();
while (true) {
Member

Seems like this could just be while (first_unused_drawing >= last_used_drawing) { (replacing the if/break further down) if I'm not mistaken.

Seems like this could just be `while (first_unused_drawing >= last_used_drawing) {` (replacing the `if/break` further down) if I'm not mistaken.
Author
Member

The iterators need to be advanced before checking the condition. I made a little utility function to make this loop nicer.

The iterators need to be advanced before checking the condition. I made a little utility function to make this loop nicer.
LukasTonne marked this conversation as resolved
@ -2310,0 +2301,4 @@
}
/* Remap drawing indices in frame data. */
for (Layer *layer : this->layers_for_write()) {
Member

Could this be done in the if (drawings_to_remove.size() > 0) { ? In which case, it might be good to do

if (drawings_to_remove.is_empty()) {
   return;
}

and then do the shrinking and remapping.

Could this be done in the `if (drawings_to_remove.size() > 0) {` ? In which case, it might be good to do ```cpp if (drawings_to_remove.is_empty()) { return; } ``` and then do the shrinking and remapping.
LukasTonne marked this conversation as resolved
Lukas Tönne added 3 commits 2024-04-10 15:42:04 +02:00
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
d743c866e5
Early exit to avoid looping over layers if nothing is removed.
Lukas Tönne requested review from Falk David 2024-04-10 15:42:45 +02:00
Falk David approved these changes 2024-04-10 17:48:57 +02:00
Member

@blender-bot build

@blender-bot build
Lukas Tönne merged commit efd07d8207 into main 2024-04-10 18:23:43 +02:00
Lukas Tönne deleted branch gp3-fix-remove-unused-drawings 2024-04-10 18:23:45 +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#120433
No description provided.