GPv3: Overlay: only show visible and editable materials. #115740
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#115740
Loading…
Reference in New Issue
No description provided.
Delete Branch "casey-bianco-davis/blender:GPv3-Overlay-Visible-&-Editable-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?
Makes it so that locked materials will not have their edit mode points and lines visible, and hidden materials will not have their strokes, fills, (edit) points and (edit) lines visible.
Thanks. I added some comments.
@ -272,3 +275,1 @@
total_line_ids_num += curves.points_num();
/* Add one id for the last segment of every cyclic curve. */
total_line_ids_num += array_utils::count_booleans(curves.cyclic());
editable_strokes.foreach_index(GrainSize(512), [&](const int curve_i) {
This shouldn't be in a loop. We should have something like:
We'd need a variant of
count_booleans
that also takes anIndexMask
.@ -282,3 +293,3 @@
".selection", ATTR_DOMAIN_POINT, true);
for (const int curve_i : curves.curves_range()) {
editable_strokes.foreach_index(GrainSize(512), [&](const int curve_i) {
Using
GrainSize
here means that this runs in parallel, but the loop has to be run serial. So we need to removeGrainSize
here.@ -314,3 +327,1 @@
for (const int curve_i : range) {
const IndexRange points = points_by_curve[curve_i];
const bool is_cyclic = cyclic[curve_i];
editable_strokes.foreach_index(GrainSize(512), [&](const int curve_i) {
Same as above (the
parallel_for
from before is actually wrong).GPU_indexbuf_add_generic_vert
can't be called in parallel as it is not atomic.@ -339,3 +348,1 @@
if (!ed::curves::has_anything_selected(selection, points)) {
continue;
}
editable_strokes.foreach_index(GrainSize(512), [&](const int curve_i) {
Same as above.
@ -408,1 +422,4 @@
int pos = 0;
for (const int curve_i : curves.curves_range()) {
IndexRange points = points_by_curve[curve_i];
if (visible_strokes.contains(curve_i)) {
Note: This
contains
takesO(log n)
which is a bit unfortunate. There might be a better way to avoid this but I can't immediatly see it. So for now I think it's fine.I noticed this to here's a some code that instead loop thru the missing curves. I think the code is a bit less readable but should more efficient.
Right, I think the
contains
is much easier to understand in comparison. Let's keep the version you had before and if this does come up in a profile at some point, we can improve it.@ -409,0 +434,4 @@
/* Calculate the vertex offsets for all the visible curves. */
int num_cyclic = 0;
int num_points = 0;
visible_strokes.foreach_index(GrainSize(512), [&](const int curve_i, const int pos) {
Same as above. Remove
GrainSize
.@ -520,3 +539,1 @@
IndexRange verts_range = IndexRange(verts_start_offset, num_verts);
MutableSpan<GreasePencilStrokeVert> verts_slice = verts.slice(verts_range);
MutableSpan<GreasePencilColorVert> cols_slice = cols.slice(verts_range);
visible_strokes.foreach_index(GrainSize(512), [&](const int curve_i, const int pos) {
Same as above.
Added some more comments. Mix of cleanup and optimizations.
@ -180,0 +187,4 @@
return *static_cast<const bool *>(info.data) ? mask.size() : 0;
}
int64_t value = 0;
mask.foreach_index([&](const int64_t init) {
const int64_t i
@ -180,0 +189,4 @@
int64_t value = 0;
mask.foreach_index([&](const int64_t init) {
const bool is_cyclic = varray[init];
value += (is_cyclic ? 1 : 0);
Since this is a generic version, this should be
value += (varray[i] ? 1 : 0);
orvalue += int(varray[i])
@ -324,3 +330,1 @@
}
GPU_indexbuf_add_primitive_restart(&elb);
for (const int point : points) {
const int point_i
@ -170,0 +176,4 @@
if (material != nullptr && material->gp_style != nullptr &&
(material->gp_style->flag & GP_MATERIAL_HIDE) != 0)
{
hidden_material_indices.add(mat_i);
Use
add_new
here since we know that every key we had has to be different from previously added keys.@ -229,0 +248,4 @@
using namespace blender;
/* Get all the hidden material indices. */
VectorSet<int> hidden_material_indices = get_hidden_material_indices(object);
I think it's worth it to add a small optimization here: Hiding materials is not very common (on average), so we should add a check here for
hidden_material_indices.is_empty()
and then just returndrawing.strokes().curves_range()
.@ -180,0 +186,4 @@
if (info.type == CommonVArrayInfo::Type::Single) {
return *static_cast<const bool *>(info.data) ? mask.size() : 0;
}
int64_t value = 0;
Better to modify the existing
count_booleans
function to have a mask argument. When the mask is a full selection, it should end up being the same anyway. Then you can provide an overload without a mask.@ -229,0 +256,4 @@
/* Get all the strokes that have their material visible. */
const VArray<int> materials = *attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_CURVE, -1);
Read the material index with a default of 0. But also, seems this work can be skipped when there is no attribute
This looks good to me now. Just a cleanup comment, but will approve this.
@ -183,0 +205,4 @@
if (locked_material_indices.contains(0)) {
return curves_range;
}
else {
No need for an
else
afterreturn
@ -207,0 +239,4 @@
if (locked_material_indices.contains(0)) {
return points_range;
}
else {
Same as above