Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-09-12 01:36:06 +0300
committerHans Goudey <h.goudey@me.com>2022-09-12 01:36:06 +0300
commit0aeb1f0c5bb95be426d96a5ad9924610d909899d (patch)
tree7662d28b86f0de0894e48f2aa9ece429424c1a0b /source/blender/blenkernel/intern/key.c
parent789297ecb91002aa7c4e7c59a8a6c4fd2b80c462 (diff)
Start converting mesh positions to a generic attribute
Diffstat (limited to 'source/blender/blenkernel/intern/key.c')
-rw-r--r--source/blender/blenkernel/intern/key.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 2ba81c54872..2e55e3e8fef 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -1507,7 +1507,6 @@ static void do_latt_key(Object *ob, Key *key, char *out, const int tot)
}
}
-static void keyblock_data_convert_to_mesh(const float (*fp)[3], MVert *mvert, const int totvert);
static void keyblock_data_convert_to_lattice(const float (*fp)[3],
BPoint *bpoint,
const int totpoint);
@@ -1607,9 +1606,9 @@ float *BKE_key_evaluate_object_ex(
switch (GS(obdata->name)) {
case ID_ME: {
Mesh *mesh = (Mesh *)obdata;
- MVert *verts = BKE_mesh_verts_for_write(mesh);
+ const float(*positions)[3] = BKE_mesh_positions_for_write(mesh);
const int totvert = min_ii(tot, mesh->totvert);
- keyblock_data_convert_to_mesh((const float(*)[3])out, verts, totvert);
+ memcpy(out, positions, sizeof(float[3]) * totvert);
break;
}
case ID_LT: {
@@ -2194,11 +2193,8 @@ void BKE_keyblock_update_from_mesh(const Mesh *me, KeyBlock *kb)
return;
}
- const MVert *mvert = BKE_mesh_verts(me);
- fp = kb->data;
- for (a = 0; a < tot; a++, fp++, mvert++) {
- copy_v3_v3(*fp, mvert->co);
- }
+ const float(*positions)[3] = BKE_mesh_positions(me);
+ memcpy(kb->data, positions, sizeof(float[3]) * tot);
}
void BKE_keyblock_convert_from_mesh(const Mesh *me, const Key *key, KeyBlock *kb)
@@ -2217,19 +2213,10 @@ void BKE_keyblock_convert_from_mesh(const Mesh *me, const Key *key, KeyBlock *kb
BKE_keyblock_update_from_mesh(me, kb);
}
-static void keyblock_data_convert_to_mesh(const float (*fp)[3], MVert *mvert, const int totvert)
-{
- for (int i = 0; i < totvert; i++, fp++, mvert++) {
- copy_v3_v3(mvert->co, *fp);
- }
-}
-
-void BKE_keyblock_convert_to_mesh(const KeyBlock *kb, MVert *mvert, const int totvert)
+void BKE_keyblock_convert_to_mesh(const KeyBlock *kb, float (*positions)[3], const int totvert)
{
- const float(*fp)[3] = kb->data;
const int tot = min_ii(kb->totelem, totvert);
-
- keyblock_data_convert_to_mesh(fp, mvert, tot);
+ memcpy(kb->data, positions, sizeof(float[3]) * tot);
}
void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
@@ -2242,8 +2229,8 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
return;
}
- MVert *verts = MEM_dupallocN(BKE_mesh_verts(mesh));
- BKE_keyblock_convert_to_mesh(kb, verts, mesh->totvert);
+ float(*positions)[3] = MEM_dupallocN(BKE_mesh_positions(mesh));
+ BKE_keyblock_convert_to_mesh(kb, positions, mesh->totvert);
const MEdge *edges = BKE_mesh_edges(mesh);
const MPoly *polys = BKE_mesh_polys(mesh);
const MLoop *loops = BKE_mesh_loops(mesh);
@@ -2268,10 +2255,10 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
if (poly_normals_needed) {
BKE_mesh_calc_normals_poly(
- verts, mesh->totvert, loops, mesh->totloop, polys, mesh->totpoly, poly_normals);
+ positions, mesh->totvert, loops, mesh->totloop, polys, mesh->totpoly, poly_normals);
}
if (vert_normals_needed) {
- BKE_mesh_calc_normals_poly_and_vertex(verts,
+ BKE_mesh_calc_normals_poly_and_vertex(positions,
mesh->totvert,
loops,
mesh->totloop,
@@ -2282,7 +2269,7 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
}
if (loop_normals_needed) {
short(*clnors)[2] = CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL); /* May be NULL. */
- BKE_mesh_normals_loop_split(verts,
+ BKE_mesh_normals_loop_split(positions,
vert_normals,
mesh->totvert,
edges,
@@ -2306,7 +2293,7 @@ void BKE_keyblock_mesh_calc_normals(const KeyBlock *kb,
if (free_poly_normals) {
MEM_freeN(poly_normals);
}
- MEM_freeN(verts);
+ MEM_freeN(positions);
}
/************************* raw coords ************************/