From 65bb33a668b74fb9c488d3ef0ab01ed844d8e89d Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 12 Nov 2024 17:52:19 -0500 Subject: [PATCH] Cleanup: Remove unused shape key functions These were last used in some sculpt code that has been refactored to do things more efficiently. For that same reason I don't think we're likely to need them elsewhere. --- source/blender/blenkernel/BKE_key.hh | 7 - source/blender/blenkernel/intern/key.cc | 184 ------------------------ 2 files changed, 191 deletions(-) diff --git a/source/blender/blenkernel/BKE_key.hh b/source/blender/blenkernel/BKE_key.hh index 37929a2e4a7..202a9064a3d 100644 --- a/source/blender/blenkernel/BKE_key.hh +++ b/source/blender/blenkernel/BKE_key.hh @@ -143,13 +143,6 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb, float (*r_face_normals)[3], float (*r_loop_normals)[3]); -void BKE_keyblock_update_from_vertcos(const Object *ob, KeyBlock *kb, const float (*vertCos)[3]); -void BKE_keyblock_convert_from_vertcos(const Object *ob, KeyBlock *kb, const float (*vertCos)[3]); -float (*BKE_keyblock_convert_to_vertcos(const Object *ob, const KeyBlock *kb))[3]; - -/** RAW coordinates offsets. */ -void BKE_keyblock_update_from_offset(const Object *ob, KeyBlock *kb, const float (*ofs)[3]); - /* other management */ /** diff --git a/source/blender/blenkernel/intern/key.cc b/source/blender/blenkernel/intern/key.cc index 0b612ff4b09..e530ccf3879 100644 --- a/source/blender/blenkernel/intern/key.cc +++ b/source/blender/blenkernel/intern/key.cc @@ -2294,190 +2294,6 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb, /************************* raw coords ************************/ -void BKE_keyblock_update_from_vertcos(const Object *ob, KeyBlock *kb, const float (*vertCos)[3]) -{ - const float(*co)[3] = vertCos; - float *fp = static_cast(kb->data); - int tot, a; - -#ifndef NDEBUG - if (ob->type == OB_LATTICE) { - Lattice *lt = static_cast(ob->data); - BLI_assert((lt->pntsu * lt->pntsv * lt->pntsw) == kb->totelem); - } - else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) { - Curve *cu = static_cast(ob->data); - BLI_assert(BKE_keyblock_curve_element_count(&cu->nurb) == kb->totelem); - } - else if (ob->type == OB_MESH) { - Mesh *mesh = static_cast(ob->data); - BLI_assert(mesh->verts_num == kb->totelem); - } - else { - BLI_assert(0 == kb->totelem); - } -#endif - - tot = kb->totelem; - if (tot == 0) { - return; - } - - /* Copy coords to key-block. */ - if (ELEM(ob->type, OB_MESH, OB_LATTICE)) { - for (a = 0; a < tot; a++, fp += 3, co++) { - copy_v3_v3(fp, *co); - } - } - else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) { - const Curve *cu = (const Curve *)ob->data; - const BezTriple *bezt; - const BPoint *bp; - - LISTBASE_FOREACH (const Nurb *, nu, &cu->nurb) { - if (nu->bezt) { - for (a = nu->pntsu, bezt = nu->bezt; a; a--, bezt++) { - for (int i = 0; i < 3; i++, co++) { - copy_v3_v3(&fp[i * 3], *co); - } - fp += KEYELEM_FLOAT_LEN_BEZTRIPLE; - } - } - else { - for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a; a--, bp++, co++) { - copy_v3_v3(fp, *co); - fp += KEYELEM_FLOAT_LEN_BPOINT; - } - } - } - } -} - -void BKE_keyblock_convert_from_vertcos(const Object *ob, KeyBlock *kb, const float (*vertCos)[3]) -{ - int tot = 0, elemsize; - - MEM_SAFE_FREE(kb->data); - - /* Count of vertex coords in array */ - if (ob->type == OB_MESH) { - const Mesh *mesh = (const Mesh *)ob->data; - tot = mesh->verts_num; - elemsize = mesh->key->elemsize; - } - else if (ob->type == OB_LATTICE) { - const Lattice *lt = (const Lattice *)ob->data; - tot = lt->pntsu * lt->pntsv * lt->pntsw; - elemsize = lt->key->elemsize; - } - else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) { - const Curve *cu = (const Curve *)ob->data; - elemsize = cu->key->elemsize; - tot = BKE_keyblock_curve_element_count(&cu->nurb); - } - - if (tot == 0) { - return; - } - - kb->data = MEM_mallocN(tot * elemsize, __func__); - - /* Copy coords to key-block. */ - BKE_keyblock_update_from_vertcos(ob, kb, vertCos); -} - -float (*BKE_keyblock_convert_to_vertcos(const Object *ob, const KeyBlock *kb))[3] -{ - float(*vertCos)[3], (*co)[3]; - const float *fp = static_cast(kb->data); - int tot = 0, a; - - /* Count of vertex coords in array */ - if (ob->type == OB_MESH) { - const Mesh *mesh = (const Mesh *)ob->data; - tot = mesh->verts_num; - } - else if (ob->type == OB_LATTICE) { - const Lattice *lt = (const Lattice *)ob->data; - tot = lt->pntsu * lt->pntsv * lt->pntsw; - } - else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) { - const Curve *cu = (const Curve *)ob->data; - tot = BKE_nurbList_verts_count(&cu->nurb); - } - - if (tot == 0) { - return nullptr; - } - - co = vertCos = static_cast(MEM_mallocN(tot * sizeof(*vertCos), __func__)); - - /* Copy coords to array */ - if (ELEM(ob->type, OB_MESH, OB_LATTICE)) { - for (a = 0; a < tot; a++, fp += 3, co++) { - copy_v3_v3(*co, fp); - } - } - else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) { - const Curve *cu = (const Curve *)ob->data; - const BezTriple *bezt; - const BPoint *bp; - - LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) { - if (nu->bezt) { - for (a = nu->pntsu, bezt = nu->bezt; a; a--, bezt++) { - for (int i = 0; i < 3; i++, co++) { - copy_v3_v3(*co, &fp[i * 3]); - } - fp += KEYELEM_FLOAT_LEN_BEZTRIPLE; - } - } - else { - for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a; a--, bp++, co++) { - copy_v3_v3(*co, fp); - fp += KEYELEM_FLOAT_LEN_BPOINT; - } - } - } - } - - return vertCos; -} - -void BKE_keyblock_update_from_offset(const Object *ob, KeyBlock *kb, const float (*ofs)[3]) -{ - int a; - float *fp = static_cast(kb->data); - - if (ELEM(ob->type, OB_MESH, OB_LATTICE)) { - for (a = 0; a < kb->totelem; a++, fp += 3, ofs++) { - add_v3_v3(fp, *ofs); - } - } - else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) { - const Curve *cu = (const Curve *)ob->data; - const BezTriple *bezt; - const BPoint *bp; - - LISTBASE_FOREACH (const Nurb *, nu, &cu->nurb) { - if (nu->bezt) { - for (a = nu->pntsu, bezt = nu->bezt; a; a--, bezt++) { - for (int i = 0; i < 3; i++, ofs++) { - add_v3_v3(&fp[i * 3], *ofs); - } - fp += KEYELEM_FLOAT_LEN_BEZTRIPLE; - } - } - else { - for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a; a--, bp++, ofs++) { - add_v3_v3(fp, *ofs); - fp += KEYELEM_FLOAT_LEN_BPOINT; - } - } - } - } -} - bool BKE_keyblock_move(Object *ob, int org_index, int new_index) { Key *key = BKE_key_from_object(ob);