14 |
|
#include "color.h" |
15 |
|
#include "resolu.h" |
16 |
|
#include "lookup.h" |
17 |
– |
#include "random.h" |
17 |
|
#include "calcomp.h" |
18 |
|
|
19 |
|
#ifndef MAXMODLIST |
20 |
|
#define MAXMODLIST 1024 /* maximum modifiers we'll track */ |
21 |
|
#endif |
22 |
|
|
23 |
< |
int treebufsiz = BUFSIZ; /* current tree buffer size */ |
23 |
> |
size_t treebufsiz = BUFSIZ; /* current tree buffer size */ |
24 |
|
|
25 |
|
typedef double DCOLOR[3]; /* double-precision color */ |
26 |
|
|
92 |
|
struct rtproc *next; /* next in list of processes */ |
93 |
|
SUBPROC pd; /* rtrace pipe descriptors */ |
94 |
|
unsigned long raynum; /* ray number for this tree */ |
95 |
< |
int bsiz; /* ray tree buffer length */ |
95 |
> |
size_t bsiz; /* ray tree buffer length */ |
96 |
|
char *buf; /* ray tree buffer */ |
97 |
< |
int nbr; /* number of bytes from rtrace */ |
97 |
> |
size_t nbr; /* number of bytes from rtrace */ |
98 |
|
}; /* rtrace process buffer */ |
99 |
|
|
100 |
|
/* rtrace command and defaults */ |
107 |
|
char *myrtopts[] = { "-h-", "-x", "1", "-y", "0", |
108 |
|
"-dt", "0", "-as", "0", "-aa", "0", NULL }; |
109 |
|
|
110 |
< |
#define RTCOEFF "-o~~TmWdp" /* compute coefficients only */ |
111 |
< |
#define RTCONTRIB "-o~~TmVdp" /* compute ray contributions */ |
110 |
> |
#define RTCOEFF "-o~~~~TmWdp" /* compute coefficients only */ |
111 |
> |
#define RTCONTRIB "-o~~~~TmVdp" /* compute ray contributions */ |
112 |
|
|
113 |
|
struct rtproc rt0; /* head of rtrace process list */ |
114 |
|
|
956 |
|
default: |
957 |
|
error(INTERNAL, "botched output format"); |
958 |
|
} |
960 |
– |
if (waitflush < 0 && frandom() < 0.001) |
961 |
– |
fflush(fout); /* staggers writes */ |
959 |
|
} |
960 |
|
|
961 |
|
/* output ray tallies and clear for next accumulation */ |
1075 |
|
{ |
1076 |
|
struct rtproc *rtfree = NULL; |
1077 |
|
fd_set readset, errset; |
1078 |
< |
int nr; |
1078 |
> |
ssize_t nr; |
1079 |
|
struct rtproc *rt; |
1080 |
|
int n; |
1081 |
|
|
1120 |
|
if (nr <= 0) |
1121 |
|
error(USER, "rtrace process died"); |
1122 |
|
rt->nbr += nr; /* advance & check */ |
1123 |
< |
if (rt->nbr >= 4 && !memcmp(rt->buf+rt->nbr-4, |
1124 |
< |
"~\t~\t", 4)) { |
1125 |
< |
rt->nbr -= 4; /* elide terminator */ |
1123 |
> |
if (rt->nbr >= 8 && !memcmp(rt->buf+rt->nbr-8, |
1124 |
> |
"~\t~\t~\t~\t", 8)) { |
1125 |
> |
rt->nbr -= 8; /* elide terminator */ |
1126 |
|
queue_raytree(rt); |
1127 |
|
rtfree = rt; /* ready for next ray */ |
1128 |
|
} |