ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/o_instance.c
(Generate patch)

Comparing ray/src/rt/o_instance.c (file contents):
Revision 1.5 by greg, Sun Apr 23 19:33:59 1989 UTC vs.
Revision 2.5 by greg, Tue Feb 25 02:47:23 2003 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines