ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/o_face.c
Revision: 2.7
Committed: Tue Jul 8 18:25:00 2014 UTC (9 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R2, rad4R2P2, rad5R0, rad5R1, rad4R2, rad4R2P1, rad5R3
Changes since 2.6: +4 -4 lines
Log Message:
Eliminated unnecessary "extern" and "register" modifiers

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: o_face.c,v 2.6 2006/03/02 16:51:55 greg Exp $";
3 #endif
4 /*
5 * o_face.c - compute ray intersection with faces.
6 */
7
8 #include "copyright.h"
9
10 #include "ray.h"
11 #include "face.h"
12 #include "rtotypes.h"
13
14
15 int
16 o_face( /* compute intersection with polygonal face */
17 OBJREC *o,
18 RAY *r
19 )
20 {
21 double rdot; /* direction . normal */
22 double t; /* distance to intersection */
23 FVECT pisect; /* intersection point */
24 FACE *f; /* face record */
25
26 f = getface(o);
27
28 /*
29 * First, we find the distance to the plane containing the
30 * face. If this distance is less than zero or greater
31 * than a previous intersection, we return. Otherwise,
32 * we determine whether in fact the ray intersects the
33 * face. The ray intersects the face if the
34 * point of intersection with the plane of the face
35 * is inside the face.
36 */
37 /* compute dist. to plane */
38 rdot = -DOT(r->rdir, f->norm);
39 if (rdot <= FTINY && rdot >= -FTINY) /* ray parallels plane */
40 t = FHUGE;
41 else
42 t = (DOT(r->rorg, f->norm) - f->offset) / rdot;
43
44 if (t <= FTINY || t >= r->rot) /* not good enough */
45 return(0);
46 /* compute intersection */
47 VSUM(pisect, r->rorg, r->rdir, t);
48
49 if (!inface(pisect, f)) /* ray intersects face? */
50 return(0);
51
52 r->ro = o;
53 r->rot = t;
54 VCOPY(r->rop, pisect);
55 VCOPY(r->ron, f->norm);
56 r->rod = rdot;
57 r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
58 r->uv[0] = r->uv[1] = 0.0;
59 r->rox = NULL;
60
61 return(1); /* hit */
62 }