forked from bartvdbraak/blender
Correction for previous commit to make normals direction always inside
This commit is contained in:
parent
8486a2187f
commit
d78accb585
@ -2429,7 +2429,7 @@ static void init_render_mball(Render *re, ObjectRen *obr)
|
|||||||
VlakRen *vlr, *vlr1;
|
VlakRen *vlr, *vlr1;
|
||||||
Material *ma;
|
Material *ma;
|
||||||
float *data, *nors, *orco=NULL, mat[4][4], imat[3][3], xn, yn, zn;
|
float *data, *nors, *orco=NULL, mat[4][4], imat[3][3], xn, yn, zn;
|
||||||
int a, need_orco, vlakindex, *index, is_negative;
|
int a, need_orco, vlakindex, *index, negative_scale;
|
||||||
ListBase dispbase= {NULL, NULL};
|
ListBase dispbase= {NULL, NULL};
|
||||||
|
|
||||||
if (ob!=find_basis_mball(re->scene, ob))
|
if (ob!=find_basis_mball(re->scene, ob))
|
||||||
@ -2438,6 +2438,7 @@ static void init_render_mball(Render *re, ObjectRen *obr)
|
|||||||
mult_m4_m4m4(mat, re->viewmat, ob->obmat);
|
mult_m4_m4m4(mat, re->viewmat, ob->obmat);
|
||||||
invert_m4_m4(ob->imat, mat);
|
invert_m4_m4(ob->imat, mat);
|
||||||
copy_m3_m4(imat, ob->imat);
|
copy_m3_m4(imat, ob->imat);
|
||||||
|
negative_scale = is_negative_m4(mat);
|
||||||
|
|
||||||
ma= give_render_material(re, ob, 1);
|
ma= give_render_material(re, ob, 1);
|
||||||
|
|
||||||
@ -2462,8 +2463,6 @@ static void init_render_mball(Render *re, ObjectRen *obr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is_negative = is_negative_m4(re->viewmat);
|
|
||||||
|
|
||||||
for(a=0; a<dl->nr; a++, data+=3, nors+=3) {
|
for(a=0; a<dl->nr; a++, data+=3, nors+=3) {
|
||||||
|
|
||||||
ver= RE_findOrAddVert(obr, obr->totvert++);
|
ver= RE_findOrAddVert(obr, obr->totvert++);
|
||||||
@ -2480,8 +2479,7 @@ static void init_render_mball(Render *re, ObjectRen *obr)
|
|||||||
ver->n[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
|
ver->n[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
|
||||||
ver->n[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
|
ver->n[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
|
||||||
normalize_v3(ver->n);
|
normalize_v3(ver->n);
|
||||||
if(is_negative)
|
//if(ob->transflag & OB_NEG_SCALE) negate_v3(ver->n);
|
||||||
negate_v3(ver->n);
|
|
||||||
|
|
||||||
if(need_orco) {
|
if(need_orco) {
|
||||||
ver->orco= orco;
|
ver->orco= orco;
|
||||||
@ -2498,7 +2496,7 @@ static void init_render_mball(Render *re, ObjectRen *obr)
|
|||||||
vlr->v3= RE_findOrAddVert(obr, index[2]);
|
vlr->v3= RE_findOrAddVert(obr, index[2]);
|
||||||
vlr->v4= 0;
|
vlr->v4= 0;
|
||||||
|
|
||||||
if(ob->transflag & OB_NEG_SCALE)
|
if(negative_scale)
|
||||||
normal_tri_v3( vlr->n,vlr->v1->co, vlr->v2->co, vlr->v3->co);
|
normal_tri_v3( vlr->n,vlr->v1->co, vlr->v2->co, vlr->v3->co);
|
||||||
else
|
else
|
||||||
normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co);
|
normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co);
|
||||||
@ -2515,7 +2513,7 @@ static void init_render_mball(Render *re, ObjectRen *obr)
|
|||||||
vlr1->index= vlakindex;
|
vlr1->index= vlakindex;
|
||||||
vlr1->v2= vlr1->v3;
|
vlr1->v2= vlr1->v3;
|
||||||
vlr1->v3= RE_findOrAddVert(obr, index[3]);
|
vlr1->v3= RE_findOrAddVert(obr, index[3]);
|
||||||
if(ob->transflag & OB_NEG_SCALE)
|
if(negative_scale)
|
||||||
normal_tri_v3( vlr1->n,vlr1->v1->co, vlr1->v2->co, vlr1->v3->co);
|
normal_tri_v3( vlr1->n,vlr1->v1->co, vlr1->v2->co, vlr1->v3->co);
|
||||||
else
|
else
|
||||||
normal_tri_v3( vlr1->n,vlr1->v3->co, vlr1->v2->co, vlr1->v1->co);
|
normal_tri_v3( vlr1->n,vlr1->v3->co, vlr1->v2->co, vlr1->v1->co);
|
||||||
|
Loading…
Reference in New Issue
Block a user