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/modifiers/intern/MOD_array.c')
-rw-r--r--source/blender/modifiers/intern/MOD_array.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index fa5149a45ba..56db68b163c 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -306,14 +306,14 @@ static void mesh_merge_transform(Mesh *result,
mul_m4_v3(cap_offset, mv->co);
/* Reset MVert flags for caps */
mv->flag = mv->bweight = 0;
+ }
- /* We have to correct normals too, if we do not tag them as dirty later! */
- if (!recalc_normals_later) {
- float no[3];
- normal_short_to_float_v3(no, mv->no);
- mul_mat3_m4_v3(cap_offset, no);
- normalize_v3(no);
- normal_float_to_short_v3(mv->no, no);
+ /* We have to correct normals too, if we do not tag them as dirty later! */
+ if (!recalc_normals_later) {
+ float(*dst_vert_normals)[3] = BKE_mesh_vertex_normals_for_write(result);
+ for (i = 0; i < cap_nverts; i++) {
+ mul_mat3_m4_v3(cap_offset, dst_vert_normals[cap_verts_index + i]);
+ normalize_v3(dst_vert_normals[cap_verts_index + i]);
}
}
@@ -370,7 +370,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
Mesh *mesh)
{
const MVert *src_mvert;
- MVert *mv, *mv_prev, *result_dm_verts;
+ MVert *result_dm_verts;
MEdge *me;
MLoop *ml;
@@ -582,6 +582,14 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
first_chunk_nverts = chunk_nverts;
unit_m4(current_offset);
+ const float(*src_vert_normals)[3] = NULL;
+ float(*dst_vert_normals)[3] = NULL;
+ if (!use_recalc_normals) {
+ src_vert_normals = BKE_mesh_vertex_normals_ensure(mesh);
+ dst_vert_normals = BKE_mesh_vertex_normals_for_write(result);
+ BKE_mesh_vertex_normals_clear_dirty(result);
+ }
+
for (c = 1; c < count; c++) {
/* copy customdata to new geometry */
CustomData_copy_data(&mesh->vdata, &result->vdata, 0, c * chunk_nverts, chunk_nverts);
@@ -589,23 +597,21 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
CustomData_copy_data(&mesh->ldata, &result->ldata, 0, c * chunk_nloops, chunk_nloops);
CustomData_copy_data(&mesh->pdata, &result->pdata, 0, c * chunk_npolys, chunk_npolys);
- mv_prev = result_dm_verts;
- mv = mv_prev + c * chunk_nverts;
+ const int vert_offset = c * chunk_nverts;
/* recalculate cumulative offset here */
mul_m4_m4m4(current_offset, current_offset, offset);
/* apply offset to all new verts */
- for (i = 0; i < chunk_nverts; i++, mv++, mv_prev++) {
- mul_m4_v3(current_offset, mv->co);
+ for (i = 0; i < chunk_nverts; i++) {
+ const int i_dst = vert_offset + i;
+ mul_m4_v3(current_offset, result_dm_verts[i_dst].co);
/* We have to correct normals too, if we do not tag them as dirty! */
if (!use_recalc_normals) {
- float no[3];
- normal_short_to_float_v3(no, mv->no);
- mul_mat3_m4_v3(current_offset, no);
- normalize_v3(no);
- normal_float_to_short_v3(mv->no, no);
+ copy_v3_v3(dst_vert_normals[i_dst], src_vert_normals[i]);
+ mul_mat3_m4_v3(current_offset, dst_vert_normals[i_dst]);
+ normalize_v3(dst_vert_normals[i_dst]);
}
}