Cleanup: Use const in more places in mesh modifier evaluation

This commit is contained in:
Hans Goudey 2024-03-27 22:24:40 -04:00
parent b35831ad6c
commit 94b985371d
3 changed files with 15 additions and 12 deletions

View File

@ -140,7 +140,7 @@ Mesh *BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase *
bool BKE_mesh_attribute_required(const char *name); bool BKE_mesh_attribute_required(const char *name);
float (*BKE_mesh_orco_verts_get(Object *ob))[3]; float (*BKE_mesh_orco_verts_get(const Object *ob))[3];
void BKE_mesh_orco_verts_transform(Mesh *mesh, float (*orco)[3], int totvert, bool invert); void BKE_mesh_orco_verts_transform(Mesh *mesh, float (*orco)[3], int totvert, bool invert);
/** /**

View File

@ -318,7 +318,7 @@ void DM_interp_vert_data(const DerivedMesh *source,
&source->vertData, &dest->vertData, src_indices, weights, nullptr, count, dest_index); &source->vertData, &dest->vertData, src_indices, weights, nullptr, count, dest_index);
} }
static float (*get_editbmesh_orco_verts(BMEditMesh *em))[3] static float (*get_editbmesh_orco_verts(const BMEditMesh *em))[3]
{ {
BMIter iter; BMIter iter;
BMVert *eve; BMVert *eve;
@ -338,7 +338,7 @@ static float (*get_editbmesh_orco_verts(BMEditMesh *em))[3]
} }
/* orco custom data layer */ /* orco custom data layer */
static float (*get_orco_coords(Object *ob, BMEditMesh *em, int layer, int *free))[3] static float (*get_orco_coords(const Object *ob, const BMEditMesh *em, int layer, int *free))[3]
{ {
*free = 0; *free = 0;
@ -355,11 +355,11 @@ static float (*get_orco_coords(Object *ob, BMEditMesh *em, int layer, int *free)
/* apply shape key for cloth, this should really be solved /* apply shape key for cloth, this should really be solved
* by a more flexible customdata system, but not simple */ * by a more flexible customdata system, but not simple */
if (!em) { if (!em) {
ClothModifierData *clmd = (ClothModifierData *)BKE_modifiers_findby_type( const ClothModifierData *clmd = (const ClothModifierData *)BKE_modifiers_findby_type(
ob, eModifierType_Cloth); ob, eModifierType_Cloth);
if (clmd && clmd->sim_parms->shapekey_rest) { if (clmd && clmd->sim_parms->shapekey_rest) {
KeyBlock *kb = BKE_keyblock_find_by_index(BKE_key_from_object(ob), const KeyBlock *kb = BKE_keyblock_find_by_index(
clmd->sim_parms->shapekey_rest); BKE_key_from_object(const_cast<Object *>(ob)), clmd->sim_parms->shapekey_rest);
if (kb && kb->data) { if (kb && kb->data) {
return (float(*)[3])kb->data; return (float(*)[3])kb->data;
@ -373,7 +373,7 @@ static float (*get_orco_coords(Object *ob, BMEditMesh *em, int layer, int *free)
return nullptr; return nullptr;
} }
static Mesh *create_orco_mesh(Object *ob, Mesh *mesh, BMEditMesh *em, int layer) static Mesh *create_orco_mesh(const Object *ob, const Mesh *mesh, const BMEditMesh *em, int layer)
{ {
Mesh *orco_mesh; Mesh *orco_mesh;
float(*orco)[3]; float(*orco)[3];
@ -410,8 +410,11 @@ static MutableSpan<float3> orco_coord_layer_ensure(Mesh *mesh, const eCustomData
return MutableSpan(reinterpret_cast<float3 *>(data), mesh->verts_num); return MutableSpan(reinterpret_cast<float3 *>(data), mesh->verts_num);
} }
static void add_orco_mesh( static void add_orco_mesh(Object *ob,
Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orco, const eCustomDataType layer) const BMEditMesh *em,
Mesh *mesh,
const Mesh *mesh_orco,
const eCustomDataType layer)
{ {
const int totvert = mesh->verts_num; const int totvert = mesh->verts_num;

View File

@ -1005,10 +1005,10 @@ void BKE_mesh_texspace_get_reference(Mesh *mesh,
} }
} }
float (*BKE_mesh_orco_verts_get(Object *ob))[3] float (*BKE_mesh_orco_verts_get(const Object *ob))[3]
{ {
Mesh *mesh = static_cast<Mesh *>(ob->data); const Mesh *mesh = static_cast<const Mesh *>(ob->data);
Mesh *tme = mesh->texcomesh ? mesh->texcomesh : mesh; const Mesh *tme = mesh->texcomesh ? mesh->texcomesh : mesh;
/* Get appropriate vertex coordinates */ /* Get appropriate vertex coordinates */
float(*vcos)[3] = (float(*)[3])MEM_calloc_arrayN(mesh->verts_num, sizeof(*vcos), "orco mesh"); float(*vcos)[3] = (float(*)[3])MEM_calloc_arrayN(mesh->verts_num, sizeof(*vcos), "orco mesh");