--- ray/src/util/ranimove1.c 2008/11/10 19:08:20 3.15 +++ ray/src/util/ranimove1.c 2011/05/20 02:06:39 3.17 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: ranimove1.c,v 3.15 2008/11/10 19:08:20 greg Exp $"; +static const char RCSid[] = "$Id: ranimove1.c,v 3.17 2011/05/20 02:06:39 greg Exp $"; #endif /* * ranimove1.c @@ -30,14 +30,14 @@ float *zbuffer; /* depth at each pixel */ OBJECT *obuffer; /* object id at each pixel */ short *xmbuffer; /* x motion at each pixel */ short *ymbuffer; /* y motion at each pixel */ -BYTE *abuffer; /* accuracy at each pixel */ -BYTE *sbuffer; /* sample count per pixel */ +uby8 *abuffer; /* accuracy at each pixel */ +uby8 *sbuffer; /* sample count per pixel */ VIEW vwprev; /* last frame's view */ COLOR *cprev; /* last frame colors */ float *zprev; /* last frame depth */ OBJECT *oprev; /* last frame objects */ -BYTE *aprev; /* last frame accuracy */ +uby8 *aprev; /* last frame accuracy */ float *cerrmap; /* conspicuous error map */ COLOR *val2map; /* value-squared map for variance */ @@ -107,6 +107,7 @@ next_frame(void) /* prepare next frame buffer */ error(USER, errmsg); } if (cbuffer == NULL) { + int n; /* compute resolution and allocate */ switch (sscanf(vval(RESOLUTION), "%d %d %lf", &hres, &vres, &pixaspect)) { @@ -130,30 +131,34 @@ next_frame(void) /* prepare next frame buffer */ obuffer = (OBJECT *)malloc(sizeof(OBJECT)*hres*vres); xmbuffer = (short *)malloc(sizeof(short)*hres*vres); ymbuffer = (short *)malloc(sizeof(short)*hres*vres); - abuffer = (BYTE *)calloc(hres*vres, sizeof(BYTE)); - sbuffer = (BYTE *)calloc(hres*vres, sizeof(BYTE)); + abuffer = (uby8 *)calloc(hres*vres, sizeof(uby8)); + sbuffer = (uby8 *)calloc(hres*vres, sizeof(uby8)); cprev = (COLOR *)malloc(sizeof(COLOR)*hres*vres); zprev = (float *)malloc(sizeof(float)*hres*vres); oprev = (OBJECT *)malloc(sizeof(OBJECT)*hres*vres); - aprev = (BYTE *)malloc(sizeof(BYTE)*hres*vres); + aprev = (uby8 *)malloc(sizeof(uby8)*hres*vres); if ((cbuffer==NULL) | (zbuffer==NULL) | (obuffer==NULL) | (xmbuffer==NULL) | (ymbuffer==NULL) | (abuffer==NULL) | (sbuffer==NULL) | (cprev==NULL) | (zprev == NULL) | (oprev==NULL) | (aprev==NULL)) error(SYSTEM, "out of memory in init_frame"); + for (n = hres*vres; n--; ) { + zprev[n] = -1.f; + oprev[n] = OVOID; + } frm_stop = getTime() + rtperfrm; } else { COLOR *cp; /* else just swap buffers */ float *fp; OBJECT *op; - BYTE *bp; + uby8 *bp; cp = cprev; cprev = cbuffer; cbuffer = cp; fp = zprev; zprev = zbuffer; zbuffer = fp; op = oprev; oprev = obuffer; obuffer = op; bp = aprev; aprev = abuffer; abuffer = bp; - memset(abuffer, '\0', sizeof(BYTE)*hres*vres); - memset(sbuffer, '\0', sizeof(BYTE)*hres*vres); + memset(abuffer, '\0', sizeof(uby8)*hres*vres); + memset(sbuffer, '\0', sizeof(uby8)*hres*vres); frm_stop += rtperfrm; } cerrmap = NULL; @@ -371,8 +376,10 @@ init_frame_sample(void) /* sample our initial frame * if (!sample_here(x, y)) { /* just cast */ rayorigin(&ir, PRIMARY, NULL, NULL); if (!localhit(&ir, &thescene)) { - if (ir.ro != &Aftplane) - sourcehit(&ir); + if (ir.ro != &Aftplane && sourcehit(&ir)) { + rayshade(&ir, ir.ro->omod); + rayparticipate(&ir); + } copycolor(cbuffer[n], ir.rcol); zbuffer[n] = ir.rot; obuffer[n] = ir.robj; @@ -401,7 +408,7 @@ init_frame_sample(void) /* sample our initial frame * zbuffer[n] = ir.rot; obuffer[n] = ir.robj; sbuffer[n] = 1; - if (ir.rot >= FHUGE) + if (ir.rot >= 0.99*FHUGE) abuffer[n] = ADISTANT; else { abuffer[n] = ALOWQ; @@ -454,15 +461,12 @@ getambcolor( /* get ambient color for object if we ca if (obj == OVOID) return(0); - op = objptr(obj); - if ((op->otype == OBJ_INSTANCE) & (op->omod == OVOID)) + op = objptr(obj); /* search for material */ + if (op->omod == OVOID) return(0); - /* search for material */ - do { - if (op->omod == OVOID || ofun[op->otype].flags & T_X) - return(0); - op = objptr(op->omod); - } while (!ismaterial(op->otype)); + op = findmaterial(objptr(op->omod)); + if (op == NULL) + return(0); /* * Since this routine is called to compute the difference * from rendering with and without interreflections, @@ -476,7 +480,7 @@ getambcolor( /* get ambient color for object if we ca if (lv[0] == op->oname[0] && !strcmp(lv+1, op->oname+1)) break; - if ((lv != NULL) != hirendparams.ambincl) + if ((lv != NULL) ^ hirendparams.ambincl) return(0); } switch (op->otype) { @@ -580,7 +584,7 @@ comperr( /* estimate relative error in neighborhood * extern void comp_frame_error(void) /* initialize frame error values */ { - BYTE *edone = NULL; + uby8 *edone = NULL; COLOR objamb; double eest; int neigh[NSAMPOK]; @@ -604,7 +608,7 @@ comp_frame_error(void) /* initialize frame error valu * error should be less than the ambient value divided * by the returned ray value -- we take half of this. */ - edone = (BYTE *)calloc(hres*vres, sizeof(BYTE)); + edone = (uby8 *)calloc(hres*vres, sizeof(uby8)); for (y = vres; y--; ) for (x = hres; x--; ) { n = fndx(x, y);