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);
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);
/**

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);
}
static float (*get_editbmesh_orco_verts(BMEditMesh *em))[3]
static float (*get_editbmesh_orco_verts(const BMEditMesh *em))[3]
{
BMIter iter;
BMVert *eve;
@ -338,7 +338,7 @@ static float (*get_editbmesh_orco_verts(BMEditMesh *em))[3]
}
/* 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;
@ -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
* by a more flexible customdata system, but not simple */
if (!em) {
ClothModifierData *clmd = (ClothModifierData *)BKE_modifiers_findby_type(
const ClothModifierData *clmd = (const ClothModifierData *)BKE_modifiers_findby_type(
ob, eModifierType_Cloth);
if (clmd && clmd->sim_parms->shapekey_rest) {
KeyBlock *kb = BKE_keyblock_find_by_index(BKE_key_from_object(ob),
clmd->sim_parms->shapekey_rest);
const KeyBlock *kb = BKE_keyblock_find_by_index(
BKE_key_from_object(const_cast<Object *>(ob)), clmd->sim_parms->shapekey_rest);
if (kb && 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;
}
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;
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);
}
static void add_orco_mesh(
Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orco, const eCustomDataType layer)
static void add_orco_mesh(Object *ob,
const BMEditMesh *em,
Mesh *mesh,
const Mesh *mesh_orco,
const eCustomDataType layer)
{
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);
Mesh *tme = mesh->texcomesh ? mesh->texcomesh : mesh;
const Mesh *mesh = static_cast<const Mesh *>(ob->data);
const Mesh *tme = mesh->texcomesh ? mesh->texcomesh : mesh;
/* Get appropriate vertex coordinates */
float(*vcos)[3] = (float(*)[3])MEM_calloc_arrayN(mesh->verts_num, sizeof(*vcos), "orco mesh");