From d29d7030b64895574a1fdb4edd9764e5ce89f013 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 27 Mar 2004 18:27:55 +0000 Subject: - bug #979 the non-flat quad detecting routine apparently didn't do anything anymore! I've fixed it now with more comments, so people are warned not to mesh with this... er... mess! --- .../renderconverter/intern/convertBlenderScene.c | 42 +++++++++++----------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'source') diff --git a/source/blender/renderconverter/intern/convertBlenderScene.c b/source/blender/renderconverter/intern/convertBlenderScene.c index 3c6af6f819b..94632f2e2c8 100644 --- a/source/blender/renderconverter/intern/convertBlenderScene.c +++ b/source/blender/renderconverter/intern/convertBlenderScene.c @@ -2735,36 +2735,24 @@ static void check_non_flat_quads(void) if(vlr->mat->mode & MA_WIRE); else { - /* blahj, render normals are inverted in render */ - CalcNormFloat4(vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co, nor); + /* render normals are inverted in render! we calculate normal of single tria here */ + CalcNormFloat(vlr->v4->co, vlr->v3->co, vlr->v1->co, nor); xn= nor[0]*vlr->n[0] + nor[1]*vlr->n[1] + nor[2]*vlr->n[2]; - if( fabs(xn) < 0.990 ) { + if( fabs(xn) < 0.9990 ) { // checked on noisy fractal grid if( xn<0.0 ) flipnorm= 1; else flipnorm= 0; - /* recalc this nor, previous calc was with calcnormfloat4 */ - if(flipnorm) { - if (vlr->flag & R_DIVIDE_24) CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v4->co, vlr->n); - else CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->n); - } - else { - if (vlr->flag & R_DIVIDE_24) CalcNormFloat(vlr->v4->co, vlr->v2->co, vlr->v1->co, vlr->n); - else CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); - } - vlr1= RE_findOrAddVlak(R.totvlak++); *vlr1= *vlr; vlr1->flag |= R_FACE_SPLIT; - - if(flipnorm) VecMulf(nor, -1.0); - VECCOPY(vlr1->n, nor); - if (vlr->flag&R_DIVIDE_24) { - vlr1->v1=vlr->v2; - vlr1->v2=vlr->v3; - vlr1->v3=vlr->v4; - vlr->v3 =vlr->v4; + /* new vertex pointers */ + if (vlr->flag & R_DIVIDE_24) { + vlr1->v1= vlr->v2; + vlr1->v2= vlr->v3; + vlr1->v3= vlr->v4; + vlr->v3 = vlr->v4; vlr1->flag |= R_DIVIDE_24; } @@ -2775,8 +2763,18 @@ static void check_non_flat_quads(void) vlr1->flag &= ~R_DIVIDE_24; } + vlr->v4 = vlr1->v4 = NULL; + + /* new normals */ + if(flipnorm) { + CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->n); + CalcNormFloat(vlr1->v1->co, vlr1->v2->co, vlr1->v3->co, vlr1->n); + } + else { + CalcNormFloat(vlr->v3->co, vlr->v2->co, vlr->v1->co, vlr->n); + CalcNormFloat(vlr1->v3->co, vlr1->v2->co, vlr1->v1->co, vlr1->n); + } - vlr->v4 = vlr1->v4 = 0; /* so later UV can be pulled from original tface, look for R_DIVIDE_24 for direction */ vlr1->tface=vlr->tface; -- cgit v1.2.3