GPv3: Make new strokes selected after operators (copy/paste etc.) #120291

Open
opened 2024-04-05 11:14:34 +02:00 by Lukas Tönne · 7 comments
Member

Paste operator and others deselect everything before creating new strokes, but don't make newly added strokes selected.

Paste operator and others deselect everything before creating new strokes, but don't make newly added strokes selected.
Lukas Tönne added the
Type
To Do
label 2024-04-05 11:14:34 +02:00
Lukas Tönne added this to the Grease Pencil project 2024-04-05 11:14:36 +02:00
Member

I can confirm. From a quick look, this seems to happen when the all the strokes (from a drawing) are selected for copy/pasting. I think .selection attribute is removed when everything is selected?

I can confirm. From a quick look, this seems to happen when the all the strokes (from a drawing) are selected for copy/pasting. I think `.selection` attribute is removed when everything is selected?
Member

@PratikPB2123 You are completely right. That's the mistake I made in the copy/paste code: I assumed there was always a .selection attribute already on the strokes at the clipboard (since you copy selected strokes), so no need to set the attribute again when pasting. But that is not the case when all strokes are selected. Because of that slightly odd and easy to forget 'When there is no selection attribute, everything is selected' optimization.

@PratikPB2123 You are completely right. That's the mistake I made in the copy/paste code: I assumed there was always a `.selection` attribute already on the strokes at the clipboard (since you copy _selected_ strokes), so no need to set the attribute again when pasting. But that is not the case when all strokes are selected. Because of that slightly odd and easy to forget 'When there is no selection attribute, everything is selected' optimization.
Member

@SietseB hi, so do we have to handle this .selection attribute case in paste operator? Maybe just fill the range with the help of pasted_curves_range (this is for strokes, we can create similar for points) after joining geometry?

@SietseB hi, so do we have to handle this `.selection` attribute case in paste operator? Maybe just fill the range with the help of `pasted_curves_range` (this is for strokes, we can create similar for points) after joining geometry?
Member

Another issue I spotted about "selection". When paste operator is called, only the ".selection" attribute array of active drawing is set to false: https://projects.blender.org/blender/blender/src/branch/main/source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc#L2242-L2247
I expect it to be false for all the drawing at current scene frame.

Another issue I spotted about "selection". When paste operator is called, only the ".selection" attribute array of active drawing is set to false: https://projects.blender.org/blender/blender/src/branch/main/source/blender/editors/grease_pencil/intern/grease_pencil_edit.cc#L2242-L2247 I expect it to be false for all the drawing at current scene frame.
Member

BTW, fix for above problem: !120363

BTW, fix for above problem: !120363
Member

@PratikPB2123 Making the pasted strokes selected, is probably easiest to set the .selection state of the strokes/points on the clipboard, before joining the geometries. Then you don't have to worry about ranges at all.
Something like:

bke::GSpanAttributeWriter selection_in_clipboard = ed::curves::ensure_selection_attribute(
    clipboard.curves, selection_domain, CD_PROP_BOOL);
ed::curves::fill_selection_true(selection_in_clipboard.span);
selection_in_clipboard.finish();
@PratikPB2123 Making the pasted strokes selected, is probably easiest to set the `.selection` state of the strokes/points on the clipboard, before joining the geometries. Then you don't have to worry about ranges at all. Something like: ```cpp bke::GSpanAttributeWriter selection_in_clipboard = ed::curves::ensure_selection_attribute( clipboard.curves, selection_domain, CD_PROP_BOOL); ed::curves::fill_selection_true(selection_in_clipboard.span); selection_in_clipboard.finish(); ```
Member

Hi, this indeed worked but "after joining geometries".
fill_selection_true is not required because ensure_selection_attribute itself will create a new array filled with 01 if attribute does not exists.

Can you make a PR? 🙂

Hi, this indeed worked but "after joining geometries". `fill_selection_true` is not required because `ensure_selection_attribute` itself will create a new array filled with `01` if attribute does not exists. Can you make a PR? 🙂
Sign in to join this conversation.
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#120291
No description provided.