--- ray/src/rt/raytrace.c 2003/03/11 17:08:55 2.37 +++ ray/src/rt/raytrace.c 2003/12/31 01:50:02 2.44 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: raytrace.c,v 2.37 2003/03/11 17:08:55 greg Exp $"; +static const char RCSid[] = "$Id: raytrace.c,v 2.44 2003/12/31 01:50:02 greg Exp $"; #endif /* * raytrace.c - routines for tracing and shading rays. @@ -20,7 +20,7 @@ static const char RCSid[] = "$Id: raytrace.c,v 2.37 20 unsigned long raynum = 0; /* next unique ray number */ unsigned long nrays = 0; /* number of calls to localhit */ -static FLOAT Lambfa[5] = {PI, PI, PI, 0.0, 0.0}; +static RREAL Lambfa[5] = {PI, PI, PI, 0.0, 0.0}; OBJREC Lamb = { OVOID, MAT_PLASTIC, "Lambertian", {0, 5, NULL, Lambfa}, NULL, @@ -31,10 +31,6 @@ OBJREC Aftplane; /* aft clipping plane object */ static int raymove(), checkhit(); static void checkset(); -#ifndef MAXLOOP -#define MAXLOOP 0 /* modifier loop detection */ -#endif - #define RAYHIT (-1) /* return value for intercepted ray */ @@ -158,12 +154,6 @@ int mod; { int gotmat; register OBJREC *m; -#if MAXLOOP - static int depth = 0; - /* check for infinite loop */ - if (depth++ >= MAXLOOP) - objerror(r->ro, USER, "possible modifier loop"); -#endif r->rt = r->rot; /* set effective ray length */ for (gotmat = 0; !gotmat && mod != OVOID; mod = m->omod) { m = objptr(mod); @@ -174,11 +164,10 @@ int mod; } ******/ /* hack for irradiance calculation */ - if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS))) { + if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) && + m->otype != MAT_CLIP && + (ofun[m->otype].flags & (T_M|T_X))) { if (irr_ignore(m->otype)) { -#if MAXLOOP - depth--; -#endif raytrans(r); return(1); } @@ -188,9 +177,6 @@ int mod; /* materials call raytexture */ gotmat = (*ofun[m->otype].funp)(m, r); } -#if MAXLOOP - depth--; -#endif return(gotmat); } @@ -227,17 +213,12 @@ register RAY *r; } +void raytexture(r, mod) /* get material modifiers */ RAY *r; -int mod; +OBJECT mod; { register OBJREC *m; -#if MAXLOOP - static int depth = 0; - /* check for infinite loop */ - if (depth++ >= MAXLOOP) - objerror(r->ro, USER, "modifier loop"); -#endif /* execute textures and patterns */ for ( ; mod != OVOID; mod = m->omod) { m = objptr(mod); @@ -253,9 +234,6 @@ int mod; objerror(r->ro, USER, errmsg); } } -#if MAXLOOP - depth--; /* end here */ -#endif } @@ -276,19 +254,20 @@ double coef; /* compute foreground and background */ foremat = backmat = 0; /* foreground */ - copystruct(&fr, r); + fr = *r; if (coef > FTINY) foremat = rayshade(&fr, fore); /* background */ - copystruct(&br, r); + br = *r; if (coef < 1.0-FTINY) backmat = rayshade(&br, back); /* check for transparency */ - if (backmat ^ foremat) + if (backmat ^ foremat) { if (backmat && coef > FTINY) raytrans(&fr); else if (foremat && coef < 1.0-FTINY) raytrans(&br); + } /* mix perturbations */ for (i = 0; i < 3; i++) r->pert[i] = coef*fr.pert[i] + (1.0-coef)*br.pert[i]; @@ -485,7 +464,7 @@ register CUBE *scene; } cxset[0] = 0; raymove(curpos, cxset, sflags, r, scene); - return(r->ro != NULL & r->ro != &Aftplane); + return((r->ro != NULL) & (r->ro != &Aftplane)); }