--- ray/src/rt/raytrace.c 1991/05/01 11:17:01 1.15 +++ ray/src/rt/raytrace.c 1991/05/10 08:51:06 1.17 @@ -1,4 +1,4 @@ -/* Copyright (c) 1990 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -118,14 +118,6 @@ int mod; { static int depth = 0; register OBJREC *m; - /* check for irradiance calc. */ - if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS))) { - if (irr_ignore(objptr(mod)->otype)) - raytrans(r); - else - (*ofun[Lamb.otype].funp)(&Lamb, r); - return; - } /* check for infinite loop */ if (depth++ >= MAXLOOP) objerror(r->ro, USER, "possible modifier loop"); @@ -137,6 +129,16 @@ int mod; error(USER, errmsg); } ******/ + /* hack for irradiance calculation */ + if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS))) { + if (irr_ignore(m->otype)) { + depth--; + raytrans(r); + return; + } + if (m->otype != MAT_ILLUM) + m = &Lamb; + } (*ofun[m->otype].funp)(m, r); /* execute function */ m->lastrno = r->rno; if (ismaterial(m->otype)) { /* materials call raytexture */ @@ -320,6 +322,8 @@ register CUBE *scene; else if (r->rdir[i] < -FTINY) sflags |= 0x10 << i; } + if (sflags == 0) + error(CONSISTENCY, "zero ray direction in localhit"); t = 0.0; if (!incube(scene, curpos)) { /* find distance to entry */