ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/o_instance.c
Revision: 1.7
Committed: Fri Jan 19 00:00:17 1990 UTC (34 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.6: +1 -1 lines
Log Message:
improved portability and speed of bcopy()

File Contents

# Content
1 /* Copyright (c) 1988 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * o_instance.c - routines for computing ray intersections with octrees.
9 *
10 * 11/11/88
11 */
12
13 #include "ray.h"
14
15 #include "instance.h"
16
17
18 o_instance(o, r) /* compute ray intersection with octree */
19 OBJREC *o;
20 register RAY *r;
21 {
22 extern long nrays;
23 RAY rcont;
24 register INSTANCE *in;
25 register int i;
26 /* get the octree */
27 in = getinstance(o, IO_ALL);
28 /* copy old ray */
29 copystruct(&rcont, r);
30 /* transform it */
31 rcont.rno = nrays;
32 rcont.ro = NULL;
33 rcont.rot = FHUGE;
34 multp3(rcont.rorg, r->rorg, in->b.xfm);
35 multv3(rcont.rdir, r->rdir, in->b.xfm);
36 for (i = 0; i < 3; i++)
37 rcont.rdir[i] /= in->b.sca;
38 /* trace it */
39 if (!localhit(&rcont, &in->obj->scube))
40 return(0); /* missed */
41 if (rcont.rot * in->f.sca >= r->rot)
42 return(0); /* not close enough */
43
44 if (o->omod != OVOID) { /* if we have modifier, use it */
45 r->ro = o;
46 r->rofs = 1.0; setident4(r->rofx);
47 r->robs = 1.0; setident4(r->robx);
48 } else { /* else use theirs */
49 r->ro = rcont.ro;
50 multmat4(r->rofx, rcont.rofx, in->f.xfm);
51 r->rofs = rcont.rofs * in->f.sca;
52 multmat4(r->robx, in->b.xfm, rcont.robx);
53 r->robs = in->b.sca * rcont.robs;
54 }
55 /* transform it back */
56 r->rot = rcont.rot * in->f.sca;
57 multp3(r->rop, rcont.rop, in->f.xfm);
58 multv3(r->ron, rcont.ron, in->f.xfm);
59 for (i = 0; i < 3; i++)
60 r->ron[i] /= in->f.sca;
61 r->rod = rcont.rod;
62 /* return hit */
63 return(1);
64 }