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.1 by greg, Thu Feb 2 10:41:32 1989 UTC vs.
Revision 2.1 by greg, Tue Nov 12 17:10:10 1991 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 >        extern long  raynum;
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);
27 >        in = getinstance(o, IO_ALL);
28 >                                        /* duplicate and clear ray */
29 >        copystruct(&rcont, r);
30 >        rayclear(&rcont);
31 >                                        /* transform ray to new space */
32 >        multp3(rcont.rorg, r->rorg, in->x.b.xfm);
33 >        multv3(rcont.rdir, r->rdir, in->x.b.xfm);
34          for (i = 0; i < 3; i++)
35 <                rcont.rdir[i] /= in->b.sca;
35 >                rcont.rdir[i] /= in->x.b.sca;
36                                          /* trace it */
37          if (!localhit(&rcont, &in->obj->scube))
38 <                return(0);              /* missed */
39 <        if (rcont.rot * in->f.sca >= r->rot)
40 <                return(0);              /* not close enough */
41 <                                        /* if we have modifier, use it */
42 <        if (o->omod != OVOID)
38 >                return(0);                      /* missed */
39 >        if (rcont.rot * in->x.f.sca >= r->rot)
40 >                return(0);                      /* not close enough */
41 >
42 >        if (o->omod != OVOID) {         /* if we have modifier, use it */
43                  r->ro = o;
44 <        else {                          /* else use theirs */
44 >                r->rox = NULL;
45 >        } else {                        /* else use theirs */
46                  r->ro = rcont.ro;
47 <                multmat4(r->rox, in->b.xfm, rcont.rox);
48 <                r->ros = in->b.sca * rcont.ros;
47 >                if (rcont.rox != NULL) {
48 >                        newrayxf(r);            /* allocate transformation */
49 >                                        /* NOTE: r->rox may equal rcont.rox! */
50 >                        multmat4(r->rox->f.xfm, rcont.rox->f.xfm, in->x.f.xfm);
51 >                        r->rox->f.sca = rcont.rox->f.sca * in->x.f.sca;
52 >                        multmat4(r->rox->b.xfm, in->x.b.xfm, rcont.rox->b.xfm);
53 >                        r->rox->b.sca = in->x.b.sca * rcont.rox->b.sca;
54 >                } else
55 >                        r->rox = &in->x;
56          }
57                                          /* transform it back */
58 <        r->rot = rcont.rot * in->f.sca;
59 <        multp3(r->rop, rcont.rop, in->f.xfm);
60 <        multv3(r->ron, rcont.ron, in->f.xfm);
58 >        r->rot = rcont.rot * in->x.f.sca;
59 >        multp3(r->rop, rcont.rop, in->x.f.xfm);
60 >        multv3(r->ron, rcont.ron, in->x.f.xfm);
61          for (i = 0; i < 3; i++)
62 <                r->ron[i] /= in->f.sca;
62 >                r->ron[i] /= in->x.f.sca;
63          r->rod = rcont.rod;
64                                          /* return hit */
65          return(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines