diff options
author | Hans Goudey <h.goudey@me.com> | 2021-07-02 07:03:09 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-07-02 07:03:27 +0300 |
commit | 9f5c0ffb5ec293af2e4f003c2178d21e20805b47 (patch) | |
tree | eb5b5c98fae3402da6ad98472ad5f5ea1cfbacd0 /source/blender/editors | |
parent | 016a2707f573efe113f89ced1870912de19a16a1 (diff) |
Cleanup: Use const variables for object's evaluated mesh
Generally the evaluated mesh should not be changed, since that is the
job of the modifier stack. Current code is far from const correct in
that regard. This commit uses a const variable for the reult of
`BKE_object_get_evaluated_mesh` in some cases. The most common
remaining case is retrieving a BVH tree from the mesh.
Diffstat (limited to 'source/blender/editors')
4 files changed, 11 insertions, 11 deletions
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c index aa144dd3f3c..942fe143787 100644 --- a/source/blender/editors/mesh/editmesh_knife_project.c +++ b/source/blender/editors/mesh/editmesh_knife_project.c @@ -59,7 +59,7 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C, { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ARegion *region = CTX_wm_region(C); - struct Mesh *me_eval; + const struct Mesh *me_eval; bool me_eval_needs_free; if (ob->type == OB_MESH || ob->runtime.data_eval) { @@ -113,7 +113,7 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C, BKE_nurbList_free(&nurbslist); if (me_eval_needs_free) { - BKE_mesh_free(me_eval); + BKE_mesh_free((struct Mesh *)me_eval); } } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index fe36d62b832..caf2bc46ad8 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -179,7 +179,7 @@ static MDeformVert *defweight_prev_init(MDeformVert *dvert_prev, * (without evaluating modifiers) */ static bool vertex_paint_use_fast_update_check(Object *ob) { - Mesh *me_eval = BKE_object_get_evaluated_mesh(ob); + const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob); if (me_eval != NULL) { Mesh *me = BKE_mesh_from_object(ob); diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 9e0973f5fde..706d52f43b2 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -96,7 +96,7 @@ typedef struct SceneStatsFmt { char totgpstroke[MAX_INFO_NUM_LEN], totgppoint[MAX_INFO_NUM_LEN]; } SceneStatsFmt; -static bool stats_mesheval(Mesh *me_eval, bool is_selected, SceneStats *stats) +static bool stats_mesheval(const Mesh *me_eval, bool is_selected, SceneStats *stats) { if (me_eval == NULL) { return false; @@ -149,8 +149,8 @@ static void stats_object(Object *ob, switch (ob->type) { case OB_MESH: { /* we assume evaluated mesh is already built, this strictly does stats now. */ - Mesh *me_eval = BKE_object_get_evaluated_mesh(ob); - if (!BLI_gset_add(objects_gset, me_eval)) { + const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob); + if (!BLI_gset_add(objects_gset, (void *)me_eval)) { break; } stats_mesheval(me_eval, is_selected, stats); @@ -165,8 +165,8 @@ static void stats_object(Object *ob, case OB_SURF: case OB_CURVE: case OB_FONT: { - Mesh *me_eval = BKE_object_get_evaluated_mesh(ob); - if ((me_eval != NULL) && !BLI_gset_add(objects_gset, me_eval)) { + const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob); + if ((me_eval != NULL) && !BLI_gset_add(objects_gset, (void *)me_eval)) { break; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 660ae9da506..6b9da431510 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -117,10 +117,10 @@ void ED_draw_object_facemap(Depsgraph *depsgraph, return; } - Mesh *me = ob->data; + const Mesh *me = ob->data; { Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval); + const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval); if (me_eval != NULL) { me = me_eval; } @@ -160,7 +160,7 @@ void ED_draw_object_facemap(Depsgraph *depsgraph, const MPoly *mp; int i; if (me->runtime.looptris.array) { - MLoopTri *mlt = me->runtime.looptris.array; + const MLoopTri *mlt = me->runtime.looptris.array; for (mp = mpoly, i = 0; i < mpoly_len; i++, mp++) { if (facemap_data[i] == facemap) { for (int j = 2; j < mp->totloop; j++) { |