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.6 by greg, Tue Oct 24 13:58:45 1989 UTC vs.
Revision 2.2 by greg, Sun Dec 20 10:11:53 1992 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines