Merge branch 'blender-v4.0-release'

This commit is contained in:
Hans Goudey
2023-10-17 09:56:58 +02:00
5 changed files with 50 additions and 3 deletions

View File

@@ -539,6 +539,7 @@ void BKE_mesh_flush_hidden_from_faces(struct Mesh *me);
void BKE_mesh_flush_select_from_faces(struct Mesh *me);
void BKE_mesh_flush_select_from_verts(struct Mesh *me);
void BKE_mesh_flush_select_from_edges(struct Mesh *me);
/* spatial evaluation */
/**

View File

@@ -683,6 +683,44 @@ void BKE_mesh_flush_select_from_verts(Mesh *me)
select_poly.finish();
}
void BKE_mesh_flush_select_from_edges(Mesh *me)
{
using namespace blender;
using namespace blender::bke;
MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> select_edge = *attributes.lookup_or_default<bool>(
".select_edge", ATTR_DOMAIN_POINT, false);
if (select_edge.is_single() && !select_edge.get_internal_single()) {
attributes.remove(".select_vert");
attributes.remove(".select_poly");
return;
}
SpanAttributeWriter<bool> select_vert = attributes.lookup_or_add_for_write_only_span<bool>(
".select_vert", ATTR_DOMAIN_POINT);
SpanAttributeWriter<bool> select_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".select_poly", ATTR_DOMAIN_FACE);
{
IndexMaskMemory memory;
const VArray<bool> hide_vert = *attributes.lookup_or_default<bool>(
".hide_vert", ATTR_DOMAIN_POINT, false);
array_utils::copy(
*attributes.lookup_or_default<bool>(".select_vert", ATTR_DOMAIN_POINT, false),
IndexMask::from_bools(hide_vert, memory).complement(hide_vert.index_range(), memory),
select_vert.span);
}
{
IndexMaskMemory memory;
const VArray<bool> hide_poly = *attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
array_utils::copy(
*attributes.lookup_or_default<bool>(".select_vert", ATTR_DOMAIN_FACE, false),
IndexMask::from_bools(hide_poly, memory).complement(hide_poly.index_range(), memory),
select_poly.span);
}
select_vert.finish();
select_poly.finish();
}
/** \} */
/* -------------------------------------------------------------------- */

View File

@@ -225,7 +225,7 @@ DEF_ENUM(rna_enum_attribute_type_with_auto_items)
DEF_ENUM(rna_enum_attribute_domain_items)
DEF_ENUM(rna_enum_attribute_domain_edge_face_items)
DEF_ENUM(rna_enum_attribute_domain_only_mesh_items)
DEF_ENUM(rna_enum_attribute_domain_point_face_curve_items)
DEF_ENUM(rna_enum_attribute_domain_point_edge_face_curve_items)
DEF_ENUM(rna_enum_attribute_curves_domain_items)
DEF_ENUM(rna_enum_color_attribute_domain_items)
DEF_ENUM(rna_enum_attribute_domain_without_corner_items)

View File

@@ -100,8 +100,9 @@ const EnumPropertyItem rna_enum_attribute_domain_only_mesh_items[] = {
{0, nullptr, 0, nullptr, nullptr},
};
const EnumPropertyItem rna_enum_attribute_domain_point_face_curve_items[] = {
const EnumPropertyItem rna_enum_attribute_domain_point_edge_face_curve_items[] = {
{ATTR_DOMAIN_POINT, "POINT", 0, "Point", "Attribute on point"},
{ATTR_DOMAIN_EDGE, "EDGE", 0, "Edge", "Attribute on mesh edge"},
{ATTR_DOMAIN_FACE, "FACE", 0, "Face", "Attribute on mesh faces"},
{ATTR_DOMAIN_CURVE, "CURVE", 0, "Spline", "Attribute on spline"},
{0, nullptr, 0, nullptr, nullptr},

View File

@@ -54,6 +54,13 @@ static void node_geo_exec(GeoNodeExecParams params)
selection);
BKE_mesh_flush_select_from_verts(mesh);
break;
case ATTR_DOMAIN_EDGE:
bke::try_capture_field_on_geometry(geometry.get_component_for_write<MeshComponent>(),
".select_edge",
ATTR_DOMAIN_EDGE,
selection);
BKE_mesh_flush_select_from_edges(mesh);
break;
case ATTR_DOMAIN_FACE:
/* Remove attributes in case they are on the wrong domain, which can happen after
* conversion to and from other geometry types. */
@@ -93,7 +100,7 @@ static void node_rna(StructRNA *srna)
"domain",
"Domain",
"",
rna_enum_attribute_domain_point_face_curve_items,
rna_enum_attribute_domain_point_edge_face_curve_items,
NOD_inline_enum_accessors(custom1),
ATTR_DOMAIN_POINT);
}