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

Comparing ray/src/rt/srcdraw.c (file contents):
Revision 2.5 by greg, Sat Feb 22 02:07:29 2003 UTC vs.
Revision 2.10 by greg, Fri Oct 24 05:29:43 2003 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   *  External symbols declared in ray.h
8   */
9  
10 < /* ====================================================================
11 < * The Radiance Software License, Version 1.0
12 < *
13 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
14 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
15 < *
16 < * Redistribution and use in source and binary forms, with or without
17 < * modification, are permitted provided that the following conditions
18 < * are met:
19 < *
20 < * 1. Redistributions of source code must retain the above copyright
21 < *         notice, this list of conditions and the following disclaimer.
22 < *
23 < * 2. Redistributions in binary form must reproduce the above copyright
24 < *       notice, this list of conditions and the following disclaimer in
25 < *       the documentation and/or other materials provided with the
26 < *       distribution.
27 < *
28 < * 3. The end-user documentation included with the redistribution,
29 < *           if any, must include the following acknowledgment:
30 < *             "This product includes Radiance software
31 < *                 (http://radsite.lbl.gov/)
32 < *                 developed by the Lawrence Berkeley National Laboratory
33 < *               (http://www.lbl.gov/)."
34 < *       Alternately, this acknowledgment may appear in the software itself,
35 < *       if and wherever such third-party acknowledgments normally appear.
36 < *
37 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
38 < *       and "The Regents of the University of California" must
39 < *       not be used to endorse or promote products derived from this
40 < *       software without prior written permission. For written
41 < *       permission, please contact [email protected].
42 < *
43 < * 5. Products derived from this software may not be called "Radiance",
44 < *       nor may "Radiance" appear in their name, without prior written
45 < *       permission of Lawrence Berkeley National Laboratory.
46 < *
47 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
48 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
51 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
54 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
55 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
56 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
57 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 < * SUCH DAMAGE.
59 < * ====================================================================
60 < *
61 < * This software consists of voluntary contributions made by many
62 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
63 < * information on Lawrence Berkeley National Laboratory, please see
64 < * <http://www.lbl.gov/>.
65 < */
10 > #include "copyright.h"
11  
12   #include  "ray.h"
13  
# Line 82 | Line 27 | typedef struct splist {
27          struct splist   *next;                  /* next source in list */
28          int     sn;                             /* source number */
29          short   nv;                             /* number of vertices */
30 <        FLOAT   vl[3][2];                       /* vertex array (last) */
30 >        RREAL   vl[3][2];                       /* vertex array (last) */
31   } SPLIST;                               /* source polygon list */
32  
33   extern VIEW     ourview;                /* our view parameters */
# Line 92 | Line 37 | static SPLIST  *sphead = NULL;         /* our list of source p
37  
38   static int
39   inregion(p, cv, crit)                   /* check if vertex is in region */
40 < FLOAT   p[2];
40 > RREAL   p[2];
41   double  cv;
42   int     crit;
43   {
# Line 112 | Line 57 | int    crit;
57  
58   static
59   clipregion(a, b, cv, crit, r)           /* find intersection with boundary */
60 < register FLOAT  a[2], b[2];
60 > register RREAL  a[2], b[2];
61   double  cv;
62   int     crit;
63 < FLOAT   r[2];   /* return value */
63 > RREAL   r[2];   /* return value */
64   {
65          switch (crit) {
66          case CLIP_ABOVE:
# Line 134 | Line 79 | FLOAT  r[2];   /* return value */
79  
80   static int
81   hp_clip_poly(vl, nv, cv, crit, vlo)     /* clip polygon to half-plane */
82 < FLOAT   vl[][2];
82 > RREAL   vl[][2];
83   int     nv;
84   double  cv;
85   int     crit;
86 < FLOAT   vlo[][2];       /* return value */
86 > RREAL   vlo[][2];       /* return value */
87   {
88 <        FLOAT   *s, *p;
88 >        RREAL   *s, *p;
89          register int    j, nvo;
90  
91          s = vl[nv-1];
# Line 161 | Line 106 | FLOAT  vlo[][2];       /* return value */
106  
107   static int
108   box_clip_poly(vl, nv, xl, xr, yb, ya, vlo)      /* clip polygon to box */
109 < FLOAT   vl[MAXVERT][2];
109 > RREAL   vl[MAXVERT][2];
110   int     nv;
111   double  xl, xr, yb, ya;
112 < FLOAT   vlo[MAXVERT][2];        /* return value */
112 > RREAL   vlo[MAXVERT][2];        /* return value */
113   {
114 <        FLOAT   vlt[MAXVERT][2];
114 >        RREAL   vlt[MAXVERT][2];
115          int     nvt, nvo;
116  
117          nvt = hp_clip_poly(vl, nv, yb, CLIP_BELOW, vlt);
# Line 180 | Line 125 | FLOAT  vlo[MAXVERT][2];        /* return value */
125  
126   static double
127   minw2(vl, nv, ar2)                      /* compute square of minimum width */
128 < FLOAT   vl[][2];
128 > RREAL   vl[][2];
129   int     nv;
130   double  ar2;
131   {
132          double  d2, w2, w2min, w2max;
133 <        register FLOAT  *p0, *p1, *p2;
133 >        register RREAL  *p0, *p1, *p2;
134          int     i, j;
135                                  /* find minimum for all widths */
136          w2min = FHUGE;
# Line 213 | Line 158 | double ar2;
158  
159   static
160   convex_center(vl, nv, cv)               /* compute center of convex polygon */
161 < register FLOAT  vl[][2];
161 > register RREAL  vl[][2];
162   int     nv;
163 < FLOAT   cv[2];          /* return value */
163 > RREAL   cv[2];          /* return value */
164   {
165          register int    i;
166                                          /* simple average (suboptimal) */
# Line 231 | Line 176 | FLOAT  cv[2];          /* return value */
176  
177   static double
178   poly_area(vl, nv)                       /* compute area of polygon */
179 < register FLOAT  vl[][2];
179 > register RREAL  vl[][2];
180   int     nv;
181   {
182          double  a;
183 <        FLOAT   v0[2], v1[2];
183 >        RREAL   v0[2], v1[2];
184          register int    i;
185  
186          a = 0.;
# Line 253 | Line 198 | int    nv;
198  
199   static int
200   convex_hull(vl, nv, vlo)                /* compute polygon's convex hull */
201 < FLOAT   vl[][2];
201 > RREAL   vl[][2];
202   int     nv;
203 < FLOAT   vlo[][2];       /* return value */
203 > RREAL   vlo[][2];       /* return value */
204   {
205          int     nvo, nvt;
206 <        FLOAT   vlt[MAXVERT][2];
206 >        RREAL   vlt[MAXVERT][2];
207          double  voa, vta;
208          register int    i, j;
209                                          /* start with original polygon */
# Line 290 | Line 235 | FLOAT  vlo[][2];       /* return value */
235   static
236   spinsert(sn, vl, nv)                    /* insert new source polygon */
237   int     sn;
238 < FLOAT   vl[][2];
238 > RREAL   vl[][2];
239   int     nv;
240   {
241          register SPLIST *spn;
# Line 299 | Line 244 | int    nv;
244          if (nv < 3)
245                  return;
246          if (nv > 3)
247 <                spn = (SPLIST *)malloc(sizeof(SPLIST)+sizeof(FLOAT)*2*(nv-3));
247 >                spn = (SPLIST *)malloc(sizeof(SPLIST)+sizeof(RREAL)*2*(nv-3));
248          else
249                  spn = (SPLIST *)malloc(sizeof(SPLIST));
250          if (spn == NULL)
# Line 316 | Line 261 | int    nv;
261   int
262   sourcepoly(sn, sp)                      /* compute image polygon for source */
263   int     sn;
264 < FLOAT   sp[MAXVERT][2];
264 > RREAL   sp[MAXVERT][2];
265   {
266 <        static char     cubeord[8][6] = {{1,3,2,6,4,5},{0,4,5,7,3,2},
266 >        static short    cubeord[8][6] = {{1,3,2,6,4,5},{0,4,5,7,3,2},
267                                           {0,1,3,7,6,4},{0,1,5,7,6,2},
268                                           {0,2,6,7,5,1},{0,4,6,7,3,1},
269                                           {0,2,3,7,5,4},{1,5,4,6,2,3}};
270          register SRCREC *s = source + sn;
271          FVECT   ap, ip;
272 <        FLOAT   pt[6][2];
272 >        RREAL   pt[6][2];
273          int     dir;
274          register int    i, j;
275  
# Line 340 | Line 285 | FLOAT  sp[MAXVERT][2];
285                  for (j = 0; j < 4; j++) {       /* four corners */
286                          for (i = 0; i < 3; i++) {
287                                  ap[i] = s->sloc[i];
288 <                                if (j==1|j==2) ap[i] += s->ss[SU][i];
288 >                                if ((j==1)|(j==2)) ap[i] += s->ss[SU][i];
289                                  else ap[i] -= s->ss[SU][i];
290 <                                if (j==2|j==3) ap[i] += s->ss[SV][i];
290 >                                if ((j==2)|(j==3)) ap[i] += s->ss[SV][i];
291                                  else ap[i] -= s->ss[SV][i];
292                                  if (s->sflags & SDISTANT) {
293                                          ap[i] *= 1. + ourview.vfore;
# Line 386 | Line 331 | FLOAT  sp[MAXVERT][2];
331   init_drawsources(rad)
332   int     rad;                            /* source sample size */
333   {
334 <        FLOAT   spoly[MAXVERT][2];
334 >        RREAL   spoly[MAXVERT][2];
335          int     nsv;
336          register SPLIST *sp;
337          register int    i;
# Line 418 | Line 363 | COLOR  *pic[];                         /* subimage pixel value array */
363   float   *zbf[];                         /* subimage distance array (opt.) */
364   int     x0, xsiz, y0, ysiz;             /* origin and size of subimage */
365   {
366 <        FLOAT   spoly[MAXVERT][2], ppoly[MAXVERT][2];
366 >        RREAL   spoly[MAXVERT][2], ppoly[MAXVERT][2];
367          int     nsv, npv;
368          int     xmin, xmax, ymin, ymax, x, y;
369 <        FLOAT   cxy[2];
369 >        RREAL   cxy[2];
370          double  w;
371          RAY     sr;
372          register SPLIST *sp;
# Line 464 | Line 409 | int    x0, xsiz, y0, ysiz;             /* origin and size of subimag
409                                  if (source[sp->sn].sflags & SSPOT &&
410                                                  spotout(&sr, source[sp->sn].sl.s))
411                                          continue;       /* outside spot */
412 <                                rayorigin(&sr, NULL, SHADOW, 1.0);
413 <                                sr.rsrc = sp->sn;
412 >                                w = poly_area(ppoly, npv) * hres * vres;
413 >                                if (w < .95) {          /* subpixel source */
414 >                                        rayorigin(&sr, NULL, SHADOW, 1.0);
415 >                                        sr.rsrc = sp->sn;
416 >                                } else
417 >                                        rayorigin(&sr, NULL, PRIMARY, 1.0);
418                                  rayvalue(&sr);          /* compute value */
419                                  if (bright(sr.rcol) <= FTINY)
420                                          continue;       /* missed/blocked */
421                                                          /* modify pixel */
422                                  if (zbf[y-y0] != NULL &&
423 <                                                sr.rt < 0.999*zbf[y-y0][x-x0])
423 >                                                sr.rt < 0.99*zbf[y-y0][x-x0])
424                                          zbf[y-y0][x-x0] = sr.rt;
425                                  else if (!bigdiff(sr.rcol, pic[y-y0][x-x0],
426 <                                                0.001)) /* source sample */
426 >                                                0.01))  /* source sample */
427                                          setcolor(pic[y-y0][x-x0], 0., 0., 0.);
479                                w = poly_area(ppoly, npv) * hres * vres;
428                                  scalecolor(sr.rcol, w);
429                                  scalecolor(pic[y-y0][x-x0], 1.-w);
430                                  addcolor(pic[y-y0][x-x0], sr.rcol);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines