--- ray/src/hd/rhd_qtree.c 1997/12/31 09:06:54 3.16 +++ ray/src/hd/rhd_qtree.c 1998/08/10 18:39:46 3.18 @@ -1,4 +1,4 @@ -/* Copyright (c) 1997 Silicon Graphics, Inc. */ +/* Copyright (c) 1998 Silicon Graphics, Inc. */ #ifndef lint static char SCCSid[] = "$SunId$ SGI"; @@ -29,6 +29,8 @@ double qtDepthEps = .05; /* epsilon to compare depths int qtMinNodesiz = 2; /* minimum node dimension (pixels) */ struct rleaves qtL; /* our pile of leaves */ +int rayqleft = 0; /* rays left to queue before flush */ + static int4 falleaves; /* our list of fallen leaves */ #define composted(li) (qtL.bl <= qtL.tl ? \ @@ -330,9 +332,9 @@ dropit: } -dev_value(c, p, v) /* add a pixel value to our quadtree */ +dev_value(c, d, p) /* add a pixel value to our quadtree */ COLR c; -FVECT p, v; +FVECT d, p; { register int li; int mapit; @@ -351,11 +353,18 @@ FVECT p, v; qtCompost(LFREEPCT); mapit = 0; /* we'll map it later */ } - VCOPY(qtL.wp[li], p); - qtL.wd[li] = encodedir(v); + if (p == NULL) + VSUM(qtL.wp[li], odev.v.vp, d, FHUGE); + else + VCOPY(qtL.wp[li], p); + qtL.wd[li] = encodedir(d); tmCvColrs(&qtL.brt[li], qtL.chr[li], c, 1); - if (putleaf(li, 1) && mapit) - tmMapPixels(qtL.rgb+li, qtL.brt+li, qtL.chr+li, 1); + if (putleaf(li, 1)) { + if (mapit) + tmMapPixels(qtL.rgb+li, qtL.brt+li, qtL.chr+li, 1); + if (--rayqleft == 0) + dev_flush(); /* flush output */ + } }