bug fix #1127
authorTon Roosendaal <ton@blender.org>
Wed, 7 Apr 2004 18:19:30 +0000 (18:19 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 7 Apr 2004 18:19:30 +0000 (18:19 +0000)
Quads in radiositizer got normals calculated using 3 vertices only. this
can go wrong in occasions... and made blender hang.
Used CalcNormFloat4() instead!

source/blender/radiosity/intern/source/raddisplay.c
source/blender/radiosity/intern/source/radfactors.c
source/blender/radiosity/intern/source/radpreprocess.c

index 8046f07874d4e14786863970c51281bd95fb9533..4be1ea7f63b45c7faec32f068a285d696167c807 100644 (file)
@@ -64,6 +64,8 @@
 #include "BIF_space.h"
 #include "BIF_mywindow.h"
 
+#include "BSE_view.h"
+
 #include "radio.h"
 
 /* cpack has to be endian-insensitive! (old irisgl function) */
@@ -217,6 +219,7 @@ void drawpatch_ext(RPatch *patch, unsigned int col)
                if (sa->spacetype==SPACE_VIEW3D) {
                        /* use mywinget() here: otherwise it draws in header */
                        if(sa->win != mywinget()) areawinset(sa->win);
+                       persp(PERSP_VIEW);
                        drawnodeWire(patch->first);
                }
                sa= sa->next;
index 5e2812138e2ace2612e057978cf69051276933ca..fb66f994cbcadae4bde4aa5fdba5accb083fea21 100644 (file)
@@ -312,20 +312,23 @@ int makeformfactors(RPatch *shoot)
 {
        RNode **re;
        float len, vec[3], up[3], side[3], tar[5][3], *fp;
-       int a, overfl;
+       int a=0, overfl;
 
        if(RG.totelem==0) return 0;
-
+       
        memset(RG.formfactors, 0, 4*RG.totelem);
 
        /* set up hemiview */
        /* first: random upvector */
        do {
+               a++;
                vec[0]= (float)BLI_drand();
                vec[1]= (float)BLI_drand();
                vec[2]= (float)BLI_drand();
                Crossf(up, shoot->norm, vec);
                len= Normalise(up);
+               /* this safety for input normals that are zero or illegal sized */
+               if(a>3) return 0;
        } while(len==0.0 || len>1.0);
 
        VECCOPY(hemitop.up, up);
@@ -372,16 +375,6 @@ int makeformfactors(RPatch *shoot)
        }
        
        if(overfl) {
-               /*
-               drawOverflowElem();
-               while(get_mbut()&L_MOUSE==0) {
-                       if(get_mbut()&M_MOUSE) {
-                               viewmove();
-                               drawpatch_ext(shoot,0xFF77FF);
-                               drawOverflowElem();
-                       }
-               }
-               */
                if(shoot->first->down1) {
                        splitpatch(shoot);
                        return 0;
index 9d418bff153f66fd0740597851781768aa59b31f..80c6294db020faec2faa03df520007c4825f9a6d 100644 (file)
@@ -431,9 +431,14 @@ void rad_collect_meshes()
                                                rn->f= RAD_PATCH;       /* this node is a Patch */
                                                rn->type= rp->type;
 
-                                               CalcNormFloat(v1, v2, v3, rp->norm);
-                                               if(rn->type==4) rp->area= AreaQ3Dfl(v1, v2, v3, v4);
-                                               else rp->area= AreaT3Dfl(v1, v2, v3);
+                                               if(rn->type==4) {
+                                                       rp->area= AreaQ3Dfl(v1, v2, v3, v4);
+                                                       CalcNormFloat4(v1, v2, v3, v4, rp->norm);
+                                               }
+                                               else {
+                                                       rp->area= AreaT3Dfl(v1, v2, v3);
+                                                       CalcNormFloat(v1, v2, v3, rp->norm);
+                                               }
 
                                                rn->area= rp->area;