diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image_proj.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 27d19532785..ca012f20f01 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -414,6 +414,7 @@ typedef struct ProjPaintState { int totvert_eval; const MVert *mvert_eval; + const float (*vert_normals)[3]; const MEdge *medge_eval; const MPoly *mpoly_eval; const MLoop *mloop_eval; @@ -1718,10 +1719,10 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps, float no[3], angle_cos; if (mp->flag & ME_SMOOTH) { - const short *no1, *no2, *no3; - no1 = ps->mvert_eval[lt_vtri[0]].no; - no2 = ps->mvert_eval[lt_vtri[1]].no; - no3 = ps->mvert_eval[lt_vtri[2]].no; + const float *no1, *no2, *no3; + no1 = ps->vert_normals[lt_vtri[0]]; + no2 = ps->vert_normals[lt_vtri[1]]; + no3 = ps->vert_normals[lt_vtri[2]]; no[0] = w[0] * no1[0] + w[1] * no2[0] + w[2] * no3[0]; no[1] = w[0] * no1[1] + w[1] * no2[1] + w[2] * no3[1]; @@ -3871,7 +3872,6 @@ static void proj_paint_state_screen_coords_init(ProjPaintState *ps, const int di static void proj_paint_state_cavity_init(ProjPaintState *ps) { - const MVert *mv; const MEdge *me; float *cavities; int a; @@ -3891,13 +3891,11 @@ static void proj_paint_state_cavity_init(ProjPaintState *ps) sub_v3_v3(edges[me->v1], e); counter[me->v1]++; } - for (a = 0, mv = ps->mvert_eval; a < ps->totvert_eval; a++, mv++) { + for (a = 0; a < ps->totvert_eval; a++) { if (counter[a] > 0) { - float no[3]; mul_v3_fl(edges[a], 1.0f / counter[a]); - normal_short_to_float_v3(no, mv->no); /* Augment the difference. */ - cavities[a] = saacos(10.0f * dot_v3v3(no, edges[a])) * (float)M_1_PI; + cavities[a] = saacos(10.0f * dot_v3v3(ps->vert_normals[a], edges[a])) * (float)M_1_PI; } else { cavities[a] = 0.0; @@ -3964,7 +3962,7 @@ static void proj_paint_state_vert_flags_init(ProjPaintState *ps) ps->vertFlags = MEM_callocN(sizeof(char) * ps->totvert_eval, "paint-vertFlags"); for (a = 0, mv = ps->mvert_eval; a < ps->totvert_eval; a++, mv++) { - normal_short_to_float_v3(no, mv->no); + copy_v3_v3(no, ps->vert_normals[a]); if (UNLIKELY(ps->is_flip_object)) { negate_v3(no); } @@ -4064,6 +4062,7 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p ps->mat_array[totmat - 1] = NULL; ps->mvert_eval = ps->me_eval->mvert; + ps->vert_normals = BKE_mesh_vertex_normals_ensure(ps->me_eval); if (ps->do_mask_cavity) { ps->medge_eval = ps->me_eval->medge; } |