ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/raytrace.c
Revision: 2.44
Committed: Wed Dec 31 01:50:02 2003 UTC (20 years, 4 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.43: +1 -26 lines
Log Message:
Created a source occluder cache to accelerate shadow testing.

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2 greg 2.44 static const char RCSid[] = "$Id: raytrace.c,v 2.43 2003/09/09 03:28:43 greg Exp $";
3 greg 1.1 #endif
4     /*
5     * raytrace.c - routines for tracing and shading rays.
6     *
7 greg 2.34 * External symbols declared in ray.h
8     */
9    
10 greg 2.35 #include "copyright.h"
11 greg 1.1
12     #include "ray.h"
13    
14     #include "otypes.h"
15    
16 greg 1.15 #include "otspecial.h"
17    
18 greg 2.3 #define MAXCSET ((MAXSET+1)*2-1) /* maximum check set size */
19    
20 greg 2.6 unsigned long raynum = 0; /* next unique ray number */
21     unsigned long nrays = 0; /* number of calls to localhit */
22 greg 1.1
23 schorsch 2.40 static RREAL Lambfa[5] = {PI, PI, PI, 0.0, 0.0};
24 greg 1.15 OBJREC Lamb = {
25     OVOID, MAT_PLASTIC, "Lambertian",
26 greg 2.2 {0, 5, NULL, Lambfa}, NULL,
27 greg 1.15 }; /* a Lambertian surface */
28    
29 greg 2.17 OBJREC Aftplane; /* aft clipping plane object */
30 greg 2.16
31 greg 2.34 static int raymove(), checkhit();
32     static void checkset();
33 greg 2.5
34 greg 1.1 #define RAYHIT (-1) /* return value for intercepted ray */
35    
36    
37 greg 2.34 int
38 greg 1.1 rayorigin(r, ro, rt, rw) /* start new ray from old one */
39     register RAY *r, *ro;
40     int rt;
41     double rw;
42     {
43 gwlarson 2.31 double re;
44    
45 greg 1.1 if ((r->parent = ro) == NULL) { /* primary ray */
46     r->rlvl = 0;
47     r->rweight = rw;
48     r->crtype = r->rtype = rt;
49     r->rsrc = -1;
50     r->clipset = NULL;
51 greg 1.21 r->revf = raytrace;
52 greg 2.23 copycolor(r->cext, cextinction);
53 greg 2.26 copycolor(r->albedo, salbedo);
54 greg 2.23 r->gecc = seccg;
55     r->slights = NULL;
56 greg 1.1 } else { /* spawned ray */
57     r->rlvl = ro->rlvl;
58     if (rt & RAYREFL) {
59     r->rlvl++;
60     r->rsrc = -1;
61     r->clipset = ro->clipset;
62 greg 2.22 r->rmax = 0.0;
63 greg 1.1 } else {
64     r->rsrc = ro->rsrc;
65     r->clipset = ro->newcset;
66 greg 2.22 r->rmax = ro->rmax <= FTINY ? 0.0 : ro->rmax - ro->rot;
67 greg 1.1 }
68 greg 1.21 r->revf = ro->revf;
69 greg 2.23 copycolor(r->cext, ro->cext);
70 greg 2.26 copycolor(r->albedo, ro->albedo);
71 greg 2.23 r->gecc = ro->gecc;
72     r->slights = ro->slights;
73 greg 1.1 r->crtype = ro->crtype | (r->rtype = rt);
74     VCOPY(r->rorg, ro->rop);
75 gwlarson 2.31 r->rweight = ro->rweight * rw;
76     /* estimate absorption */
77     re = colval(ro->cext,RED) < colval(ro->cext,GRN) ?
78     colval(ro->cext,RED) : colval(ro->cext,GRN);
79     if (colval(ro->cext,BLU) < re) re = colval(ro->cext,BLU);
80     if (re > 0.)
81     r->rweight *= exp(-re*ro->rot);
82 greg 1.1 }
83 greg 1.22 rayclear(r);
84     return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1);
85     }
86    
87    
88 greg 2.34 void
89 greg 1.22 rayclear(r) /* clear a ray for (re)evaluation */
90     register RAY *r;
91     {
92 greg 1.20 r->rno = raynum++;
93 greg 1.1 r->newcset = r->clipset;
94 greg 2.36 r->hitf = rayhit;
95 greg 2.28 r->robj = OVOID;
96 greg 2.17 r->ro = NULL;
97 greg 2.34 r->rox = NULL;
98 gregl 2.29 r->rt = r->rot = FHUGE;
99 greg 1.1 r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
100 greg 2.37 r->uv[0] = r->uv[1] = 0.0;
101 greg 1.1 setcolor(r->pcol, 1.0, 1.0, 1.0);
102     setcolor(r->rcol, 0.0, 0.0, 0.0);
103     }
104    
105    
106 greg 2.34 void
107 greg 1.21 raytrace(r) /* trace a ray and compute its value */
108 greg 1.8 RAY *r;
109 greg 1.1 {
110 greg 1.15 if (localhit(r, &thescene))
111 greg 2.24 raycont(r); /* hit local surface, evaluate */
112 greg 2.16 else if (r->ro == &Aftplane) {
113 greg 2.23 r->ro = NULL; /* hit aft clipping plane */
114 greg 2.16 r->rot = FHUGE;
115     } else if (sourcehit(r))
116 greg 2.24 rayshade(r, r->ro->omod); /* distant source */
117 greg 1.1
118 greg 2.23 rayparticipate(r); /* for participating medium */
119    
120 greg 1.1 if (trace != NULL)
121     (*trace)(r); /* trace execution */
122     }
123    
124    
125 greg 2.34 void
126 greg 1.8 raycont(r) /* check for clipped object and continue */
127     register RAY *r;
128     {
129 greg 2.7 if ((r->clipset != NULL && inset(r->clipset, r->ro->omod)) ||
130 greg 2.24 !rayshade(r, r->ro->omod))
131 greg 1.8 raytrans(r);
132     }
133    
134    
135 greg 2.34 void
136 greg 1.1 raytrans(r) /* transmit ray as is */
137 greg 1.8 register RAY *r;
138 greg 1.1 {
139     RAY tr;
140    
141     if (rayorigin(&tr, r, TRANS, 1.0) == 0) {
142     VCOPY(tr.rdir, r->rdir);
143     rayvalue(&tr);
144     copycolor(r->rcol, tr.rcol);
145 greg 1.10 r->rt = r->rot + tr.rt;
146 greg 1.1 }
147     }
148    
149    
150 greg 2.34 int
151 greg 1.1 rayshade(r, mod) /* shade ray r with material mod */
152     register RAY *r;
153     int mod;
154     {
155 greg 2.9 int gotmat;
156 greg 1.1 register OBJREC *m;
157 greg 1.19 r->rt = r->rot; /* set effective ray length */
158 greg 2.9 for (gotmat = 0; !gotmat && mod != OVOID; mod = m->omod) {
159 greg 1.1 m = objptr(mod);
160 greg 1.4 /****** unnecessary test since modifier() is always called
161 greg 1.1 if (!ismodifier(m->otype)) {
162     sprintf(errmsg, "illegal modifier \"%s\"", m->oname);
163     error(USER, errmsg);
164     }
165 greg 1.4 ******/
166 greg 1.16 /* hack for irradiance calculation */
167 greg 2.38 if (do_irrad && !(r->crtype & ~(PRIMARY|TRANS)) &&
168 greg 2.43 m->otype != MAT_CLIP &&
169 greg 2.38 (ofun[m->otype].flags & (T_M|T_X))) {
170 greg 1.16 if (irr_ignore(m->otype)) {
171     raytrans(r);
172 greg 2.15 return(1);
173 greg 1.16 }
174 greg 1.18 if (!islight(m->otype))
175 greg 1.16 m = &Lamb;
176     }
177 greg 2.9 /* materials call raytexture */
178     gotmat = (*ofun[m->otype].funp)(m, r);
179 greg 1.1 }
180 greg 2.9 return(gotmat);
181 greg 2.23 }
182    
183    
184 greg 2.34 void
185 greg 2.23 rayparticipate(r) /* compute ray medium participation */
186     register RAY *r;
187     {
188     COLOR ce, ca;
189     double re, ge, be;
190    
191     if (intens(r->cext) <= 1./FHUGE)
192     return; /* no medium */
193 greg 2.27 re = r->rot*colval(r->cext,RED);
194     ge = r->rot*colval(r->cext,GRN);
195     be = r->rot*colval(r->cext,BLU);
196 greg 2.26 if (r->crtype & SHADOW) { /* no scattering for sources */
197     re *= 1. - colval(r->albedo,RED);
198     ge *= 1. - colval(r->albedo,GRN);
199     be *= 1. - colval(r->albedo,BLU);
200     }
201     setcolor(ce, re<=0. ? 1. : re>92. ? 0. : exp(-re),
202     ge<=0. ? 1. : ge>92. ? 0. : exp(-ge),
203     be<=0. ? 1. : be>92. ? 0. : exp(-be));
204 greg 2.23 multcolor(r->rcol, ce); /* path absorption */
205 greg 2.26 if (r->crtype & SHADOW || intens(r->albedo) <= FTINY)
206 greg 2.23 return; /* no scattering */
207 greg 2.26 setcolor(ca,
208     colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)),
209     colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)),
210     colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU)));
211 greg 2.23 addcolor(r->rcol, ca); /* ambient in scattering */
212     srcscatter(r); /* source in scattering */
213 greg 1.1 }
214    
215    
216 greg 2.39 void
217 greg 1.1 raytexture(r, mod) /* get material modifiers */
218     RAY *r;
219 greg 2.39 OBJECT mod;
220 greg 1.1 {
221 gwlarson 2.33 register OBJREC *m;
222 greg 1.1 /* execute textures and patterns */
223     for ( ; mod != OVOID; mod = m->omod) {
224     m = objptr(mod);
225 greg 2.9 /****** unnecessary test since modifier() is always called
226     if (!ismodifier(m->otype)) {
227 greg 1.1 sprintf(errmsg, "illegal modifier \"%s\"", m->oname);
228     error(USER, errmsg);
229     }
230 greg 2.9 ******/
231 greg 2.20 if ((*ofun[m->otype].funp)(m, r)) {
232     sprintf(errmsg, "conflicting material \"%s\"",
233     m->oname);
234     objerror(r->ro, USER, errmsg);
235     }
236 greg 1.1 }
237     }
238    
239    
240 greg 2.34 int
241 greg 1.1 raymixture(r, fore, back, coef) /* mix modifiers */
242     register RAY *r;
243     OBJECT fore, back;
244     double coef;
245     {
246 greg 2.9 RAY fr, br;
247     int foremat, backmat;
248 greg 1.1 register int i;
249 greg 2.24 /* bound coefficient */
250 greg 1.1 if (coef > 1.0)
251     coef = 1.0;
252     else if (coef < 0.0)
253     coef = 0.0;
254 greg 2.13 /* compute foreground and background */
255 greg 2.24 foremat = backmat = 0;
256 greg 2.9 /* foreground */
257 schorsch 2.41 fr = *r;
258 greg 2.24 if (coef > FTINY)
259 greg 2.9 foremat = rayshade(&fr, fore);
260     /* background */
261 schorsch 2.41 br = *r;
262 greg 2.24 if (coef < 1.0-FTINY)
263 greg 2.9 backmat = rayshade(&br, back);
264 greg 2.24 /* check for transparency */
265 schorsch 2.41 if (backmat ^ foremat) {
266 gwlarson 2.33 if (backmat && coef > FTINY)
267 greg 2.24 raytrans(&fr);
268 gwlarson 2.33 else if (foremat && coef < 1.0-FTINY)
269 greg 2.24 raytrans(&br);
270 schorsch 2.41 }
271 greg 2.12 /* mix perturbations */
272 greg 1.1 for (i = 0; i < 3; i++)
273 greg 2.12 r->pert[i] = coef*fr.pert[i] + (1.0-coef)*br.pert[i];
274     /* mix pattern colors */
275 greg 2.9 scalecolor(fr.pcol, coef);
276     scalecolor(br.pcol, 1.0-coef);
277 greg 2.12 copycolor(r->pcol, fr.pcol);
278     addcolor(r->pcol, br.pcol);
279 greg 2.24 /* return value tells if material */
280     if (!foremat & !backmat)
281     return(0);
282 greg 2.12 /* mix returned ray values */
283 greg 2.24 scalecolor(fr.rcol, coef);
284     scalecolor(br.rcol, 1.0-coef);
285     copycolor(r->rcol, fr.rcol);
286     addcolor(r->rcol, br.rcol);
287     r->rt = bright(fr.rcol) > bright(br.rcol) ? fr.rt : br.rt;
288     return(1);
289 greg 1.1 }
290    
291    
292     double
293 greg 2.21 raydist(r, flags) /* compute (cumulative) ray distance */
294     register RAY *r;
295     register int flags;
296     {
297     double sum = 0.0;
298    
299     while (r != NULL && r->crtype&flags) {
300     sum += r->rot;
301     r = r->parent;
302     }
303     return(sum);
304     }
305    
306    
307     double
308 greg 1.1 raynormal(norm, r) /* compute perturbed normal for ray */
309     FVECT norm;
310     register RAY *r;
311     {
312     double newdot;
313     register int i;
314    
315     /* The perturbation is added to the surface normal to obtain
316     * the new normal. If the new normal would affect the surface
317     * orientation wrt. the ray, a correction is made. The method is
318     * still fraught with problems since reflected rays and similar
319     * directions calculated from the surface normal may spawn rays behind
320     * the surface. The only solution is to curb textures at high
321 greg 1.9 * incidence (namely, keep DOT(rdir,pert) < Rdot).
322 greg 1.1 */
323    
324     for (i = 0; i < 3; i++)
325     norm[i] = r->ron[i] + r->pert[i];
326    
327     if (normalize(norm) == 0.0) {
328     objerror(r->ro, WARNING, "illegal normal perturbation");
329     VCOPY(norm, r->ron);
330     return(r->rod);
331     }
332     newdot = -DOT(norm, r->rdir);
333     if ((newdot > 0.0) != (r->rod > 0.0)) { /* fix orientation */
334     for (i = 0; i < 3; i++)
335     norm[i] += 2.0*newdot*r->rdir[i];
336     newdot = -newdot;
337     }
338     return(newdot);
339 greg 1.12 }
340    
341    
342 greg 2.34 void
343 greg 1.12 newrayxf(r) /* get new tranformation matrix for ray */
344     RAY *r;
345     {
346     static struct xfn {
347     struct xfn *next;
348     FULLXF xf;
349     } xfseed = { &xfseed }, *xflast = &xfseed;
350     register struct xfn *xp;
351     register RAY *rp;
352    
353     /*
354     * Search for transform in circular list that
355     * has no associated ray in the tree.
356     */
357     xp = xflast;
358     for (rp = r->parent; rp != NULL; rp = rp->parent)
359     if (rp->rox == &xp->xf) { /* xp in use */
360     xp = xp->next; /* move to next */
361     if (xp == xflast) { /* need new one */
362 greg 2.34 xp = (struct xfn *)malloc(sizeof(struct xfn));
363 greg 1.12 if (xp == NULL)
364     error(SYSTEM,
365     "out of memory in newrayxf");
366     /* insert in list */
367     xp->next = xflast->next;
368     xflast->next = xp;
369     break; /* we're done */
370     }
371     rp = r; /* start check over */
372     }
373     /* got it */
374     r->rox = &xp->xf;
375     xflast = xp;
376 greg 1.1 }
377    
378    
379 greg 2.34 void
380 greg 1.1 flipsurface(r) /* reverse surface orientation */
381     register RAY *r;
382     {
383     r->rod = -r->rod;
384     r->ron[0] = -r->ron[0];
385     r->ron[1] = -r->ron[1];
386     r->ron[2] = -r->ron[2];
387     r->pert[0] = -r->pert[0];
388     r->pert[1] = -r->pert[1];
389     r->pert[2] = -r->pert[2];
390     }
391    
392    
393 greg 2.36 void
394     rayhit(oset, r) /* standard ray hit test */
395     OBJECT *oset;
396     RAY *r;
397     {
398     OBJREC *o;
399     int i;
400    
401     for (i = oset[0]; i > 0; i--) {
402     o = objptr(oset[i]);
403     if ((*ofun[o->otype].funp)(o, r))
404     r->robj = oset[i];
405     }
406     }
407    
408    
409 greg 2.34 int
410 greg 1.1 localhit(r, scene) /* check for hit in the octree */
411     register RAY *r;
412     register CUBE *scene;
413     {
414 greg 2.3 OBJECT cxset[MAXCSET+1]; /* set of checked objects */
415 greg 1.1 FVECT curpos; /* current cube position */
416 greg 1.11 int sflags; /* sign flags */
417 greg 1.1 double t, dt;
418     register int i;
419    
420 greg 1.21 nrays++; /* increment trace counter */
421 greg 1.11 sflags = 0;
422 greg 1.1 for (i = 0; i < 3; i++) {
423     curpos[i] = r->rorg[i];
424 greg 2.8 if (r->rdir[i] > 1e-7)
425 greg 1.11 sflags |= 1 << i;
426 greg 2.8 else if (r->rdir[i] < -1e-7)
427 greg 1.11 sflags |= 0x10 << i;
428 greg 1.1 }
429 greg 1.17 if (sflags == 0)
430     error(CONSISTENCY, "zero ray direction in localhit");
431 greg 2.17 /* start off assuming nothing hit */
432     if (r->rmax > FTINY) { /* except aft plane if one */
433     r->ro = &Aftplane;
434     r->rot = r->rmax;
435     for (i = 0; i < 3; i++)
436     r->rop[i] = r->rorg[i] + r->rot*r->rdir[i];
437     }
438     /* find global cube entrance point */
439 greg 1.1 t = 0.0;
440     if (!incube(scene, curpos)) {
441     /* find distance to entry */
442     for (i = 0; i < 3; i++) {
443     /* plane in our direction */
444 greg 1.11 if (sflags & 1<<i)
445 greg 1.1 dt = scene->cuorg[i];
446 greg 1.11 else if (sflags & 0x10<<i)
447 greg 1.1 dt = scene->cuorg[i] + scene->cusize;
448     else
449     continue;
450     /* distance to the plane */
451     dt = (dt - r->rorg[i])/r->rdir[i];
452     if (dt > t)
453     t = dt; /* farthest face is the one */
454     }
455     t += FTINY; /* fudge to get inside cube */
456 greg 2.17 if (t >= r->rot) /* clipped already */
457     return(0);
458 greg 1.1 /* advance position */
459     for (i = 0; i < 3; i++)
460     curpos[i] += r->rdir[i]*t;
461    
462     if (!incube(scene, curpos)) /* non-intersecting ray */
463     return(0);
464     }
465 greg 2.3 cxset[0] = 0;
466 greg 2.19 raymove(curpos, cxset, sflags, r, scene);
467 schorsch 2.42 return((r->ro != NULL) & (r->ro != &Aftplane));
468 greg 1.1 }
469    
470    
471     static int
472 greg 2.3 raymove(pos, cxs, dirf, r, cu) /* check for hit as we move */
473     FVECT pos; /* current position, modified herein */
474     OBJECT *cxs; /* checked objects, modified by checkhit */
475 greg 1.11 int dirf; /* direction indicators to speed tests */
476 greg 1.1 register RAY *r;
477     register CUBE *cu;
478     {
479     int ax;
480     double dt, t;
481    
482     if (istree(cu->cutree)) { /* recurse on subcubes */
483     CUBE cukid;
484 greg 1.11 register int br, sgn;
485 greg 1.1
486     cukid.cusize = cu->cusize * 0.5; /* find subcube */
487     VCOPY(cukid.cuorg, cu->cuorg);
488     br = 0;
489     if (pos[0] >= cukid.cuorg[0]+cukid.cusize) {
490     cukid.cuorg[0] += cukid.cusize;
491     br |= 1;
492     }
493     if (pos[1] >= cukid.cuorg[1]+cukid.cusize) {
494     cukid.cuorg[1] += cukid.cusize;
495     br |= 2;
496     }
497     if (pos[2] >= cukid.cuorg[2]+cukid.cusize) {
498     cukid.cuorg[2] += cukid.cusize;
499     br |= 4;
500     }
501     for ( ; ; ) {
502     cukid.cutree = octkid(cu->cutree, br);
503 greg 2.3 if ((ax = raymove(pos,cxs,dirf,r,&cukid)) == RAYHIT)
504 greg 1.1 return(RAYHIT);
505     sgn = 1 << ax;
506 greg 1.11 if (sgn & dirf) /* positive axis? */
507 greg 1.1 if (sgn & br)
508     return(ax); /* overflow */
509     else {
510     cukid.cuorg[ax] += cukid.cusize;
511     br |= sgn;
512     }
513 greg 1.11 else
514     if (sgn & br) {
515     cukid.cuorg[ax] -= cukid.cusize;
516     br &= ~sgn;
517     } else
518     return(ax); /* underflow */
519 greg 1.1 }
520     /*NOTREACHED*/
521     }
522 greg 2.18 if (isfull(cu->cutree)) {
523     if (checkhit(r, cu, cxs))
524     return(RAYHIT);
525     } else if (r->ro == &Aftplane && incube(cu, r->rop))
526 greg 1.1 return(RAYHIT);
527     /* advance to next cube */
528 greg 1.11 if (dirf&0x11) {
529     dt = dirf&1 ? cu->cuorg[0] + cu->cusize : cu->cuorg[0];
530 greg 1.1 t = (dt - pos[0])/r->rdir[0];
531     ax = 0;
532     } else
533     t = FHUGE;
534 greg 1.11 if (dirf&0x22) {
535     dt = dirf&2 ? cu->cuorg[1] + cu->cusize : cu->cuorg[1];
536 greg 1.1 dt = (dt - pos[1])/r->rdir[1];
537     if (dt < t) {
538     t = dt;
539     ax = 1;
540     }
541     }
542 greg 1.11 if (dirf&0x44) {
543     dt = dirf&4 ? cu->cuorg[2] + cu->cusize : cu->cuorg[2];
544 greg 1.1 dt = (dt - pos[2])/r->rdir[2];
545     if (dt < t) {
546     t = dt;
547     ax = 2;
548     }
549     }
550     pos[0] += r->rdir[0]*t;
551     pos[1] += r->rdir[1]*t;
552     pos[2] += r->rdir[2]*t;
553     return(ax);
554     }
555    
556    
557 greg 2.34 static int
558 greg 2.3 checkhit(r, cu, cxs) /* check for hit in full cube */
559 greg 1.1 register RAY *r;
560     CUBE *cu;
561 greg 2.3 OBJECT *cxs;
562 greg 1.1 {
563     OBJECT oset[MAXSET+1];
564    
565     objset(oset, cu->cutree);
566 greg 2.36 checkset(oset, cxs); /* avoid double-checking */
567    
568     (*r->hitf)(oset, r); /* test for hit in set */
569    
570     if (r->robj == OVOID)
571 greg 1.1 return(0); /* no scores yet */
572    
573     return(incube(cu, r->rop)); /* hit OK if in current cube */
574 greg 2.2 }
575    
576    
577 greg 2.34 static void
578 greg 2.2 checkset(os, cs) /* modify checked set and set to check */
579 greg 2.3 register OBJECT *os; /* os' = os - cs */
580     register OBJECT *cs; /* cs' = cs + os */
581 greg 2.2 {
582     OBJECT cset[MAXCSET+MAXSET+1];
583 greg 2.3 register int i, j;
584     int k;
585 greg 2.2 /* copy os in place, cset <- cs */
586     cset[0] = 0;
587     k = 0;
588     for (i = j = 1; i <= os[0]; i++) {
589     while (j <= cs[0] && cs[j] < os[i])
590     cset[++cset[0]] = cs[j++];
591     if (j > cs[0] || os[i] != cs[j]) { /* object to check */
592     os[++k] = os[i];
593     cset[++cset[0]] = os[i];
594     }
595     }
596 greg 2.3 if (!(os[0] = k)) /* new "to check" set size */
597     return; /* special case */
598 greg 2.2 while (j <= cs[0]) /* get the rest of cs */
599     cset[++cset[0]] = cs[j++];
600 greg 2.3 if (cset[0] > MAXCSET) /* truncate "checked" set if nec. */
601 greg 2.2 cset[0] = MAXCSET;
602 greg 2.3 /* setcopy(cs, cset); */ /* copy cset back to cs */
603     os = cset;
604     for (i = os[0]; i-- >= 0; )
605     *cs++ = *os++;
606 greg 1.1 }