GPv3: Material locking #114580
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#114580
Loading…
Reference in New Issue
No description provided.
Delete Branch "filedescriptor/blender:gpv3-lock-materials"
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?
This PR adds the material locking functionality from the current grease pencil.
Material locking allows the user to lock strokes with that material.
The strategy for implementing this functionality is as follows:
retrieve_editable_strokes/points
.IndexMask
of elements that are both selected but also not locked.TODO:
@ -252,3 +252,2 @@
static void smooth_curve_attribute(const OffsetIndices<int> points_by_curve,
const VArray<bool> &selection,
static void smooth_curve_attribute(const IndexMask &curves_to_smooth,
I find it a bit more consistent to move the index mask argument below the curve data arguments, so below
cyclic
. That way all of the "constants" come before the "operation specific" things@ -260,3 +261,3 @@
GMutableSpan data)
{
threading::parallel_for(points_by_curve.index_range(), 512, [&](const IndexRange range) {
curves_to_smooth.foreach_index([&](const int64_t curve_i) {
Add
GrainSize(512)
to keep this loop multi-threaded@ -505,1 +518,3 @@
selection.materialize(points_to_delete);
/* Mark all points in the editable curves to be deleted. */
Array<bool> points_to_delete(curves.points_num(), false);
editable_strokes.foreach_index([&](const int64_t curve_i) {
bke::curves::fill_points
@ -597,2 +611,3 @@
static Array<bool> get_points_to_dissolve(bke::CurvesGeometry &curves, const DissolveMode mode)
static Array<bool> get_points_to_dissolve(bke::CurvesGeometry &curves,
const IndexMask &editable_points,
I find this combination of the use of selection and "editable" in the same function pretty confusing. Better to combine selection and locking outside of here so the function only needs one index mask argument.
@ -836,3 +853,3 @@
curves.attributes_for_write().lookup_or_add_for_write_span<int>("material_index",
ATTR_DOMAIN_CURVE);
selected_curves.foreach_index(
editable_strokes.foreach_index(
Might as well use
index_mask::masked_fill
@ -149,0 +169,4 @@
const bke::greasepencil::Drawing &drawing,
IndexMaskMemory &memory)
{
using namespace blender;
We're already in the blender namespace here
@ -149,0 +189,4 @@
/* Get all the selected strokes. */
const IndexMask selected_strokes = ed::curves::retrieve_selected_curves(curves, memory);
/* The editable strokes are all strokes that have an unlocked material and are selected. */
return IndexMask::from_predicate(
We talked about anding two bit vectors here
@ -29,3 +27,1 @@
.slice(points_by_curve[curve_i].drop_front(amount_start).drop_back(amount_end))
.fill(inverted ? true : false);
}
curves_mask.foreach_index_optimized<int64_t>([&](const int64_t curve_i) {
Think I'd go with
foreach_index
rather thanforeach_index_optimized
, this isn't that performance sensitive and the inside of the loop isn't completely trivial.@ -164,0 +166,4 @@
return init;
}
for (const int i : indices_range) {
if (span[indices_to_check[i]] == value) {
Slice the index mask here first, and keep the
span.slice(range).contains(value);
in case that slice is a range. IndexMask operator [] isO(logn)
, and should be avoided wherever possible.Same below
I can check if it's a range and slice, but if it's not a range, I still have to use the
operator[]
I think. Usingforeach_index
won't work, because I can'treturn true
from that if I findvalue
. Only thing I could maybe do is write to anstd::atomic<bool>
or something.Also I'm not sure if I can do any of the stuff you mentioned in the case below. At this point we know the
varray
is neither a single nor a span, so we either have to useoperator[]
ormaterialize
I think.@ -260,3 +314,1 @@
if (has_anything_selected(selection_curve)) {
fill_selection_true(selection_curve);
}
curves_mask.foreach_index_optimized<int64_t>([&](const int64_t curve_i) {
foreach_index_optimized
->foreach_index(GrainSize(256)
foreach_index_optimized
should only be used where there's a clear performance benefit (when the inner loop is very simple). We should be careful about bloating the binary size when it doesn't make a difference. Please double check that the new code isn't removing parallelism in more places. I won't bother repeating this comment elsewhere for now.@ -151,2 +151,4 @@
const IndexMask &indices_to_check,
const bool value)
{
const CommonVArrayInfo info = varray.common_info();
Mentioned this in person-- we should avoid using
operator[]
forIndexMask
, it's much slower than the alternative here.Took a look at optimizing this and finishing the todo mentioned in the code:
@ -231,1 +269,3 @@
void select_all(bke::CurvesGeometry &curves, const eAttrDomain selection_domain, int action)
static void invert_selection(MutableSpan<float> selection, const IndexMask &mask)
{
mask.foreach_index_optimized<int64_t>(
GrainSize(2048)
@ -280,3 +355,1 @@
threading::parallel_for(curves.curves_range(), 256, [&](const IndexRange range) {
for (const int curve_i : range) {
const IndexRange points = points_by_curve[curve_i];
curves_mask.foreach_index_optimized<int64_t>([&](const int64_t curve_i) {
foreach_index
(not "optimized"). Same below, and probably other places.@ -129,0 +134,4 @@
IndexMaskMemory &memory);
IndexMask retrieve_editable_elements(Object &object,
const bke::greasepencil::Drawing &drawing,
const eAttrDomain selection_domain,
const eAttrDomain selection_domain
->eAttrDomain selection_domain
@ -169,3 +169,2 @@
closest_distances.reinitialize(points.size());
closest_distances.fill(std::numeric_limits<float>::max());
Vector<float> closest_distances(points.size());
Use
foreach_segment
and afor
loop inside to avoid reconstructing this vector from scratch every time. Like the docstring says,foreach_segment
should be used whenever processing more than one element in a loop can be faster.This seems unrelated to this PR
Why is it unrelated? With the changes in the PR, the
Vector
that was reused for many curves is now constructed from scratch for every curve.Sorry, I missunderstood you, will make the changes.
@blender-bot build