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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-07-09 23:15:26 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-07-09 23:15:26 +0400
commitb915ba5e970b1dd594e81318828321c5fb8c38f7 (patch)
treeaa988dd88610607a8eb64d8a14875c7f48d1aa3b /source
parent12c128ac040a842f3fb72a1f4e103abf061a47e2 (diff)
[#17298] surface normal direction compensation for objects with negative scale in rendering with radiosity
from Roelf De Kock (kiemdoder) Fixes bug [#7969] Mirroring Object Breaks Radiosity Calculations - copied from the tracker. The code in this patch detects whether an object has negative scale (test the OB_NEG_SCALE bit in Object.transflag) and then compensate for the negative scale when the surface normals are calculated for a radiosity render.
Diffstat (limited to 'source')
-rw-r--r--source/blender/radiosity/intern/source/radrender.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/radiosity/intern/source/radrender.c b/source/blender/radiosity/intern/source/radrender.c
index e5ef1e9a4a2..68b5fa81f43 100644
--- a/source/blender/radiosity/intern/source/radrender.c
+++ b/source/blender/radiosity/intern/source/radrender.c
@@ -369,9 +369,18 @@ printf(" Rad elems: %d emittors %d\n", RG.totelem, RG.totpatch);
if(vlr->mat->mode & MA_RADIO) {
/* during render, vlr->n gets flipped/corrected, we cannot have that */
- if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co, rf->norm);
- else CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, rf->norm);
-
+ if (obr->ob->transflag & OB_NEG_SCALE){
+ /* The object has negative scale that will cause the normals to flip.
+ To counter this unwanted normal flip, swap vertex 2 and 4 for a quad
+ or vertex 2 and 3 (see flip_face) for a triangle in the call to CalcNormFloat4
+ in order to flip the normals back to the way they were in the original mesh. */
+ if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v4->co, vlr->v3->co, vlr->v2->co, rf->norm);
+ else CalcNormFloat(vlr->v1->co, vlr->v3->co, vlr->v2->co, rf->norm);
+ }else{
+ if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co, rf->norm);
+ else CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, rf->norm);
+ }
+
rf->totrad[0]= vlr->mat->emit*vlr->mat->r;
rf->totrad[1]= vlr->mat->emit*vlr->mat->g;
rf->totrad[2]= vlr->mat->emit*vlr->mat->b;