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

Comparing ray/src/rt/m_direct.c (file contents):
Revision 2.8 by greg, Sat Feb 22 02:07:28 2003 UTC vs.
Revision 2.12 by schorsch, Tue Mar 30 16:13:01 2004 UTC

# Line 6 | Line 6 | static const char      RCSid[] = "$Id$";
6   *   their associated virtual light sources
7   */
8  
9 < /* ====================================================================
10 < * The Radiance Software License, Version 1.0
11 < *
12 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
13 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
14 < *
15 < * Redistribution and use in source and binary forms, with or without
16 < * modification, are permitted provided that the following conditions
17 < * are met:
18 < *
19 < * 1. Redistributions of source code must retain the above copyright
20 < *         notice, this list of conditions and the following disclaimer.
21 < *
22 < * 2. Redistributions in binary form must reproduce the above copyright
23 < *       notice, this list of conditions and the following disclaimer in
24 < *       the documentation and/or other materials provided with the
25 < *       distribution.
26 < *
27 < * 3. The end-user documentation included with the redistribution,
28 < *           if any, must include the following acknowledgment:
29 < *             "This product includes Radiance software
30 < *                 (http://radsite.lbl.gov/)
31 < *                 developed by the Lawrence Berkeley National Laboratory
32 < *               (http://www.lbl.gov/)."
33 < *       Alternately, this acknowledgment may appear in the software itself,
34 < *       if and wherever such third-party acknowledgments normally appear.
35 < *
36 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
37 < *       and "The Regents of the University of California" must
38 < *       not be used to endorse or promote products derived from this
39 < *       software without prior written permission. For written
40 < *       permission, please contact [email protected].
41 < *
42 < * 5. Products derived from this software may not be called "Radiance",
43 < *       nor may "Radiance" appear in their name, without prior written
44 < *       permission of Lawrence Berkeley National Laboratory.
45 < *
46 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
47 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
48 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
49 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
50 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
51 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
52 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
53 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
54 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
56 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 < * SUCH DAMAGE.
58 < * ====================================================================
59 < *
60 < * This software consists of voluntary contributions made by many
61 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
62 < * information on Lawrence Berkeley National Laboratory, please see
63 < * <http://www.lbl.gov/>.
64 < */
9 > #include "copyright.h"
10  
11   #include  "ray.h"
67
12   #include  "otypes.h"
13 <
13 > #include  "rtotypes.h"
14   #include  "source.h"
71
15   #include  "func.h"
16  
17   /*
# Line 85 | Line 28 | static const char      RCSid[] = "$Id$";
28   *      n A1 A2 .. An
29   */
30  
31 + static int redirect(OBJREC  *m, RAY  *r, int  n);
32 + static int dir_proj(MAT4  pm, OBJREC  *o, SRCREC  *s, int  n);
33  
89 static int  dir_proj();
90
34   VSMATERIAL  direct1_vs = {dir_proj, 1};
35   VSMATERIAL  direct2_vs = {dir_proj, 2};
36  
# Line 96 | Line 39 | VSMATERIAL  direct2_vs = {dir_proj, 2};
39                                  getfunc(m, 8, 0xff, 1) )
40  
41  
42 < int
43 < m_direct(m, r)                  /* shade redirected ray */
44 < register OBJREC  *m;
45 < register RAY  *r;
42 > extern int
43 > m_direct(                       /* shade redirected ray */
44 >        register OBJREC  *m,
45 >        register RAY  *r
46 > )
47   {
48                                          /* check if source ray */
49          if (r->rsrc >= 0 && source[r->rsrc].so != r->ro)
# Line 116 | Line 60 | register RAY  *r;
60   }
61  
62  
63 < int
64 < redirect(m, r, n)               /* compute n'th ray redirection */
65 < OBJREC  *m;
66 < RAY  *r;
67 < int  n;
63 > static int
64 > redirect(               /* compute n'th ray redirection */
65 >        OBJREC  *m,
66 >        RAY  *r,
67 >        int  n
68 > )
69   {
70          MFUNC  *mf;
71          register EPNODE  **va;
# Line 155 | Line 100 | int  n;
100          errno = 0;
101          va = mf->ep + 4*n;
102          coef = evalue(va[0]);
103 <        if (errno)
103 >        if (errno == EDOM || errno == ERANGE)
104                  goto computerr;
105          if (coef <= FTINY || rayorigin(&nr, r, TRANS, coef) < 0)
106                  return(0);
107          va++;                           /* compute direction */
108          for (j = 0; j < 3; j++) {
109                  nr.rdir[j] = evalue(va[j]);
110 <                if (errno)
110 >                if (errno == EDOM || errno == ERANGE)
111                          goto computerr;
112          }
113          if (mf->f != &unitxf)
# Line 187 | Line 132 | computerr:
132  
133  
134   static int
135 < dir_proj(pm, o, s, n)           /* compute a director's projection */
136 < MAT4  pm;
137 < OBJREC  *o;
138 < SRCREC  *s;
139 < int  n;
135 > dir_proj(               /* compute a director's projection */
136 >        MAT4  pm,
137 >        OBJREC  *o,
138 >        SRCREC  *s,
139 >        int  n
140 > )
141   {
142          RAY  tr;
143          OBJREC  *m;
# Line 233 | Line 179 | int  n;
179          errno = 0;
180          va = mf->ep + 4*n;
181          coef = evalue(va[0]);
182 <        if (errno)
182 >        if (errno == EDOM || errno == ERANGE)
183                  goto computerr;
184          if (coef <= FTINY)
185                  return(0);              /* insignificant */
186          va++;
187          for (i = 0; i < 3; i++) {
188                  newdir[i] = evalue(va[i]);
189 <                if (errno)
189 >                if (errno == EDOM || errno == ERANGE)
190                          goto computerr;
191          }
192          if (mf->f != &unitxf)
# Line 258 | Line 204 | int  n;
204                          pm[i][j] += nv[i]*h[j];
205                  pm[3][j] = -od*h[j];
206          }
207 <        if (newdot > 0.0 ^ olddot > 0.0)        /* add mirroring */
207 >        if ((newdot > 0.0) ^ (olddot > 0.0))    /* add mirroring */
208                  for (j = 0; j < 3; j++) {
209                          for (i = 0; i < 3; i++)
210                                  pm[i][j] -= 2.*nv[i]*nv[j];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines