From 50fdbf3ec0a2d9a5b1f004be550fd40edbfc1e77 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Aug 2019 11:46:04 +1000 Subject: Cleanup: use const arguments for vertex coords --- source/blender/blenkernel/BKE_curve.h | 2 +- source/blender/blenkernel/BKE_key.h | 10 +++++-- source/blender/blenkernel/BKE_lattice.h | 2 +- source/blender/blenkernel/BKE_mesh.h | 4 +-- source/blender/blenkernel/BKE_pbvh.h | 2 +- source/blender/blenkernel/intern/curve.c | 2 +- source/blender/blenkernel/intern/key.c | 8 ++--- source/blender/blenkernel/intern/lattice.c | 2 +- source/blender/blenkernel/intern/mesh.c | 34 ++++++++-------------- source/blender/blenkernel/intern/pbvh.c | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 2 +- .../blender/editors/sculpt_paint/sculpt_intern.h | 2 +- 12 files changed, 33 insertions(+), 39 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 51ff4673aba..dff38f6b609 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -125,7 +125,7 @@ bool BKE_curve_nurb_vert_active_get(struct Curve *cu, struct Nurb **r_nu, void * void BKE_curve_nurb_vert_active_validate(struct Curve *cu); float (*BKE_curve_nurbs_vertexCos_get(struct ListBase *lb, int *r_numVerts))[3]; -void BK_curve_nurbs_vertexCos_apply(struct ListBase *lb, float (*vertexCos)[3]); +void BK_curve_nurbs_vertexCos_apply(struct ListBase *lb, const float (*vertexCos)[3]); float (*BKE_curve_nurbs_keyVertexCos_get(struct ListBase *lb, float *key))[3]; void BKE_curve_nurbs_keyVertexTilts_apply(struct ListBase *lb, float *key); diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index 58ad3f6230d..6e34f4f07d9 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -92,13 +92,17 @@ void BKE_keyblock_mesh_calc_normals(struct KeyBlock *kb, float (*r_polynors)[3], float (*r_loopnors)[3]); -void BKE_keyblock_update_from_vertcos(struct Object *ob, struct KeyBlock *kb, float (*vertCos)[3]); +void BKE_keyblock_update_from_vertcos(struct Object *ob, + struct KeyBlock *kb, + const float (*vertCos)[3]); void BKE_keyblock_convert_from_vertcos(struct Object *ob, struct KeyBlock *kb, - float (*vertCos)[3]); + const float (*vertCos)[3]); float (*BKE_keyblock_convert_to_vertcos(struct Object *ob, struct KeyBlock *kb))[3]; -void BKE_keyblock_update_from_offset(struct Object *ob, struct KeyBlock *kb, float (*ofs)[3]); +void BKE_keyblock_update_from_offset(struct Object *ob, + struct KeyBlock *kb, + const float (*ofs)[3]); /* other management */ bool BKE_keyblock_move(struct Object *ob, int org_index, int new_index); diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index c4173cd867e..d6df7517ceb 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -89,7 +89,7 @@ void armature_deform_verts(struct Object *armOb, struct bGPDstroke *gps); float (*BKE_lattice_vertexcos_get(struct Object *ob, int *r_numVerts))[3]; -void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]); +void BKE_lattice_vertexcos_apply(struct Object *ob, const float (*vertexCos)[3]); void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 94d118bde36..3de52239d84 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -268,8 +268,8 @@ void BKE_mesh_mselect_active_set(struct Mesh *me, int index, int type); void BKE_mesh_count_selected_items(const struct Mesh *mesh, int r_count[3]); -void BKE_mesh_apply_vert_coords(struct Mesh *mesh, float (*vertCoords)[3]); -void BKE_mesh_apply_vert_normals(struct Mesh *mesh, short (*vertNormals)[3]); +void BKE_mesh_apply_vert_coords(struct Mesh *mesh, const float (*vertCoords)[3]); +void BKE_mesh_apply_vert_normals(struct Mesh *mesh, const short (*vertNormals)[3]); /* *** mesh_evaluate.c *** */ diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 62544efad2c..d34ff424e05 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -279,7 +279,7 @@ void BKE_pbvh_node_layer_disp_free(PBVHNode *node); /* vertex deformer */ float (*BKE_pbvh_get_vertCos(struct PBVH *pbvh))[3]; -void BKE_pbvh_apply_vertCos(struct PBVH *pbvh, float (*vertCos)[3], const int totvert); +void BKE_pbvh_apply_vertCos(struct PBVH *pbvh, const float (*vertCos)[3], const int totvert); bool BKE_pbvh_isDeformed(struct PBVH *pbvh); /* Vertex Iterator */ diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 980e8043a42..5ec0483d637 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -4639,7 +4639,7 @@ float (*BKE_curve_nurbs_vertexCos_get(ListBase *lb, int *r_numVerts))[3] return cos; } -void BK_curve_nurbs_vertexCos_apply(ListBase *lb, float (*vertexCos)[3]) +void BK_curve_nurbs_vertexCos_apply(ListBase *lb, const float (*vertexCos)[3]) { const float *co = vertexCos[0]; Nurb *nu; diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 61de6a8c06a..9a38f348361 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -2066,9 +2066,9 @@ void BKE_keyblock_mesh_calc_normals(struct KeyBlock *kb, } /************************* raw coords ************************/ -void BKE_keyblock_update_from_vertcos(Object *ob, KeyBlock *kb, float (*vertCos)[3]) +void BKE_keyblock_update_from_vertcos(Object *ob, KeyBlock *kb, const float (*vertCos)[3]) { - float(*co)[3] = vertCos; + const float(*co)[3] = vertCos; float *fp = kb->data; int tot, a; @@ -2126,7 +2126,7 @@ void BKE_keyblock_update_from_vertcos(Object *ob, KeyBlock *kb, float (*vertCos) } } -void BKE_keyblock_convert_from_vertcos(Object *ob, KeyBlock *kb, float (*vertCos)[3]) +void BKE_keyblock_convert_from_vertcos(Object *ob, KeyBlock *kb, const float (*vertCos)[3]) { int tot = 0, elemsize; @@ -2219,7 +2219,7 @@ float (*BKE_keyblock_convert_to_vertcos(Object *ob, KeyBlock *kb))[3] } /************************* raw coord offsets ************************/ -void BKE_keyblock_update_from_offset(Object *ob, KeyBlock *kb, float (*ofs)[3]) +void BKE_keyblock_update_from_offset(Object *ob, KeyBlock *kb, const float (*ofs)[3]) { int a; float *fp = kb->data; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 83b354ffb4a..44ab4b066c1 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -1075,7 +1075,7 @@ float (*BKE_lattice_vertexcos_get(struct Object *ob, int *r_numVerts))[3] return vertexCos; } -void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]) +void BKE_lattice_vertexcos_apply(struct Object *ob, const float (*vertexCos)[3]) { Lattice *lt = ob->data; int i, numVerts = lt->pntsu * lt->pntsv * lt->pntsw; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 4f39d34574e..0811b3cef3b 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1665,35 +1665,25 @@ void BKE_mesh_count_selected_items(const Mesh *mesh, int r_count[3]) /* We could support faces in paint modes. */ } -void BKE_mesh_apply_vert_coords(Mesh *mesh, float (*vertCoords)[3]) +void BKE_mesh_apply_vert_coords(Mesh *mesh, const float (*vertCoords)[3]) { - MVert *vert; - int i; - - /* this will just return the pointer if it wasn't a referenced layer */ - vert = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MVERT, mesh->totvert); - mesh->mvert = vert; - - for (i = 0; i < mesh->totvert; ++i, ++vert) { - copy_v3_v3(vert->co, vertCoords[i]); + /* This will just return the pointer if it wasn't a referenced layer. */ + MVert *mv = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MVERT, mesh->totvert); + mesh->mvert = mv; + for (int i = 0; i < mesh->totvert; i++, mv++) { + copy_v3_v3(mv->co, vertCoords[i]); } - mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL; } -void BKE_mesh_apply_vert_normals(Mesh *mesh, short (*vertNormals)[3]) +void BKE_mesh_apply_vert_normals(Mesh *mesh, const short (*vertNormals)[3]) { - MVert *vert; - int i; - - /* this will just return the pointer if it wasn't a referenced layer */ - vert = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MVERT, mesh->totvert); - mesh->mvert = vert; - - for (i = 0; i < mesh->totvert; ++i, ++vert) { - copy_v3_v3_short(vert->no, vertNormals[i]); + /* This will just return the pointer if it wasn't a referenced layer. */ + MVert *mv = CustomData_duplicate_referenced_layer(&mesh->vdata, CD_MVERT, mesh->totvert); + mesh->mvert = mv; + for (int i = 0; i < mesh->totvert; i++, mv++) { + copy_v3_v3_short(mv->no, vertNormals[i]); } - mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL; } diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 64a16a0e3be..81e4537964b 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -2324,7 +2324,7 @@ float (*BKE_pbvh_get_vertCos(PBVH *pbvh))[3] return vertCos; } -void BKE_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3], const int totvert) +void BKE_pbvh_apply_vertCos(PBVH *pbvh, const float (*vertCos)[3], const int totvert) { if (totvert != pbvh->totvert) { BLI_assert(!"PBVH: Given deforming vcos number does not natch PBVH vertex number!"); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 440c4d42cae..bee39581ac2 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3987,7 +3987,7 @@ static void do_gravity(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, fl BLI_task_parallel_range(0, totnode, &data, do_gravity_task_cb_ex, &settings); } -void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) +void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, const float (*vertCos)[3]) { Mesh *me = (Mesh *)ob->data; float(*ofs)[3] = NULL; diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index e646accf108..928af8cc77f 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -342,7 +342,7 @@ SculptUndoNode *sculpt_undo_get_node(PBVHNode *node); void sculpt_undo_push_begin(const char *name); void sculpt_undo_push_end(void); -void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]); +void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, const float (*vertCos)[3]); void sculpt_update_object_bounding_box(struct Object *ob); -- cgit v1.2.3