| 22 |
|
|
| 23 |
|
static RAY queued_ray; |
| 24 |
|
|
| 25 |
< |
extern void |
| 25 |
> |
void |
| 26 |
|
ray_pinit( /* initialize ray-tracing processes */ |
| 27 |
|
char *otnm, |
| 28 |
|
int nproc |
| 34 |
|
} |
| 35 |
|
|
| 36 |
|
|
| 37 |
< |
extern void |
| 37 |
> |
int |
| 38 |
|
ray_psend( /* add a ray to our send queue */ |
| 39 |
|
RAY *r |
| 40 |
|
) |
| 41 |
|
{ |
| 42 |
|
if (r == NULL) |
| 43 |
< |
return; |
| 43 |
> |
return(0); |
| 44 |
|
if (ray_pnidle <= 0) |
| 45 |
< |
error(INTERNAL, "illegal call to ray_psend"); |
| 45 |
> |
return(0); |
| 46 |
|
queued_ray = *r; |
| 47 |
|
ray_pnidle = 0; |
| 48 |
+ |
return(1); |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
|
| 52 |
< |
extern int |
| 52 |
> |
int |
| 53 |
|
ray_pqueue( /* queue a ray for computation */ |
| 54 |
|
RAY *r |
| 55 |
|
) |
| 56 |
|
{ |
| 57 |
+ |
RNUMBER rno; |
| 58 |
+ |
|
| 59 |
|
if (r == NULL) |
| 60 |
|
return(0); |
| 61 |
< |
ray_value(r); |
| 61 |
> |
if (ray_pnidle <= 0) { |
| 62 |
> |
RAY new_ray = *r; |
| 63 |
> |
*r = queued_ray; |
| 64 |
> |
queued_ray = new_ray; |
| 65 |
> |
} |
| 66 |
> |
rno = r->rno; |
| 67 |
> |
r->rno = raynum++; |
| 68 |
> |
samplendx++; |
| 69 |
> |
rayvalue(r); |
| 70 |
> |
r->rno = rno; |
| 71 |
|
return(1); |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
|
| 75 |
< |
extern int |
| 75 |
> |
int |
| 76 |
|
ray_presult( /* check for a completed ray */ |
| 77 |
|
RAY *r, |
| 78 |
|
int poll |
| 81 |
|
if (r == NULL) |
| 82 |
|
return(0); |
| 83 |
|
if (ray_pnidle <= 0) { |
| 72 |
– |
ray_value(&queued_ray); |
| 84 |
|
*r = queued_ray; |
| 85 |
+ |
r->rno = raynum++; |
| 86 |
+ |
samplendx++; |
| 87 |
+ |
rayvalue(r); |
| 88 |
+ |
r->rno = queued_ray.rno; |
| 89 |
|
ray_pnidle = 1; |
| 90 |
|
return(1); |
| 91 |
|
} |
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
|
| 96 |
< |
extern void |
| 96 |
> |
void |
| 97 |
|
ray_pdone( /* reap children and free data */ |
| 98 |
|
int freall |
| 99 |
|
) |
| 103 |
|
} |
| 104 |
|
|
| 105 |
|
|
| 106 |
< |
extern void |
| 106 |
> |
void |
| 107 |
|
ray_popen( /* open the specified # processes */ |
| 108 |
|
int nadd |
| 109 |
|
) |
| 110 |
|
{ |
| 111 |
|
if (ray_pnprocs + nadd > 1) { |
| 112 |
< |
error(WARNING, "Only single process supported"); |
| 112 |
> |
error(WARNING, "only single process supported"); |
| 113 |
|
nadd = 1 - ray_pnprocs; |
| 114 |
|
} |
| 115 |
|
ray_pnprocs += nadd; |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
|
| 120 |
< |
extern void |
| 120 |
> |
void |
| 121 |
|
ray_pclose( /* close one or more child processes */ |
| 122 |
|
int nsub |
| 123 |
|
) |
| 127 |
|
ray_pnprocs -= nsub; |
| 128 |
|
if ((ray_pnidle -= nsub) < 0) |
| 129 |
|
ray_pnidle = 0; |
| 115 |
– |
} |
| 116 |
– |
|
| 117 |
– |
|
| 118 |
– |
void |
| 119 |
– |
quit(ec) /* make sure exit is called */ |
| 120 |
– |
int ec; |
| 121 |
– |
{ |
| 122 |
– |
exit(ec); |
| 130 |
|
} |