Grease Pencil: Slightly optimize IndexMask usage in draw extraction
Instead of computing an index mask for all curves, then returning an intersection with the visible curves, just use the visible curves as a universe for the original calculation. Also add another early out for when there are no NURBS curves.
This commit is contained in:
@@ -450,18 +450,15 @@ static IndexMask grease_pencil_get_visible_nurbs_curves(Object &object,
|
||||
return IndexMask(0);
|
||||
}
|
||||
|
||||
const VArray<int8_t> types = curves.curve_types();
|
||||
|
||||
const IndexMask selected_editable_strokes =
|
||||
ed::greasepencil::retrieve_editable_and_selected_strokes(
|
||||
object, drawing, layer_index, memory);
|
||||
|
||||
const IndexMask nurbs_curves = IndexMask::from_predicate(
|
||||
curves.curves_range(), GrainSize(4096), memory, [&](const int64_t curve_i) {
|
||||
const VArray<int8_t> types = curves.curve_types();
|
||||
return IndexMask::from_predicate(
|
||||
selected_editable_strokes, GrainSize(4096), memory, [&](const int64_t curve_i) {
|
||||
return types[curve_i] == CURVE_TYPE_NURBS;
|
||||
});
|
||||
|
||||
return IndexMask::from_intersection(selected_editable_strokes, nurbs_curves, memory);
|
||||
}
|
||||
|
||||
static IndexMask grease_pencil_get_visible_non_nurbs_curves(
|
||||
@@ -470,14 +467,15 @@ static IndexMask grease_pencil_get_visible_non_nurbs_curves(
|
||||
const bke::CurvesGeometry &curves = drawing.strokes();
|
||||
const IndexMask visible_strokes = ed::greasepencil::retrieve_visible_strokes(
|
||||
object, drawing, memory);
|
||||
if (!curves.has_curve_with_type(CURVE_TYPE_NURBS)) {
|
||||
return visible_strokes;
|
||||
}
|
||||
|
||||
const VArray<int8_t> types = curves.curve_types();
|
||||
const IndexMask non_nurbs_curves = IndexMask::from_predicate(
|
||||
curves.curves_range(), GrainSize(4096), memory, [&](const int64_t curve_i) {
|
||||
return types[curve_i] != CURVE_TYPE_NURBS;
|
||||
return IndexMask::from_predicate(
|
||||
visible_strokes, GrainSize(4096), memory, [&](const int64_t curve) {
|
||||
return types[curve] != CURVE_TYPE_NURBS;
|
||||
});
|
||||
|
||||
return IndexMask::from_intersection(visible_strokes, non_nurbs_curves, memory);
|
||||
}
|
||||
|
||||
static void grease_pencil_cache_add_nurbs(Object &object,
|
||||
|
||||
Reference in New Issue
Block a user