[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15508] trunk/blender/source/blender/ radiosity/intern/source/radrender.c: [#17298] surface normal direction compensation for objects with negative scale in rendering with radiosity
Campbell Barton
ideasman42 at gmail.com
Wed Jul 9 21:15:27 CEST 2008
Revision: 15508
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15508
Author: campbellbarton
Date: 2008-07-09 21:15:26 +0200 (Wed, 09 Jul 2008)
Log Message:
-----------
[#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.
Modified Paths:
--------------
trunk/blender/source/blender/radiosity/intern/source/radrender.c
Modified: trunk/blender/source/blender/radiosity/intern/source/radrender.c
===================================================================
--- trunk/blender/source/blender/radiosity/intern/source/radrender.c 2008-07-09 19:15:15 UTC (rev 15507)
+++ trunk/blender/source/blender/radiosity/intern/source/radrender.c 2008-07-09 19:15:26 UTC (rev 15508)
@@ -369,9 +369,18 @@
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;
More information about the Bf-blender-cvs
mailing list