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:
Diffstat (limited to 'source/blender/blenkernel/intern/key.c')
-rw-r--r--source/blender/blenkernel/intern/key.c42
1 files changed, 13 insertions, 29 deletions
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 2ba81c54872..010b45f4778 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: {
@@ -2184,21 +2183,15 @@ void BKE_keyblock_convert_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nu
void BKE_keyblock_update_from_mesh(const Mesh *me, KeyBlock *kb)
{
- float(*fp)[3];
- int a, tot;
-
BLI_assert(me->totvert == kb->totelem);
- tot = me->totvert;
+ const int tot = me->totvert;
if (tot == 0) {
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 +2210,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)
+void BKE_keyblock_convert_to_mesh(const KeyBlock *kb, float (*positions)[3], 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)
-{
- 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 +2226,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 +2252,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 +2266,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 +2290,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 ************************/