ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/o_instance.c
Revision: 1.1
Committed: Thu Feb 2 10:41:32 1989 UTC (35 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# User Rev Content
1 greg 1.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, GET_ALL);
28     /* copy old ray */
29     bcopy(r, &rcont, sizeof(RAY));
30     /* transform it */
31     rcont.rno = nrays;
32     rcont.ro = NULL;
33     rcont.rot = FHUGE;
34     rcont.rno = nrays;
35     multp3(rcont.rorg, r->rorg, in->b.xfm);
36     multv3(rcont.rdir, r->rdir, in->b.xfm);
37     for (i = 0; i < 3; i++)
38     rcont.rdir[i] /= in->b.sca;
39     /* trace it */
40     if (!localhit(&rcont, &in->obj->scube))
41     return(0); /* missed */
42     if (rcont.rot * in->f.sca >= r->rot)
43     return(0); /* not close enough */
44     /* if we have modifier, use it */
45     if (o->omod != OVOID)
46     r->ro = o;
47     else { /* else use theirs */
48     r->ro = rcont.ro;
49     multmat4(r->rox, in->b.xfm, rcont.rox);
50     r->ros = in->b.sca * rcont.ros;
51     }
52     /* transform it back */
53     r->rot = rcont.rot * in->f.sca;
54     multp3(r->rop, rcont.rop, in->f.xfm);
55     multv3(r->ron, rcont.ron, in->f.xfm);
56     for (i = 0; i < 3; i++)
57     r->ron[i] /= in->f.sca;
58     r->rod = rcont.rod;
59     /* return hit */
60     return(1);
61     }