ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/o_instance.c
Revision: 1.4
Committed: Thu Apr 20 08:25:22 1989 UTC (35 years ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.3: +5 -3 lines
Log Message:
moved setting of ray transformation to intersection routines (bug)

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 greg 1.4
45     if (o->omod != OVOID) { /* if we have modifier, use it */
46 greg 1.1 r->ro = o;
47 greg 1.4 r->rofs = 1.0; setident4(r->rofx);
48     r->robs = 1.0; setident4(r->robx);
49     } else { /* else use theirs */
50 greg 1.1 r->ro = rcont.ro;
51 greg 1.3 multmat4(r->rofx, rcont.rofx, in->f.xfm);
52     r->rofs = rcont.rofs * in->f.sca;
53 greg 1.2 multmat4(r->robx, in->b.xfm, rcont.robx);
54     r->robs = in->b.sca * rcont.robs;
55 greg 1.1 }
56     /* transform it back */
57     r->rot = rcont.rot * in->f.sca;
58     multp3(r->rop, rcont.rop, in->f.xfm);
59     multv3(r->ron, rcont.ron, in->f.xfm);
60     for (i = 0; i < 3; i++)
61     r->ron[i] /= in->f.sca;
62     r->rod = rcont.rod;
63     /* return hit */
64     return(1);
65     }