Cleanup: Use const pointers for evaluated meshes

Helps with the fix to #105912
This commit is contained in:
Hans Goudey 2023-03-27 11:48:10 -04:00
parent efda95840d
commit 1af3c16962
5 changed files with 38 additions and 35 deletions

@ -18,7 +18,7 @@ typedef enum MeshForeachFlag {
} MeshForeachFlag;
void BKE_mesh_foreach_mapped_vert(
struct Mesh *mesh,
const struct Mesh *mesh,
void (*func)(void *userData, int index, const float co[3], const float no[3]),
void *userData,
MeshForeachFlag flag);

@ -159,14 +159,14 @@ void BKE_mesh_remap_calc_source_cddata_masks_from_map_modes(
float BKE_mesh_remap_calc_difference_from_mesh(const struct SpaceTransform *space_transform,
const float (*vert_positions_dst)[3],
int numverts_dst,
struct Mesh *me_src);
const struct Mesh *me_src);
/**
* Set r_space_transform so that best bbox of dst matches best bbox of src.
*/
void BKE_mesh_remap_find_best_match_from_mesh(const float (*vert_positions_dst)[3],
int numverts_dst,
struct Mesh *me_src,
const struct Mesh *me_src,
struct SpaceTransform *r_space_transform);
void BKE_mesh_remap_calc_verts_from_mesh(int mode,
@ -176,7 +176,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(int mode,
const float (*vert_positions_dst)[3],
int numverts_dst,
bool dirty_nors_dst,
struct Mesh *me_src,
const struct Mesh *me_src,
struct Mesh *me_dst,
MeshPairRemap *r_map);
@ -189,7 +189,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(int mode,
const struct MEdge *edges_dst,
int numedges_dst,
bool dirty_nors_dst,
struct Mesh *me_src,
const struct Mesh *me_src,
struct Mesh *me_dst,
MeshPairRemap *r_map);
@ -211,7 +211,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(int mode,
bool use_split_nors_dst,
float split_angle_dst,
bool dirty_nors_dst,
struct Mesh *me_src,
const struct Mesh *me_src,
MeshRemapIslandsCalc gen_islands_src,
float islands_precision_src,
struct MeshPairRemap *r_map);
@ -226,7 +226,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(int mode,
const int *corner_verts,
const struct MPoly *polys_dst,
int numpolys_dst,
struct Mesh *me_src,
const struct Mesh *me_src,
struct MeshPairRemap *r_map);
#ifdef __cplusplus

@ -256,7 +256,7 @@ int BKE_object_data_transfer_dttype_to_srcdst_index(const int dtdata_type)
* is set).
*/
static void data_transfer_mesh_attributes_transfer_active_color_string(
Mesh *mesh_dst, Mesh *mesh_src, const eAttrDomainMask mask_domain, const int data_type)
Mesh *mesh_dst, const Mesh *mesh_src, const eAttrDomainMask mask_domain, const int data_type)
{
if (mesh_dst->active_color_attribute) {
return;
@ -264,14 +264,17 @@ static void data_transfer_mesh_attributes_transfer_active_color_string(
const char *active_color_src = BKE_id_attributes_active_color_name(&mesh_src->id);
if ((data_type == CD_PROP_COLOR) &&
!BKE_id_attribute_search(
&mesh_src->id, active_color_src, CD_MASK_PROP_COLOR, ATTR_DOMAIN_MASK_COLOR)) {
if ((data_type == CD_PROP_COLOR) && !BKE_id_attribute_search(&const_cast<ID &>(mesh_src->id),
active_color_src,
CD_MASK_PROP_COLOR,
ATTR_DOMAIN_MASK_COLOR)) {
return;
}
else if ((data_type == CD_PROP_BYTE_COLOR) &&
!BKE_id_attribute_search(
&mesh_src->id, active_color_src, CD_MASK_PROP_BYTE_COLOR, ATTR_DOMAIN_MASK_COLOR)) {
!BKE_id_attribute_search(&const_cast<ID &>(mesh_src->id),
active_color_src,
CD_MASK_PROP_BYTE_COLOR,
ATTR_DOMAIN_MASK_COLOR)) {
return;
}
@ -300,7 +303,7 @@ static void data_transfer_mesh_attributes_transfer_active_color_string(
* is set).
*/
static void data_transfer_mesh_attributes_transfer_default_color_string(
Mesh *mesh_dst, Mesh *mesh_src, const eAttrDomainMask mask_domain, const int data_type)
Mesh *mesh_dst, const Mesh *mesh_src, const eAttrDomainMask mask_domain, const int data_type)
{
if (mesh_dst->default_color_attribute) {
return;
@ -308,12 +311,14 @@ static void data_transfer_mesh_attributes_transfer_default_color_string(
const char *default_color_src = BKE_id_attributes_default_color_name(&mesh_src->id);
if ((data_type == CD_PROP_COLOR) &&
!BKE_id_attribute_search(
&mesh_src->id, default_color_src, CD_MASK_PROP_COLOR, ATTR_DOMAIN_MASK_COLOR)) {
if ((data_type == CD_PROP_COLOR) && !BKE_id_attribute_search(&const_cast<ID &>(mesh_src->id),
default_color_src,
CD_MASK_PROP_COLOR,
ATTR_DOMAIN_MASK_COLOR)) {
return;
}
else if ((data_type == CD_PROP_BYTE_COLOR) && !BKE_id_attribute_search(&mesh_src->id,
else if ((data_type == CD_PROP_BYTE_COLOR) &&
!BKE_id_attribute_search(&const_cast<ID &>(mesh_src->id),
default_color_src,
CD_MASK_PROP_BYTE_COLOR,
ATTR_DOMAIN_MASK_COLOR)) {
@ -344,7 +349,7 @@ static void data_transfer_mesh_attributes_transfer_default_color_string(
/* Generic pre/post processing, only used by custom loop normals currently. */
static void data_transfer_dtdata_type_preprocess(Mesh *me_src,
static void data_transfer_dtdata_type_preprocess(const Mesh *me_src,
Mesh *me_dst,
const int dtdata_type,
const bool dirty_nors_dst)
@ -396,10 +401,7 @@ static void data_transfer_dtdata_type_preprocess(Mesh *me_src,
}
}
static void data_transfer_dtdata_type_postprocess(Object * /*ob_src*/,
Object * /*ob_dst*/,
Mesh * /*me_src*/,
Mesh *me_dst,
static void data_transfer_dtdata_type_postprocess(Mesh *me_dst,
const int dtdata_type,
const bool changed)
{
@ -895,7 +897,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
static bool data_transfer_layersmapping_generate(ListBase *r_map,
Object *ob_src,
Object *ob_dst,
Mesh *me_src,
const Mesh *me_src,
Mesh *me_dst,
const int elem_type,
int cddata_type,
@ -909,7 +911,8 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
const int tolayers,
SpaceTransform *space_transform)
{
CustomData *cd_src, *cd_dst;
const CustomData *cd_src;
CustomData *cd_dst;
cd_datatransfer_interp interp = nullptr;
void *interp_data = nullptr;
@ -1299,7 +1302,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
SpaceTransform auto_space_transform;
Mesh *me_src;
const Mesh *me_src;
/* Assumed always true if not using an evaluated mesh as destination. */
bool dirty_nors_dst = true;
@ -1356,7 +1359,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
if (!me_src) {
return changed;
}
BKE_mesh_wrapper_ensure_mdata(me_src);
BKE_mesh_wrapper_ensure_mdata(const_cast<Mesh *>(me_src));
if (auto_transform) {
if (space_transform == nullptr) {
@ -1751,7 +1754,7 @@ bool BKE_object_data_transfer_ex(struct Depsgraph *depsgraph,
}
}
data_transfer_dtdata_type_postprocess(ob_src, ob_dst, me_src, me_dst, dtdata_type, changed);
data_transfer_dtdata_type_postprocess(me_dst, dtdata_type, changed);
}
for (int i = 0; i < DATAMAX; i++) {

@ -31,7 +31,7 @@
* path needs to consist of both edit mesh and edit data checks. */
void BKE_mesh_foreach_mapped_vert(
Mesh *mesh,
const Mesh *mesh,
void (*func)(void *userData, int index, const float co[3], const float no[3]),
void *userData,
MeshForeachFlag flag)

@ -112,7 +112,7 @@ static bool mesh_remap_bvhtree_query_raycast(BVHTreeFromMesh *treedata,
float BKE_mesh_remap_calc_difference_from_mesh(const SpaceTransform *space_transform,
const float (*vert_positions_dst)[3],
const int numverts_dst,
Mesh *me_src)
const Mesh *me_src)
{
BVHTreeFromMesh treedata = {nullptr};
BVHTreeNearest nearest = {0};
@ -241,7 +241,7 @@ static void mesh_calc_eigen_matrix(const float (*positions)[3],
void BKE_mesh_remap_find_best_match_from_mesh(const float (*vert_positions_dst)[3],
const int numverts_dst,
Mesh *me_src,
const Mesh *me_src,
SpaceTransform *r_space_transform)
{
/* Note that those are done so that we successively get actual mirror matrix
@ -463,7 +463,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
const float (*vert_positions_dst)[3],
const int numverts_dst,
const bool /*dirty_nors_dst*/,
Mesh *me_src,
const Mesh *me_src,
Mesh *me_dst,
MeshPairRemap *r_map)
{
@ -686,7 +686,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
const MEdge *edges_dst,
const int numedges_dst,
const bool /*dirty_nors_dst*/,
Mesh *me_src,
const Mesh *me_src,
Mesh *me_dst,
MeshPairRemap *r_map)
{
@ -1239,7 +1239,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
const bool use_split_nors_dst,
const float split_angle_dst,
const bool dirty_nors_dst,
Mesh *me_src,
const Mesh *me_src,
MeshRemapIslandsCalc gen_islands_src,
const float islands_precision_src,
MeshPairRemap *r_map)
@ -2151,7 +2151,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
const int *corner_verts_dst,
const MPoly *polys_dst,
const int numpolys_dst,
Mesh *me_src,
const Mesh *me_src,
MeshPairRemap *r_map)
{
const float full_weight = 1.0f;