27
27
#include " BKE_object.hh"
28
28
#include " BKE_object_deform.h"
29
29
#include " BKE_report.hh"
30
+ #include " BKE_subdiv_mesh.hh"
30
31
#include " BKE_subsurf.hh"
31
32
32
33
#include " DEG_depsgraph.hh"
@@ -199,7 +200,7 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
199
200
200
201
static void envelope_bone_weighting (Object *ob,
201
202
Mesh *mesh,
202
- float (* verts)[3] ,
203
+ const blender::Span<blender::float3> verts,
203
204
int numbones,
204
205
Bone **bonelist,
205
206
bDeformGroup **dgrouplist,
@@ -298,7 +299,8 @@ static void add_verts_to_dgroups(ReportList *reports,
298
299
bPoseChannel *pchan;
299
300
Mesh *mesh;
300
301
Mat4 bbone_array[MAX_BBONE_SUBDIV], *bbone = nullptr ;
301
- float (*root)[3 ], (*tip)[3 ], (*verts)[3 ];
302
+ float (*root)[3 ], (*tip)[3 ];
303
+ blender::Array<blender::float3> verts;
302
304
bool *selected;
303
305
int numbones, vertsfilled = 0 , segments = 0 ;
304
306
const bool wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT);
@@ -412,23 +414,23 @@ static void add_verts_to_dgroups(ReportList *reports,
412
414
413
415
/* create verts */
414
416
mesh = static_cast <Mesh *>(ob->data );
415
- verts = static_cast <float (*)[3 ]>(
416
- MEM_callocN (mesh->verts_num * sizeof (*verts), " closestboneverts" ));
417
+ verts.reinitialize (mesh->verts_num );
417
418
418
419
if (wpmode) {
419
420
/* if in weight paint mode, use final verts from evaluated mesh */
420
421
const Object *ob_eval = DEG_get_evaluated (depsgraph, ob);
421
422
const Mesh *mesh_eval = BKE_object_get_evaluated_mesh (ob_eval);
422
423
if (mesh_eval) {
423
- BKE_mesh_foreach_mapped_vert_coords_get (mesh_eval, verts, mesh->verts_num );
424
+ BKE_mesh_foreach_mapped_vert_coords_get (
425
+ mesh_eval, reinterpret_cast <float (*)[3 ]>(verts.data ()), mesh->verts_num );
424
426
vertsfilled = 1 ;
425
427
}
426
428
}
427
429
else if (BKE_modifiers_findby_type (ob, eModifierType_Subsurf)) {
428
430
/* Is subdivision-surface on? Lets use the verts on the limit surface then.
429
431
* = same amount of vertices as mesh, but vertices moved to the
430
432
* subdivision-surfaced position, like for 'optimal'. */
431
- subsurf_calculate_limit_positions (mesh, verts);
433
+ blender::bke::subdiv::calculate_limit_positions (mesh, verts);
432
434
vertsfilled = 1 ;
433
435
}
434
436
@@ -445,8 +447,16 @@ static void add_verts_to_dgroups(ReportList *reports,
445
447
if (heat) {
446
448
const char *error = nullptr ;
447
449
448
- heat_bone_weighting (
449
- ob, mesh, verts, numbones, dgrouplist, dgroupflip, root, tip, selected, &error);
450
+ heat_bone_weighting (ob,
451
+ mesh,
452
+ reinterpret_cast <float (*)[3 ]>(verts.data ()),
453
+ numbones,
454
+ dgrouplist,
455
+ dgroupflip,
456
+ root,
457
+ tip,
458
+ selected,
459
+ &error);
450
460
if (error) {
451
461
BKE_report (reports, RPT_WARNING, error);
452
462
}
@@ -475,7 +485,6 @@ static void add_verts_to_dgroups(ReportList *reports,
475
485
MEM_freeN (root);
476
486
MEM_freeN (tip);
477
487
MEM_freeN (selected);
478
- MEM_freeN (verts);
479
488
}
480
489
481
490
void ED_object_vgroup_calc_from_armature (ReportList *reports,
0 commit comments