GPv3: Assign material #113573

Merged
Pratik Borhade merged 2 commits from PratikPB2123/blender:gpv3-assign-material into main 2023-10-18 12:58:05 +02:00
Member

Assign active material to selected strokes. This is similar to legacy GP
operator GPENCIL_OT_stroke_change_color.
Implements #113481

Assign active material to selected strokes. This is similar to legacy GP operator `GPENCIL_OT_stroke_change_color`. Implements #113481
Pratik Borhade added 1 commit 2023-10-12 08:31:49 +02:00
67c4ad2085 GPv3: Assign material
Assign active material to selected strokes. This is similar to legacy GP
operator `GPENCIL_OT_stroke_change_color`.
Implements #113481
Pratik Borhade requested review from Falk David 2023-10-12 08:31:57 +02:00
Pratik Borhade added the
Module
Grease Pencil
label 2023-10-12 08:32:07 +02:00
Pratik Borhade added this to the Grease Pencil project 2023-10-12 08:32:18 +02:00
Falk David requested changes 2023-10-13 11:48:52 +02:00
Falk David left a comment
Member

Thanks! Added some comments.

Thanks! Added some comments.
@ -802,0 +821,4 @@
bke::SpanAttributeWriter<int> materials = curves.attributes_for_write().lookup_or_add_for_write_span<int>(
"material_index", ATTR_DOMAIN_CURVE);
const VArray<bool> selection = *curves.attributes().lookup_or_default<bool>(
Member

Use

IndexMaskMemory memory;
IndexMask selected_curves = ed::curves::retrieve_selected_curves(curves, memory);

(you'll have to make retrieve_selected_curves non-static and declare it in the ED_curves.hh header).

Use ``` IndexMaskMemory memory; IndexMask selected_curves = ed::curves::retrieve_selected_curves(curves, memory); ``` (you'll have to make `retrieve_selected_curves` non-static and declare it in the `ED_curves.hh` header).
filedescriptor marked this conversation as resolved
@ -802,0 +826,4 @@
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
for (int curve_index : curves.curves_range()) {
Member

With the change above, you can now do:

selected_curves.foreach_index([&](GrainSize(512), [&](const int curve_index) {
   materials.span[curve_index] = material_index;
});
With the change above, you can now do: ``` selected_curves.foreach_index([&](GrainSize(512), [&](const int curve_index) { materials.span[curve_index] = material_index; }); ```
filedescriptor marked this conversation as resolved
Pratik Borhade added 1 commit 2023-10-17 12:08:44 +02:00
Falk David approved these changes 2023-10-17 16:32:09 +02:00
Falk David left a comment
Member

Looks good :)

Looks good :)
Pratik Borhade merged commit 2a5c499585 into main 2023-10-18 12:58:05 +02:00
Pratik Borhade deleted branch gpv3-assign-material 2023-10-18 12:58:07 +02:00
Author
Member

Merged, thanks for reviewing :)

Merged, thanks for reviewing :)
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
2 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#113573
No description provided.