Merge branch 'master' into refactor-mesh-selection-generic

This commit is contained in:
Hans Goudey 2022-09-07 21:58:37 -05:00
commit 87dfabc545
132 changed files with 939 additions and 985 deletions

View File

@ -755,12 +755,6 @@ class CustomDataAttributes {
bool foreach_attribute(const AttributeForeachCallback callback, eAttrDomain domain) const;
};
AttributeAccessor mesh_attributes(const Mesh &mesh);
MutableAttributeAccessor mesh_attributes_for_write(Mesh &mesh);
AttributeAccessor pointcloud_attributes(const PointCloud &pointcloud);
MutableAttributeAccessor pointcloud_attributes_for_write(PointCloud &pointcloud);
/* -------------------------------------------------------------------- */
/** \name #AttributeIDRef Inline Methods
* \{ */

View File

@ -665,18 +665,18 @@ void BKE_mesh_normals_loop_custom_set(const struct MVert *mverts,
const float (*polynors)[3],
int numPolys,
short (*r_clnors_data)[2]);
void BKE_mesh_normals_loop_custom_from_vertices_set(const struct MVert *mverts,
const float (*vert_normals)[3],
float (*r_custom_vertnors)[3],
int numVerts,
struct MEdge *medges,
int numEdges,
const struct MLoop *mloops,
int numLoops,
const struct MPoly *mpolys,
const float (*polynors)[3],
int numPolys,
short (*r_clnors_data)[2]);
void BKE_mesh_normals_loop_custom_from_verts_set(const struct MVert *mverts,
const float (*vert_normals)[3],
float (*r_custom_vertnors)[3],
int numVerts,
struct MEdge *medges,
int numEdges,
const struct MLoop *mloops,
int numLoops,
const struct MPoly *mpolys,
const float (*polynors)[3],
int numPolys,
short (*r_clnors_data)[2]);
/**
* Computes average per-vertex normals from given custom loop normals.
@ -717,12 +717,12 @@ void BKE_mesh_calc_normals_split_ex(struct Mesh *mesh,
void BKE_mesh_set_custom_normals(struct Mesh *mesh, float (*r_custom_loopnors)[3]);
/**
* Higher level functions hiding most of the code needed around call to
* #BKE_mesh_normals_loop_custom_from_vertices_set().
* #BKE_mesh_normals_loop_custom_from_verts_set().
*
* \param r_custom_vertnors: is not const, since code will replace zero_v3 normals there
* with automatically computed vectors.
*/
void BKE_mesh_set_custom_normals_from_vertices(struct Mesh *mesh, float (*r_custom_vertnors)[3]);
void BKE_mesh_set_custom_normals_from_verts(struct Mesh *mesh, float (*r_custom_vertnors)[3]);
/* *** mesh_evaluate.cc *** */
@ -812,10 +812,10 @@ void BKE_mesh_polygon_flip(const struct MPoly *mpoly,
*
* \note Invalidates tessellation, caller must handle that.
*/
void BKE_mesh_polygons_flip(const struct MPoly *mpoly,
struct MLoop *mloop,
struct CustomData *ldata,
int totpoly);
void BKE_mesh_polys_flip(const struct MPoly *mpoly,
struct MLoop *mloop,
struct CustomData *ldata,
int totpoly);
/* Merge verts. */
/* Enum for merge_mode of #BKE_mesh_merge_verts.

View File

@ -25,16 +25,16 @@ typedef enum eMeshFairingDepth {
/* affect_vertices is used to define the fairing area. Indexed by vertex index, set to true when
* the vertex should be modified by fairing. */
void BKE_bmesh_prefair_and_fair_vertices(struct BMesh *bm,
bool *affect_vertices,
eMeshFairingDepth depth);
void BKE_bmesh_prefair_and_fair_verts(struct BMesh *bm,
bool *affect_verts,
eMeshFairingDepth depth);
/* This function can optionally use the MVert coordinates of deform_mverts to read and write the
* fairing result. When NULL, the function will use mesh->mverts directly. */
void BKE_mesh_prefair_and_fair_vertices(struct Mesh *mesh,
struct MVert *deform_mverts,
bool *affect_vertices,
eMeshFairingDepth depth);
void BKE_mesh_prefair_and_fair_verts(struct Mesh *mesh,
struct MVert *deform_mverts,
bool *affect_verts,
eMeshFairingDepth depth);
#ifdef __cplusplus
}

View File

