Cleanup: Use mesh helper functions to access vertex group data

This commit is contained in:
Hans Goudey
2025-07-01 16:38:14 -04:00
committed by Hans Goudey
parent c21a98d76a
commit cec05ab440
11 changed files with 38 additions and 56 deletions

View File

@@ -23,7 +23,6 @@
#include "BKE_colortools.hh" /* CurveMapping. */
#include "BKE_context.hh"
#include "BKE_customdata.hh"
#include "BKE_deform.hh"
#include "BKE_modifier.hh"
#include "BKE_texture.h" /* Texture masking. */
@@ -212,8 +211,7 @@ void weightvg_do_mask(const ModifierEvalContext *ctx,
/* Proceed only if vgroup is valid, else use constant factor. */
/* Get actual deform-verts (ie vertex group data). */
const MDeformVert *dvert = static_cast<const MDeformVert *>(
CustomData_get_layer(&mesh->vert_data, CD_MDEFORMVERT));
const MDeformVert *dvert = mesh->deform_verts().data();
/* Proceed only if vgroup is valid, else assume factor = O. */
if (dvert == nullptr) {
return;

View File

@@ -186,7 +186,7 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh
return mesh;
}
const bool has_mdef = CustomData_has_layer(&mesh->vert_data, CD_MDEFORMVERT);
const bool has_mdef = !mesh->deform_verts().is_empty();
/* If no vertices were ever added to an object's vgroup, dvert might be nullptr. */
if (!has_mdef) {
/* If this modifier is not allowed to add vertices, just return. */

View File

@@ -250,7 +250,7 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh
}
}
const bool has_mdef = CustomData_has_layer(&mesh->vert_data, CD_MDEFORMVERT);
const bool has_mdef = !mesh->deform_verts().is_empty();
/* If no vertices were ever added to an object's vgroup, dvert might be nullptr. */
if (!has_mdef) {
/* If not affecting all vertices, just return. */

View File

@@ -460,7 +460,7 @@ static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh
if (defgrp_index == -1) {
return mesh;
}
const bool has_mdef = CustomData_has_layer(&mesh->vert_data, CD_MDEFORMVERT);
const bool has_mdef = !mesh->deform_verts().is_empty();
/* If no vertices were ever added to an object's vgroup, dvert might be nullptr. */
/* As this modifier never add vertices to vgroup, just return. */
if (!has_mdef) {

View File

@@ -28,7 +28,6 @@
#include "DNA_screen_types.h"
#include "BKE_context.hh"
#include "BKE_customdata.hh"
#include "BKE_deform.hh"
#include "BKE_modifier.hh"
#include "BKE_screen.hh"
@@ -55,12 +54,7 @@ static Span<MDeformVert> get_vertex_group(const Mesh &mesh, const int defgrp_ind
if (defgrp_index == -1) {
return {};
}
const MDeformVert *vertex_group = static_cast<const MDeformVert *>(
CustomData_get_layer(&mesh.vert_data, CD_MDEFORMVERT));
if (!vertex_group) {
return {};
}
return {vertex_group, mesh.verts_num};
return mesh.deform_verts();
}
static IndexMask selected_indices_from_vertex_group(Span<MDeformVert> vertex_group,