@ -402,7 +402,7 @@ typedef struct SculptBoundaryEditInfo {
int original_vertex_i;
/* How many steps were needed to reach this vertex from the boundary. */
int num_propagation_steps;
int propagation_steps_num;
/* Strength that is used to deform this vertex. */
float strength_factor;
@ -416,10 +416,10 @@ typedef struct SculptBoundaryPreviewEdge {
typedef struct SculptBoundary {
/* Vertex indices of the active boundary. */
PBVHVertRef *vertices;
int *vertices_i;
int vertices_capacity;
int num_vertices;
PBVHVertRef *verts;
int *verts_i;
int verts_capacity;
int verts_num;
/* Distance from a vertex in the boundary to initial vertex indexed by vertex index, taking into
* account the length of all edges between them. Any vertex that is not in the boundary will have
@ -429,7 +429,7 @@ typedef struct SculptBoundary {
/* Data for drawing the preview. */
SculptBoundaryPreviewEdge *edges;
int edges_capacity;
int num_edges;
int edges_num;
/* True if the boundary loops into itself. */
bool forms_loop;

View File

@ -389,7 +389,7 @@ const struct CCGKey *BKE_pbvh_get_grid_key(const PBVH *pbvh);
struct CCGElem **BKE_pbvh_get_grids(const PBVH *pbvh);
BLI_bitmap **BKE_pbvh_get_grid_visibility(const PBVH *pbvh);
int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh);
int BKE_pbvh_get_grid_num_verts(const PBVH *pbvh);
int BKE_pbvh_get_grid_num_faces(const PBVH *pbvh);
/**

View File

@ -826,7 +826,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
mesh_final = BKE_mesh_copy_for_eval(mesh_input, true);
ASSERT_IS_VALID_MESH(mesh_final);
}
MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh_final);
MutableAttributeAccessor attributes = mesh_final->attributes_for_write();
SpanAttributeWriter<float3> rest_positions =
attributes.lookup_or_add_for_write_only_span<float3>("rest_position", ATTR_DOMAIN_POINT);
if (rest_positions) {

View File

@ -103,11 +103,11 @@ static std::optional<blender::bke::MutableAttributeAccessor> get_attribute_acces
Mesh &mesh = reinterpret_cast<Mesh &>(id);
/* The attribute API isn't implemented for BMesh, so edit mode meshes are not supported. */
BLI_assert(mesh.edit_mesh == nullptr);
return mesh_attributes_for_write(mesh);
return mesh.attributes_for_write();
}
case ID_PT: {
PointCloud &pointcloud = reinterpret_cast<PointCloud &>(id);
return pointcloud_attributes_for_write(pointcloud);
return pointcloud.attributes_for_write();
}
case ID_CV: {
Curves &curves_id = reinterpret_cast<Curves &>(id);

View File

@ -1294,7 +1294,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
break;
case BVHTREE_FROM_LOOPTRI_NO_HIDDEN: {
blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*mesh);
blender::bke::AttributeAccessor attributes = mesh->attributes();
mask = looptri_no_hidden_map_get(
mesh->polys().data(),
attributes.lookup_or_default(".hide_poly", ATTR_DOMAIN_FACE, false),
@ -1454,7 +1454,7 @@ BVHTree *BKE_bvhtree_from_pointcloud_get(BVHTreeFromPointCloud *data,
return nullptr;
}
blender::bke::AttributeAccessor attributes = blender::bke::pointcloud_attributes(*pointcloud);
blender::bke::AttributeAccessor attributes = pointcloud->attributes();
blender::VArraySpan<blender::float3> positions = attributes.lookup_or_default<blender::float3>(
"position", ATTR_DOMAIN_POINT, blender::float3(0));

View File

@ -711,7 +711,7 @@ Mesh *curve_to_mesh_sweep(const CurvesGeometry &main,
Set<AttributeIDRef> main_attributes_set;
MutableAttributeAccessor mesh_attributes = bke::mesh_attributes_for_write(*mesh);
MutableAttributeAccessor mesh_attributes = mesh->attributes_for_write();
main_attributes.for_all([&](const AttributeIDRef &id, const AttributeMetaData meta_data) {
if (!should_add_attribute_to_mesh(main_attributes, mesh_attributes, id)) {

View File

@ -5411,6 +5411,9 @@ void CustomData_blend_read(BlendDataReader *reader, CustomData *data, const int
else if (layer->type == CD_GRID_PAINT_MASK) {
blend_read_paint_mask(reader, count, static_cast<GridPaintMask *>(layer->data));
}
else if (layer->type == CD_MDEFORMVERT) {
BKE_defvert_blend_read(reader, count, static_cast<MDeformVert *>(layer->data));
}
i++;
}
}

View File

@ -7,7 +7,6 @@
#include "BKE_fcurve.h"
#include "ED_keyframing.h"
#include "ED_types.h" /* For SELECT. */
#include "DNA_anim_types.h"

View File

@ -149,7 +149,7 @@ VArray<float3> mesh_normals_varray(const Mesh &mesh,
* array and copy the face normal for each of its corners. In this case using the mesh
* component's generic domain interpolation is fine, the data will still be normalized,
* since the face normal is just copied to every corner. */
return mesh_attributes(mesh).adapt_domain(
return mesh.attributes().adapt_domain(
VArray<float3>::ForSpan({(float3 *)BKE_mesh_poly_normals_ensure(&mesh), mesh.totpoly}),
ATTR_DOMAIN_FACE,
ATTR_DOMAIN_CORNER);
@ -1324,18 +1324,19 @@ static const AttributeAccessorFunctions &get_mesh_accessor_functions_ref()
return fn;
}
AttributeAccessor mesh_attributes(const Mesh &mesh)
{
return AttributeAccessor(&mesh, get_mesh_accessor_functions_ref());
}
MutableAttributeAccessor mesh_attributes_for_write(Mesh &mesh)
{
return MutableAttributeAccessor(&mesh, get_mesh_accessor_functions_ref());
}
} // namespace blender::bke
blender::bke::AttributeAccessor Mesh::attributes() const
{
return blender::bke::AttributeAccessor(this, blender::bke::get_mesh_accessor_functions_ref());
}
blender::bke::MutableAttributeAccessor Mesh::attributes_for_write()
{
return blender::bke::MutableAttributeAccessor(this,
blender::bke::get_mesh_accessor_functions_ref());
}
std::optional<blender::bke::AttributeAccessor> MeshComponent::attributes() const
{
return blender::bke::AttributeAccessor(mesh_, blender::bke::get_mesh_accessor_functions_ref());

View File

@ -201,18 +201,20 @@ static const AttributeAccessorFunctions &get_pointcloud_accessor_functions_ref()
return fn;
}
AttributeAccessor pointcloud_attributes(const PointCloud &pointcloud)
{
return AttributeAccessor(&pointcloud, get_pointcloud_accessor_functions_ref());
}
MutableAttributeAccessor pointcloud_attributes_for_write(PointCloud &pointcloud)
{
return MutableAttributeAccessor(&pointcloud, get_pointcloud_accessor_functions_ref());
}
} // namespace blender::bke
blender::bke::AttributeAccessor PointCloud::attributes() const
{
return blender::bke::AttributeAccessor(this,
blender::bke::get_pointcloud_accessor_functions_ref());
}
blender::bke::MutableAttributeAccessor PointCloud::attributes_for_write()
{
return blender::bke::MutableAttributeAccessor(
this, blender::bke::get_pointcloud_accessor_functions_ref());
}
std::optional<blender::bke::AttributeAccessor> PointCloudComponent::attributes() const
{
return blender::bke::AttributeAccessor(pointcloud_,

View File

@ -18,7 +18,7 @@ namespace blender::bke {
MeshFieldContext::MeshFieldContext(const Mesh &mesh, const eAttrDomain domain)
: mesh_(mesh), domain_(domain)
{
BLI_assert(mesh_attributes(mesh).domain_supported(domain_));
BLI_assert(mesh.attributes().domain_supported(domain_));
}
CurvesFieldContext::CurvesFieldContext(const CurvesGeometry &curves, const eAttrDomain domain)
@ -94,13 +94,13 @@ GeometryFieldContext::GeometryFieldContext(const InstancesComponent &instances)
std::optional<AttributeAccessor> GeometryFieldContext::attributes() const
{
if (const Mesh *mesh = this->mesh()) {
return mesh_attributes(*mesh);
return mesh->attributes();
}
if (const CurvesGeometry *curves = this->curves()) {
return curves->attributes();
}
if (const PointCloud *pointcloud = this->pointcloud()) {
return pointcloud_attributes(*pointcloud);
return pointcloud->attributes();
}
if (const InstancesComponent *instances = this->instances()) {
return instances->attributes();

View File

@ -2715,7 +2715,7 @@ bool BKE_gpencil_convert_mesh(Main *bmain,
gpl_fill, scene->r.cfra + frame_offset, GP_GETFRAME_ADD_NEW);
int i;
const VArray<int> mesh_material_indices = mesh_attributes(*me_eval).lookup_or_default<int>(
const VArray<int> mesh_material_indices = me_eval->attributes().lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
for (i = 0; i < mpoly_len; i++) {
const MPoly *mp = &polys[i];

View File

@ -249,7 +249,6 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
else {
Set<std::string> names_to_skip;
if (!BLO_write_is_undo(writer)) {
BKE_mesh_legacy_convert_hide_layers_to_flags(mesh);
BKE_mesh_legacy_convert_material_indices_to_mpoly(mesh);
/* When converting to the old mesh format, don't save redundant attributes. */
@ -265,6 +264,7 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
mesh->medge = const_cast<MEdge *>(mesh->edges().data());
mesh->mpoly = const_cast<MPoly *>(mesh->polys().data());
mesh->mloop = const_cast<MLoop *>(mesh->loops().data());
mesh->dvert = const_cast<MDeformVert *>(mesh->deform_verts().data());
}
CustomData_blend_write_prepare(mesh->vdata, vert_layers, names_to_skip);
@ -319,9 +319,6 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_data_address(reader, &mesh->adt);
BKE_animdata_blend_read_data(reader, mesh->adt);
/* Normally BKE_defvert_blend_read should be called in CustomData_blend_read,
* but for backwards compatibility in do_versions to work we do it here. */
BKE_defvert_blend_read(reader, mesh->totvert, mesh->dvert);
BLO_read_list(reader, &mesh->vertex_group_names);
CustomData_blend_read(reader, &mesh->vdata, mesh->totvert);
@ -329,6 +326,11 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
CustomData_blend_read(reader, &mesh->fdata, mesh->totface);
CustomData_blend_read(reader, &mesh->ldata, mesh->totloop);
CustomData_blend_read(reader, &mesh->pdata, mesh->totpoly);
if (mesh->deform_verts().is_empty()) {
/* Vertex group data was also an owning pointer in old Blender versions.
* Don't read them again if they were read as part of #CustomData. */
BKE_defvert_blend_read(reader, mesh->totvert, mesh->dvert);
}
mesh->texflag &= ~ME_AUTOSPACE_EVALUATED;
mesh->edit_mesh = nullptr;
@ -1347,7 +1349,7 @@ void BKE_mesh_material_index_remove(Mesh *me, short index)
{
using namespace blender;
using namespace blender::bke;
MutableAttributeAccessor attributes = mesh_attributes_for_write(*me);
MutableAttributeAccessor attributes = me->attributes_for_write();
AttributeWriter<int> material_indices = attributes.lookup_for_write<int>("material_index");
if (!material_indices) {
return;
@ -1372,7 +1374,7 @@ bool BKE_mesh_material_index_used(Mesh *me, short index)
{
using namespace blender;
using namespace blender::bke;
const AttributeAccessor attributes = mesh_attributes(*me);
const AttributeAccessor attributes = me->attributes();
const VArray<int> material_indices = attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
if (material_indices.is_single()) {
@ -1386,7 +1388,7 @@ void BKE_mesh_material_index_clear(Mesh *me)
{
using namespace blender;
using namespace blender::bke;
MutableAttributeAccessor attributes = mesh_attributes_for_write(*me);
MutableAttributeAccessor attributes = me->attributes_for_write();
attributes.remove("material_index");
BKE_mesh_tessface_clear(me);
@ -1415,7 +1417,7 @@ void BKE_mesh_material_remap(Mesh *me, const uint *remap, uint remap_len)
}
}
else {
MutableAttributeAccessor attributes = mesh_attributes_for_write(*me);
MutableAttributeAccessor attributes = me->attributes_for_write();
AttributeWriter<int> material_indices = attributes.lookup_for_write<int>("material_index");
if (!material_indices) {
return;
@ -1662,7 +1664,7 @@ void BKE_mesh_mselect_validate(Mesh *me)
mselect_dst = (MSelect *)MEM_malloc_arrayN(
(me->totselect), sizeof(MSelect), "Mesh selection history");
const AttributeAccessor attributes = mesh_attributes(*me);
const AttributeAccessor attributes = me->attributes();
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
const VArray<bool> selection_edge = attributes.lookup_or_default<bool>(
@ -1774,7 +1776,7 @@ void BKE_mesh_count_selected_items(const Mesh *mesh, int r_count[3])
void BKE_mesh_vert_coords_get(const Mesh *mesh, float (*vert_coords)[3])
{
blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*mesh);
blender::bke::AttributeAccessor attributes = mesh->attributes();
VArray<float3> positions = attributes.lookup_or_default(
"position", ATTR_DOMAIN_POINT, float3(0));
positions.materialize({(float3 *)vert_coords, mesh->totvert});

View File

@ -414,7 +414,7 @@ static void copy_poly_attributes(Mesh *dest_mesh,
Span<short> material_remap,
MutableSpan<int> dst_material_indices)
{
const VArray<int> src_material_indices = bke::mesh_attributes(*orig_me).lookup_or_default<int>(
const VArray<int> src_material_indices = orig_me->attributes().lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
const int src_index = src_material_indices[index_in_orig_me];
if (material_remap.size() > 0 && material_remap.index_range().contains(src_index)) {
@ -608,7 +608,7 @@ static void copy_or_interp_loop_attributes(Mesh *dest_mesh,
get_poly2d_cos(orig_me, orig_mp, cos_2d, mim.to_target_transform[orig_me_index], axis_mat);
}
CustomData *target_cd = &dest_mesh->ldata;
const Span<MVert> dst_vertices = dest_mesh->verts();
const Span<MVert> dst_verts = dest_mesh->verts();
const Span<MLoop> dst_loops = dest_mesh->loops();
for (int i = 0; i < mp->totloop; ++i) {
int loop_index = mp->loopstart + i;
@ -619,7 +619,7 @@ static void copy_or_interp_loop_attributes(Mesh *dest_mesh,
* The coordinate needs to be projected into 2d, just like the interpolating polygon's
* coordinates were. The `dest_mesh` coordinates are already in object 0 local space. */
float co[2];
mul_v2_m3v3(co, axis_mat, dst_vertices[dst_loops[loop_index].v].co);
mul_v2_m3v3(co, axis_mat, dst_verts[dst_loops[loop_index].v].co);
interp_weights_poly_v2(weights.data(), cos_2d, orig_mp->totloop, co);
}
for (int source_layer_i = 0; source_layer_i < source_cd->totlayer; ++source_layer_i) {
@ -722,10 +722,10 @@ static Mesh *imesh_to_mesh(IMesh *im, MeshesToIMeshInfo &mim)
merge_vertex_loop_poly_customdata_layers(result, mim);
/* Set the vertex coordinate values and other data. */
MutableSpan<MVert> vertices = result->verts_for_write();
MutableSpan<MVert> verts = result->verts_for_write();
for (int vi : im->vert_index_range()) {
const Vert *v = im->vert(vi);
MVert *mv = &vertices[vi];
MVert *mv = &verts[vi];
copy_v3fl_v3db(mv->co, v->co);
if (v->orig != NO_INDEX) {
const Mesh *orig_me;
@ -738,8 +738,8 @@ static Mesh *imesh_to_mesh(IMesh *im, MeshesToIMeshInfo &mim)
/* Set the loopstart and totloop for each output poly,
* and set the vertices in the appropriate loops. */
bke::SpanAttributeWriter<int> dst_material_indices =
bke::mesh_attributes_for_write(*result).lookup_or_add_for_write_only_span<int>(
"material_index", ATTR_DOMAIN_FACE);
result->attributes_for_write().lookup_or_add_for_write_only_span<int>("material_index",
ATTR_DOMAIN_FACE);
int cur_loop_index = 0;
MutableSpan<MLoop> dst_loops = result->loops_for_write();
MutableSpan<MPoly> dst_polys = result->polys_for_write();

View File

@ -158,8 +158,8 @@ static void serialize_and_initialize_deduplicated_edges(Mesh &mesh,
if (select_new_edges) {
SpanAttributeWriter<bool> selection_edge =
mesh_attributes_for_write(mesh).lookup_or_add_for_write_span<bool>(".selection_edge",
ATTR_DOMAIN_EDGE);
mesh.attributes_for_write().lookup_or_add_for_write_span<bool>(".selection_edge",
ATTR_DOMAIN_EDGE);
threading::parallel_for_each(edge_maps, [&](EdgeMap &edge_map) {
const int task_index = &edge_map - edge_maps.data();
int new_edge_index = edge_index_offsets[task_index];

View File

@ -193,7 +193,7 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
MEdge *medge = edges.data();
MPoly *mpoly = polys.data();
MLoop *mloop = loops.data();
MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh);
MutableAttributeAccessor attributes = mesh->attributes_for_write();
SpanAttributeWriter<int> material_indices = attributes.lookup_or_add_for_write_only_span<int>(
"material_index", ATTR_DOMAIN_FACE);
MLoopUV *mloopuv = static_cast<MLoopUV *>(CustomData_add_layer_named(
@ -639,9 +639,8 @@ void BKE_pointcloud_from_mesh(Mesh *me, PointCloud *pointcloud)
/* Copy over all attributes. */
CustomData_merge(&me->vdata, &pointcloud->pdata, CD_MASK_PROP_ALL, CD_DUPLICATE, me->totvert);
bke::AttributeAccessor mesh_attributes = bke::mesh_attributes(*me);
bke::MutableAttributeAccessor point_attributes = bke::pointcloud_attributes_for_write(
*pointcloud);
bke::AttributeAccessor mesh_attributes = me->attributes();
bke::MutableAttributeAccessor point_attributes = pointcloud->attributes_for_write();
const VArray<float3> mesh_positions = mesh_attributes.lookup_or_default<float3>(
"position", ATTR_DOMAIN_POINT, float3(0));
@ -1085,7 +1084,7 @@ Mesh *BKE_mesh_new_from_object_to_bmain(Main *bmain,
BKE_mesh_nomain_to_mesh(mesh, mesh_in_bmain, nullptr, &CD_MASK_MESH, true);
/* Anonymous attributes shouldn't exist on original data. */
blender::bke::mesh_attributes_for_write(*mesh_in_bmain).remove_anonymous();
mesh_in_bmain->attributes_for_write().remove_anonymous();
/* User-count is required because so far mesh was in a limbo, where library management does
* not perform any user management (i.e. copy of a mesh will not increase users of materials). */

View File

@ -717,7 +717,7 @@ void BKE_mesh_polygon_flip(const MPoly *mpoly, MLoop *mloop, CustomData *ldata)
BKE_mesh_polygon_flip_ex(mpoly, mloop, ldata, nullptr, mdisp, true);
}
void BKE_mesh_polygons_flip(const MPoly *mpoly, MLoop *mloop, CustomData *ldata, int totpoly)
void BKE_mesh_polys_flip(const MPoly *mpoly, MLoop *mloop, CustomData *ldata, int totpoly)
{
MDisps *mdisp = (MDisps *)CustomData_get_layer(ldata, CD_MDISPS);
const MPoly *mp;
@ -736,7 +736,7 @@ void BKE_mesh_flush_hidden_from_verts(Mesh *me)
{
using namespace blender;
using namespace blender::bke;
MutableAttributeAccessor attributes = mesh_attributes_for_write(*me);
MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> hide_vert = attributes.lookup_or_default<bool>(
".hide_vert", ATTR_DOMAIN_POINT, false);
@ -776,7 +776,7 @@ void BKE_mesh_flush_hidden_from_polys(Mesh *me)
{
using namespace blender;
using namespace blender::bke;
MutableAttributeAccessor attributes = mesh_attributes_for_write(*me);
MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> hide_poly = attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
@ -821,7 +821,7 @@ void BKE_mesh_flush_hidden_from_polys(Mesh *me)
void BKE_mesh_flush_select_from_polys(Mesh *me)
{
using namespace blender::bke;
MutableAttributeAccessor attributes = mesh_attributes_for_write(*me);
MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> selection_poly = attributes.lookup_or_default<bool>(
".selection_poly", ATTR_DOMAIN_FACE, false);
if (selection_poly.is_single() && !selection_poly.get_internal_single()) {
@ -877,7 +877,7 @@ static void mesh_flush_select_from_verts(const Span<MEdge> edges,
void BKE_mesh_flush_select_from_verts(Mesh *me)
{
using namespace blender::bke;
MutableAttributeAccessor attributes = mesh_attributes_for_write(*me);
MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
if (selection_vert.is_single() && !selection_vert.get_internal_single()) {

View File

@ -76,13 +76,13 @@ class FairingContext {
virtual ~FairingContext() = default;
void fair_vertices(bool *affected,
const eMeshFairingDepth depth,
VertexWeight *vertex_weight,
LoopWeight *loop_weight)
void fair_verts(bool *affected,
const eMeshFairingDepth depth,
VertexWeight *vertex_weight,
LoopWeight *loop_weight)
{
fair_vertices_ex(affected, (int)depth, vertex_weight, loop_weight);
fair_verts_ex(affected, (int)depth, vertex_weight, loop_weight);
}
protected:
@ -143,28 +143,28 @@ class FairingContext {
loop_weight);
}
void fair_vertices_ex(const bool *affected,
const int order,
VertexWeight *vertex_weight,
LoopWeight *loop_weight)
void fair_verts_ex(const bool *affected,
const int order,
VertexWeight *vertex_weight,
LoopWeight *loop_weight)
{
Map<int, int> vert_col_map;
int num_affected_vertices = 0;
int affected_verts_num = 0;
for (int i = 0; i < totvert_; i++) {
if (!affected[i]) {
continue;
}
vert_col_map.add(i, num_affected_vertices);
num_affected_vertices++;
vert_col_map.add(i, affected_verts_num);
affected_verts_num++;
}
/* Early return, nothing to do. */
if (ELEM(num_affected_vertices, 0, totvert_)) {
if (ELEM(affected_verts_num, 0, totvert_)) {
return;
}
/* Setup fairing matrices */
LinearSolver *solver = EIG_linear_solver_new(num_affected_vertices, num_affected_vertices, 3);
LinearSolver *solver = EIG_linear_solver_new(affected_verts_num, affected_verts_num, 3);
for (auto item : vert_col_map.items()) {
const int v = item.key;
const int col = item.value;
@ -450,42 +450,40 @@ class UniformLoopWeight : public LoopWeight {
}
};
static void prefair_and_fair_vertices(FairingContext *fairing_context,
bool *affected_vertices,
const eMeshFairingDepth depth)
static void prefair_and_fair_verts(FairingContext *fairing_context,
bool *affected_verts,
const eMeshFairingDepth depth)
{
/* Prefair. */
UniformVertexWeight *uniform_vertex_weights = new UniformVertexWeight(fairing_context);
UniformLoopWeight *uniform_loop_weights = new UniformLoopWeight();
fairing_context->fair_vertices(
affected_vertices, depth, uniform_vertex_weights, uniform_loop_weights);
fairing_context->fair_verts(affected_verts, depth, uniform_vertex_weights, uniform_loop_weights);
delete uniform_vertex_weights;
/* Fair. */
VoronoiVertexWeight *voronoi_vertex_weights = new VoronoiVertexWeight(fairing_context);
/* TODO: Implement cotangent loop weights. */
fairing_context->fair_vertices(
affected_vertices, depth, voronoi_vertex_weights, uniform_loop_weights);
fairing_context->fair_verts(affected_verts, depth, voronoi_vertex_weights, uniform_loop_weights);
delete uniform_loop_weights;
delete voronoi_vertex_weights;
}
void BKE_mesh_prefair_and_fair_vertices(struct Mesh *mesh,
struct MVert *deform_mverts,
bool *affect_vertices,
const eMeshFairingDepth depth)
void BKE_mesh_prefair_and_fair_verts(struct Mesh *mesh,
struct MVert *deform_mverts,
bool *affect_verts,
const eMeshFairingDepth depth)
{
MeshFairingContext *fairing_context = new MeshFairingContext(mesh, deform_mverts);
prefair_and_fair_vertices(fairing_context, affect_vertices, depth);
prefair_and_fair_verts(fairing_context, affect_verts, depth);
delete fairing_context;
}
void BKE_bmesh_prefair_and_fair_vertices(struct BMesh *bm,
bool *affect_vertices,
const eMeshFairingDepth depth)
void BKE_bmesh_prefair_and_fair_verts(struct BMesh *bm,
bool *affect_verts,
const eMeshFairingDepth depth)
{
BMeshFairingContext *fairing_context = new BMeshFairingContext(bm);
prefair_and_fair_vertices(fairing_context, affect_vertices, depth);
prefair_and_fair_verts(fairing_context, affect_verts, depth);
delete fairing_context;
}

View File

@ -926,7 +926,7 @@ void BKE_mesh_legacy_convert_hide_layers_to_flags(Mesh *mesh)
{
using namespace blender;
using namespace blender::bke;
const AttributeAccessor attributes = mesh_attributes(*mesh);
const AttributeAccessor attributes = mesh->attributes();
MutableSpan<MVert> verts = mesh->verts_for_write();
const VArray<bool> hide_vert = attributes.lookup_or_default<bool>(
@ -960,7 +960,7 @@ void BKE_mesh_legacy_convert_flags_to_hide_layers(Mesh *mesh)
{
using namespace blender;
using namespace blender::bke;
MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh);
MutableAttributeAccessor attributes = mesh->attributes_for_write();
const Span<MVert> verts = mesh->verts();
if (std::any_of(
@ -1012,7 +1012,7 @@ void BKE_mesh_legacy_convert_material_indices_to_mpoly(Mesh *mesh)
{
using namespace blender;
using namespace blender::bke;
const AttributeAccessor attributes = mesh_attributes(*mesh);
const AttributeAccessor attributes = mesh->attributes();
MutableSpan<MPoly> polys = mesh->polys_for_write();
const VArray<int> material_indices = attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
@ -1027,7 +1027,7 @@ void BKE_mesh_legacy_convert_mpoly_to_material_indices(Mesh *mesh)
{
using namespace blender;
using namespace blender::bke;
MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh);
MutableAttributeAccessor attributes = mesh->attributes_for_write();
const Span<MPoly> polys = mesh->polys();
if (std::any_of(
polys.begin(), polys.end(), [](const MPoly &poly) { return poly.mat_nr != 0; })) {
@ -1052,7 +1052,7 @@ void BKE_mesh_legacy_convert_selection_layers_to_flags(Mesh *mesh)
{
using namespace blender;
using namespace blender::bke;
const AttributeAccessor attributes = mesh_attributes(*mesh);
const AttributeAccessor attributes = mesh->attributes();
MutableSpan<MVert> verts = mesh->verts_for_write();
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
@ -1086,7 +1086,7 @@ void BKE_mesh_legacy_convert_flags_to_selection_layers(Mesh *mesh)
{
using namespace blender;
using namespace blender::bke;
MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh);
MutableAttributeAccessor attributes = mesh->attributes_for_write();
const Span<MVert> verts = mesh->verts();
if (std::any_of(

View File

@ -354,11 +354,11 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
ml = src_loops + mp->loopstart;
/* check faces with all vertices merged */
bool all_vertices_merged = true;
bool all_verts_merged = true;
for (j = 0; j < mp->totloop; j++, ml++) {
if (vtargetmap[ml->v] == -1) {
all_vertices_merged = false;
all_verts_merged = false;
/* This will be used to check for poly using several time the same vert. */
BLI_BITMAP_DISABLE(vert_tag, ml->v);
}
@ -368,7 +368,7 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh,
}
}
if (UNLIKELY(all_vertices_merged)) {
if (UNLIKELY(all_verts_merged)) {
if (merge_mode == MESH_MERGE_VERTS_DUMP_IF_MAPPED) {
/* In this mode, all vertices merged is enough to dump face */
continue;

View File

@ -2021,18 +2021,18 @@ void BKE_mesh_normals_loop_custom_set(const MVert *mverts,
false);
}
void BKE_mesh_normals_loop_custom_from_vertices_set(const MVert *mverts,
const float (*vert_normals)[3],
float (*r_custom_vertnors)[3],
const int numVerts,
MEdge *medges,
const int numEdges,
const MLoop *mloops,
const int numLoops,
const MPoly *mpolys,
const float (*polynors)[3],
const int numPolys,
short (*r_clnors_data)[2])
void BKE_mesh_normals_loop_custom_from_verts_set(const MVert *mverts,
const float (*vert_normals)[3],
float (*r_custom_vertnors)[3],
const int numVerts,
MEdge *medges,
const int numEdges,
const MLoop *mloops,
const int numLoops,
const MPoly *mpolys,
const float (*polynors)[3],
const int numPolys,
short (*r_clnors_data)[2])
{
mesh_normals_loop_custom_set(mverts,
vert_normals,
@ -2087,7 +2087,7 @@ void BKE_mesh_set_custom_normals(Mesh *mesh, float (*r_custom_loopnors)[3])
mesh_set_custom_normals(mesh, r_custom_loopnors, false);
}
void BKE_mesh_set_custom_normals_from_vertices(Mesh *mesh, float (*r_custom_vertnors)[3])
void BKE_mesh_set_custom_normals_from_verts(Mesh *mesh, float (*r_custom_vertnors)[3])
{
mesh_set_custom_normals(mesh, r_custom_vertnors, true);
}

View File

@ -243,7 +243,7 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
(void)0
blender::bke::AttributeWriter<int> material_indices =
blender::bke::mesh_attributes_for_write(*mesh).lookup_for_write<int>("material_index");
mesh->attributes_for_write().lookup_for_write<int>("material_index");
blender::MutableVArraySpan<int> material_indices_span(material_indices.varray);
MVert *mv = mverts;
@ -1152,7 +1152,7 @@ bool BKE_mesh_validate_material_indices(Mesh *me)
bool is_valid = true;
blender::bke::AttributeWriter<int> material_indices =
blender::bke::mesh_attributes_for_write(*me).lookup_for_write<int>("material_index");
me->attributes_for_write().lookup_for_write<int>("material_index");
blender::MutableVArraySpan<int> material_indices_span(material_indices.varray);
for (const int i : material_indices_span.index_range()) {
if (material_indices_span[i] < 0 || material_indices_span[i] > mat_nr_max) {

View File

@ -354,10 +354,9 @@ static GridCoord *vertex_grid_coord_with_grid_index(const Vertex *vertex, const
/* Get grid coordinates which correspond to corners of the given face.
* All the grid coordinates will be from the same grid index. */
static void grid_coords_from_face_vertices(
const MultiresReshapeSmoothContext *reshape_smooth_context,
const Face *face,
const GridCoord *grid_coords[])
static void grid_coords_from_face_verts(const MultiresReshapeSmoothContext *reshape_smooth_context,
const Face *face,
const GridCoord *grid_coords[])
{
BLI_assert(face->num_corners == 4);
@ -417,7 +416,7 @@ static void foreach_toplevel_grid_coord_task(void *__restrict userdata_v,
const Face *face = &reshape_smooth_context->geometry.faces[face_index];
const GridCoord *face_grid_coords[4];
grid_coords_from_face_vertices(reshape_smooth_context, face, face_grid_coords);
grid_coords_from_face_verts(reshape_smooth_context, face, face_grid_coords);
for (int y = 0; y < inner_grid_size; ++y) {
const float ptex_v = (float)y * inner_grid_size_1_inv;

View File

@ -161,7 +161,7 @@ static bool is_vertex_diagonal(BMVert *from_v, BMVert *to_v)
*/
static void unsubdivide_face_center_vertex_tag(BMesh *bm, BMVert *initial_vertex)
{
bool *visited_vertices = MEM_calloc_arrayN(bm->totvert, sizeof(bool), "visited vertices");
bool *visited_verts = MEM_calloc_arrayN(bm->totvert, sizeof(bool), "visited vertices");
GSQueue *queue;
queue = BLI_gsqueue_new(sizeof(BMVert *));
@ -177,7 +177,7 @@ static void unsubdivide_face_center_vertex_tag(BMesh *bm, BMVert *initial_vertex
int neighbor_vertex_index = BM_elem_index_get(neighbor_v);
if (neighbor_v != initial_vertex && is_vertex_diagonal(neighbor_v, initial_vertex)) {
BLI_gsqueue_push(queue, &neighbor_v);
visited_vertices[neighbor_vertex_index] = true;
visited_verts[neighbor_vertex_index] = true;
BM_elem_flag_set(neighbor_v, BM_ELEM_TAG, true);
}
}
@ -211,10 +211,10 @@ static void unsubdivide_face_center_vertex_tag(BMesh *bm, BMVert *initial_vertex
BM_ITER_ELEM (f, &iter, diagonal_v, BM_FACES_OF_VERT) {
BM_ITER_ELEM (neighbor_v, &iter_a, f, BM_VERTS_OF_FACE) {
int neighbor_vertex_index = BM_elem_index_get(neighbor_v);
if (!visited_vertices[neighbor_vertex_index] && neighbor_v != diagonal_v &&
if (!visited_verts[neighbor_vertex_index] && neighbor_v != diagonal_v &&
is_vertex_diagonal(neighbor_v, diagonal_v)) {
BLI_gsqueue_push(queue, &neighbor_v);
visited_vertices[neighbor_vertex_index] = true;
visited_verts[neighbor_vertex_index] = true;
BM_elem_flag_set(neighbor_v, BM_ELEM_TAG, true);
}
}
@ -224,7 +224,7 @@ static void unsubdivide_face_center_vertex_tag(BMesh *bm, BMVert *initial_vertex
}
BLI_gsqueue_free(queue);
MEM_freeN(visited_vertices);
MEM_freeN(visited_verts);
}
/**
@ -352,14 +352,14 @@ static bool unsubdivide_tag_disconnected_mesh_element(BMesh *bm, int *elem_id, i
*/
static int unsubdivide_init_elem_ids(BMesh *bm, int *elem_id)
{
bool *visited_vertices = MEM_calloc_arrayN(bm->totvert, sizeof(bool), "visited vertices");
bool *visited_verts = MEM_calloc_arrayN(bm->totvert, sizeof(bool), "visited vertices");
int current_id = 0;
for (int i = 0; i < bm->totvert; i++) {
if (!visited_vertices[i]) {
if (!visited_verts[i]) {
GSQueue *queue;
queue = BLI_gsqueue_new(sizeof(BMVert *));
visited_vertices[i] = true;
visited_verts[i] = true;
elem_id[i] = current_id;
BMVert *iv = BM_vert_at_index(bm, i);
BLI_gsqueue_push(queue, &iv);
@ -372,8 +372,8 @@ static int unsubdivide_init_elem_ids(BMesh *bm, int *elem_id)
BM_ITER_ELEM (ed, &iter, current_v, BM_EDGES_OF_VERT) {
neighbor_v = BM_edge_other_vert(ed, current_v);
const int neighbor_index = BM_elem_index_get(neighbor_v);
if (!visited_vertices[neighbor_index]) {
visited_vertices[neighbor_index] = true;
if (!visited_verts[neighbor_index]) {
visited_verts[neighbor_index] = true;
elem_id[neighbor_index] = current_id;
BLI_gsqueue_push(queue, &neighbor_v);
}
@ -383,7 +383,7 @@ static int unsubdivide_init_elem_ids(BMesh *bm, int *elem_id)
BLI_gsqueue_free(queue);
}
}
MEM_freeN(visited_vertices);
MEM_freeN(visited_verts);
return current_id;
}

View File

@ -1511,7 +1511,7 @@ void BKE_sculptsession_free(Object *ob)
}
if (ss->boundary_preview) {
MEM_SAFE_FREE(ss->boundary_preview->vertices);
MEM_SAFE_FREE(ss->boundary_preview->verts);
MEM_SAFE_FREE(ss->boundary_preview->edges);
MEM_SAFE_FREE(ss->boundary_preview->distance);
MEM_SAFE_FREE(ss->boundary_preview->edit_info);
@ -2134,7 +2134,7 @@ void BKE_sculpt_sync_face_sets_visibility_to_base_mesh(Mesh *mesh)
return;
}
MutableAttributeAccessor attributes = mesh_attributes_for_write(*mesh);
MutableAttributeAccessor attributes = mesh->attributes_for_write();
SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_only_span<bool>(
".hide_poly", ATTR_DOMAIN_FACE);
if (!hide_poly) {

View File

@ -2120,8 +2120,8 @@ void psys_particle_on_dm(Mesh *mesh_final,
const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(mesh_final);
if (from == PART_FROM_VERT) {
const MVert *vertices = BKE_mesh_verts(mesh_final);
copy_v3_v3(vec, vertices[mapindex].co);
const MVert *verts = BKE_mesh_verts(mesh_final);
copy_v3_v3(vec, verts[mapindex].co);
if (nor) {
copy_v3_v3(nor, vert_normals[mapindex]);

View File

@ -1831,7 +1831,7 @@ BLI_bitmap **BKE_pbvh_get_grid_visibility(const PBVH *pbvh)
return pbvh->grid_hidden;
}
int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh)
int BKE_pbvh_get_grid_num_verts(const PBVH *pbvh)
{
BLI_assert(pbvh->header.type == PBVH_GRIDS);
return pbvh->totgrid * pbvh->gridkey.grid_area;

View File

@ -194,8 +194,7 @@ static void pointcloud_random(PointCloud *pointcloud)
RNG *rng = BLI_rng_new(0);
blender::bke::MutableAttributeAccessor attributes =
blender::bke::pointcloud_attributes_for_write(*pointcloud);
blender::bke::MutableAttributeAccessor attributes = pointcloud->attributes_for_write();
blender::bke::SpanAttributeWriter positions =
attributes.lookup_or_add_for_write_only_span<float3>(POINTCLOUD_ATTR_POSITION,
ATTR_DOMAIN_POINT);
@ -258,7 +257,7 @@ PointCloud *BKE_pointcloud_new_nomain(const int totpoint)
static std::optional<blender::bounds::MinMaxResult<float3>> point_cloud_bounds(
const PointCloud &pointcloud)
{
blender::bke::AttributeAccessor attributes = blender::bke::pointcloud_attributes(pointcloud);
blender::bke::AttributeAccessor attributes = pointcloud.attributes();
blender::VArraySpan<float3> positions = attributes.lookup_or_default<float3>(
POINTCLOUD_ATTR_POSITION, ATTR_DOMAIN_POINT, float3(0));
blender::VArray<float> radii = attributes.lookup_or_default<float>(

View File

@ -2632,7 +2632,7 @@ static void springs_from_mesh(Object *ob)
BodyPoint *bp;
int a;
float scale = 1.0f;
const MVert *vertices = BKE_mesh_verts(me);
const MVert *verts = BKE_mesh_verts(me);
sb = ob->soft;
if (me && sb) {
@ -2643,7 +2643,7 @@ static void springs_from_mesh(Object *ob)
if (me->totvert) {
bp = ob->soft->bpoint;
for (a = 0; a < me->totvert; a++, bp++) {
copy_v3_v3(bp->origS, vertices[a].co);
copy_v3_v3(bp->origS, verts[a].co);
mul_m4_v3(ob->obmat, bp->origS);
}
}
@ -2755,15 +2755,15 @@ static void mesh_faces_to_scratch(Object *ob)
MLoopTri *looptri, *lt;
BodyFace *bodyface;
int a;
const MVert *vertices = BKE_mesh_verts(me);
const MPoly *polygons = BKE_mesh_polys(me);
const MVert *verts = BKE_mesh_verts(me);
const MPoly *polys = BKE_mesh_polys(me);
const MLoop *loops = BKE_mesh_loops(me);
/* Allocate and copy faces. */
sb->scratch->totface = poly_to_tri_count(me->totpoly, me->totloop);
looptri = lt = MEM_mallocN(sizeof(*looptri) * sb->scratch->totface, __func__);
BKE_mesh_recalc_looptri(loops, polygons, vertices, me->totloop, me->totpoly, looptri);
BKE_mesh_recalc_looptri(loops, polys, verts, me->totloop, me->totpoly, looptri);
bodyface = sb->scratch->bodyface = MEM_mallocN(sizeof(BodyFace) * sb->scratch->totface,
"SB_body_Faces");

View File

@ -996,9 +996,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain)
if ((key = blo_do_versions_newlibadr(fd, lib, me->key)) && key->refkey) {
data = key->refkey->data;
tot = MIN2(me->totvert, key->refkey->totelem);
MVert *vertices = BKE_mesh_verts_for_write(me);
MVert *verts = BKE_mesh_verts_for_write(me);
for (a = 0; a < tot; a++, data += 3) {
copy_v3_v3(vertices[a].co, data);
copy_v3_v3(verts[a].co, data);
}
}
}

View File

@ -956,7 +956,7 @@ static void convert_bmesh_hide_flags_to_mesh_attributes(BMesh &bm,
return;
}
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh);
bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
BM_mesh_elem_table_ensure(&bm, BM_VERT | BM_EDGE | BM_FACE);
write_fn_to_attribute<bool>(attributes, ".hide_vert", ATTR_DOMAIN_POINT, [&](const int i) {
@ -986,7 +986,7 @@ static void convert_bmesh_selection_flags_to_mesh_attributes(BMesh &bm,
return;
}
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh);
bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
BM_mesh_elem_table_ensure(&bm, BM_VERT | BM_EDGE | BM_FACE);
if (need_selection_vert) {
@ -1190,10 +1190,9 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
if (need_material_index) {
BM_mesh_elem_table_ensure(bm, BM_FACE);
write_fn_to_attribute<int>(
blender::bke::mesh_attributes_for_write(*me),
"material_index",
ATTR_DOMAIN_FACE,
[&](const int i) { return static_cast<int>(BM_face_at_index(bm, i)->mat_nr); });
me->attributes_for_write(), "material_index", ATTR_DOMAIN_FACE, [&](const int i) {
return static_cast<int>(BM_face_at_index(bm, i)->mat_nr);
});
}
/* Patch hook indices and vertex parents. */
@ -1471,10 +1470,9 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
if (need_material_index) {
BM_mesh_elem_table_ensure(bm, BM_FACE);
write_fn_to_attribute<int>(
blender::bke::mesh_attributes_for_write(*me),
"material_index",
ATTR_DOMAIN_FACE,
[&](const int i) { return static_cast<int>(BM_face_at_index(bm, i)->mat_nr); });
me->attributes_for_write(), "material_index", ATTR_DOMAIN_FACE, [&](const int i) {
return static_cast<int>(BM_face_at_index(bm, i)->mat_nr);
});
}
convert_bmesh_hide_flags_to_mesh_attributes(

View File

@ -141,7 +141,7 @@ static void pointcloud_batch_cache_ensure_pos(const PointCloud &pointcloud,
return;
}
const bke::AttributeAccessor attributes = bke::pointcloud_attributes(pointcloud);
const bke::AttributeAccessor attributes = pointcloud.attributes();
const VArraySpan<float3> positions = attributes.lookup<float3>("position", ATTR_DOMAIN_POINT);
const VArray<float> radii = attributes.lookup<float>("radius", ATTR_DOMAIN_POINT);
/* From the opengl wiki:

View File

@ -807,15 +807,15 @@ struct DRWCacheBuildingContext {
};
static bool draw_subdiv_topology_info_cb(const SubdivForeachContext *foreach_context,
const int num_vertices,
const int num_verts,
const int num_edges,
const int num_loops,
const int num_polygons,
const int num_polys,
const int *subdiv_polygon_offset)
{
/* num_loops does not take into account meshes with only loose geometry, which might be meshes
* used as custom bone shapes, so let's check the num_vertices also. */
if (num_vertices == 0 && num_loops == 0) {
* used as custom bone shapes, so let's check the num_verts also. */
if (num_verts == 0 && num_loops == 0) {
return false;
}
@ -826,12 +826,12 @@ static bool draw_subdiv_topology_info_cb(const SubdivForeachContext *foreach_con
if (num_loops != 0) {
cache->num_subdiv_edges = (uint)num_edges;
cache->num_subdiv_loops = (uint)num_loops;
cache->num_subdiv_verts = (uint)num_vertices;
cache->num_subdiv_quads = (uint)num_polygons;
cache->num_subdiv_verts = (uint)num_verts;
cache->num_subdiv_quads = (uint)num_polys;
cache->subdiv_polygon_offset = static_cast<int *>(MEM_dupallocN(subdiv_polygon_offset));
}
cache->may_have_loose_geom = num_vertices != 0 || num_edges != 0;
cache->may_have_loose_geom = num_verts != 0 || num_edges != 0;
/* Initialize cache buffers, prefer dynamic usage so we can reuse memory on the host even after
* it was sent to the device, since we may use the data while building other buffers on the CPU
@ -882,7 +882,7 @@ static bool draw_subdiv_topology_info_cb(const SubdivForeachContext *foreach_con
if (cache->num_subdiv_verts) {
ctx->vert_origindex_map = static_cast<int *>(
MEM_mallocN(cache->num_subdiv_verts * sizeof(int), "subdiv_vert_origindex_map"));
for (int i = 0; i < num_vertices; i++) {
for (int i = 0; i < num_verts; i++) {
ctx->vert_origindex_map[i] = -1;
}
}
@ -1967,9 +1967,8 @@ static void draw_subdiv_cache_ensure_mat_offsets(DRWSubdivCache *cache,
return;
}
const blender::VArraySpan<int> material_indices = blender::bke::mesh_attributes(*mesh_eval)
.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
const blender::VArraySpan<int> material_indices = mesh_eval->attributes().lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
/* Count number of subdivided polygons for each material. */
int *mat_start = static_cast<int *>(MEM_callocN(sizeof(int) * mat_len, "subdiv mat_start"));

View File

@ -51,7 +51,6 @@
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_transform.h"
#include "ED_types.h"
#include "ED_util.h"
#include "DEG_depsgraph.h"
@ -459,9 +458,7 @@ static void draw_marker_line(const uchar *color, int xpos, int ymin, int ymax)
static int marker_get_icon_id(TimeMarker *marker, int flag)
{
if (flag & DRAW_MARKERS_LOCAL) {
return (marker->flag & ACTIVE) ? ICON_PMARKER_ACT :
(marker->flag & SELECT) ? ICON_PMARKER_SEL :
ICON_PMARKER;
return (marker->flag & SELECT) ? ICON_PMARKER_SEL : ICON_PMARKER;
}
#ifdef DURIAN_CAMERA_SWITCH
if (marker->camera) {

View File

@ -47,7 +47,6 @@
#include "ED_select_utils.h"
#include "ED_transform.h"
#include "ED_transform_snap_object_context.h"
#include "ED_types.h"
#include "ED_view3d.h"
#include "curve_intern.h"
@ -2088,7 +2087,7 @@ bool ed_editnurb_extrude_flag(EditNurb *editnurb, const uint8_t flag)
const int copy_from = intvls_u[i - 1];
const int copy_to = intvls_u[i];
const int copy_count = copy_to - copy_from + 1;
const bool sel_status = selected_u || selected_v ? SELECT : DESELECT;
const bool sel_status = selected_u || selected_v ? true : false;
ED_curve_bpcpy(editnurb, new_bp_u_v, old_bp_v + copy_from, copy_count);
select_bpoints(new_bp_u_v, 1, copy_count, sel_status, flag, HIDDEN);
new_bp_u_v += copy_count;
@ -2154,7 +2153,7 @@ static void adduplicateflagNurb(
starta = a;
while ((bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag)) {
if (!split) {
select_beztriple(bezt, DESELECT, flag, HIDDEN);
select_beztriple(bezt, false, flag, HIDDEN);
}
enda = a;
if (a >= nu->pntsu - 1) {
@ -2194,7 +2193,7 @@ static void adduplicateflagNurb(
}
for (b = 0, bezt1 = newnu->bezt; b < newnu->pntsu; b++, bezt1++) {
select_beztriple(bezt1, SELECT, flag, HIDDEN);
select_beztriple(bezt1, true, flag, HIDDEN);
}
BLI_addtail(newnurb, newnu);
@ -2212,7 +2211,7 @@ static void adduplicateflagNurb(
newnu->flagu &= ~CU_NURB_CYCLIC;
for (b = 0, bezt1 = newnu->bezt; b < newnu->pntsu; b++, bezt1++) {
select_beztriple(bezt1, SELECT, flag, HIDDEN);
select_beztriple(bezt1, true, flag, HIDDEN);
}
BLI_addtail(newnurb, newnu);
@ -2224,7 +2223,7 @@ static void adduplicateflagNurb(
starta = a;
while (bp->f1 & flag) {
if (!split) {
select_bpoint(bp, DESELECT, flag, HIDDEN);
select_bpoint(bp, false, flag, HIDDEN);
}
enda = a;
if (a >= nu->pntsu - 1) {
@ -2264,7 +2263,7 @@ static void adduplicateflagNurb(
}
for (b = 0, bp1 = newnu->bp; b < newnu->pntsu; b++, bp1++) {
select_bpoint(bp1, SELECT, flag, HIDDEN);
select_bpoint(bp1, true, flag, HIDDEN);
}
BLI_addtail(newnurb, newnu);
@ -2282,7 +2281,7 @@ static void adduplicateflagNurb(
newnu->flagu &= ~CU_NURB_CYCLIC;
for (b = 0, bp1 = newnu->bp; b < newnu->pntsu; b++, bp1++) {
select_bpoint(bp1, SELECT, flag, HIDDEN);
select_bpoint(bp1, true, flag, HIDDEN);
}
BLI_addtail(newnurb, newnu);
@ -2502,7 +2501,7 @@ static void adduplicateflagNurb(
for (b = 0, bp1 = nu->bp; b < nu->pntsu * nu->pntsv; b++, bp1++) {
bp1->f1 &= ~SURF_SEEN;
if (!split) {
select_bpoint(bp1, DESELECT, flag, HIDDEN);
select_bpoint(bp1, false, flag, HIDDEN);
}
}
}
@ -3237,11 +3236,11 @@ static int hide_exec(bContext *C, wmOperator *op)
sel = 0;
while (a--) {
if (invert == 0 && BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
select_beztriple(bezt, false, SELECT, HIDDEN);
bezt->hide = 1;
}
else if (invert && !BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
select_beztriple(bezt, false, SELECT, HIDDEN);
bezt->hide = 1;
}
if (bezt->hide) {
@ -3259,11 +3258,11 @@ static int hide_exec(bContext *C, wmOperator *op)
sel = 0;
while (a--) {
if (invert == 0 && (bp->f1 & SELECT)) {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
select_bpoint(bp, false, SELECT, HIDDEN);
bp->hide = 1;
}
else if (invert && (bp->f1 & SELECT) == 0) {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
select_bpoint(bp, false, SELECT, HIDDEN);
bp->hide = 1;
}
if (bp->hide) {
@ -4353,7 +4352,7 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
keyIndex_updateBP(cu->editnurb, bp1, bp, 1);
*bp = *bp1;
bp1++;
select_bpoint(bp, SELECT, SELECT, HIDDEN);
select_bpoint(bp, true, SELECT, HIDDEN);
}
else {
keyIndex_updateBP(cu->editnurb, bp2, bp, 1);
@ -4808,7 +4807,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
bezt->f2 |= SELECT;
}
else {
select_beztriple(bezt, SELECT, SELECT, HIDDEN);
select_beztriple(bezt, true, SELECT, HIDDEN);
}
}
else {
@ -4822,7 +4821,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
BKE_curve_nurb_vert_active_set(cu, nu, bezt);
}
else {
select_bpoint(bp, SELECT, SELECT, HIDDEN);
select_bpoint(bp, true, SELECT, HIDDEN);
BKE_curve_nurb_vert_active_set(cu, nu, bp);
}
break;
@ -4834,7 +4833,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
bezt->f2 &= ~SELECT;
}
else {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
select_beztriple(bezt, false, SELECT, HIDDEN);
}
if (bezt == vert) {
cu->actvert = CU_ACT_NONE;
@ -4848,7 +4847,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
}
}
else {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
select_bpoint(bp, false, SELECT, HIDDEN);
if (bp == vert) {
cu->actvert = CU_ACT_NONE;
}
@ -4863,7 +4862,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
bezt->f2 &= ~SELECT;
}
else {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
select_beztriple(bezt, false, SELECT, HIDDEN);
}
if (bezt == vert) {
cu->actvert = CU_ACT_NONE;
@ -4874,7 +4873,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
bezt->f2 |= SELECT;
}
else {
select_beztriple(bezt, SELECT, SELECT, HIDDEN);
select_beztriple(bezt, true, SELECT, HIDDEN);
}
BKE_curve_nurb_vert_active_set(cu, nu, bezt);
}
@ -4888,13 +4887,13 @@ bool ED_curve_editnurb_select_pick(bContext *C,
}
else {
if (bp->f1 & SELECT) {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
select_bpoint(bp, false, SELECT, HIDDEN);
if (bp == vert) {
cu->actvert = CU_ACT_NONE;
}
}
else {
select_bpoint(bp, SELECT, SELECT, HIDDEN);
select_bpoint(bp, true, SELECT, HIDDEN);
BKE_curve_nurb_vert_active_set(cu, nu, bp);
}
}
@ -4910,7 +4909,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
bezt->f2 |= SELECT;
}
else {
select_beztriple(bezt, SELECT, SELECT, HIDDEN);
select_beztriple(bezt, true, SELECT, HIDDEN);
}
}
else {
@ -4924,7 +4923,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
BKE_curve_nurb_vert_active_set(cu, nu, bezt);
}
else {
select_bpoint(bp, SELECT, SELECT, HIDDEN);
select_bpoint(bp, true, SELECT, HIDDEN);
BKE_curve_nurb_vert_active_set(cu, nu, bp);
}
break;
@ -6407,7 +6406,7 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
if (split) {
/* deselect for split operator */
for (b = 0, bezt1 = nu->bezt; b < nu->pntsu; b++, bezt1++) {
select_beztriple(bezt1, DESELECT, SELECT, true);
select_beztriple(bezt1, false, SELECT, true);
}
}
@ -6417,7 +6416,7 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
if (split) {
/* deselect for split operator */
for (b = 0, bp1 = nu->bp; b < nu->pntsu * nu->pntsv; b++, bp1++) {
select_bpoint(bp1, DESELECT, SELECT, HIDDEN);
select_bpoint(bp1, false, SELECT, HIDDEN);
}
}

View File

@ -30,7 +30,6 @@
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_types.h"
#include "ED_view3d.h"
#include "curve_intern.h"
@ -47,7 +46,7 @@
bool select_beztriple(BezTriple *bezt, bool selstatus, uint8_t flag, eVisible_Types hidden)
{
if ((bezt->hide == 0) || (hidden == HIDDEN)) {
if (selstatus == SELECT) { /* selects */
if (selstatus) { /* selects */
bezt->f1 |= flag;
bezt->f2 |= flag;
bezt->f3 |= flag;
@ -66,7 +65,7 @@ bool select_beztriple(BezTriple *bezt, bool selstatus, uint8_t flag, eVisible_Ty
bool select_bpoint(BPoint *bp, bool selstatus, uint8_t flag, bool hidden)
{
if ((bp->hide == 0) || (hidden == 1)) {
if (selstatus == SELECT) {
if (selstatus) {
bp->f1 |= flag;
return true;
}
@ -80,17 +79,17 @@ bool select_bpoint(BPoint *bp, bool selstatus, uint8_t flag, bool hidden)
static bool swap_selection_beztriple(BezTriple *bezt)
{
if (bezt->f2 & SELECT) {
return select_beztriple(bezt, DESELECT, SELECT, VISIBLE);
return select_beztriple(bezt, false, SELECT, VISIBLE);
}
return select_beztriple(bezt, SELECT, SELECT, VISIBLE);
return select_beztriple(bezt, true, SELECT, VISIBLE);
}
static bool swap_selection_bpoint(BPoint *bp)
{
if (bp->f1 & SELECT) {
return select_bpoint(bp, DESELECT, SELECT, VISIBLE);
return select_bpoint(bp, false, SELECT, VISIBLE);
}
return select_bpoint(bp, SELECT, SELECT, VISIBLE);
return select_bpoint(bp, true, SELECT, VISIBLE);
}
bool ED_curve_nurb_select_check(const View3D *v3d, const Nurb *nu)
@ -336,9 +335,9 @@ static void select_adjacent_cp(ListBase *editnurb,
break;
}
if ((lastsel == false) && (bezt->hide == 0) &&
((bezt->f2 & SELECT) || (selstatus == DESELECT))) {
((bezt->f2 & SELECT) || (selstatus == false))) {
bezt += next;
if (!(bezt->f2 & SELECT) || (selstatus == DESELECT)) {
if (!(bezt->f2 & SELECT) || (selstatus == false)) {
bool sel = select_beztriple(bezt, selstatus, SELECT, VISIBLE);
if (sel && !cont) {
lastsel = true;
@ -363,10 +362,9 @@ static void select_adjacent_cp(ListBase *editnurb,
if (a - abs(next) < 0) {
break;
}
if ((lastsel == false) && (bp->hide == 0) &&
((bp->f1 & SELECT) || (selstatus == DESELECT))) {
if ((lastsel == false) && (bp->hide == 0) && ((bp->f1 & SELECT) || (selstatus == false))) {
bp += next;
if (!(bp->f1 & SELECT) || (selstatus == DESELECT)) {
if (!(bp->f1 & SELECT) || (selstatus == false)) {
bool sel = select_bpoint(bp, selstatus, SELECT, VISIBLE);
if (sel && !cont) {
lastsel = true;
@ -477,7 +475,7 @@ static int de_select_first_exec(bContext *C, wmOperator *UNUSED(op))
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
selectend_nurb(obedit, FIRST, true, DESELECT);
selectend_nurb(obedit, FIRST, true, false);
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(obedit->data);
@ -510,7 +508,7 @@ static int de_select_last_exec(bContext *C, wmOperator *UNUSED(op))
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
selectend_nurb(obedit, LAST, true, DESELECT);
selectend_nurb(obedit, LAST, true, false);
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(obedit->data);
@ -780,12 +778,12 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op))
for (b = 0; b < nu->pntsu; b++, bp++) {
if (direction) {
if (a == v) {
select_bpoint(bp, SELECT, SELECT, VISIBLE);
select_bpoint(bp, true, SELECT, VISIBLE);
}
}
else {
if (b == u) {
select_bpoint(bp, SELECT, SELECT, VISIBLE);
select_bpoint(bp, true, SELECT, VISIBLE);
}
}
}
@ -923,7 +921,7 @@ static void curve_select_more(Object *obedit)
if (a % nu->pntsu != 0) {
tempbp = bp - 1;
if (!(tempbp->f1 & SELECT)) {
select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
select_bpoint(tempbp, true, SELECT, VISIBLE);
}
}
@ -932,7 +930,7 @@ static void curve_select_more(Object *obedit)
sel = 0;
tempbp = bp + nu->pntsu;
if (!(tempbp->f1 & SELECT)) {
sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
sel = select_bpoint(tempbp, true, SELECT, VISIBLE);
}
/* make sure selected bpoint is discarded */
if (sel == 1) {
@ -944,7 +942,7 @@ static void curve_select_more(Object *obedit)
if (a + nu->pntsu < nu->pntsu * nu->pntsv) {
tempbp = bp - nu->pntsu;
if (!(tempbp->f1 & SELECT)) {
select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
select_bpoint(tempbp, true, SELECT, VISIBLE);
}
}
@ -953,7 +951,7 @@ static void curve_select_more(Object *obedit)
sel = 0;
tempbp = bp + 1;
if (!(tempbp->f1 & SELECT)) {
sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
sel = select_bpoint(tempbp, true, SELECT, VISIBLE);
}
if (sel) {
bp++;
@ -1080,7 +1078,7 @@ static void curve_select_less(Object *obedit)
}
if (sel != 4) {
select_bpoint(bp, DESELECT, SELECT, VISIBLE);
select_bpoint(bp, false, SELECT, VISIBLE);
BLI_BITMAP_ENABLE(selbpoints, a);
}
}
@ -1130,7 +1128,7 @@ static void curve_select_less(Object *obedit)
}
if (sel != 2) {
select_beztriple(bezt, DESELECT, SELECT, VISIBLE);
select_beztriple(bezt, false, SELECT, VISIBLE);
lastsel = true;
}
else {
@ -1175,7 +1173,7 @@ static void curve_select_less(Object *obedit)
}
if (sel != 2) {
select_bpoint(bp, DESELECT, SELECT, VISIBLE);
select_bpoint(bp, false, SELECT, VISIBLE);
lastsel = true;
}
else {
@ -1359,7 +1357,7 @@ static void select_nth_bezt(Nurb *nu, BezTriple *bezt, const struct CheckerInter
while (a--) {
const int depth = abs(start - a);
if (!WM_operator_properties_checker_interval_test(params, depth)) {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
select_beztriple(bezt, false, SELECT, HIDDEN);
}
bezt--;
@ -1382,7 +1380,7 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, const struct CheckerIntervalPara
while (a--) {
const int depth = abs(pnt - startpnt) + abs(row - startrow);
if (!WM_operator_properties_checker_interval_test(params, depth)) {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
select_bpoint(bp, false, SELECT, HIDDEN);
}
pnt--;
@ -1645,7 +1643,7 @@ static bool curve_nurb_select_similar_type(Object *ob,
}
if (select) {
select_beztriple(bezt, SELECT, SELECT, VISIBLE);
select_beztriple(bezt, true, SELECT, VISIBLE);
changed = true;
}
}
@ -1690,7 +1688,7 @@ static bool curve_nurb_select_similar_type(Object *ob,
}
if (select) {
select_bpoint(bp, SELECT, SELECT, VISIBLE);
select_bpoint(bp, true, SELECT, VISIBLE);
changed = true;
}
}
@ -1898,10 +1896,10 @@ static void curve_select_shortest_path_curve(Nurb *nu, int vert_src, int vert_ds
i = vert_src;
while (true) {
if (nu->type & CU_BEZIER) {
select_beztriple(&nu->bezt[i], SELECT, SELECT, HIDDEN);
select_beztriple(&nu->bezt[i], true, SELECT, HIDDEN);
}
else {
select_bpoint(&nu->bp[i], SELECT, SELECT, HIDDEN);
select_bpoint(&nu->bp[i], true, SELECT, HIDDEN);
}
if (i == vert_dst) {
@ -1979,10 +1977,10 @@ static void curve_select_shortest_path_surf(Nurb *nu, int vert_src, int vert_dst
int i = 0;
while (vert_curr != vert_src && i++ < vert_num) {
if (nu->type == CU_BEZIER) {
select_beztriple(&nu->bezt[vert_curr], SELECT, SELECT, HIDDEN);
select_beztriple(&nu->bezt[vert_curr], true, SELECT, HIDDEN);
}
else {
select_bpoint(&nu->bp[vert_curr], SELECT, SELECT, HIDDEN);
select_bpoint(&nu->bp[vert_curr], true, SELECT, HIDDEN);
}
vert_curr = data[vert_curr].vert_prev;
}

View File

@ -548,7 +548,7 @@ static void snap_curves_to_surface_exec_object(Object &curves_ob,
BKE_mesh_runtime_looptri_len(&surface_mesh)};
VArraySpan<float2> surface_uv_map;
if (curves_id.surface_uv_map != nullptr) {
const bke::AttributeAccessor surface_attributes = bke::mesh_attributes(surface_mesh);
const bke::AttributeAccessor surface_attributes = surface_mesh.attributes();
surface_uv_map = surface_attributes
.lookup(curves_id.surface_uv_map, ATTR_DOMAIN_CORNER, CD_PROP_FLOAT2)
.typed<float2>();

View File

@ -282,7 +282,7 @@ static int geometry_attribute_convert_exec(bContext *C, wmOperator *op)
RNA_enum_get(op->ptr, "mode"));
Mesh *mesh = reinterpret_cast<Mesh *>(ob_data);
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh);
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
/* General conversion steps are always the same:
* 1. Convert old data to right domain and data type.
@ -646,8 +646,7 @@ bool ED_geometry_attribute_convert(Mesh *mesh,
return false;
}
blender::bke::MutableAttributeAccessor attributes = blender::bke::mesh_attributes_for_write(
*mesh);
blender::bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
GVArray src_varray = attributes.lookup_or_default(name, new_domain, new_type);

View File

@ -1,27 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2008 Blender Foundation. All rights reserved. */
/** \file
* \ingroup editors
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/* **************** GENERAL EDITOR-WIDE TYPES AND DEFINES ************************** */
/* old blender defines... should be deprecated? */
#define DESELECT 0
#define SELECT 1
#define ACTIVE 2
/* proposal = put scene pointers on function calls? */
// #define BASACT (scene->basact)
// #define OBACT (BASACT ? BASACT->object : NULL)
#ifdef __cplusplus
}
#endif

View File

@ -67,11 +67,11 @@ void paintface_flush_flags(bContext *C,
return;
}
bke::AttributeAccessor attributes_me = bke::mesh_attributes(*me);
bke::AttributeAccessor attributes_me = me->attributes();
Mesh *me_orig = (Mesh *)ob_eval->runtime.data_orig;
bke::MutableAttributeAccessor attributes_orig = bke::mesh_attributes_for_write(*me_orig);
bke::MutableAttributeAccessor attributes_orig = me_orig->attributes_for_write();
Mesh *me_eval = (Mesh *)ob_eval->runtime.data_eval;
bke::MutableAttributeAccessor attributes_eval = bke::mesh_attributes_for_write(*me_eval);
bke::MutableAttributeAccessor attributes_eval = me_eval->attributes_for_write();
bool updated = false;
if (me_orig != nullptr && me_eval != nullptr && me_orig->totpoly == me->totpoly) {
@ -154,7 +154,7 @@ void paintface_hide(bContext *C, Object *ob, const bool unselected)
return;
}
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
bke::SpanAttributeWriter<bool> hide_poly = attributes.lookup_or_add_for_write_span<bool>(
".hide_poly", ATTR_DOMAIN_FACE);
bke::SpanAttributeWriter<bool> selection_poly = attributes.lookup_or_add_for_write_span<bool>(
@ -188,7 +188,7 @@ void paintface_reveal(bContext *C, Object *ob, const bool select)
return;
}
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
if (select) {
const VArray<bool> hide_poly = attributes.lookup_or_default<bool>(
@ -224,7 +224,7 @@ static void select_linked_tfaces_with_seams(Mesh *me, const uint index, const bo
const Span<MEdge> edges = me->edges();
const Span<MPoly> polys = me->polys();
const Span<MLoop> loops = me->loops();
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> hide_poly = attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
bke::SpanAttributeWriter<bool> selection_poly = attributes.lookup_or_add_for_write_span<bool>(
@ -321,7 +321,7 @@ bool paintface_deselect_all_visible(bContext *C, Object *ob, int action, bool fl
return false;
}
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> hide_poly = attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
bke::SpanAttributeWriter<bool> selection_poly = attributes.lookup_or_add_for_write_span<bool>(
@ -388,7 +388,7 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3])
const Span<MVert> verts = me->verts();
const Span<MPoly> polys = me->polys();
const Span<MLoop> loops = me->loops();
bke::AttributeAccessor attributes = bke::mesh_attributes(*me);
bke::AttributeAccessor attributes = me->attributes();
const VArray<bool> hide_poly = attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
const VArray<bool> selection_poly = attributes.lookup_or_default<bool>(
@ -426,7 +426,7 @@ bool paintface_mouse_select(bContext *C,
/* Get the face under the cursor */
Mesh *me = BKE_mesh_from_object(ob);
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> hide_poly = attributes.lookup_or_default<bool>(
".hide_poly", ATTR_DOMAIN_FACE, false);
bke::AttributeWriter<bool> selection_poly = attributes.lookup_or_add_for_write<bool>(
@ -496,8 +496,8 @@ void paintvert_flush_flags(Object *ob)
return;
}
const bke::AttributeAccessor attributes_orig = bke::mesh_attributes(*me);
bke::MutableAttributeAccessor attributes_eval = bke::mesh_attributes_for_write(*me_eval);
const bke::AttributeAccessor attributes_orig = me->attributes();
bke::MutableAttributeAccessor attributes_eval = me_eval->attributes_for_write();
const int *orig_indices = (const int *)CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX);
@ -551,7 +551,7 @@ bool paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags)
return false;
}
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> hide_vert = attributes.lookup_or_default<bool>(
".hide_vert", ATTR_DOMAIN_POINT, false);
bke::SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_span<bool>(
@ -627,7 +627,7 @@ void paintvert_select_ungrouped(Object *ob, bool extend, bool flush_flags)
paintvert_deselect_all_visible(ob, SEL_DESELECT, false);
}
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> hide_vert = attributes.lookup_or_default<bool>(
".hide_vert", ATTR_DOMAIN_POINT, false);
bke::SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_span<bool>(
@ -657,7 +657,7 @@ void paintvert_hide(bContext *C, Object *ob, const bool unselected)
return;
}
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
bke::SpanAttributeWriter<bool> hide_vert = attributes.lookup_or_add_for_write_span<bool>(
".hide_vert", ATTR_DOMAIN_POINT);
bke::SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_span<bool>(
@ -691,7 +691,7 @@ void paintvert_reveal(bContext *C, Object *ob, const bool select)
return;
}
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> hide_vert = attributes.lookup_or_default<bool>(
".hide_vert", ATTR_DOMAIN_POINT, false);
bke::SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_span<bool>(

View File

@ -41,7 +41,7 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
int valence;
uint objects_empty_len = 0;
uint failed_axis_len = 0;
uint failed_vertices_len = 0;
uint failed_verts_len = 0;
turns = RNA_int_get(op->ptr, "turns");
steps = RNA_int_get(op->ptr, "steps");
@ -97,7 +97,7 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
}
if (v1 == NULL || v2 == NULL) {
failed_vertices_len++;
failed_verts_len++;
continue;
}
@ -151,7 +151,7 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
if (failed_axis_len == objects_len - objects_empty_len) {
BKE_report(op->reports, RPT_ERROR, "Invalid/unset axis");
}
else if (failed_vertices_len == objects_len - objects_empty_len) {
else if (failed_verts_len == objects_len - objects_empty_len) {
BKE_report(op->reports, RPT_ERROR, "You have to select a string of connected vertices too");
}

View File

@ -893,7 +893,7 @@ static void mesh_add_verts(Mesh *mesh, int len)
mesh->totvert = totvert;
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh);
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_span<bool>(
".selection_vert", ATTR_DOMAIN_POINT);
selection_vert.span.take_back(len).fill(true);
@ -932,7 +932,7 @@ static void mesh_add_edges(Mesh *mesh, int len)
edge.flag = ME_EDGEDRAW | ME_EDGERENDER;
}
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh);
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> selection_edge = attributes.lookup_or_add_for_write_span<bool>(
".selection_edge", ATTR_DOMAIN_EDGE);
selection_edge.span.take_back(len).fill(true);
@ -993,7 +993,7 @@ static void mesh_add_polys(Mesh *mesh, int len)
mesh->totpoly = totpoly;
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh);
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<bool> selection_poly = attributes.lookup_or_add_for_write_span<bool>(
".selection_poly", ATTR_DOMAIN_FACE);
selection_poly.span.take_back(len).fill(true);

View File

@ -254,7 +254,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
CustomData_copy_data_named(&me->pdata, pdata, 0, *polyofs, me->totpoly);
blender::bke::AttributeWriter<int> material_indices =
blender::bke::mesh_attributes_for_write(*me).lookup_for_write<int>("material_index");
me->attributes_for_write().lookup_for_write<int>("material_index");
if (material_indices) {
blender::MutableVArraySpan<int> material_indices_span(material_indices.varray);
for (const int i : material_indices_span.index_range()) {

View File

@ -3158,7 +3158,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
}
/* Anonymous attributes shouldn't be available on the applied geometry. */
blender::bke::mesh_attributes_for_write(*new_mesh).remove_anonymous();
new_mesh->attributes_for_write().remove_anonymous();
BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */
}

View File

@ -599,7 +599,7 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList *UNUSED(reports),
MVert *mvert = verts.data();
MEdge *medge = edges.data();
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
bke::SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_span<bool>(
".selection_vert", ATTR_DOMAIN_POINT);
@ -774,7 +774,7 @@ static bool modifier_apply_obdata(
BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, &CD_MASK_MESH, true);
/* Anonymous attributes shouldn't be available on the applied geometry. */
blender::bke::mesh_attributes_for_write(*me).remove_anonymous();
me->attributes_for_write().remove_anonymous();
if (md_eval->type == eModifierType_Multires) {
multires_customdata_delete(me);

View File

@ -131,8 +131,8 @@ static int voxel_remesh_exec(bContext *C, wmOperator *op)
}
/* Output mesh will be all smooth or all flat shading. */
const Span<MPoly> polygons = mesh->polys();
const bool smooth_normals = polygons.first().flag & ME_SMOOTH;
const Span<MPoly> polys = mesh->polys();
const bool smooth_normals = polys.first().flag & ME_SMOOTH;
float isovalue = 0.0f;
if (mesh->flag & ME_REMESH_REPROJECT_VOLUME) {

View File

@ -209,7 +209,7 @@ bool ED_vgroup_parray_alloc(ID *id,
MEM_mallocN(sizeof(void *) * me->totvert, __func__));
if (use_vert_sel) {
const bke::AttributeAccessor attributes = bke::mesh_attributes(*me);
const bke::AttributeAccessor attributes = me->attributes();
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
@ -669,7 +669,7 @@ static void vgroup_copy_active_to_sel(Object *ob, eVGroupSelect subset_type)
}
}
else {
const bke::AttributeAccessor attributes = bke::mesh_attributes(*me);
const bke::AttributeAccessor attributes = me->attributes();
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
@ -1061,7 +1061,7 @@ static void vgroup_select_verts(Object *ob, int select)
else {
const Span<MDeformVert> dverts = me->deform_verts();
if (!dverts.is_empty()) {
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
const VArray<bool> hide_vert = attributes.lookup_or_default<bool>(
".hide_vert", ATTR_DOMAIN_POINT, false);
bke::SpanAttributeWriter<bool> selection_vert =
@ -1536,7 +1536,7 @@ static void vgroup_fix(
if (!(me->editflag & ME_EDIT_PAINT_VERT_SEL)) {
return;
}
const bke::AttributeAccessor attributes = bke::mesh_attributes(*me);
const bke::AttributeAccessor attributes = me->attributes();
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
for (i = 0; i < me->totvert && mvert; i++, mvert++) {
@ -1923,7 +1923,7 @@ static void vgroup_smooth_subset(Object *ob,
BMesh *bm = em ? em->bm : nullptr;
Mesh *me = em ? nullptr : static_cast<Mesh *>(ob->data);
const bke::AttributeAccessor attributes = bke::mesh_attributes(*me);
const bke::AttributeAccessor attributes = me->attributes();
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
@ -2485,7 +2485,7 @@ void ED_vgroup_mirror(Object *ob,
BLI_bitmap *vert_tag = BLI_BITMAP_NEW(me->totvert, __func__);
MutableSpan<MDeformVert> dverts = me->deform_verts_for_write();
const bke::AttributeAccessor attributes = bke::mesh_attributes(*me);
const bke::AttributeAccessor attributes = me->attributes();
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
@ -2640,7 +2640,7 @@ static void vgroup_assign_verts(Object *ob, const float weight)
}
}
else {
const bke::AttributeAccessor attributes = bke::mesh_attributes(*me);
const bke::AttributeAccessor attributes = me->attributes();
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
@ -4373,7 +4373,7 @@ static void vgroup_copy_active_to_sel_single(Object *ob, const int def_nr)
}
MutableSpan<MDeformVert> dverts = me->deform_verts_for_write();
const bke::AttributeAccessor attributes = bke::mesh_attributes(*me);
const bke::AttributeAccessor attributes = me->attributes();
const VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);

View File

@ -167,11 +167,10 @@ struct AddOperationExecutor {
/* Find UV map. */
VArraySpan<float2> surface_uv_map;
if (curves_id_orig_->surface_uv_map != nullptr) {
surface_uv_map = bke::mesh_attributes(surface_orig)
.lookup<float2>(curves_id_orig_->surface_uv_map, ATTR_DOMAIN_CORNER);
surface_uv_map_eval_ = bke::mesh_attributes(*surface_eval_)
.lookup<float2>(curves_id_orig_->surface_uv_map,
ATTR_DOMAIN_CORNER);
surface_uv_map = surface_orig.attributes().lookup<float2>(curves_id_orig_->surface_uv_map,
ATTR_DOMAIN_CORNER);
surface_uv_map_eval_ = surface_eval_->attributes().lookup<float2>(
curves_id_orig_->surface_uv_map, ATTR_DOMAIN_CORNER);
}
if (surface_uv_map.is_empty()) {

View File

@ -137,9 +137,9 @@ struct DensityAddOperationExecutor {
/* Find UV map. */
VArraySpan<float2> surface_uv_map;
if (curves_id_orig_->surface_uv_map != nullptr) {
surface_uv_map = bke::mesh_attributes(*surface_orig_)
surface_uv_map = surface_orig_->attributes()
.lookup<float2>(curves_id_orig_->surface_uv_map, ATTR_DOMAIN_CORNER);
surface_uv_map_eval_ = bke::mesh_attributes(*surface_eval_)
surface_uv_map_eval_ = surface_eval_->attributes()
.lookup<float2>(curves_id_orig_->surface_uv_map,
ATTR_DOMAIN_CORNER);
}

View File

@ -180,8 +180,8 @@ struct SlideOperationExecutor {
}
surface_looptris_orig_ = {BKE_mesh_runtime_looptri_ensure(surface_orig_),
BKE_mesh_runtime_looptri_len(surface_orig_)};
surface_uv_map_orig_ =
bke::mesh_attributes(*surface_orig_).lookup<float2>(uv_map_name, ATTR_DOMAIN_CORNER);
surface_uv_map_orig_ = surface_orig_->attributes().lookup<float2>(uv_map_name,
ATTR_DOMAIN_CORNER);
if (surface_uv_map_orig_.is_empty()) {
report_missing_uv_map_on_original_surface(stroke_extension.reports);
return;
@ -209,8 +209,8 @@ struct SlideOperationExecutor {
BKE_mesh_runtime_looptri_len(surface_eval_)};
surface_verts_eval_ = surface_eval_->verts();
surface_loops_eval_ = surface_eval_->loops();
surface_uv_map_eval_ =
bke::mesh_attributes(*surface_eval_).lookup<float2>(uv_map_name, ATTR_DOMAIN_CORNER);
surface_uv_map_eval_ = surface_eval_->attributes().lookup<float2>(uv_map_name,
ATTR_DOMAIN_CORNER);
if (surface_uv_map_eval_.is_empty()) {
report_missing_uv_map_on_evaluated_surface(stroke_extension.reports);
return;

View File

@ -1959,7 +1959,7 @@ static void do_wpaint_brush_blur_task_cb_ex(void *__restrict userdata,
const float *sculpt_normal_frontface = SCULPT_brush_frontface_normal_from_falloff_shape(
ss, data->brush->falloff_shape);
const blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*data->me);
const blender::bke::AttributeAccessor attributes = data->me->attributes();
const blender::VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
@ -2049,7 +2049,7 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata,
sub_v3_v3v3(brush_dir, cache->location, cache->last_location);
project_plane_v3_v3v3(brush_dir, brush_dir, cache->view_normal);
const blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*data->me);
const blender::bke::AttributeAccessor attributes = data->me->attributes();
const blender::VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
@ -2166,7 +2166,7 @@ static void do_wpaint_brush_draw_task_cb_ex(void *__restrict userdata,
const float *sculpt_normal_frontface = SCULPT_brush_frontface_normal_from_falloff_shape(
ss, data->brush->falloff_shape);
const blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*data->me);
const blender::bke::AttributeAccessor attributes = data->me->attributes();
const blender::VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
@ -2235,7 +2235,7 @@ static void do_wpaint_brush_calc_average_weight_cb_ex(
const float *sculpt_normal_frontface = SCULPT_brush_frontface_normal_from_falloff_shape(
ss, data->brush->falloff_shape);
const blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*data->me);
const blender::bke::AttributeAccessor attributes = data->me->attributes();
const blender::VArray<bool> selection_vert = attributes.lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
@ -2970,9 +2970,9 @@ static void do_vpaint_brush_blur_loops(bContext *C,
Color *previous_color = static_cast<Color *>(ss->cache->prev_colors_vpaint);
const blender::VArray<bool> selection_vert = bke::mesh_attributes(*me).lookup_or_default<bool>(
const blender::VArray<bool> selection_vert = me->attributes().lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
const blender::VArray<bool> selection_poly = bke::mesh_attributes(*me).lookup_or_default<bool>(
const blender::VArray<bool> selection_poly = me->attributes().lookup_or_default<bool>(
".selection_poly", ATTR_DOMAIN_FACE, false);
blender::threading::parallel_for(IndexRange(totnode), 1LL, [&](IndexRange range) {
@ -3115,9 +3115,9 @@ static void do_vpaint_brush_blur_verts(bContext *C,
Color *previous_color = static_cast<Color *>(ss->cache->prev_colors_vpaint);
const blender::VArray<bool> selection_vert = bke::mesh_attributes(*me).lookup_or_default<bool>(
const blender::VArray<bool> selection_vert = me->attributes().lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
const blender::VArray<bool> selection_poly = bke::mesh_attributes(*me).lookup_or_default<bool>(
const blender::VArray<bool> selection_poly = me->attributes().lookup_or_default<bool>(
".selection_poly", ATTR_DOMAIN_FACE, false);
blender::threading::parallel_for(IndexRange(totnode), 1LL, [&](IndexRange range) {
@ -3267,9 +3267,9 @@ static void do_vpaint_brush_smear(bContext *C,
Color *color_prev_smear = static_cast<Color *>(vpd->smear.color_prev);
Color *color_prev = reinterpret_cast<Color *>(ss->cache->prev_colors_vpaint);
const blender::VArray<bool> selection_vert = bke::mesh_attributes(*me).lookup_or_default<bool>(
const blender::VArray<bool> selection_vert = me->attributes().lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
const blender::VArray<bool> selection_poly = bke::mesh_attributes(*me).lookup_or_default<bool>(
const blender::VArray<bool> selection_poly = me->attributes().lookup_or_default<bool>(
".selection_poly", ATTR_DOMAIN_FACE, false);
blender::threading::parallel_for(IndexRange(totnode), 1LL, [&](IndexRange range) {
@ -3437,7 +3437,7 @@ static void calculate_average_color(VPaintData<Color, Traits, domain> *vpd,
{
using Blend = typename Traits::BlendType;
const blender::VArray<bool> selection_vert = bke::mesh_attributes(*me).lookup_or_default<bool>(
const blender::VArray<bool> selection_vert = me->attributes().lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
VPaintAverageAccum<Blend> *accum = (VPaintAverageAccum<Blend> *)MEM_mallocN(
@ -3555,9 +3555,9 @@ static void vpaint_do_draw(bContext *C,
Color *previous_color = static_cast<Color *>(ss->cache->prev_colors_vpaint);
const blender::VArray<bool> selection_vert = bke::mesh_attributes(*me).lookup_or_default<bool>(
const blender::VArray<bool> selection_vert = me->attributes().lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
const blender::VArray<bool> selection_poly = bke::mesh_attributes(*me).lookup_or_default<bool>(
const blender::VArray<bool> selection_poly = me->attributes().lookup_or_default<bool>(
".selection_poly", ATTR_DOMAIN_FACE, false);
blender::threading::parallel_for(IndexRange(totnode), 1LL, [&](IndexRange range) {
@ -4074,9 +4074,9 @@ static bool vertex_color_set(Object *ob, ColorPaint4f paintcol_in, CustomDataLay
return false;
}
const blender::VArray<bool> selection_vert = bke::mesh_attributes(*me).lookup_or_default<bool>(
const blender::VArray<bool> selection_vert = me->attributes().lookup_or_default<bool>(
".selection_vert", ATTR_DOMAIN_POINT, false);
const blender::VArray<bool> selection_poly = bke::mesh_attributes(*me).lookup_or_default<bool>(
const blender::VArray<bool> selection_poly = me->attributes().lookup_or_default<bool>(
".selection_poly", ATTR_DOMAIN_FACE, false);
Color paintcol = fromFloat<Color>(paintcol_in);

View File

@ -92,7 +92,7 @@ static bool vertex_paint_from_weight(Object *ob)
return false;
}
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
bke::GAttributeWriter color_attribute = attributes.lookup_for_write(active_color_layer->name);
if (!color_attribute) {
@ -159,7 +159,7 @@ static IndexMask get_selected_indices(const Mesh &mesh,
Vector<int64_t> &indices)
{
using namespace blender;
bke::AttributeAccessor attributes = bke::mesh_attributes(mesh);
const bke::AttributeAccessor attributes = mesh.attributes();
if (mesh.editflag & ME_EDIT_PAINT_FACE_SEL) {
const VArray<bool> selection = attributes.lookup_or_default<bool>(
@ -176,7 +176,7 @@ static IndexMask get_selected_indices(const Mesh &mesh,
return IndexMask(attributes.domain_size(domain));
}
static void face_corner_color_equalize_vertices(Mesh &mesh, const IndexMask selection)
static void face_corner_color_equalize_verts(Mesh &mesh, const IndexMask selection)
{
using namespace blender;
@ -186,7 +186,7 @@ static void face_corner_color_equalize_vertices(Mesh &mesh, const IndexMask sele
return;
}
bke::AttributeAccessor attributes = bke::mesh_attributes(mesh);
bke::AttributeAccessor attributes = mesh.attributes();
if (attributes.lookup_meta_data(active_color_layer->name)->domain == ATTR_DOMAIN_POINT) {
return;
@ -211,7 +211,7 @@ static bool vertex_color_smooth(Object *ob)
Vector<int64_t> indices;
const IndexMask selection = get_selected_indices(*me, ATTR_DOMAIN_CORNER, indices);
face_corner_color_equalize_vertices(*me, selection);
face_corner_color_equalize_verts(*me, selection);
tag_object_after_update(ob);
@ -260,7 +260,7 @@ static bool transform_active_color(Mesh &mesh, const TransformFn &transform_fn)
return false;
}
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(mesh);
bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
bke::GAttributeWriter color_attribute = attributes.lookup_for_write(active_color_layer->name);
if (!color_attribute) {

View File

@ -116,7 +116,7 @@ int SCULPT_vertex_count_get(SculptSession *ss)
case PBVH_BMESH:
return BM_mesh_elem_count(BKE_pbvh_get_bmesh(ss->pbvh), BM_VERT);
case PBVH_GRIDS:
return BKE_pbvh_get_grid_num_vertices(ss->pbvh);
return BKE_pbvh_get_grid_num_verts(ss->pbvh);
}
return 0;
@ -562,7 +562,7 @@ bool SCULPT_vertex_has_face_set(SculptSession *ss, PBVHVertRef vertex, int face_
return true;
}
void SCULPT_visibility_sync_all_face_sets_to_vertices(Object *ob)
void SCULPT_visibility_sync_all_face_sets_to_verts(Object *ob)
{
SculptSession *ss = ob->sculpt;
Mesh *mesh = BKE_object_get_original_mesh(ob);
@ -1102,7 +1102,7 @@ void SCULPT_floodfill_init(SculptSession *ss, SculptFloodFill *flood)
SCULPT_vertex_random_access_ensure(ss);
flood->queue = BLI_gsqueue_new(sizeof(intptr_t));
flood->visited_vertices = BLI_BITMAP_NEW(vertex_count, "visited vertices");
flood->visited_verts = BLI_BITMAP_NEW(vertex_count, "visited verts");
}
void SCULPT_floodfill_add_initial(SculptFloodFill *flood, PBVHVertRef vertex)
@ -1113,7 +1113,7 @@ void SCULPT_floodfill_add_initial(SculptFloodFill *flood, PBVHVertRef vertex)
void SCULPT_floodfill_add_and_skip_initial(SculptFloodFill *flood, PBVHVertRef vertex)
{
BLI_gsqueue_push(flood->queue, &vertex);
BLI_BITMAP_ENABLE(flood->visited_vertices, vertex.i);
BLI_BITMAP_ENABLE(flood->visited_verts, vertex.i);
}
void SCULPT_floodfill_add_initial_with_symmetry(Sculpt *sd,
@ -1192,7 +1192,7 @@ void SCULPT_floodfill_execute(SculptSession *ss,
const PBVHVertRef to_v = ni.vertex;
int to_v_i = BKE_pbvh_vertex_to_index(ss->pbvh, to_v);
if (BLI_BITMAP_TEST(flood->visited_vertices, to_v_i)) {
if (BLI_BITMAP_TEST(flood->visited_verts, to_v_i)) {
continue;
}
@ -1200,7 +1200,7 @@ void SCULPT_floodfill_execute(SculptSession *ss,
continue;
}
BLI_BITMAP_ENABLE(flood->visited_vertices, BKE_pbvh_vertex_to_index(ss->pbvh, to_v));
BLI_BITMAP_ENABLE(flood->visited_verts, BKE_pbvh_vertex_to_index(ss->pbvh, to_v));
if (func(ss, from_v, to_v, ni.is_duplicate, userdata)) {
BLI_gsqueue_push(flood->queue, &to_v);
@ -1212,7 +1212,7 @@ void SCULPT_floodfill_execute(SculptSession *ss,
void SCULPT_floodfill_free(SculptFloodFill *flood)
{
MEM_SAFE_FREE(flood->visited_vertices);
MEM_SAFE_FREE(flood->visited_verts);
BLI_gsqueue_free(flood->queue);
flood->queue = NULL;
}

View File

@ -128,22 +128,22 @@ static void sculpt_boundary_index_add(SculptBoundary *boundary,
const PBVHVertRef new_vertex,
const int new_index,
const float distance,
GSet *included_vertices)
GSet *included_verts)
{
boundary->vertices[boundary->num_vertices] = new_vertex;
boundary->verts[boundary->verts_num] = new_vertex;
if (boundary->distance) {
boundary->distance[new_index] = distance;
}
if (included_vertices) {
BLI_gset_add(included_vertices, POINTER_FROM_INT(new_index));
if (included_verts) {
BLI_gset_add(included_verts, POINTER_FROM_INT(new_index));
}
boundary->num_vertices++;
if (boundary->num_vertices >= boundary->vertices_capacity) {
boundary->vertices_capacity += BOUNDARY_INDICES_BLOCK_SIZE;
boundary->vertices = MEM_reallocN_id(
boundary->vertices, boundary->vertices_capacity * sizeof(PBVHVertRef), "boundary indices");
boundary->verts_num++;
if (boundary->verts_num >= boundary->verts_capacity) {
boundary->verts_capacity += BOUNDARY_INDICES_BLOCK_SIZE;
boundary->verts = MEM_reallocN_id(
boundary->verts, boundary->verts_capacity * sizeof(PBVHVertRef), "boundary indices");
}
};
@ -152,11 +152,11 @@ static void sculpt_boundary_preview_edge_add(SculptBoundary *boundary,
const PBVHVertRef v2)
{
boundary->edges[boundary->num_edges].v1 = v1;
boundary->edges[boundary->num_edges].v2 = v2;
boundary->num_edges++;
boundary->edges[boundary->edges_num].v1 = v1;
boundary->edges[boundary->edges_num].v2 = v2;
boundary->edges_num++;
if (boundary->num_edges >= boundary->edges_capacity) {
if (boundary->edges_num >= boundary->edges_capacity) {
boundary->edges_capacity += BOUNDARY_INDICES_BLOCK_SIZE;
boundary->edges = MEM_reallocN_id(boundary->edges,
boundary->edges_capacity * sizeof(SculptBoundaryPreviewEdge),
@ -209,7 +209,7 @@ static bool sculpt_boundary_is_vertex_in_editable_boundary(SculptSession *ss,
typedef struct BoundaryFloodFillData {
SculptBoundary *boundary;
GSet *included_vertices;
GSet *included_verts;
EdgeSet *preview_edges;
PBVHVertRef last_visited_vertex;
@ -233,7 +233,7 @@ static bool boundary_floodfill_cb(
boundary->distance[from_v_i] + edge_len :
0.0f;
sculpt_boundary_index_add(
boundary, to_v, to_v_i, distance_boundary_to_dst, data->included_vertices);
boundary, to_v, to_v_i, distance_boundary_to_dst, data->included_verts);
if (!is_duplicate) {
sculpt_boundary_preview_edge_add(boundary, from_v, to_v);
}
@ -247,7 +247,7 @@ static void sculpt_boundary_indices_init(SculptSession *ss,
{
const int totvert = SCULPT_vertex_count_get(ss);
boundary->vertices = MEM_malloc_arrayN(
boundary->verts = MEM_malloc_arrayN(
BOUNDARY_INDICES_BLOCK_SIZE, sizeof(PBVHVertRef), "boundary indices");
if (init_boundary_distances) {
@ -256,7 +256,7 @@ static void sculpt_boundary_indices_init(SculptSession *ss,
boundary->edges = MEM_malloc_arrayN(
BOUNDARY_INDICES_BLOCK_SIZE, sizeof(SculptBoundaryPreviewEdge), "boundary edges");
GSet *included_vertices = BLI_gset_int_new_ex("included vertices", BOUNDARY_INDICES_BLOCK_SIZE);
GSet *included_verts = BLI_gset_int_new_ex("included verts", BOUNDARY_INDICES_BLOCK_SIZE);
SculptFloodFill flood;
SCULPT_floodfill_init(ss, &flood);
@ -268,12 +268,12 @@ static void sculpt_boundary_indices_init(SculptSession *ss,
copy_v3_v3(boundary->initial_vertex_position,
SCULPT_vertex_co_get(ss, boundary->initial_vertex));
sculpt_boundary_index_add(
boundary, initial_boundary_vertex, initial_boundary_index, 0.0f, included_vertices);
boundary, initial_boundary_vertex, initial_boundary_index, 0.0f, included_verts);
SCULPT_floodfill_add_initial(&flood, boundary->initial_vertex);
BoundaryFloodFillData fdata = {
.boundary = boundary,
.included_vertices = included_vertices,
.included_verts = included_verts,
.last_visited_vertex = {BOUNDARY_VERTEX_NONE},
};
@ -286,7 +286,7 @@ static void sculpt_boundary_indices_init(SculptSession *ss,
sculpt_boundary_is_vertex_in_editable_boundary(ss, fdata.last_visited_vertex)) {
SculptVertexNeighborIter ni;
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, fdata.last_visited_vertex, ni) {
if (BLI_gset_haskey(included_vertices, POINTER_FROM_INT(ni.index)) &&
if (BLI_gset_haskey(included_verts, POINTER_FROM_INT(ni.index)) &&
sculpt_boundary_is_vertex_in_editable_boundary(ss, ni.vertex)) {
sculpt_boundary_preview_edge_add(boundary, fdata.last_visited_vertex, ni.vertex);
boundary->forms_loop = true;
@ -295,7 +295,7 @@ static void sculpt_boundary_indices_init(SculptSession *ss,
SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
}
BLI_gset_free(included_vertices, NULL);
BLI_gset_free(included_verts, NULL);
}
/**
@ -318,7 +318,7 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
for (int i = 0; i < totvert; i++) {
boundary->edit_info[i].original_vertex_i = BOUNDARY_VERTEX_NONE;
boundary->edit_info[i].num_propagation_steps = BOUNDARY_STEPS_NONE;
boundary->edit_info[i].propagation_steps_num = BOUNDARY_STEPS_NONE;
}
GSQueue *current_iteration = BLI_gsqueue_new(sizeof(PBVHVertRef));
@ -326,38 +326,38 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
/* Initialized the first iteration with the vertices already in the boundary. This is propagation
* step 0. */
BLI_bitmap *visited_vertices = BLI_BITMAP_NEW(SCULPT_vertex_count_get(ss), "visited_vertices");
for (int i = 0; i < boundary->num_vertices; i++) {
int index = BKE_pbvh_vertex_to_index(ss->pbvh, boundary->vertices[i]);
BLI_bitmap *visited_verts = BLI_BITMAP_NEW(SCULPT_vertex_count_get(ss), "visited_verts");
for (int i = 0; i < boundary->verts_num; i++) {
int index = BKE_pbvh_vertex_to_index(ss->pbvh, boundary->verts[i]);
boundary->edit_info[index].original_vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh,
boundary->vertices[i]);
boundary->edit_info[index].num_propagation_steps = 0;
boundary->verts[i]);
boundary->edit_info[index].propagation_steps_num = 0;
/* This ensures that all duplicate vertices in the boundary have the same original_vertex
* index, so the deformation for them will be the same. */
if (has_duplicates) {
SculptVertexNeighborIter ni_duplis;
SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN (ss, boundary->vertices[i], ni_duplis) {
SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN (ss, boundary->verts[i], ni_duplis) {
if (ni_duplis.is_duplicate) {
boundary->edit_info[ni_duplis.index].original_vertex_i = BKE_pbvh_vertex_to_index(
ss->pbvh, boundary->vertices[i]);
ss->pbvh, boundary->verts[i]);
}
}
SCULPT_VERTEX_NEIGHBORS_ITER_END(ni_duplis);
}
BLI_gsqueue_push(current_iteration, &boundary->vertices[i]);
BLI_gsqueue_push(current_iteration, &boundary->verts[i]);
}
int num_propagation_steps = 0;
int propagation_steps_num = 0;
float accum_distance = 0.0f;
while (true) {
/* Stop adding steps to edit info. This happens when a steps is further away from the boundary
* than the brush radius or when the entire mesh was already processed. */
if (accum_distance > radius || BLI_gsqueue_is_empty(current_iteration)) {
boundary->max_propagation_steps = num_propagation_steps;
boundary->max_propagation_steps = propagation_steps_num;
break;
}
@ -371,22 +371,22 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN (ss, from_v, ni) {
const bool is_visible = SCULPT_vertex_visible_get(ss, ni.vertex);
if (!is_visible ||
boundary->edit_info[ni.index].num_propagation_steps != BOUNDARY_STEPS_NONE) {
boundary->edit_info[ni.index].propagation_steps_num != BOUNDARY_STEPS_NONE) {
continue;
}
boundary->edit_info[ni.index].original_vertex_i =
boundary->edit_info[from_v_i].original_vertex_i;
BLI_BITMAP_ENABLE(visited_vertices, ni.index);
BLI_BITMAP_ENABLE(visited_verts, ni.index);
if (ni.is_duplicate) {
/* Grids duplicates handling. */
boundary->edit_info[ni.index].num_propagation_steps =
boundary->edit_info[from_v_i].num_propagation_steps;
boundary->edit_info[ni.index].propagation_steps_num =
boundary->edit_info[from_v_i].propagation_steps_num;
}
else {
boundary->edit_info[ni.index].num_propagation_steps =
boundary->edit_info[from_v_i].num_propagation_steps + 1;
boundary->edit_info[ni.index].propagation_steps_num =
boundary->edit_info[from_v_i].propagation_steps_num + 1;
BLI_gsqueue_push(next_iteration, &ni.vertex);
@ -400,8 +400,8 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
if (ni_duplis.is_duplicate) {
boundary->edit_info[ni_duplis.index].original_vertex_i =
boundary->edit_info[from_v_i].original_vertex_i;
boundary->edit_info[ni_duplis.index].num_propagation_steps =
boundary->edit_info[from_v_i].num_propagation_steps + 1;
boundary->edit_info[ni_duplis.index].propagation_steps_num =
boundary->edit_info[from_v_i].propagation_steps_num + 1;
}
}
SCULPT_VERTEX_NEIGHBORS_ITER_END(ni_duplis);
@ -428,10 +428,10 @@ static void sculpt_boundary_edit_data_init(SculptSession *ss,
BLI_gsqueue_push(current_iteration, &next_v);
}
num_propagation_steps++;
propagation_steps_num++;
}
MEM_SAFE_FREE(visited_vertices);
MEM_SAFE_FREE(visited_verts);
BLI_gsqueue_free(current_iteration);
BLI_gsqueue_free(next_iteration);
@ -449,9 +449,9 @@ static void sculpt_boundary_falloff_factor_init(SculptSession *ss,
BKE_curvemapping_init(brush->curve);
for (int i = 0; i < totvert; i++) {
if (boundary->edit_info[i].num_propagation_steps != -1) {
if (boundary->edit_info[i].propagation_steps_num != -1) {
boundary->edit_info[i].strength_factor = BKE_brush_curve_strength(
brush, boundary->edit_info[i].num_propagation_steps, boundary->max_propagation_steps);
brush, boundary->edit_info[i].propagation_steps_num, boundary->max_propagation_steps);
}
if (boundary->edit_info[i].original_vertex_i ==
@ -542,7 +542,7 @@ SculptBoundary *SCULPT_boundary_data_init(Object *object,
void SCULPT_boundary_data_free(SculptBoundary *boundary)
{
MEM_SAFE_FREE(boundary->vertices);
MEM_SAFE_FREE(boundary->verts);
MEM_SAFE_FREE(boundary->edges);
MEM_SAFE_FREE(boundary->distance);
MEM_SAFE_FREE(boundary->edit_info);
@ -564,7 +564,7 @@ static void sculpt_boundary_bend_data_init(SculptSession *ss, SculptBoundary *bo
boundary->bend.pivot_positions = MEM_calloc_arrayN(totvert, sizeof(float[3]), "pivot positions");
for (int i = 0; i < totvert; i++) {
if (boundary->edit_info[i].num_propagation_steps != boundary->max_propagation_steps) {
if (boundary->edit_info[i].propagation_steps_num != boundary->max_propagation_steps) {
continue;
}
@ -586,7 +586,7 @@ static void sculpt_boundary_bend_data_init(SculptSession *ss, SculptBoundary *bo
}
for (int i = 0; i < totvert; i++) {
if (boundary->edit_info[i].num_propagation_steps == BOUNDARY_STEPS_NONE) {
if (boundary->edit_info[i].propagation_steps_num == BOUNDARY_STEPS_NONE) {
continue;
}
copy_v3_v3(boundary->bend.pivot_positions[i],
@ -602,7 +602,7 @@ static void sculpt_boundary_slide_data_init(SculptSession *ss, SculptBoundary *b
boundary->slide.directions = MEM_calloc_arrayN(totvert, sizeof(float[3]), "slide directions");
for (int i = 0; i < totvert; i++) {
if (boundary->edit_info[i].num_propagation_steps != boundary->max_propagation_steps) {
if (boundary->edit_info[i].propagation_steps_num != boundary->max_propagation_steps) {
continue;
}
sub_v3_v3v3(
@ -614,7 +614,7 @@ static void sculpt_boundary_slide_data_init(SculptSession *ss, SculptBoundary *b
}
for (int i = 0; i < totvert; i++) {
if (boundary->edit_info[i].num_propagation_steps == BOUNDARY_STEPS_NONE) {
if (boundary->edit_info[i].propagation_steps_num == BOUNDARY_STEPS_NONE) {
continue;
}
copy_v3_v3(boundary->slide.directions[i],
@ -625,15 +625,14 @@ static void sculpt_boundary_slide_data_init(SculptSession *ss, SculptBoundary *b
static void sculpt_boundary_twist_data_init(SculptSession *ss, SculptBoundary *boundary)
{
zero_v3(boundary->twist.pivot_position);
float(*poly_verts)[3] = MEM_malloc_arrayN(
boundary->num_vertices, sizeof(float[3]), "poly verts");
for (int i = 0; i < boundary->num_vertices; i++) {
add_v3_v3(boundary->twist.pivot_position, SCULPT_vertex_co_get(ss, boundary->vertices[i]));
copy_v3_v3(poly_verts[i], SCULPT_vertex_co_get(ss, boundary->vertices[i]));
float(*poly_verts)[3] = MEM_malloc_arrayN(boundary->verts_num, sizeof(float[3]), "poly verts");
for (int i = 0; i < boundary->verts_num; i++) {
add_v3_v3(boundary->twist.pivot_position, SCULPT_vertex_co_get(ss, boundary->verts[i]));
copy_v3_v3(poly_verts[i], SCULPT_vertex_co_get(ss, boundary->verts[i]));
}
mul_v3_fl(boundary->twist.pivot_position, 1.0f / boundary->num_vertices);
mul_v3_fl(boundary->twist.pivot_position, 1.0f / boundary->verts_num);
if (boundary->forms_loop) {
normal_poly_v3(boundary->twist.rotation_axis, poly_verts, boundary->num_vertices);
normal_poly_v3(boundary->twist.rotation_axis, poly_verts, boundary->verts_num);
}
else {
sub_v3_v3v3(boundary->twist.rotation_axis,
@ -684,7 +683,7 @@ static void do_boundary_brush_bend_task_cb_ex(void *__restrict userdata,
const float angle = angle_factor * M_PI;
BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) {
if (boundary->edit_info[vd.index].num_propagation_steps == -1) {
if (boundary->edit_info[vd.index].propagation_steps_num == -1) {
continue;
}
@ -732,7 +731,7 @@ static void do_boundary_brush_slide_task_cb_ex(void *__restrict userdata,
const float disp = sculpt_boundary_displacement_from_grab_delta_get(ss, boundary);
BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) {
if (boundary->edit_info[vd.index].num_propagation_steps == -1) {
if (boundary->edit_info[vd.index].propagation_steps_num == -1) {
continue;
}
@ -778,7 +777,7 @@ static void do_boundary_brush_inflate_task_cb_ex(void *__restrict userdata,
const float disp = sculpt_boundary_displacement_from_grab_delta_get(ss, boundary);
BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) {
if (boundary->edit_info[vd.index].num_propagation_steps == -1) {
if (boundary->edit_info[vd.index].propagation_steps_num == -1) {
continue;
}
@ -822,7 +821,7 @@ static void do_boundary_brush_grab_task_cb_ex(void *__restrict userdata,
SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n], SCULPT_UNDO_COORDS);
BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) {
if (boundary->edit_info[vd.index].num_propagation_steps == -1) {
if (boundary->edit_info[vd.index].propagation_steps_num == -1) {
continue;
}
@ -873,7 +872,7 @@ static void do_boundary_brush_twist_task_cb_ex(void *__restrict userdata,
const float angle = angle_factor * M_PI;
BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) {
if (boundary->edit_info[vd.index].num_propagation_steps == -1) {
if (boundary->edit_info[vd.index].propagation_steps_num == -1) {
continue;
}
@ -919,7 +918,7 @@ static void do_boundary_brush_smooth_task_cb_ex(void *__restrict userdata,
SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n], SCULPT_UNDO_COORDS);
BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) {
if (boundary->edit_info[vd.index].num_propagation_steps == -1) {
if (boundary->edit_info[vd.index].propagation_steps_num == -1) {
continue;
}
@ -931,10 +930,10 @@ static void do_boundary_brush_smooth_task_cb_ex(void *__restrict userdata,
float coord_accum[3] = {0.0f, 0.0f, 0.0f};
int total_neighbors = 0;
const int current_propagation_steps = boundary->edit_info[vd.index].num_propagation_steps;
const int current_propagation_steps = boundary->edit_info[vd.index].propagation_steps_num;
SculptVertexNeighborIter ni;
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vd.vertex, ni) {
if (current_propagation_steps == boundary->edit_info[ni.index].num_propagation_steps) {
if (current_propagation_steps == boundary->edit_info[ni.index].propagation_steps_num) {
add_v3_v3(coord_accum, SCULPT_vertex_co_get(ss, ni.vertex));
total_neighbors++;
}
@ -1053,8 +1052,8 @@ void SCULPT_boundary_edges_preview_draw(const uint gpuattr,
}
immUniformColor3fvAlpha(outline_col, outline_alpha);
GPU_line_width(2.0f);
immBegin(GPU_PRIM_LINES, ss->boundary_preview->num_edges * 2);
for (int i = 0; i < ss->boundary_preview->num_edges; i++) {
immBegin(GPU_PRIM_LINES, ss->boundary_preview->edges_num * 2);
for (int i = 0; i < ss->boundary_preview->edges_num; i++) {
immVertex3fv(gpuattr, SCULPT_vertex_co_get(ss, ss->boundary_preview->edges[i].v1));
immVertex3fv(gpuattr, SCULPT_vertex_co_get(ss, ss->boundary_preview->edges[i].v2));
}

View File

@ -351,13 +351,13 @@ static float sculpt_expand_gradient_value_get(SculptSession *ss,
static BLI_bitmap *sculpt_expand_bitmap_from_enabled(SculptSession *ss, ExpandCache *expand_cache)
{
const int totvert = SCULPT_vertex_count_get(ss);
BLI_bitmap *enabled_vertices = BLI_BITMAP_NEW(totvert, "enabled vertices");
BLI_bitmap *enabled_verts = BLI_BITMAP_NEW(totvert, "enabled verts");
for (int i = 0; i < totvert; i++) {
const bool enabled = sculpt_expand_state_get(
ss, expand_cache, BKE_pbvh_index_to_vertex(ss->pbvh, i));
BLI_BITMAP_SET(enabled_vertices, i, enabled);
BLI_BITMAP_SET(enabled_verts, i, enabled);
}
return enabled_vertices;
return enabled_verts;
}
/**
@ -366,13 +366,13 @@ static BLI_bitmap *sculpt_expand_bitmap_from_enabled(SculptSession *ss, ExpandCa
* vertex that is not enabled.
*/
static BLI_bitmap *sculpt_expand_boundary_from_enabled(SculptSession *ss,
const BLI_bitmap *enabled_vertices,
const BLI_bitmap *enabled_verts,
const bool use_mesh_boundary)
{
const int totvert = SCULPT_vertex_count_get(ss);
BLI_bitmap *boundary_vertices = BLI_BITMAP_NEW(totvert, "boundary vertices");
BLI_bitmap *boundary_verts = BLI_BITMAP_NEW(totvert, "boundary verts");
for (int i = 0; i < totvert; i++) {
if (!BLI_BITMAP_TEST(enabled_vertices, i)) {
if (!BLI_BITMAP_TEST(enabled_verts, i)) {
continue;
}
@ -381,7 +381,7 @@ static BLI_bitmap *sculpt_expand_boundary_from_enabled(SculptSession *ss,
bool is_expand_boundary = false;
SculptVertexNeighborIter ni;
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, vertex, ni) {
if (!BLI_BITMAP_TEST(enabled_vertices, ni.index)) {
if (!BLI_BITMAP_TEST(enabled_verts, ni.index)) {
is_expand_boundary = true;
}
}
@ -391,10 +391,10 @@ static BLI_bitmap *sculpt_expand_boundary_from_enabled(SculptSession *ss,
is_expand_boundary = true;
}
BLI_BITMAP_SET(boundary_vertices, i, is_expand_boundary);
BLI_BITMAP_SET(boundary_verts, i, is_expand_boundary);
}
return boundary_vertices;
return boundary_verts;
}
/* Functions implementing different algorithms for initializing falloff values. */
@ -596,7 +596,7 @@ static float *sculpt_expand_boundary_topology_falloff_create(Object *ob, const P
SculptSession *ss = ob->sculpt;
const int totvert = SCULPT_vertex_count_get(ss);
float *dists = MEM_calloc_arrayN(totvert, sizeof(float), "spherical dist");
BLI_bitmap *visited_vertices = BLI_BITMAP_NEW(totvert, "visited vertices");
BLI_bitmap *visited_verts = BLI_BITMAP_NEW(totvert, "visited verts");
GSQueue *queue = BLI_gsqueue_new(sizeof(PBVHVertRef));
/* Search and initialize a boundary per symmetry pass, then mark those vertices as visited. */
@ -614,9 +614,9 @@ static float *sculpt_expand_boundary_topology_falloff_create(Object *ob, const P
continue;
}
for (int i = 0; i < boundary->num_vertices; i++) {
BLI_gsqueue_push(queue, &boundary->vertices[i]);
BLI_BITMAP_ENABLE(visited_vertices, boundary->vertices_i[i]);
for (int i = 0; i < boundary->verts_num; i++) {
BLI_gsqueue_push(queue, &boundary->verts[i]);
BLI_BITMAP_ENABLE(visited_verts, boundary->verts_i[i]);
}
SCULPT_boundary_data_free(boundary);
}
@ -635,18 +635,18 @@ static float *sculpt_expand_boundary_topology_falloff_create(Object *ob, const P
SculptVertexNeighborIter ni;
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, v_next, ni) {
if (BLI_BITMAP_TEST(visited_vertices, ni.index)) {
if (BLI_BITMAP_TEST(visited_verts, ni.index)) {
continue;
}
dists[ni.index] = dists[v_next_i] + 1.0f;
BLI_BITMAP_ENABLE(visited_vertices, ni.index);
BLI_BITMAP_ENABLE(visited_verts, ni.index);
BLI_gsqueue_push(queue, &ni.vertex);
}
SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
}
BLI_gsqueue_free(queue);
MEM_freeN(visited_vertices);
MEM_freeN(visited_verts);
return dists;
}
@ -669,7 +669,7 @@ static float *sculpt_expand_diagonals_falloff_create(Object *ob, const PBVHVertR
}
/* Search and mask as visited the initial vertices using the enabled symmetry passes. */
BLI_bitmap *visited_vertices = BLI_BITMAP_NEW(totvert, "visited vertices");
BLI_bitmap *visited_verts = BLI_BITMAP_NEW(totvert, "visited verts");
GSQueue *queue = BLI_gsqueue_new(sizeof(PBVHVertRef));
const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
for (char symm_it = 0; symm_it <= symm; symm_it++) {
@ -682,7 +682,7 @@ static float *sculpt_expand_diagonals_falloff_create(Object *ob, const PBVHVertR
int symm_vertex_i = BKE_pbvh_vertex_to_index(ss->pbvh, symm_vertex);
BLI_gsqueue_push(queue, &symm_vertex);
BLI_BITMAP_ENABLE(visited_vertices, symm_vertex_i);
BLI_BITMAP_ENABLE(visited_verts, symm_vertex_i);
}
if (BLI_gsqueue_is_empty(queue)) {
@ -700,18 +700,18 @@ static float *sculpt_expand_diagonals_falloff_create(Object *ob, const PBVHVertR
const MPoly *p = &ss->mpoly[ss->pmap[v_next_i].indices[j]];
for (int l = 0; l < p->totloop; l++) {
const PBVHVertRef neighbor_v = BKE_pbvh_make_vref(ss->mloop[p->loopstart + l].v);
if (BLI_BITMAP_TEST(visited_vertices, neighbor_v.i)) {
if (BLI_BITMAP_TEST(visited_verts, neighbor_v.i)) {
continue;
}
dists[neighbor_v.i] = dists[v_next_i] + 1.0f;
BLI_BITMAP_ENABLE(visited_vertices, neighbor_v.i);
BLI_BITMAP_ENABLE(visited_verts, neighbor_v.i);
BLI_gsqueue_push(queue, &neighbor_v);
}
}
}
BLI_gsqueue_free(queue);
MEM_freeN(visited_vertices);
MEM_freeN(visited_verts);
return dists;
}
@ -842,27 +842,27 @@ static void sculpt_expand_mesh_face_falloff_from_vertex_falloff(SculptSession *s
*/
static void sculpt_expand_geodesics_from_state_boundary(Object *ob,
ExpandCache *expand_cache,
BLI_bitmap *enabled_vertices)
BLI_bitmap *enabled_verts)
{
SculptSession *ss = ob->sculpt;
BLI_assert(BKE_pbvh_type(ss->pbvh) == PBVH_FACES);
GSet *initial_vertices = BLI_gset_int_new("initial_vertices");
BLI_bitmap *boundary_vertices = sculpt_expand_boundary_from_enabled(ss, enabled_vertices, false);
GSet *initial_verts = BLI_gset_int_new("initial_verts");
BLI_bitmap *boundary_verts = sculpt_expand_boundary_from_enabled(ss, enabled_verts, false);
const int totvert = SCULPT_vertex_count_get(ss);
for (int i = 0; i < totvert; i++) {
if (!BLI_BITMAP_TEST(boundary_vertices, i)) {
if (!BLI_BITMAP_TEST(boundary_verts, i)) {
continue;
}
BLI_gset_add(initial_vertices, POINTER_FROM_INT(i));
BLI_gset_add(initial_verts, POINTER_FROM_INT(i));
}
MEM_freeN(boundary_vertices);
MEM_freeN(boundary_verts);
MEM_SAFE_FREE(expand_cache->vert_falloff);
MEM_SAFE_FREE(expand_cache->face_falloff);
expand_cache->vert_falloff = SCULPT_geodesic_distances_create(ob, initial_vertices, FLT_MAX);
BLI_gset_free(initial_vertices, NULL);
expand_cache->vert_falloff = SCULPT_geodesic_distances_create(ob, initial_verts, FLT_MAX);
BLI_gset_free(initial_verts, NULL);
}
/**
@ -871,7 +871,7 @@ static void sculpt_expand_geodesics_from_state_boundary(Object *ob,
*/
static void sculpt_expand_topology_from_state_boundary(Object *ob,
ExpandCache *expand_cache,
BLI_bitmap *enabled_vertices)
BLI_bitmap *enabled_verts)
{
MEM_SAFE_FREE(expand_cache->vert_falloff);
MEM_SAFE_FREE(expand_cache->face_falloff);
@ -880,19 +880,19 @@ static void sculpt_expand_topology_from_state_boundary(Object *ob,
const int totvert = SCULPT_vertex_count_get(ss);
float *dists = MEM_calloc_arrayN(totvert, sizeof(float), "topology dist");
BLI_bitmap *boundary_vertices = sculpt_expand_boundary_from_enabled(ss, enabled_vertices, false);
BLI_bitmap *boundary_verts = sculpt_expand_boundary_from_enabled(ss, enabled_verts, false);
SculptFloodFill flood;
SCULPT_floodfill_init(ss, &flood);
for (int i = 0; i < totvert; i++) {
if (!BLI_BITMAP_TEST(boundary_vertices, i)) {
if (!BLI_BITMAP_TEST(boundary_verts, i)) {
continue;
}
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
SCULPT_floodfill_add_and_skip_initial(&flood, vertex);
}
MEM_freeN(boundary_vertices);
MEM_freeN(boundary_verts);
ExpandFloodFillData fdata;
fdata.dists = dists;
@ -914,7 +914,7 @@ static void sculpt_expand_resursion_step_add(Object *ob,
return;
}
BLI_bitmap *enabled_vertices = sculpt_expand_bitmap_from_enabled(ss, expand_cache);
BLI_bitmap *enabled_verts = sculpt_expand_bitmap_from_enabled(ss, expand_cache);
/* Each time a new recursion step is created, reset the distortion strength. This is the expected
* result from the recursion, as otherwise the new falloff will render with undesired distortion
@ -923,10 +923,10 @@ static void sculpt_expand_resursion_step_add(Object *ob,
switch (recursion_type) {
case SCULPT_EXPAND_RECURSION_GEODESICS:
sculpt_expand_geodesics_from_state_boundary(ob, expand_cache, enabled_vertices);
sculpt_expand_geodesics_from_state_boundary(ob, expand_cache, enabled_verts);
break;
case SCULPT_EXPAND_RECURSION_TOPOLOGY:
sculpt_expand_topology_from_state_boundary(ob, expand_cache, enabled_vertices);
sculpt_expand_topology_from_state_boundary(ob, expand_cache, enabled_verts);
break;
}
@ -936,7 +936,7 @@ static void sculpt_expand_resursion_step_add(Object *ob,
sculpt_expand_update_max_face_falloff_factor(ss, expand_cache);
}
MEM_freeN(enabled_vertices);
MEM_freeN(enabled_verts);
}
/* Face Set Boundary falloff. */
@ -953,7 +953,7 @@ static void sculpt_expand_initialize_from_face_set_boundary(Object *ob,
SculptSession *ss = ob->sculpt;
const int totvert = SCULPT_vertex_count_get(ss);
BLI_bitmap *enabled_vertices = BLI_BITMAP_NEW(totvert, "enabled vertices");
BLI_bitmap *enabled_verts = BLI_BITMAP_NEW(totvert, "enabled verts");
for (int i = 0; i < totvert; i++) {
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
@ -963,17 +963,17 @@ static void sculpt_expand_initialize_from_face_set_boundary(Object *ob,
if (!SCULPT_vertex_has_face_set(ss, vertex, active_face_set)) {
continue;
}
BLI_BITMAP_ENABLE(enabled_vertices, i);
BLI_BITMAP_ENABLE(enabled_verts, i);
}
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
sculpt_expand_geodesics_from_state_boundary(ob, expand_cache, enabled_vertices);
sculpt_expand_geodesics_from_state_boundary(ob, expand_cache, enabled_verts);
}
else {
sculpt_expand_topology_from_state_boundary(ob, expand_cache, enabled_vertices);
sculpt_expand_topology_from_state_boundary(ob, expand_cache, enabled_verts);
}
MEM_freeN(enabled_vertices);
MEM_freeN(enabled_verts);
if (internal_falloff) {
for (int i = 0; i < totvert; i++) {
@ -1086,7 +1086,7 @@ static void sculpt_expand_snap_initialize_from_enabled(SculptSession *ss,
expand_cache->snap = false;
expand_cache->invert = false;
BLI_bitmap *enabled_vertices = sculpt_expand_bitmap_from_enabled(ss, expand_cache);
BLI_bitmap *enabled_verts = sculpt_expand_bitmap_from_enabled(ss, expand_cache);
const int totface = ss->totfaces;
for (int i = 0; i < totface; i++) {
@ -1099,7 +1099,7 @@ static void sculpt_expand_snap_initialize_from_enabled(SculptSession *ss,
bool any_disabled = false;
for (int l = 0; l < poly->totloop; l++) {
const MLoop *loop = &ss->mloop[l + poly->loopstart];
if (!BLI_BITMAP_TEST(enabled_vertices, loop->v)) {
if (!BLI_BITMAP_TEST(enabled_verts, loop->v)) {
any_disabled = true;
break;
}
@ -1110,7 +1110,7 @@ static void sculpt_expand_snap_initialize_from_enabled(SculptSession *ss,
}
}
MEM_freeN(enabled_vertices);
MEM_freeN(enabled_verts);
expand_cache->snap = prev_snap_state;
expand_cache->invert = prev_invert_state;
}
@ -1514,7 +1514,7 @@ static void sculpt_expand_reposition_pivot(bContext *C, Object *ob, ExpandCache
const bool initial_invert_state = expand_cache->invert;
expand_cache->invert = false;
BLI_bitmap *enabled_vertices = sculpt_expand_bitmap_from_enabled(ss, expand_cache);
BLI_bitmap *enabled_verts = sculpt_expand_bitmap_from_enabled(ss, expand_cache);
/* For boundary topology, position the pivot using only the boundary of the enabled vertices,
* without taking mesh boundary into account. This allows to create deformations like bending the
@ -1522,8 +1522,8 @@ static void sculpt_expand_reposition_pivot(bContext *C, Object *ob, ExpandCache
const float use_mesh_boundary = expand_cache->falloff_type !=
SCULPT_EXPAND_FALLOFF_BOUNDARY_TOPOLOGY;
BLI_bitmap *boundary_vertices = sculpt_expand_boundary_from_enabled(
ss, enabled_vertices, use_mesh_boundary);
BLI_bitmap *boundary_verts = sculpt_expand_boundary_from_enabled(
ss, enabled_verts, use_mesh_boundary);
/* Ignore invert state, as this is the expected behavior in most cases and mask are created in
* inverted state by default. */
@ -1537,7 +1537,7 @@ static void sculpt_expand_reposition_pivot(bContext *C, Object *ob, ExpandCache
for (int i = 0; i < totvert; i++) {
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
if (!BLI_BITMAP_TEST(boundary_vertices, i)) {
if (!BLI_BITMAP_TEST(boundary_verts, i)) {
continue;
}
@ -1555,8 +1555,8 @@ static void sculpt_expand_reposition_pivot(bContext *C, Object *ob, ExpandCache
total++;
}
MEM_freeN(enabled_vertices);
MEM_freeN(boundary_vertices);
MEM_freeN(enabled_verts);
MEM_freeN(boundary_verts);
if (total > 0) {
mul_v3_v3fl(ss->pivot_pos, avg, 1.0f / total);

View File

@ -746,7 +746,7 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op)
SCULPT_undo_push_end(ob);
/* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */
SCULPT_visibility_sync_all_face_sets_to_vertices(ob);
SCULPT_visibility_sync_all_face_sets_to_verts(ob);
for (int i = 0; i < totnode; i++) {
BKE_pbvh_node_mark_update_visibility(nodes[i]);
@ -933,7 +933,7 @@ static int sculpt_face_sets_change_visibility_exec(bContext *C, wmOperator *op)
}
/* Sync face sets visibility and vertex visibility. */
SCULPT_visibility_sync_all_face_sets_to_vertices(ob);
SCULPT_visibility_sync_all_face_sets_to_verts(ob);
SCULPT_undo_push_end(ob);
@ -1233,21 +1233,21 @@ static void sculpt_face_set_edit_fair_face_set(Object *ob,
const int totvert = SCULPT_vertex_count_get(ss);
Mesh *mesh = ob->data;
bool *fair_vertices = MEM_malloc_arrayN(totvert, sizeof(bool), "fair vertices");
bool *fair_verts = MEM_malloc_arrayN(totvert, sizeof(bool), "fair vertices");
SCULPT_boundary_info_ensure(ob);
for (int i = 0; i < totvert; i++) {
PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
fair_vertices[i] = !SCULPT_vertex_is_boundary(ss, vertex) &&
SCULPT_vertex_has_face_set(ss, vertex, active_face_set_id) &&
SCULPT_vertex_has_unique_face_set(ss, vertex);
fair_verts[i] = !SCULPT_vertex_is_boundary(ss, vertex) &&
SCULPT_vertex_has_face_set(ss, vertex, active_face_set_id) &&
SCULPT_vertex_has_unique_face_set(ss, vertex);
}
MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss);
BKE_mesh_prefair_and_fair_vertices(mesh, mvert, fair_vertices, fair_order);
MEM_freeN(fair_vertices);
BKE_mesh_prefair_and_fair_verts(mesh, mvert, fair_verts, fair_order);
MEM_freeN(fair_verts);
}
static void sculpt_face_set_apply_edit(Object *ob,
@ -1339,7 +1339,7 @@ static void face_set_edit_do_post_visibility_updates(Object *ob, PBVHNode **node
PBVH *pbvh = ss->pbvh;
/* Sync face sets visibility and vertex visibility as now all Face Sets are visible. */
SCULPT_visibility_sync_all_face_sets_to_vertices(ob);
SCULPT_visibility_sync_all_face_sets_to_verts(ob);
for (int i = 0; i < totnode; i++) {
BKE_pbvh_node_mark_update_visibility(nodes[i]);

View File

@ -61,9 +61,9 @@
/* Propagate distance from v1 and v2 to v0. */
static bool sculpt_geodesic_mesh_test_dist_add(
MVert *mvert, const int v0, const int v1, const int v2, float *dists, GSet *initial_vertices)
MVert *mvert, const int v0, const int v1, const int v2, float *dists, GSet *initial_verts)
{
if (BLI_gset_haskey(initial_vertices, POINTER_FROM_INT(v0))) {
if (BLI_gset_haskey(initial_verts, POINTER_FROM_INT(v0))) {
return false;
}
@ -96,7 +96,7 @@ static bool sculpt_geodesic_mesh_test_dist_add(
}
static float *SCULPT_geodesic_mesh_create(Object *ob,
GSet *initial_vertices,
GSet *initial_verts,
const float limit_radius)
{
SculptSession *ss = ob->sculpt;
@ -137,7 +137,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
BLI_LINKSTACK_INIT(queue_next);
for (int i = 0; i < totvert; i++) {
if (BLI_gset_haskey(initial_vertices, POINTER_FROM_INT(i))) {
if (BLI_gset_haskey(initial_verts, POINTER_FROM_INT(i))) {
dists[i] = 0.0f;
}
else {
@ -159,7 +159,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
/* This is an O(n^2) loop used to limit the geodesic distance calculation to a radius. When
* this optimization is needed, it is expected for the tool to request the distance to a low
* number of vertices (usually just 1 or 2). */
GSET_ITER (gs_iter, initial_vertices) {
GSET_ITER (gs_iter, initial_verts) {
const int v = POINTER_AS_INT(BLI_gsetIterator_getKey(&gs_iter));
float *v_co = verts[v].co;
for (int i = 0; i < totvert; i++) {
@ -193,7 +193,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
SWAP(int, v1, v2);
}
sculpt_geodesic_mesh_test_dist_add(
verts, v2, v1, SCULPT_GEODESIC_VERTEX_NONE, dists, initial_vertices);
verts, v2, v1, SCULPT_GEODESIC_VERTEX_NONE, dists, initial_verts);
}
if (ss->epmap[e].count != 0) {
@ -210,8 +210,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
if (ELEM(v_other, v1, v2)) {
continue;
}
if (sculpt_geodesic_mesh_test_dist_add(
verts, v_other, v1, v2, dists, initial_vertices)) {
if (sculpt_geodesic_mesh_test_dist_add(verts, v_other, v1, v2, dists, initial_verts)) {
for (int edge_map_index = 0; edge_map_index < ss->vemap[v_other].count;
edge_map_index++) {
const int e_other = ss->vemap[v_other].indices[edge_map_index];
@ -258,7 +257,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
/* For sculpt mesh data that does not support a geodesic distances algorithm, fallback to the
* distance to each vertex. In this case, only one of the initial vertices will be used to
* calculate the distance. */
static float *SCULPT_geodesic_fallback_create(Object *ob, GSet *initial_vertices)
static float *SCULPT_geodesic_fallback_create(Object *ob, GSet *initial_verts)
{
SculptSession *ss = ob->sculpt;
@ -267,7 +266,7 @@ static float *SCULPT_geodesic_fallback_create(Object *ob, GSet *initial_vertices
float *dists = MEM_malloc_arrayN(totvert, sizeof(float), "distances");
int first_affected = SCULPT_GEODESIC_VERTEX_NONE;
GSetIterator gs_iter;
GSET_ITER (gs_iter, initial_vertices) {
GSET_ITER (gs_iter, initial_verts) {
first_affected = POINTER_AS_INT(BLI_gsetIterator_getKey(&gs_iter));
break;
}
@ -290,17 +289,15 @@ static float *SCULPT_geodesic_fallback_create(Object *ob, GSet *initial_vertices
return dists;
}
float *SCULPT_geodesic_distances_create(Object *ob,
GSet *initial_vertices,
const float limit_radius)
float *SCULPT_geodesic_distances_create(Object *ob, GSet *initial_verts, const float limit_radius)
{
SculptSession *ss = ob->sculpt;
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
return SCULPT_geodesic_mesh_create(ob, initial_vertices, limit_radius);
return SCULPT_geodesic_mesh_create(ob, initial_verts, limit_radius);
case PBVH_BMESH:
case PBVH_GRIDS:
return SCULPT_geodesic_fallback_create(ob, initial_vertices);
return SCULPT_geodesic_fallback_create(ob, initial_verts);
}
BLI_assert(false);
return NULL;
@ -312,7 +309,7 @@ float *SCULPT_geodesic_from_vertex_and_symm(Sculpt *sd,
const float limit_radius)
{
SculptSession *ss = ob->sculpt;
GSet *initial_vertices = BLI_gset_int_new("initial_vertices");
GSet *initial_verts = BLI_gset_int_new("initial_verts");
const char symm = SCULPT_mesh_symmetry_xyz_get(ob);
for (char i = 0; i <= symm; ++i) {
@ -328,22 +325,22 @@ float *SCULPT_geodesic_from_vertex_and_symm(Sculpt *sd,
v = SCULPT_nearest_vertex_get(sd, ob, location, FLT_MAX, false);
}
if (v.i != PBVH_REF_NONE) {
BLI_gset_add(initial_vertices, POINTER_FROM_INT(BKE_pbvh_vertex_to_index(ss->pbvh, v)));
BLI_gset_add(initial_verts, POINTER_FROM_INT(BKE_pbvh_vertex_to_index(ss->pbvh, v)));
}
}
}
float *dists = SCULPT_geodesic_distances_create(ob, initial_vertices, limit_radius);
BLI_gset_free(initial_vertices, NULL);
float *dists = SCULPT_geodesic_distances_create(ob, initial_verts, limit_radius);
BLI_gset_free(initial_verts, NULL);
return dists;
}
float *SCULPT_geodesic_from_vertex(Object *ob, const PBVHVertRef vertex, const float limit_radius)
{
GSet *initial_vertices = BLI_gset_int_new("initial_vertices");
BLI_gset_add(initial_vertices,
GSet *initial_verts = BLI_gset_int_new("initial_verts");
BLI_gset_add(initial_verts,
POINTER_FROM_INT(BKE_pbvh_vertex_to_index(ob->sculpt->pbvh, vertex)));
float *dists = SCULPT_geodesic_distances_create(ob, initial_vertices, limit_radius);
BLI_gset_free(initial_vertices, NULL);
float *dists = SCULPT_geodesic_distances_create(ob, initial_verts, limit_radius);
BLI_gset_free(initial_verts, NULL);
return dists;
}

View File

@ -97,7 +97,7 @@ typedef struct {
/* Flood Fill. */
typedef struct {
GSQueue *queue;
BLI_bitmap *visited_vertices;
BLI_bitmap *visited_verts;
} SculptFloodFill;
typedef enum eBoundaryAutomaskMode {
@ -1005,7 +1005,7 @@ void SCULPT_connected_components_ensure(Object *ob);
void SCULPT_vertex_visible_set(SculptSession *ss, PBVHVertRef vertex, bool visible);
bool SCULPT_vertex_visible_get(SculptSession *ss, PBVHVertRef vertex);
void SCULPT_visibility_sync_all_face_sets_to_vertices(struct Object *ob);
void SCULPT_visibility_sync_all_face_sets_to_verts(struct Object *ob);
void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss);
/** \} */

View File

@ -571,49 +571,48 @@ void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float
float brush_co[3];
copy_v3_v3(brush_co, SCULPT_active_vertex_co_get(ss));
BLI_bitmap *visited_vertices = BLI_BITMAP_NEW(SCULPT_vertex_count_get(ss), "visited_vertices");
BLI_bitmap *visited_verts = BLI_BITMAP_NEW(SCULPT_vertex_count_get(ss), "visited_verts");
/* Assuming an average of 6 edges per vertex in a triangulated mesh. */
const int max_preview_vertices = SCULPT_vertex_count_get(ss) * 3 * 2;
const int max_preview_verts = SCULPT_vertex_count_get(ss) * 3 * 2;
if (ss->preview_vert_list == NULL) {
ss->preview_vert_list = MEM_callocN(max_preview_vertices * sizeof(PBVHVertRef),
"preview lines");
ss->preview_vert_list = MEM_callocN(max_preview_verts * sizeof(PBVHVertRef), "preview lines");
}
GSQueue *not_visited_vertices = BLI_gsqueue_new(sizeof(PBVHVertRef));
GSQueue *non_visited_verts = BLI_gsqueue_new(sizeof(PBVHVertRef));
PBVHVertRef active_v = SCULPT_active_vertex_get(ss);
BLI_gsqueue_push(not_visited_vertices, &active_v);
BLI_gsqueue_push(non_visited_verts, &active_v);
while (!BLI_gsqueue_is_empty(not_visited_vertices)) {
while (!BLI_gsqueue_is_empty(non_visited_verts)) {
PBVHVertRef from_v;
BLI_gsqueue_pop(not_visited_vertices, &from_v);
BLI_gsqueue_pop(non_visited_verts, &from_v);
SculptVertexNeighborIter ni;
SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN (ss, from_v, ni) {
if (totpoints + (ni.size * 2) < max_preview_vertices) {
if (totpoints + (ni.size * 2) < max_preview_verts) {
PBVHVertRef to_v = ni.vertex;
int to_v_i = ni.index;
ss->preview_vert_list[totpoints] = from_v;
totpoints++;
ss->preview_vert_list[totpoints] = to_v;
totpoints++;
if (BLI_BITMAP_TEST(visited_vertices, to_v_i)) {
if (BLI_BITMAP_TEST(visited_verts, to_v_i)) {
continue;
}
BLI_BITMAP_ENABLE(visited_vertices, to_v_i);
BLI_BITMAP_ENABLE(visited_verts, to_v_i);
const float *co = SCULPT_vertex_co_for_grab_active_get(ss, to_v);
if (len_squared_v3v3(brush_co, co) < radius * radius) {
BLI_gsqueue_push(not_visited_vertices, &to_v);
BLI_gsqueue_push(non_visited_verts, &to_v);
}
}
}
SCULPT_VERTEX_NEIGHBORS_ITER_END(ni);
}
BLI_gsqueue_free(not_visited_vertices);
BLI_gsqueue_free(non_visited_verts);
MEM_freeN(visited_vertices);
MEM_freeN(visited_verts);
ss->preview_vert_count = totpoints;
}

View File

@ -168,9 +168,9 @@ struct PartialUpdateData {
PBVH *pbvh;
bool rebuild;
char *modified_grids;
bool *modified_hidden_vertices;
bool *modified_mask_vertices;
bool *modified_color_vertices;
bool *modified_hidden_verts;
bool *modified_mask_verts;
bool *modified_color_verts;
};
/**
@ -201,25 +201,25 @@ static void update_cb_partial(PBVHNode *node, void *userdata)
const int *vert_indices;
BKE_pbvh_node_num_verts(data->pbvh, node, NULL, &verts_num);
BKE_pbvh_node_get_verts(data->pbvh, node, &vert_indices, NULL);
if (data->modified_mask_vertices != NULL) {
if (data->modified_mask_verts != NULL) {
for (int i = 0; i < verts_num; i++) {
if (data->modified_mask_vertices[vert_indices[i]]) {
if (data->modified_mask_verts[vert_indices[i]]) {
BKE_pbvh_node_mark_update_mask(node);
break;
}
}
}
if (data->modified_color_vertices != NULL) {
if (data->modified_color_verts != NULL) {
for (int i = 0; i < verts_num; i++) {
if (data->modified_color_vertices[vert_indices[i]]) {
if (data->modified_color_verts[vert_indices[i]]) {
BKE_pbvh_node_mark_update_color(node);
break;
}
}
}
if (data->modified_hidden_vertices != NULL) {
if (data->modified_hidden_verts != NULL) {
for (int i = 0; i < verts_num; i++) {
if (data->modified_hidden_vertices[vert_indices[i]]) {
if (data->modified_hidden_verts[vert_indices[i]]) {
if (data->rebuild) {
BKE_pbvh_node_mark_update_visibility(node);
}
@ -755,7 +755,7 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
BKE_sculpt_update_object_for_edit(depsgraph, ob, true, need_mask, false);
SCULPT_visibility_sync_all_face_sets_to_vertices(ob);
SCULPT_visibility_sync_all_face_sets_to_verts(ob);
BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateVisibility);
@ -790,9 +790,9 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
/* The PBVH already keeps track of which vertices need updated normals, but it doesn't keep track
* of other updated. In order to tell the corresponding PBVH nodes to update, keep track of which
* elements were updated for specific layers. */
bool *modified_hidden_vertices = NULL;
bool *modified_mask_vertices = NULL;
bool *modified_color_vertices = NULL;
bool *modified_hidden_verts = NULL;
bool *modified_mask_verts = NULL;
bool *modified_color_verts = NULL;
char *undo_modified_grids = NULL;
bool use_multires_undo = false;
@ -825,19 +825,19 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
}
break;
case SCULPT_UNDO_HIDDEN:
if (modified_hidden_vertices == NULL) {
modified_hidden_vertices = MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__);
if (modified_hidden_verts == NULL) {
modified_hidden_verts = MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__);
}
if (sculpt_undo_restore_hidden(C, unode, modified_hidden_vertices)) {
if (sculpt_undo_restore_hidden(C, unode, modified_hidden_verts)) {
rebuild = true;
update_visibility = true;
}
break;
case SCULPT_UNDO_MASK:
if (modified_mask_vertices == NULL) {
modified_mask_vertices = MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__);
if (modified_mask_verts == NULL) {
modified_mask_verts = MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__);
}
if (sculpt_undo_restore_mask(C, unode, modified_mask_vertices)) {
if (sculpt_undo_restore_mask(C, unode, modified_mask_verts)) {
update = true;
update_mask = true;
}
@ -845,10 +845,10 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
case SCULPT_UNDO_FACE_SETS:
break;
case SCULPT_UNDO_COLOR:
if (modified_color_vertices == NULL) {
modified_color_vertices = MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__);
if (modified_color_verts == NULL) {
modified_color_verts = MEM_calloc_arrayN(ss->totvert, sizeof(bool), __func__);
}
if (sculpt_undo_restore_color(C, unode, modified_color_vertices)) {
if (sculpt_undo_restore_color(C, unode, modified_color_verts)) {
update = true;
}
@ -899,9 +899,9 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
.rebuild = rebuild,
.pbvh = ss->pbvh,
.modified_grids = undo_modified_grids,
.modified_hidden_vertices = modified_hidden_vertices,
.modified_mask_vertices = modified_mask_vertices,
.modified_color_vertices = modified_color_vertices,
.modified_hidden_verts = modified_hidden_verts,
.modified_mask_verts = modified_mask_verts,
.modified_color_verts = modified_color_verts,
};
BKE_pbvh_search_callback(ss->pbvh, NULL, NULL, update_cb_partial, &data);
BKE_pbvh_update_bounds(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw);
@ -947,9 +947,9 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
}
}
MEM_SAFE_FREE(modified_hidden_vertices);
MEM_SAFE_FREE(modified_mask_vertices);
MEM_SAFE_FREE(modified_color_vertices);
MEM_SAFE_FREE(modified_hidden_verts);
MEM_SAFE_FREE(modified_mask_verts);
MEM_SAFE_FREE(modified_color_verts);
MEM_SAFE_FREE(undo_modified_grids);
}

View File

@ -345,7 +345,7 @@ static void stats_object_sculpt(const Object *ob, SceneStats *stats)
stats->tottri = ob->sculpt->bm->totface;
break;
case PBVH_GRIDS:
stats->totvertsculpt = BKE_pbvh_get_grid_num_vertices(ss->pbvh);
stats->totvertsculpt = BKE_pbvh_get_grid_num_verts(ss->pbvh);
stats->totfacesculpt = BKE_pbvh_get_grid_num_faces(ss->pbvh);
break;
}

View File

@ -276,7 +276,7 @@ IndexMask GeometryDataSource::apply_selection_filter(Vector<int64_t> &indices) c
BLI_assert(object_eval_->mode == OB_MODE_EDIT);
Object *object_orig = DEG_get_original_object(object_eval_);
const Mesh *mesh_eval = geometry_set_.get_mesh_for_read();
const bke::AttributeAccessor attributes_eval = bke::mesh_attributes(*mesh_eval);
const bke::AttributeAccessor attributes_eval = mesh_eval->attributes();
Mesh *mesh_orig = (Mesh *)object_orig->data;
BMesh *bm = mesh_orig->edit_mesh->bm;
BM_mesh_elem_table_ensure(bm, BM_VERT);

View File

@ -340,7 +340,7 @@ static bool edbm_backbuf_check_and_select_verts_obmode(Mesh *me,
const BLI_bitmap *select_bitmap = esel->select_bitmap;
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
bke::SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_span<bool>(
".selection_vert", ATTR_DOMAIN_POINT);
const VArray<bool> hide_vert = attributes.lookup_or_default<bool>(
@ -371,7 +371,7 @@ static bool edbm_backbuf_check_and_select_faces_obmode(Mesh *me,
const BLI_bitmap *select_bitmap = esel->select_bitmap;
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
bke::SpanAttributeWriter<bool> selection_poly = attributes.lookup_or_add_for_write_span<bool>(
".selection_poly", ATTR_DOMAIN_FACE);
const VArray<bool> hide_poly = attributes.lookup_or_default<bool>(
@ -1219,7 +1219,7 @@ static bool do_lasso_select_paintvert(ViewContext *vc,
}
}
else {
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
bke::SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_span<bool>(
".selection_vert", ATTR_DOMAIN_POINT);
@ -2837,7 +2837,7 @@ static bool ed_wpaint_vertex_select_pick(bContext *C,
bool found = ED_mesh_pick_vert(C, obact, mval, ED_MESH_PICK_DEFAULT_VERT_DIST, use_zbuf, &index);
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
bke::AttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write<bool>(
".selection_vert", ATTR_DOMAIN_POINT);
@ -3176,7 +3176,7 @@ static bool do_paintvert_box_select(ViewContext *vc,
}
}
else {
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
bke::SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_span<bool>(
".selection_vert", ATTR_DOMAIN_POINT);
@ -4197,7 +4197,7 @@ static bool paint_vertsel_circle_select(ViewContext *vc,
}
}
else {
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*me);
bke::MutableAttributeAccessor attributes = me->attributes_for_write();
bke::SpanAttributeWriter<bool> selection_vert = attributes.lookup_or_add_for_write_span<bool>(
".selection_vert", ATTR_DOMAIN_POINT);

View File

@ -82,7 +82,6 @@ set(SRC
../include/ED_transform.h
../include/ED_transform_snap_object_context.h
../include/ED_transverts.h
../include/ED_types.h
../include/ED_undo.h
../include/ED_userpref.h
../include/ED_util.h

View File

@ -505,9 +505,8 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
FrsMaterial tmpMat;
const blender::VArray<int> material_indices =
blender::bke::mesh_attributes(*me).lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
const blender::VArray<int> material_indices = me->attributes().lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
// We parse the vlak nodes again and import meshes while applying the clipping
// by the near and far view planes.

View File

@ -576,7 +576,7 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
mesh->totloop = group->totloop;
mesh->totcol = group->materials.size();
MVert *vertices = (MVert *)CustomData_add_layer(
MVert *verts = (MVert *)CustomData_add_layer(
&mesh->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, mesh->totvert);
MEdge *edges = (MEdge *)CustomData_add_layer(
&mesh->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, mesh->totedge);
@ -663,19 +663,19 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
else {
if (!visible) {
// first vertex
vertices->co[0] = svRep[0]->point2d()[0];
vertices->co[1] = svRep[0]->point2d()[1];
vertices->co[2] = get_stroke_vertex_z();
verts->co[0] = svRep[0]->point2d()[0];
verts->co[1] = svRep[0]->point2d()[1];
verts->co[2] = get_stroke_vertex_z();
++vertices;
++verts;
++vertex_index;
// second vertex
vertices->co[0] = svRep[1]->point2d()[0];
vertices->co[1] = svRep[1]->point2d()[1];
vertices->co[2] = get_stroke_vertex_z();
verts->co[0] = svRep[1]->point2d()[0];
verts->co[1] = svRep[1]->point2d()[1];
verts->co[2] = get_stroke_vertex_z();
++vertices;
++verts;
++vertex_index;
// first edge
@ -687,10 +687,10 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
visible = true;
// vertex
vertices->co[0] = svRep[2]->point2d()[0];
vertices->co[1] = svRep[2]->point2d()[1];
vertices->co[2] = get_stroke_vertex_z();
++vertices;
verts->co[0] = svRep[2]->point2d()[0];
verts->co[1] = svRep[2]->point2d()[1];
verts->co[2] = get_stroke_vertex_z();
++verts;
++vertex_index;
// edges

View File

@ -54,7 +54,7 @@ struct CuboidConfig {
}
};
static void calculate_vertices(const CuboidConfig &config, MutableSpan<MVert> verts)
static void calculate_verts(const CuboidConfig &config, MutableSpan<MVert> verts)
{
const float z_bottom = -config.size.z / 2.0f;
const float z_delta = config.size.z / config.edges_z;
@ -321,7 +321,7 @@ static void calculate_polys(const CuboidConfig &config,
static void calculate_uvs(const CuboidConfig &config, Mesh *mesh, const bke::AttributeIDRef &uv_id)
{
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh);
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<float2> uv_attribute =
attributes.lookup_or_add_for_write_only_span<float2>(uv_id, ATTR_DOMAIN_CORNER);
MutableSpan<float2> uvs = uv_attribute.span;
@ -409,7 +409,7 @@ Mesh *create_cuboid_mesh(const float3 &size,
MutableSpan<MPoly> polys = mesh->polys_for_write();
MutableSpan<MLoop> loops = mesh->loops_for_write();
calculate_vertices(config, verts);
calculate_verts(config, verts);
calculate_polys(config, polys, loops);
BKE_mesh_calc_edges(mesh, false, false);

View File

@ -44,7 +44,7 @@ bke::CurvesGeometry create_curve_from_vert_indices(const Mesh &mesh,
curves.cyclic_for_write().fill(false);
curves.cyclic_for_write().slice(cyclic_curves).fill(true);
const bke::AttributeAccessor mesh_attributes = bke::mesh_attributes(mesh);
const bke::AttributeAccessor mesh_attributes = mesh.attributes();
bke::MutableAttributeAccessor curves_attributes = curves.attributes_for_write();
Set<bke::AttributeIDRef> source_attribute_ids = mesh_attributes.all_ids();

View File

@ -16,7 +16,7 @@ namespace blender::geometry {
/* This class follows the MeshDataAdapter interface from openvdb. */
class OpenVDBMeshAdapter {
private:
Span<MVert> vertices_;
Span<MVert> verts_;
Span<MLoop> loops_;
Span<MLoopTri> looptris_;
float4x4 transform_;
@ -30,7 +30,7 @@ class OpenVDBMeshAdapter {
};
OpenVDBMeshAdapter::OpenVDBMeshAdapter(const Mesh &mesh, float4x4 transform)
: vertices_(mesh.verts()), loops_(mesh.loops()), transform_(transform)
: verts_(mesh.verts()), loops_(mesh.loops()), transform_(transform)
{
/* This only updates a cache and can be considered to be logically const. */
const MLoopTri *looptris = BKE_mesh_runtime_looptri_ensure(&mesh);
@ -45,7 +45,7 @@ size_t OpenVDBMeshAdapter::polygonCount() const
size_t OpenVDBMeshAdapter::pointCount() const
{
return static_cast<size_t>(vertices_.size());
return static_cast<size_t>(verts_.size());
}
size_t OpenVDBMeshAdapter::vertexCount(size_t UNUSED(polygon_index)) const
@ -59,7 +59,7 @@ void OpenVDBMeshAdapter::getIndexSpacePoint(size_t polygon_index,
openvdb::Vec3d &pos) const
{
const MLoopTri &looptri = looptris_[polygon_index];
const MVert &vertex = vertices_[loops_[looptri.tri[vertex_index]].v];
const MVert &vertex = verts_[loops_[looptri.tri[vertex_index]].v];
const float3 transformed_co = transform_ * float3(vertex.co);
pos = &transformed_co.x;
}

View File

@ -17,7 +17,7 @@ PointCloud *point_merge_by_distance(const PointCloud &src_points,
const float merge_distance,
const IndexMask selection)
{
const bke::AttributeAccessor src_attributes = bke::pointcloud_attributes(src_points);
const bke::AttributeAccessor src_attributes = src_points.attributes();
VArraySpan<float3> positions = src_attributes.lookup_or_default<float3>(
"position", ATTR_DOMAIN_POINT, float3(0));
const int src_size = positions.size();
@ -41,8 +41,7 @@ PointCloud *point_merge_by_distance(const PointCloud &src_points,
/* Create the new point cloud and add it to a temporary component for the attribute API. */
const int dst_size = src_size - duplicate_count;
PointCloud *dst_pointcloud = BKE_pointcloud_new_nomain(dst_size);
bke::MutableAttributeAccessor dst_attributes = bke::pointcloud_attributes_for_write(
*dst_pointcloud);
bke::MutableAttributeAccessor dst_attributes = dst_pointcloud->attributes_for_write();
/* By default, every point is just "merged" with itself. Then fill in the results of the merge
* finding, converting from indices into the selection to indices into the full input point

View File

@ -668,7 +668,7 @@ static AllPointCloudsInfo preprocess_pointclouds(const GeometrySet &geometry_set
pointcloud_info.pointcloud = pointcloud;
/* Access attributes. */
bke::AttributeAccessor attributes = bke::pointcloud_attributes(*pointcloud);
bke::AttributeAccessor attributes = pointcloud->attributes();
pointcloud_info.attributes.reinitialize(info.attributes.size());
for (const int attribute_index : info.attributes.index_range()) {
const AttributeIDRef &attribute_id = info.attributes.ids[attribute_index];
@ -744,8 +744,7 @@ static void execute_realize_pointcloud_tasks(const RealizeInstancesOptions &opti
PointCloudComponent &dst_component =
r_realized_geometry.get_component_for_write<PointCloudComponent>();
dst_component.replace(dst_pointcloud);
bke::MutableAttributeAccessor dst_attributes = bke::pointcloud_attributes_for_write(
*dst_pointcloud);
bke::MutableAttributeAccessor dst_attributes = dst_pointcloud->attributes_for_write();
SpanAttributeWriter<float3> positions = dst_attributes.lookup_or_add_for_write_only_span<float3>(
"position", ATTR_DOMAIN_POINT);
@ -883,7 +882,7 @@ static AllMeshesInfo preprocess_meshes(const GeometrySet &geometry_set,
}
/* Access attributes. */
bke::AttributeAccessor attributes = bke::mesh_attributes(*mesh);
bke::AttributeAccessor attributes = mesh->attributes();
mesh_info.attributes.reinitialize(info.attributes.size());
for (const int attribute_index : info.attributes.index_range()) {
const AttributeIDRef &attribute_id = info.attributes.ids[attribute_index];
@ -1045,7 +1044,7 @@ static void execute_realize_mesh_tasks(const RealizeInstancesOptions &options,
Mesh *dst_mesh = BKE_mesh_new_nomain(tot_vertices, tot_edges, 0, tot_loops, tot_poly);
MeshComponent &dst_component = r_realized_geometry.get_component_for_write<MeshComponent>();
dst_component.replace(dst_mesh);
bke::MutableAttributeAccessor dst_attributes = bke::mesh_attributes_for_write(*dst_mesh);
bke::MutableAttributeAccessor dst_attributes = dst_mesh->attributes_for_write();
MutableSpan<MVert> dst_verts = dst_mesh->verts_for_write();
MutableSpan<MEdge> dst_edges = dst_mesh->edges_for_write();
MutableSpan<MPoly> dst_polys = dst_mesh->polys_for_write();

View File

@ -391,7 +391,7 @@ void ABCGenericMeshWriter::get_geo_groups(Object *object,
struct Mesh *mesh,
std::map<std::string, std::vector<int32_t>> &geo_groups)
{
const bke::AttributeAccessor attributes = bke::mesh_attributes(*mesh);
const bke::AttributeAccessor attributes = mesh->attributes();
const VArraySpan<int> material_indices = attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);

View File

@ -57,7 +57,7 @@ static void get_uvs(const CDStreamConfig &config,
}
const int num_poly = config.totpoly;
MPoly *polygons = config.mpoly;
MPoly *mpoly = config.mpoly;
MLoop *mloop = config.mloop;
if (!config.pack_uvs) {
@ -67,7 +67,7 @@ static void get_uvs(const CDStreamConfig &config,
/* Iterate in reverse order to match exported polygons. */
for (int i = 0; i < num_poly; i++) {
MPoly &current_poly = polygons[i];
MPoly &current_poly = mpoly[i];
const MLoopUV *loopuv = mloopuv_array + current_poly.loopstart + current_poly.totloop;
for (int j = 0; j < current_poly.totloop; j++, count++) {
@ -85,7 +85,7 @@ static void get_uvs(const CDStreamConfig &config,
int idx_count = 0;
for (int i = 0; i < num_poly; i++) {
MPoly &current_poly = polygons[i];
MPoly &current_poly = mpoly[i];
MLoop *looppoly = mloop + current_poly.loopstart + current_poly.totloop;
const MLoopUV *loopuv = mloopuv_array + current_poly.loopstart + current_poly.totloop;

View File

@ -310,7 +310,7 @@ static void process_vertex_normals(CDStreamConfig &config,
}
config.mesh->flag |= ME_AUTOSMOOTH;
BKE_mesh_set_custom_normals_from_vertices(config.mesh, vnors);
BKE_mesh_set_custom_normals_from_verts(config.mesh, vnors);
MEM_freeN(vnors);
}
@ -769,7 +769,7 @@ Mesh *AbcMeshReader::read_mesh(Mesh *existing_mesh,
size_t num_polys = new_mesh->totpoly;
if (num_polys > 0) {
std::map<std::string, int> mat_map;
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*new_mesh);
bke::MutableAttributeAccessor attributes = new_mesh->attributes_for_write();
bke::SpanAttributeWriter<int> material_indices =
attributes.lookup_or_add_for_write_only_span<int>("material_index", ATTR_DOMAIN_FACE);
assign_facesets_to_material_indices(sample_sel, material_indices.span, mat_map);
@ -830,7 +830,7 @@ void AbcMeshReader::assign_facesets_to_material_indices(const ISampleSelector &s
void AbcMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, const ISampleSelector &sample_sel)
{
std::map<std::string, int> mat_map;
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh);
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<int> material_indices =
attributes.lookup_or_add_for_write_only_span<int>("material_index", ATTR_DOMAIN_FACE);
assign_facesets_to_material_indices(sample_sel, material_indices.span, mat_map);

View File

@ -288,7 +288,7 @@ static bool collect_vertex_counts_per_poly(Mesh *me,
std::vector<unsigned long> &vcount_list)
{
const Span<MPoly> polys = me->polys();
const blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*me);
const blender::bke::AttributeAccessor attributes = me->attributes();
const blender::VArray<int> material_indices = attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
bool is_triangulated = true;
@ -399,7 +399,7 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
/* performs the actual writing */
prepareToAppendValues(is_triangulated, *primitive_list, vcount_list);
const blender::bke::AttributeAccessor attributes = blender::bke::mesh_attributes(*me);
const blender::bke::AttributeAccessor attributes = me->attributes();
const blender::VArray<int> material_indices = attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);

View File

@ -807,7 +807,7 @@ void USDMeshReader::readFaceSetsSample(Main *bmain, Mesh *mesh, const double mot
std::map<pxr::SdfPath, int> mat_map;
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*mesh);
bke::MutableAttributeAccessor attributes = mesh->attributes_for_write();
bke::SpanAttributeWriter<int> material_indices =
attributes.lookup_or_add_for_write_only_span<int>("material_index", ATTR_DOMAIN_FACE);
this->assign_facesets_to_material_indices(motionSampleTime, material_indices.span, &mat_map);
@ -916,7 +916,7 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh,
MutableSpan<MPoly> polys = active_mesh->polys_for_write();
if (!polys.is_empty() && import_params_.import_materials) {
std::map<pxr::SdfPath, int> mat_map;
bke::MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*active_mesh);
bke::MutableAttributeAccessor attributes = active_mesh->attributes_for_write();
bke::SpanAttributeWriter<int> material_indices =
attributes.lookup_or_add_for_write_only_span<int>("material_index", ATTR_DOMAIN_FACE);
assign_facesets_to_material_indices(motionSampleTime, material_indices.span, &mat_map);

View File

@ -256,7 +256,7 @@ static void get_loops_polys(const Mesh *mesh, USDMeshData &usd_mesh_data)
{
/* Only construct face groups (a.k.a. geometry subsets) when we need them for material
* assignments. */
const bke::AttributeAccessor attributes = bke::mesh_attributes(*mesh);
const bke::AttributeAccessor attributes = mesh->attributes();
const VArray<int> material_indices = attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
if (!material_indices.is_single() && mesh->totcol > 1) {

View File

@ -255,7 +255,7 @@ void OBJWriter::write_vertex_coords(FormatHandler &fh,
colors_layer = BKE_id_attributes_active_color_get(&mesh->id);
}
if (write_colors && (colors_layer != nullptr)) {
const bke::AttributeAccessor attributes = bke::mesh_attributes(*mesh);
const bke::AttributeAccessor attributes = mesh->attributes();
const VArray<ColorGeometry4f> attribute = attributes.lookup_or_default<ColorGeometry4f>(
colors_layer->name, ATTR_DOMAIN_POINT, {0.0f, 0.0f, 0.0f, 0.0f});
@ -374,7 +374,7 @@ void OBJWriter::write_poly_elements(FormatHandler &fh,
}
}
const bke::AttributeAccessor attributes = bke::mesh_attributes(*obj_mesh_data.get_mesh());
const bke::AttributeAccessor attributes = obj_mesh_data.get_mesh()->attributes();
const VArray<int> material_indices = attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);

View File

@ -203,7 +203,7 @@ void OBJMesh::calc_smooth_groups(const bool use_bitflags)
void OBJMesh::calc_poly_order()
{
const bke::AttributeAccessor attributes = bke::mesh_attributes(*export_mesh_eval_);
const bke::AttributeAccessor attributes = export_mesh_eval_->attributes();
const VArray<int> material_indices = attributes.lookup_or_default<int>(
"material_index", ATTR_DOMAIN_FACE, 0);
if (material_indices.is_single() && material_indices.get_internal_single() == 0) {
@ -242,8 +242,8 @@ const Material *OBJMesh::get_object_material(const int16_t mat_nr) const
bool OBJMesh::is_ith_poly_smooth(const int poly_index) const
{
const Span<MPoly> polygons = export_mesh_eval_->polys();
return polygons[poly_index].flag & ME_SMOOTH;
const Span<MPoly> polys = export_mesh_eval_->polys();
return polys[poly_index].flag & ME_SMOOTH;
}
const char *OBJMesh::get_object_name() const
@ -325,7 +325,7 @@ void OBJMesh::store_uv_coords_and_indices()
if (uv_vert->separate) {
tot_uv_vertices_ += 1;
}
const int vertices_in_poly = polys[uv_vert->poly_index].totloop;
const int verts_in_poly = polys[uv_vert->poly_index].totloop;
/* Store UV vertex coordinates. */
uv_coords_.resize(tot_uv_vertices_);
@ -334,7 +334,7 @@ void OBJMesh::store_uv_coords_and_indices()
uv_coords_[tot_uv_vertices_ - 1] = float2(vert_uv_coords[0], vert_uv_coords[1]);
/* Store UV vertex indices. */
uv_indices_[uv_vert->poly_index].resize(vertices_in_poly);
uv_indices_[uv_vert->poly_index].resize(verts_in_poly);
/* Keep indices zero-based and let the writer handle the "+ 1" as per OBJ spec. */
uv_indices_[uv_vert->poly_index][uv_vert->loop_of_poly_index] = tot_uv_vertices_ - 1;
}

View File

@ -188,8 +188,8 @@ void MeshFromGeometry::create_polys_loops(Mesh *mesh, bool use_vertex_groups)
MutableSpan<MPoly> polys = mesh->polys_for_write();
MutableSpan<MLoop> loops = mesh->loops_for_write();
bke::SpanAttributeWriter<int> material_indices =
bke::mesh_attributes_for_write(*mesh).lookup_or_add_for_write_only_span<int>(
"material_index", ATTR_DOMAIN_FACE);
mesh->attributes_for_write().lookup_or_add_for_write_only_span<int>("material_index",
ATTR_DOMAIN_FACE);
const int64_t tot_face_elems{mesh->totpoly};
int tot_loop_idx = 0;

View File

@ -1160,6 +1160,9 @@ typedef struct IdAdtTemplate {
AnimData *adt;
} IdAdtTemplate;
/* From: `DNA_object_types.h`, see it's doc-string there. */
#define SELECT 1
/* ************************************************ */
#ifdef __cplusplus

View File

@ -439,9 +439,9 @@ enum {
/* *************** BEZTRIPLE **************** */
/* BezTriple.f1,2,3 */
/** #BezTriple.f1, #BezTriple.f2, #BezTriple.f3. */
typedef enum eBezTriple_Flag {
/* SELECT */
/* `SELECT = (1 << 0)` */
BEZT_FLAG_TEMP_TAG = (1 << 1), /* always clear. */
/* Can be used to ignore keyframe points for certain operations. */
BEZT_FLAG_IGNORE_TAG = (1 << 2),

View File

@ -18,6 +18,10 @@
namespace blender {
template<typename T> class Span;
template<typename T> class MutableSpan;
namespace bke {
class AttributeAccessor;
class MutableAttributeAccessor;
} // namespace bke
} // namespace blender
#endif
@ -346,6 +350,9 @@ typedef struct Mesh {
/** Write access to loop data. */
blender::MutableSpan<MLoop> loops_for_write();
blender::bke::AttributeAccessor attributes() const;
blender::bke::MutableAttributeAccessor attributes_for_write();
/**
* Vertex group data, encoded as an array of indices and weights for every vertex.
* \warning: May be empty.

View File

@ -477,7 +477,13 @@ typedef struct ObHook {
/* **************** OBJECT ********************* */
/* used many places, should be specialized. */
/**
* This is used as a flag for many kinds of data that use selections, examples include:
* - #BezTriple.f1, #BezTriple.f2, #BezTriple.f3
* - #bNote.flag
* - #MovieTrackingTrack.flag
* And more, ideally this would have a generic location.
*/
#define SELECT 1
/** #Object.type */

View File

@ -9,6 +9,13 @@
#include "DNA_ID.h"
#include "DNA_customdata_types.h"
#ifdef __cplusplus
namespace blender::bke {
class AttributeAccessor;
class MutableAttributeAccessor;
} // namespace blender::bke
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -32,6 +39,11 @@ typedef struct PointCloud {
short totcol;
short _pad3[3];
#ifdef __cplusplus
blender::bke::AttributeAccessor attributes() const;
blender::bke::MutableAttributeAccessor attributes_for_write();
#endif
/* Draw Cache */
void *batch_cache;
} PointCloud;

View File

@ -522,8 +522,6 @@ typedef struct SequencerScopes {
#define MAXSEQ 128
#define SELECT 1
/** #Editor.overlay_frame_flag */
#define SEQ_EDIT_OVERLAY_FRAME_SHOW 1
#define SEQ_EDIT_OVERLAY_FRAME_ABS 2
@ -549,9 +547,12 @@ typedef struct SequencerScopes {
#define SEQ_NAME_MAXSTR 64
/* From: `DNA_object_types.h`, see it's doc-string there. */
#define SELECT 1
/** #Sequence.flag */
enum {
/* SELECT */
/* `SELECT = (1 << 0)` */
SEQ_LEFTSEL = (1 << 1),
SEQ_RIGHTSEL = (1 << 2),
SEQ_OVERLAP = (1 << 3),

View File

@ -102,10 +102,10 @@ static void rna_Mesh_calc_smooth_groups(
static void rna_Mesh_normals_split_custom_do(Mesh *mesh,
float (*custom_loopnors)[3],
const bool use_vertices)
const bool use_verts)
{
if (use_vertices) {
BKE_mesh_set_custom_normals_from_vertices(mesh, custom_loopnors);
if (use_verts) {
BKE_mesh_set_custom_normals_from_verts(mesh, custom_loopnors);
}
else {
BKE_mesh_set_custom_normals(mesh, custom_loopnors);
@ -165,7 +165,7 @@ static void rna_Mesh_transform(Mesh *mesh, float mat[16], bool shape_keys)
static void rna_Mesh_flip_normals(Mesh *mesh)
{
BKE_mesh_polygons_flip(
BKE_mesh_polys_flip(
BKE_mesh_polys(mesh), BKE_mesh_loops_for_write(mesh), &mesh->ldata, mesh->totpoly);
BKE_mesh_tessface_clear(mesh);
BKE_mesh_normals_tag_dirty(mesh);

View File

@ -212,10 +212,10 @@ static void rna_ParticleHairKey_location_object_get(PointerRNA *ptr, float *valu
if (pa) {
Mesh *hair_mesh = (psmd->psys->flag & PSYS_HAIR_DYNAMICS) ? psmd->psys->hair_out_mesh : NULL;
const MVert *vertices = BKE_mesh_verts(hair_mesh);
const MVert *verts = BKE_mesh_verts(hair_mesh);
if (hair_mesh) {
const MVert *mvert = &vertices[pa->hair_index + (hkey - pa->hair)];
copy_v3_v3(values, mvert->co);
const MVert *mv = &verts[pa->hair_index + (hkey - pa->hair)];
copy_v3_v3(values, mv->co);
}
else {
float hairmat[4][4];
@ -279,9 +279,9 @@ static void hair_key_location_object_set(HairKey *hair_key,
if (hair_key_index == -1) {
return;
}
MVert *vertices = BKE_mesh_verts_for_write(hair_mesh);
MVert *mvert = &vertices[particle->hair_index + (hair_key_index)];
copy_v3_v3(mvert->co, src_co);
MVert *verts = BKE_mesh_verts_for_write(hair_mesh);
MVert *mv = &verts[particle->hair_index + (hair_key_index)];
copy_v3_v3(mv->co, src_co);
return;
}
@ -324,9 +324,9 @@ static void rna_ParticleHairKey_co_object(HairKey *hairkey,
NULL;
if (particle) {
if (hair_mesh) {
const MVert *vertices = BKE_mesh_verts(hair_mesh);
const MVert *mvert = &vertices[particle->hair_index + (hairkey - particle->hair)];
copy_v3_v3(n_co, mvert->co);
const MVert *verts = BKE_mesh_verts(hair_mesh);
const MVert *mv = &verts[particle->hair_index + (hairkey - particle->hair)];
copy_v3_v3(n_co, mv->co);
}
else {
float hairmat[4][4];

View File

@ -481,7 +481,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
}
/* About 67 million vertices max seems a decent limit for now. */
const size_t max_vertices_num = 1 << 26;
const size_t max_verts_num = 1 << 26;
/* calculate the maximum number of copies which will fit within the
* prescribed length */
@ -499,7 +499,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
* vertices.
*/
if (((size_t)count * (size_t)chunk_nverts + (size_t)start_cap_nverts +
(size_t)end_cap_nverts) > max_vertices_num) {
(size_t)end_cap_nverts) > max_verts_num) {
count = 1;
offset_is_too_small = true;
}
@ -521,7 +521,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
* vertices.
*/
else if (((size_t)count * (size_t)chunk_nverts + (size_t)start_cap_nverts +
(size_t)end_cap_nverts) > max_vertices_num) {
(size_t)end_cap_nverts) > max_verts_num) {
count = 1;
BKE_modifier_set_error(ctx->object,
&amd->modifier,

View File

@ -143,9 +143,9 @@ static void invert_boolean_array(MutableSpan<bool> array)
}
}
static void compute_masked_vertices(Span<bool> vertex_mask,
MutableSpan<int> r_vertex_map,
uint *r_verts_masked_num)
static void compute_masked_verts(Span<bool> vertex_mask,
MutableSpan<int> r_vertex_map,
uint *r_verts_masked_num)
{
BLI_assert(vertex_mask.size() == r_vertex_map.size());
@ -223,12 +223,12 @@ static void computed_masked_edges_smooth(const Mesh *mesh,
*r_verts_add_num = verts_add_num;
}
static void computed_masked_polygons(const Mesh *mesh,
Span<bool> vertex_mask,
Vector<int> &r_masked_poly_indices,
Vector<int> &r_loop_starts,
uint *r_polys_masked_num,
uint *r_loops_masked_num)
static void computed_masked_polys(const Mesh *mesh,
Span<bool> vertex_mask,
Vector<int> &r_masked_poly_indices,
Vector<int> &r_loop_starts,
uint *r_polys_masked_num,
uint *r_loops_masked_num)
{
BLI_assert(mesh->totvert == vertex_mask.size());
const Span<MPoly> polys = mesh->polys();
@ -261,15 +261,15 @@ static void computed_masked_polygons(const Mesh *mesh,
*r_loops_masked_num = loops_masked_num;
}
static void compute_interpolated_polygons(const Mesh *mesh,
Span<bool> vertex_mask,
uint verts_add_num,
uint loops_masked_num,
Vector<int> &r_masked_poly_indices,
Vector<int> &r_loop_starts,
uint *r_edges_add_num,
uint *r_polys_add_num,
uint *r_loops_add_num)
static void compute_interpolated_polys(const Mesh *mesh,
Span<bool> vertex_mask,
uint verts_add_num,
uint loops_masked_num,
Vector<int> &r_masked_poly_indices,
Vector<int> &r_loop_starts,
uint *r_edges_add_num,
uint *r_polys_add_num,
uint *r_loops_add_num)
{
BLI_assert(mesh->totvert == vertex_mask.size());
@ -333,9 +333,9 @@ static void compute_interpolated_polygons(const Mesh *mesh,
*r_loops_add_num = loops_add_num;
}
static void copy_masked_vertices_to_new_mesh(const Mesh &src_mesh,
Mesh &dst_mesh,
Span<int> vertex_map)
static void copy_masked_verts_to_new_mesh(const Mesh &src_mesh,
Mesh &dst_mesh,
Span<int> vertex_map)
{
BLI_assert(src_mesh.totvert == vertex_map.size());
const Span<MVert> src_verts = src_mesh.verts();
@ -692,7 +692,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
Array<int> vertex_map(mesh->totvert);
uint verts_masked_num;
compute_masked_vertices(vertex_mask, vertex_map, &verts_masked_num);
compute_masked_verts(vertex_mask, vertex_map, &verts_masked_num);
Array<int> edge_map(mesh->totedge);
uint edges_masked_num;
@ -709,26 +709,26 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
Vector<int> new_loop_starts;
uint polys_masked_num;
uint loops_masked_num;
computed_masked_polygons(mesh,
vertex_mask,
masked_poly_indices,
new_loop_starts,
&polys_masked_num,
&loops_masked_num);
computed_masked_polys(mesh,
vertex_mask,
masked_poly_indices,
new_loop_starts,
&polys_masked_num,
&loops_masked_num);
uint edges_add_num = 0;
uint polys_add_num = 0;
uint loops_add_num = 0;
if (use_interpolation) {
compute_interpolated_polygons(mesh,
vertex_mask,
verts_add_num,
loops_masked_num,
masked_poly_indices,
new_loop_starts,
&edges_add_num,
&polys_add_num,
&loops_add_num);
compute_interpolated_polys(mesh,
vertex_mask,
verts_add_num,
loops_masked_num,
masked_poly_indices,
new_loop_starts,
&edges_add_num,
&polys_add_num,
&loops_add_num);
}
Mesh *result = BKE_mesh_new_nomain_from_template(mesh,
@ -738,7 +738,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
loops_masked_num + loops_add_num,
polys_masked_num + polys_add_num);
copy_masked_vertices_to_new_mesh(*mesh, *result, vertex_map);
copy_masked_verts_to_new_mesh(*mesh, *result, vertex_map);
if (use_interpolation) {
add_interp_verts_copy_edges_to_new_mesh(*mesh,
*result,

View File

@ -181,15 +181,15 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
const Span<MVert> mesh_verts = mesh->verts();
const Span<MEdge> mesh_edges = mesh->edges();
const Span<MPoly> mesh_polys = mesh->polys();
const Span<MVert> me_vertices = me->verts();
const Span<MVert> me_verts = me->verts();
const Span<MEdge> me_edges = me->edges();
const Span<MPoly> me_polygons = me->polys();
const Span<MPoly> me_polys = me->polys();
/* TODO(sybren+bastien): possibly check relevant custom data layers (UV/color depending on
* flags) and duplicate those too.
* XXX(Hans): This probably isn't true anymore with various CoW improvements, etc. */
if ((me_vertices.data() == mesh_verts.data()) || (me_edges.data() == mesh_edges.data()) ||
(me_polygons.data() == mesh_polys.data())) {
if ((me_verts.data() == mesh_verts.data()) || (me_edges.data() == mesh_edges.data()) ||
(me_polys.data() == mesh_polys.data())) {
/* We need to duplicate data here, otherwise we'll modify org mesh, see T51701. */
mesh = reinterpret_cast<Mesh *>(
BKE_id_copy_ex(nullptr,

View File

@ -169,9 +169,9 @@ typedef struct GenerateOceanGeometryData {
float ix, iy;
} GenerateOceanGeometryData;
static void generate_ocean_geometry_vertices(void *__restrict userdata,
const int y,
const TaskParallelTLS *__restrict UNUSED(tls))
static void generate_ocean_geometry_verts(void *__restrict userdata,
const int y,
const TaskParallelTLS *__restrict UNUSED(tls))
{
GenerateOceanGeometryData *gogd = userdata;
int x;
@ -185,9 +185,9 @@ static void generate_ocean_geometry_vertices(void *__restrict userdata,
}
}
static void generate_ocean_geometry_polygons(void *__restrict userdata,
const int y,
const TaskParallelTLS *__restrict UNUSED(tls))
static void generate_ocean_geometry_polys(void *__restrict userdata,
const int y,
const TaskParallelTLS *__restrict UNUSED(tls))
{
GenerateOceanGeometryData *gogd = userdata;
int x;
@ -282,10 +282,10 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, co
settings.use_threading = use_threading;
/* create vertices */
BLI_task_parallel_range(0, gogd.res_y + 1, &gogd, generate_ocean_geometry_vertices, &settings);
BLI_task_parallel_range(0, gogd.res_y + 1, &gogd, generate_ocean_geometry_verts, &settings);
/* create faces */
BLI_task_parallel_range(0, gogd.res_y, &gogd, generate_ocean_geometry_polygons, &settings);
BLI_task_parallel_range(0, gogd.res_y, &gogd, generate_ocean_geometry_polys, &settings);
BKE_mesh_calc_edges(result, false, false);

View File

@ -362,7 +362,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
clnors);
}
else {
/* TODO: Ideally, we could add an option to BKE_mesh_normals_loop_custom_[from_vertices_]set()
/* TODO: Ideally, we could add an option to `BKE_mesh_normals_loop_custom_[from_verts_]set()`
* to keep current clnors instead of resetting them to default auto-computed ones,
* when given new custom normal is zero-vec.
* But this is not exactly trivial change, better to keep this optimization for later...
@ -379,18 +379,18 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
copy_v3_v3(vert_normals[mv_index], items_data[mv_index].normal);
}
BKE_mesh_normals_loop_custom_from_vertices_set(mvert,
wn_data->vert_normals,
vert_normals,
verts_num,
medge,
edges_num,
mloop,
loops_num,
mpoly,
polynors,
polys_num,
clnors);
BKE_mesh_normals_loop_custom_from_verts_set(mvert,
wn_data->vert_normals,
vert_normals,
verts_num,
medge,
edges_num,
mloop,
loops_num,
mpoly,
polynors,
polys_num,
clnors);
MEM_freeN(vert_normals);
}

View File

@ -154,7 +154,7 @@ static void node_geo_exec(GeoNodeExecParams params)
/* Store intersecting edges in attribute. */
if (attribute_outputs.intersecting_edges_id) {
MutableAttributeAccessor attributes = bke::mesh_attributes_for_write(*result);
MutableAttributeAccessor attributes = result->attributes_for_write();
SpanAttributeWriter<bool> selection = attributes.lookup_or_add_for_write_only_span<bool>(
attribute_outputs.intersecting_edges_id.get(), ATTR_DOMAIN_EDGE);

View File

@ -270,8 +270,8 @@ static void node_geo_exec(GeoNodeExecParams params)
BKE_mesh_wrapper_ensure_mdata(surface_mesh_eval);
const AttributeAccessor mesh_attributes_eval = bke::mesh_attributes(*surface_mesh_eval);
const AttributeAccessor mesh_attributes_orig = bke::mesh_attributes(*surface_mesh_orig);
const AttributeAccessor mesh_attributes_eval = surface_mesh_eval->attributes();
const AttributeAccessor mesh_attributes_orig = surface_mesh_orig->attributes();
Curves &curves_id = *curves_geometry.get_curves_for_write();
CurvesGeometry &curves = CurvesGeometry::wrap(curves_id.geometry);

View File

@ -176,9 +176,9 @@ static void copy_face_corner_attributes(const Map<AttributeIDRef, AttributeKind>
attributes, src_attributes, dst_attributes, ATTR_DOMAIN_CORNER, IndexMask(indices));
}
static void copy_masked_vertices_to_new_mesh(const Mesh &src_mesh,
Mesh &dst_mesh,
Span<int> vertex_map)
static void copy_masked_verts_to_new_mesh(const Mesh &src_mesh,
Mesh &dst_mesh,
Span<int> vertex_map)
{
BLI_assert(src_mesh.totvert == vertex_map.size());
const Span<MVert> src_verts = src_mesh.verts();
@ -239,16 +239,16 @@ static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
Span<int> masked_poly_indices,
Span<int> new_loop_starts)
{
const Span<MPoly> src_polygons = src_mesh.polys();
const Span<MPoly> src_polys = src_mesh.polys();
const Span<MLoop> src_loops = src_mesh.loops();
MutableSpan<MPoly> dst_polygons = dst_mesh.polys_for_write();
MutableSpan<MPoly> dst_polys = dst_mesh.polys_for_write();
MutableSpan<MLoop> dst_loops = dst_mesh.loops_for_write();
for (const int i_dst : masked_poly_indices.index_range()) {
const int i_src = masked_poly_indices[i_dst];
const MPoly &mp_src = src_polygons[i_src];
MPoly &mp_dst = dst_polygons[i_dst];
const MPoly &mp_src = src_polys[i_src];
MPoly &mp_dst = dst_polys[i_dst];
const int i_ml_src = mp_src.loopstart;
const int i_ml_dst = new_loop_starts[i_dst];
@ -270,16 +270,16 @@ static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
Span<int> masked_poly_indices,
Span<int> new_loop_starts)
{
const Span<MPoly> src_polygons = src_mesh.polys();
const Span<MPoly> src_polys = src_mesh.polys();
const Span<MLoop> src_loops = src_mesh.loops();
MutableSpan<MPoly> dst_polygons = dst_mesh.polys_for_write();
MutableSpan<MPoly> dst_polys = dst_mesh.polys_for_write();
MutableSpan<MLoop> dst_loops = dst_mesh.loops_for_write();
for (const int i_dst : masked_poly_indices.index_range()) {
const int i_src = masked_poly_indices[i_dst];
const MPoly &mp_src = src_polygons[i_src];
MPoly &mp_dst = dst_polygons[i_dst];
const MPoly &mp_src = src_polys[i_src];
MPoly &mp_dst = dst_polys[i_dst];
const int i_ml_src = mp_src.loopstart;
const int i_ml_dst = new_loop_starts[i_dst];
@ -302,16 +302,16 @@ static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
Span<int> masked_poly_indices,
Span<int> new_loop_starts)
{
const Span<MPoly> src_polygons = src_mesh.polys();
const Span<MPoly> src_polys = src_mesh.polys();
const Span<MLoop> src_loops = src_mesh.loops();
MutableSpan<MPoly> dst_polygons = dst_mesh.polys_for_write();
MutableSpan<MPoly> dst_polys = dst_mesh.polys_for_write();
MutableSpan<MLoop> dst_loops = dst_mesh.loops_for_write();
for (const int i_dst : masked_poly_indices.index_range()) {
const int i_src = masked_poly_indices[i_dst];
const MPoly &mp_src = src_polygons[i_src];
MPoly &mp_dst = dst_polygons[i_dst];
const MPoly &mp_src = src_polys[i_src];
MPoly &mp_dst = dst_polys[i_dst];
const int i_ml_src = mp_src.loopstart;
const int i_ml_dst = new_loop_starts[i_dst];
@ -382,8 +382,8 @@ static void separate_point_cloud_selection(GeometrySet &geometry_set,
{GEO_COMPONENT_TYPE_POINT_CLOUD}, GEO_COMPONENT_TYPE_POINT_CLOUD, false, attributes);
copy_attributes_based_on_mask(attributes,
bke::pointcloud_attributes(src_pointcloud),
bke::pointcloud_attributes_for_write(*pointcloud),
src_pointcloud.attributes(),
pointcloud->attributes_for_write(),
ATTR_DOMAIN_POINT,
selection);
geometry_set.replace_pointcloud(pointcloud);
@ -407,9 +407,9 @@ static void delete_selected_instances(GeometrySet &geometry_set,
instances.remove_instances(selection);
}
static void compute_selected_vertices_from_vertex_selection(const Span<bool> vertex_selection,
MutableSpan<int> r_vertex_map,
int *r_selected_vertices_num)
static void compute_selected_verts_from_vertex_selection(const Span<bool> vertex_selection,
MutableSpan<int> r_vertex_map,
int *r_selected_verts_num)
{
BLI_assert(vertex_selection.size() == r_vertex_map.size());
@ -424,7 +424,7 @@ static void compute_selected_vertices_from_vertex_selection(const Span<bool> ver
}
}
*r_selected_vertices_num = selected_verts_num;
*r_selected_verts_num = selected_verts_num;
}
static void compute_selected_edges_from_vertex_selection(const Mesh &mesh,
@ -452,12 +452,12 @@ static void compute_selected_edges_from_vertex_selection(const Mesh &mesh,
*r_selected_edges_num = selected_edges_num;
}
static void compute_selected_polygons_from_vertex_selection(const Mesh &mesh,
const Span<bool> vertex_selection,
Vector<int> &r_selected_poly_indices,
Vector<int> &r_loop_starts,
int *r_selected_polys_num,
int *r_selected_loops_num)
static void compute_selected_polys_from_vertex_selection(const Mesh &mesh,
const Span<bool> vertex_selection,
Vector<int> &r_selected_poly_indices,
Vector<int> &r_loop_starts,
int *r_selected_polys_num,
int *r_selected_loops_num)
{
BLI_assert(mesh.totvert == vertex_selection.size());
const Span<MPoly> polys = mesh.polys();
@ -494,13 +494,12 @@ static void compute_selected_polygons_from_vertex_selection(const Mesh &mesh,
* Checks for every edge if it is in `edge_selection`. If it is, then the two vertices of the
* edge are kept along with the edge.
*/
static void compute_selected_vertices_and_edges_from_edge_selection(
const Mesh &mesh,
const Span<bool> edge_selection,
MutableSpan<int> r_vertex_map,
MutableSpan<int> r_edge_map,
int *r_selected_vertices_num,
int *r_selected_edges_num)
static void compute_selected_verts_and_edges_from_edge_selection(const Mesh &mesh,
const Span<bool> edge_selection,
MutableSpan<int> r_vertex_map,
MutableSpan<int> r_edge_map,
int *r_selected_verts_num,
int *r_selected_edges_num)
{
BLI_assert(mesh.totedge == edge_selection.size());
const Span<MEdge> edges = mesh.edges();
@ -526,7 +525,7 @@ static void compute_selected_vertices_and_edges_from_edge_selection(
}
}
*r_selected_vertices_num = selected_verts_num;
*r_selected_verts_num = selected_verts_num;
*r_selected_edges_num = selected_edges_num;
}
@ -558,12 +557,12 @@ static void compute_selected_edges_from_edge_selection(const Mesh &mesh,
* Checks for every polygon if all the edges are in `edge_selection`. If they are, then that
* polygon is kept.
*/
static void compute_selected_polygons_from_edge_selection(const Mesh &mesh,
const Span<bool> edge_selection,
Vector<int> &r_selected_poly_indices,
Vector<int> &r_loop_starts,
int *r_selected_polys_num,
int *r_selected_loops_num)
static void compute_selected_polys_from_edge_selection(const Mesh &mesh,
const Span<bool> edge_selection,
Vector<int> &r_selected_poly_indices,
Vector<int> &r_loop_starts,
int *r_selected_polys_num,
int *r_selected_loops_num)
{
const Span<MPoly> polys = mesh.polys();
const Span<MLoop> loops = mesh.loops();
@ -612,12 +611,12 @@ static void compute_selected_mesh_data_from_vertex_selection_edge_face(
compute_selected_edges_from_vertex_selection(
mesh, vertex_selection, r_edge_map, r_selected_edges_num);
compute_selected_polygons_from_vertex_selection(mesh,
vertex_selection,
r_selected_poly_indices,
r_loop_starts,
r_selected_polys_num,
r_selected_loops_num);
compute_selected_polys_from_vertex_selection(mesh,
vertex_selection,
r_selected_poly_indices,
r_loop_starts,
r_selected_polys_num,
r_selected_loops_num);
}
/**
@ -630,23 +629,23 @@ static void compute_selected_mesh_data_from_vertex_selection(const Mesh &mesh,
MutableSpan<int> r_edge_map,
Vector<int> &r_selected_poly_indices,
Vector<int> &r_loop_starts,
int *r_selected_vertices_num,
int *r_selected_verts_num,
int *r_selected_edges_num,
int *r_selected_polys_num,
int *r_selected_loops_num)
{
compute_selected_vertices_from_vertex_selection(
vertex_selection, r_vertex_map, r_selected_vertices_num);
compute_selected_verts_from_vertex_selection(
vertex_selection, r_vertex_map, r_selected_verts_num);
compute_selected_edges_from_vertex_selection(
mesh, vertex_selection, r_edge_map, r_selected_edges_num);
compute_selected_polygons_from_vertex_selection(mesh,
vertex_selection,
r_selected_poly_indices,
r_loop_starts,
r_selected_polys_num,
r_selected_loops_num);
compute_selected_polys_from_vertex_selection(mesh,
vertex_selection,
r_selected_poly_indices,
r_loop_starts,
r_selected_polys_num,
r_selected_loops_num);
}
/**
@ -665,12 +664,12 @@ static void compute_selected_mesh_data_from_edge_selection_edge_face(
{
compute_selected_edges_from_edge_selection(
mesh, edge_selection, r_edge_map, r_selected_edges_num);
compute_selected_polygons_from_edge_selection(mesh,
edge_selection,
r_selected_poly_indices,
r_loop_starts,
r_selected_polys_num,
r_selected_loops_num);
compute_selected_polys_from_edge_selection(mesh,
edge_selection,
r_selected_poly_indices,
r_loop_starts,
r_selected_polys_num,
r_selected_loops_num);
}
/**
@ -683,35 +682,31 @@ static void compute_selected_mesh_data_from_edge_selection(const Mesh &mesh,
MutableSpan<int> r_edge_map,
Vector<int> &r_selected_poly_indices,
Vector<int> &r_loop_starts,
int *r_selected_vertices_num,
int *r_selected_verts_num,
int *r_selected_edges_num,
int *r_selected_polys_num,
int *r_selected_loops_num)
{
r_vertex_map.fill(-1);
compute_selected_vertices_and_edges_from_edge_selection(mesh,
edge_selection,
r_vertex_map,
r_edge_map,
r_selected_vertices_num,
r_selected_edges_num);
compute_selected_polygons_from_edge_selection(mesh,
edge_selection,
r_selected_poly_indices,
r_loop_starts,
r_selected_polys_num,
r_selected_loops_num);
compute_selected_verts_and_edges_from_edge_selection(
mesh, edge_selection, r_vertex_map, r_edge_map, r_selected_verts_num, r_selected_edges_num);
compute_selected_polys_from_edge_selection(mesh,
edge_selection,
r_selected_poly_indices,
r_loop_starts,
r_selected_polys_num,
r_selected_loops_num);
}
/**
* Checks for every polygon if it is in `poly_selection`.
*/
static void compute_selected_polygons_from_poly_selection(const Mesh &mesh,
const Span<bool> poly_selection,
Vector<int> &r_selected_poly_indices,
Vector<int> &r_loop_starts,
int *r_selected_polys_num,
int *r_selected_loops_num)
static void compute_selected_polys_from_poly_selection(const Mesh &mesh,
const Span<bool> poly_selection,
Vector<int> &r_selected_poly_indices,
Vector<int> &r_loop_starts,
int *r_selected_polys_num,
int *r_selected_loops_num)
{
BLI_assert(mesh.totpoly == poly_selection.size());
const Span<MPoly> polys = mesh.polys();
@ -792,7 +787,7 @@ static void compute_selected_mesh_data_from_poly_selection(const Mesh &mesh,
MutableSpan<int> r_edge_map,
Vector<int> &r_selected_poly_indices,
Vector<int> &r_loop_starts,
int *r_selected_vertices_num,
int *r_selected_verts_num,
int *r_selected_edges_num,
int *r_selected_polys_num,
int *r_selected_loops_num)
@ -834,7 +829,7 @@ static void compute_selected_mesh_data_from_poly_selection(const Mesh &mesh,
}
}
}
*r_selected_vertices_num = selected_verts_num;
*r_selected_verts_num = selected_verts_num;
*r_selected_edges_num = selected_edges_num;
*r_selected_polys_num = r_selected_poly_indices.size();
*r_selected_loops_num = selected_loops_num;
@ -919,30 +914,30 @@ static void do_mesh_separation(GeometrySet &geometry_set,
selected_polys_num);
/* Copy the selected parts of the mesh over to the new mesh. */
copy_masked_vertices_to_new_mesh(mesh_in, *mesh_out, vertex_map);
copy_masked_verts_to_new_mesh(mesh_in, *mesh_out, vertex_map);
copy_masked_edges_to_new_mesh(mesh_in, *mesh_out, vertex_map, edge_map);
copy_masked_polys_to_new_mesh(
mesh_in, *mesh_out, vertex_map, edge_map, selected_poly_indices, new_loop_starts);
/* Copy attributes. */
copy_attributes_based_on_map(attributes,
bke::mesh_attributes(mesh_in),
bke::mesh_attributes_for_write(*mesh_out),
mesh_in.attributes(),
mesh_out->attributes_for_write(),
ATTR_DOMAIN_POINT,
vertex_map);
copy_attributes_based_on_map(attributes,
bke::mesh_attributes(mesh_in),
bke::mesh_attributes_for_write(*mesh_out),
mesh_in.attributes(),
mesh_out->attributes_for_write(),
ATTR_DOMAIN_EDGE,
edge_map);
copy_attributes_based_on_mask(attributes,
bke::mesh_attributes(mesh_in),
bke::mesh_attributes_for_write(*mesh_out),
mesh_in.attributes(),
mesh_out->attributes_for_write(),
ATTR_DOMAIN_FACE,
IndexMask(Vector<int64_t>(selected_poly_indices.as_span())));
copy_face_corner_attributes(attributes,
bke::mesh_attributes(mesh_in),
bke::mesh_attributes_for_write(*mesh_out),
mesh_in.attributes(),
mesh_out->attributes_for_write(),
selected_loops_num,
selected_poly_indices,
mesh_in);
@ -1002,23 +997,21 @@ static void do_mesh_separation(GeometrySet &geometry_set,
mesh_in, *mesh_out, edge_map, selected_poly_indices, new_loop_starts);
/* Copy attributes. */
copy_attributes(attributes,
bke::mesh_attributes(mesh_in),
bke::mesh_attributes_for_write(*mesh_out),
{ATTR_DOMAIN_POINT});
copy_attributes(
attributes, mesh_in.attributes(), mesh_out->attributes_for_write(), {ATTR_DOMAIN_POINT});
copy_attributes_based_on_map(attributes,
bke::mesh_attributes(mesh_in),
bke::mesh_attributes_for_write(*mesh_out),
mesh_in.attributes(),
mesh_out->attributes_for_write(),
ATTR_DOMAIN_EDGE,
edge_map);
copy_attributes_based_on_mask(attributes,
bke::mesh_attributes(mesh_in),
bke::mesh_attributes_for_write(*mesh_out),
mesh_in.attributes(),
mesh_out->attributes_for_write(),
ATTR_DOMAIN_FACE,
IndexMask(Vector<int64_t>(selected_poly_indices.as_span())));
copy_face_corner_attributes(attributes,
bke::mesh_attributes(mesh_in),
bke::mesh_attributes_for_write(*mesh_out),
mesh_in.attributes(),
mesh_out->attributes_for_write(),
selected_loops_num,
selected_poly_indices,
mesh_in);
@ -1028,28 +1021,28 @@ static void do_mesh_separation(GeometrySet &geometry_set,
/* Fill all the maps based on the selection. */
switch (domain) {
case ATTR_DOMAIN_POINT:
compute_selected_polygons_from_vertex_selection(mesh_in,
selection,
selected_poly_indices,
new_loop_starts,
&selected_polys_num,
&selected_loops_num);
compute_selected_polys_from_vertex_selection(mesh_in,
selection,
selected_poly_indices,
new_loop_starts,
&selected_polys_num,
&selected_loops_num);
break;
case ATTR_DOMAIN_EDGE:
compute_selected_polygons_from_edge_selection(mesh_in,
selection,
selected_poly_indices,
new_loop_starts,
&selected_polys_num,
&selected_loops_num);
compute_selected_polys_from_edge_selection(mesh_in,
selection,
selected_poly_indices,
new_loop_starts,
&selected_polys_num,
&selected_loops_num);
break;
case ATTR_DOMAIN_FACE:
compute_selected_polygons_from_poly_selection(mesh_in,
selection,
selected_poly_indices,
new_loop_starts,
&selected_polys_num,
&selected_loops_num);
compute_selected_polys_from_poly_selection(mesh_in,
selection,
selected_poly_indices,
new_loop_starts,
&selected_polys_num,
&selected_loops_num);
break;
default:
BLI_assert_unreachable();
@ -1065,17 +1058,17 @@ static void do_mesh_separation(GeometrySet &geometry_set,
/* Copy attributes. */
copy_attributes(attributes,
bke::mesh_attributes(mesh_in),
bke::mesh_attributes_for_write(*mesh_out),
mesh_in.attributes(),
mesh_out->attributes_for_write(),
{ATTR_DOMAIN_POINT, ATTR_DOMAIN_EDGE});
copy_attributes_based_on_mask(attributes,
bke::mesh_attributes(mesh_in),
bke::mesh_attributes_for_write(*mesh_out),
mesh_in.attributes(),
mesh_out->attributes_for_write(),
ATTR_DOMAIN_FACE,
IndexMask(Vector<int64_t>(selected_poly_indices.as_span())));
copy_face_corner_attributes(attributes,
bke::mesh_attributes(mesh_in),
bke::mesh_attributes_for_write(*mesh_out),
mesh_in.attributes(),
mesh_out->attributes_for_write(),
selected_loops_num,
selected_poly_indices,
mesh_in);
@ -1094,8 +1087,7 @@ static void separate_mesh_selection(GeometrySet &geometry_set,
{
const Mesh &src_mesh = *geometry_set.get_mesh_for_read();
bke::MeshFieldContext field_context{src_mesh, selection_domain};
fn::FieldEvaluator evaluator{field_context,
bke::mesh_attributes(src_mesh).domain_size(selection_domain)};
fn::FieldEvaluator evaluator{field_context, src_mesh.attributes().domain_size(selection_domain)};
evaluator.add(selection_field);
evaluator.evaluate();
const VArray<bool> selection = evaluator.get_evaluated<bool>(0);

View File

@ -291,8 +291,8 @@ BLI_NOINLINE static void propagate_existing_attributes(
const Span<float3> bary_coords,
const Span<int> looptri_indices)
{
const AttributeAccessor mesh_attributes = bke::mesh_attributes(mesh);
MutableAttributeAccessor point_attributes = bke::pointcloud_attributes_for_write(points);
const AttributeAccessor mesh_attributes = mesh.attributes();
MutableAttributeAccessor point_attributes = points.attributes_for_write();
for (Map<AttributeIDRef, AttributeKind>::Item entry : attributes.items()) {
const AttributeIDRef attribute_id = entry.key;
@ -333,7 +333,7 @@ BLI_NOINLINE static void compute_attribute_outputs(const Mesh &mesh,
const Span<int> looptri_indices,
const AttributeOutputs &attribute_outputs)
{
MutableAttributeAccessor point_attributes = bke::pointcloud_attributes_for_write(points);
MutableAttributeAccessor point_attributes = points.attributes_for_write();
SpanAttributeWriter<int> ids = point_attributes.lookup_or_add_for_write_only_span<int>(
"id", ATTR_DOMAIN_POINT);
@ -396,7 +396,7 @@ static Array<float> calc_full_density_factors_with_selection(const Mesh &mesh,
const Field<bool> &selection_field)
{
const eAttrDomain domain = ATTR_DOMAIN_CORNER;
const int domain_size = bke::mesh_attributes(mesh).domain_size(domain);
const int domain_size = mesh.attributes().domain_size(domain);
Array<float> densities(domain_size, 0.0f);
bke::MeshFieldContext field_context{mesh, domain};
@ -491,8 +491,7 @@ static void point_distribution_calculate(GeometrySet &geometry_set,
}
PointCloud *pointcloud = BKE_pointcloud_new_nomain(positions.size());
bke::MutableAttributeAccessor point_attributes = bke::pointcloud_attributes_for_write(
*pointcloud);
bke::MutableAttributeAccessor point_attributes = pointcloud->attributes_for_write();
bke::SpanAttributeWriter<float3> point_positions =
point_attributes.lookup_or_add_for_write_only_span<float3>("position", ATTR_DOMAIN_POINT);
bke::SpanAttributeWriter<float> point_radii =

Some files were not shown because too many files have changed in this diff Show More