home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume21 / rayshade / patch1 < prev    next >
Encoding:
Internet Message Format  |  1990-03-21  |  54.9 KB

  1. Subject:  v21i016:  A ray tracing program, Patch1
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Craig Kolb <craig@weedeater.math.yale.edu>
  7. Posting-number: Volume 21, Issue 16
  8. Archive-name: rayshade/patch1
  9.  
  10. System: rayshade version 3.0
  11. Patch #: 1
  12. Priority: MEDIUM-HIGH
  13.  
  14. Description:
  15.     Fixed calculation of field of view in Stereo mode.
  16.  
  17.     When resolution/samples/etc. is set in the input file
  18.     more than once, the last occurrence takes precedence.
  19.  
  20.     Moved atmospheric declarations to atmosphere.h to facilitate
  21.     addition of new effects.
  22.  
  23.     Atmospheric effects are applied to background rays.
  24.  
  25.     Renamed several transformation routines to avoid name clashes
  26.     when linking with external libraries.
  27.  
  28.     Statistics are now reported in Linda implementation.
  29.  
  30.     Added -w option to enable verbose worker output.
  31.  
  32.     Linda syntax is more up-to-date.
  33.  
  34.  
  35. Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your rayshade source
  36.     directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
  37.     If you don't have the patch program, apply the following by hand,
  38.     or get patch (version 2.0, latest patchlevel).
  39.  
  40.     After patching:
  41.         make depend
  42.         make
  43.         make install
  44.  
  45.     If patch indicates that patchlevel is the wrong version, you may need
  46.     to apply one or more previous patches, or the patch may already
  47.     have been applied.  See the patchlevel.h file to find out what has or
  48.     has not been applied.  In any event, don't continue with the patch.
  49.  
  50. Index: src/patchlevel.h
  51. Prereq: 0
  52. 1c1
  53. < #define PATCHLEVEL 0
  54. ---
  55. > #define PATCHLEVEL 1
  56.  
  57. Index: README
  58. *** README.old    Mon Nov 20 13:10:11 1989
  59. --- README    Mon Nov 20 13:10:12 1989
  60. ***************
  61. *** 41,47
  62.   for image manipulation and a library for reading/reading the toolkit's
  63.   "RLE" format image files.  UTAH.BLURB is the "blurb" file from the latest
  64.   distribution of the toolkit, which can be obtained via anonymous ftp from
  65. ! cs.utah.edu (128.110.4.21), weedeater.math.yale.edu (192.26.88.42),
  66.   nl.cs.cmu.edu (128.22.222.56), and uunet.uu.net.  Also of interest is the
  67.   "fbm" library, available from nl.cs.cmu.edu:/usr/mlm/ftp/fbm.tar.Z, which
  68.   provides tools for converting Utah Raster RLE format images to/from other
  69.  
  70. --- 41,47 -----
  71.   for image manipulation and a library for reading/reading the toolkit's
  72.   "RLE" format image files.  UTAH.BLURB is the "blurb" file from the latest
  73.   distribution of the toolkit, which can be obtained via anonymous ftp from
  74. ! cs.utah.edu (128.110.4.21), weedeater.math.yale.edu (130.132.23.17),
  75.   nl.cs.cmu.edu (128.22.222.56), and uunet.uu.net.  Also of interest is the
  76.   "fbm" library, available from nl.cs.cmu.edu:/usr/mlm/ftp/fbm.tar.Z, which
  77.   provides tools for converting Utah Raster RLE format images to/from other
  78.  
  79. Index: TODO
  80. *** TODO.old    Mon Nov 20 13:10:17 1989
  81. --- TODO    Mon Nov 20 13:10:18 1989
  82. ***************
  83. *** 28,32
  84.   we test objects roughly in order.
  85.   
  86.   Improve handling of input files (error messages, #include directives, etc.).
  87. - Have workers pass statistics back to the supervisor.
  88.  
  89. --- 28,30 -----
  90.   we test objects roughly in order.
  91.   
  92.   Improve handling of input files (error messages, #include directives, etc.).
  93.  
  94. Index: src/atmosphere.c
  95. *** src/atmosphere.c.old    Mon Nov 20 13:10:29 1989
  96. --- src/atmosphere.c    Mon Nov 20 13:10:31 1989
  97. ***************
  98. *** 18,24
  99.    * name of the person performing the modification, the date of modification,
  100.    * and the reason for such modification.
  101.    *
  102. !  * $Id: atmosphere.c,v 3.0 89/10/27 02:05:46 craig Exp $
  103.    *
  104.    * $Log:    atmosphere.c,v $
  105.    * Revision 3.0  89/10/27  02:05:46  craig
  106.  
  107. --- 18,24 -----
  108.    * name of the person performing the modification, the date of modification,
  109.    * and the reason for such modification.
  110.    *
  111. !  * $Id: atmosphere.c,v 3.0.1.1 89/11/16 20:38:39 craig Exp Locker: craig $
  112.    *
  113.    * $Log:    atmosphere.c,v $
  114.    * Revision 3.0.1.1  89/11/16  20:38:39  craig
  115. ***************
  116. *** 21,26
  117.    * $Id: atmosphere.c,v 3.0 89/10/27 02:05:46 craig Exp $
  118.    *
  119.    * $Log:    atmosphere.c,v $
  120.    * Revision 3.0  89/10/27  02:05:46  craig
  121.    * Baseline for first official release.
  122.    * 
  123.  
  124. --- 21,29 -----
  125.    * $Id: atmosphere.c,v 3.0.1.1 89/11/16 20:38:39 craig Exp Locker: craig $
  126.    *
  127.    * $Log:    atmosphere.c,v $
  128. +  * Revision 3.0.1.1  89/11/16  20:38:39  craig
  129. +  * patch1: Changes to accommodate atmosphere.h.
  130. +  * 
  131.    * Revision 3.0  89/10/27  02:05:46  craig
  132.    * Baseline for first official release.
  133.    * 
  134. ***************
  135. *** 30,35
  136.   #include "typedefs.h"
  137.   #include "constants.h"
  138.   #include "funcdefs.h"
  139.   
  140.   Fog *GlobalFog;
  141.   Mist *GlobalMist;
  142.  
  143. --- 33,39 -----
  144.   #include "typedefs.h"
  145.   #include "constants.h"
  146.   #include "funcdefs.h"
  147. + #include "atmosphere.h"
  148.   
  149.   Fog *GlobalFog;
  150.   Mist *GlobalMist;
  151.  
  152. Index: src/cone.c
  153. *** src/cone.c.old    Mon Nov 20 13:10:36 1989
  154. --- src/cone.c    Mon Nov 20 13:10:37 1989
  155. ***************
  156. *** 18,24
  157.    * name of the person performing the modification, the date of modification,
  158.    * and the reason for such modification.
  159.    *
  160. !  * $Id: cone.c,v 3.0 89/10/27 02:05:47 craig Exp $
  161.    *
  162.    * $Log:    cone.c,v $
  163.    * Revision 3.0  89/10/27  02:05:47  craig
  164.  
  165. --- 18,24 -----
  166.    * name of the person performing the modification, the date of modification,
  167.    * and the reason for such modification.
  168.    *
  169. !  * $Id: cone.c,v 3.0.1.1 89/11/18 14:08:09 craig Exp Locker: craig $
  170.    *
  171.    * $Log:    cone.c,v $
  172.    * Revision 3.0.1.1  89/11/18  14:08:09  craig
  173. ***************
  174. *** 21,26
  175.    * $Id: cone.c,v 3.0 89/10/27 02:05:47 craig Exp $
  176.    *
  177.    * $Log:    cone.c,v $
  178.    * Revision 3.0  89/10/27  02:05:47  craig
  179.    * Baseline for first official release.
  180.    * 
  181.  
  182. --- 21,29 -----
  183.    * $Id: cone.c,v 3.0.1.1 89/11/18 14:08:09 craig Exp Locker: craig $
  184.    *
  185.    * $Log:    cone.c,v $
  186. +  * Revision 3.0.1.1  89/11/18  14:08:09  craig
  187. +  * patch1: Changes to reflect new names of transformation routines.
  188. +  * 
  189.    * Revision 3.0  89/10/27  02:05:47  craig
  190.    * Baseline for first official release.
  191.    * 
  192. ***************
  193. *** 125,141
  194.       /*
  195.        * Calculate rotation matrix to map from world space to cone space.
  196.        */
  197. ! /*    if (equal(axis.z*axis.z, 1.)) {
  198. !         tmp.x = 0.;
  199. !         tmp.y = -axis.z;
  200. !         tmp.z = 0.;
  201. !     } else { */
  202. !         tmp.x = axis.y;
  203. !         tmp.y = -axis.x;
  204. !         tmp.z = 0.;
  205. !     /*} */
  206. !     rotate(trans, &tmp, acos(axis.z));
  207. !     translate(trans, &base);
  208.       cone->tantheta *= cone->tantheta;
  209.   
  210.       return newobj;
  211.  
  212. --- 128,138 -----
  213.       /*
  214.        * Calculate rotation matrix to map from world space to cone space.
  215.        */
  216. !     tmp.x = axis.y;
  217. !     tmp.y = -axis.x;
  218. !     tmp.z = 0.;
  219. !     RS_rotate(trans, &tmp, acos(axis.z));
  220. !     RS_translate(trans, &base);
  221.       cone->tantheta *= cone->tantheta;
  222.   
  223.       return newobj;
  224.  
  225. Index: src/cylinder.c
  226. *** src/cylinder.c.old    Mon Nov 20 13:10:42 1989
  227. --- src/cylinder.c    Mon Nov 20 13:10:43 1989
  228. ***************
  229. *** 18,24
  230.    * name of the person performing the modification, the date of modification,
  231.    * and the reason for such modification.
  232.    *
  233. !  * $Id: cylinder.c,v 3.0 89/10/27 02:05:48 craig Exp $
  234.    *
  235.    * $Log:    cylinder.c,v $
  236.    * Revision 3.0  89/10/27  02:05:48  craig
  237.  
  238. --- 18,24 -----
  239.    * name of the person performing the modification, the date of modification,
  240.    * and the reason for such modification.
  241.    *
  242. !  * $Id: cylinder.c,v 3.0.1.1 89/11/18 14:07:52 craig Exp Locker: craig $
  243.    *
  244.    * $Log:    cylinder.c,v $
  245.    * Revision 3.0.1.1  89/11/18  14:07:52  craig
  246. ***************
  247. *** 21,26
  248.    * $Id: cylinder.c,v 3.0 89/10/27 02:05:48 craig Exp $
  249.    *
  250.    * $Log:    cylinder.c,v $
  251.    * Revision 3.0  89/10/27  02:05:48  craig
  252.    * Baseline for first official release.
  253.    * 
  254.  
  255. --- 21,29 -----
  256.    * $Id: cylinder.c,v 3.0.1.1 89/11/18 14:07:52 craig Exp Locker: craig $
  257.    *
  258.    * $Log:    cylinder.c,v $
  259. +  * Revision 3.0.1.1  89/11/18  14:07:52  craig
  260. +  * patch1: Changes to reflect new names of transformation routines.
  261. +  * 
  262.    * Revision 3.0  89/10/27  02:05:48  craig
  263.    * Baseline for first official release.
  264.    * 
  265. ***************
  266. *** 81,88
  267.       dir.x = axis.y;
  268.       dir.y = -axis.x;
  269.       dir.z = 0.;
  270. !     rotate(trans, &dir, acos(axis.z));
  271. !     translate(trans, cent);
  272.   
  273.       return newobj;
  274.   }
  275.  
  276. --- 84,91 -----
  277.       dir.x = axis.y;
  278.       dir.y = -axis.x;
  279.       dir.z = 0.;
  280. !     RS_rotate(trans, &dir, acos(axis.z));
  281. !     RS_translate(trans, cent);
  282.   
  283.       return newobj;
  284.   }
  285.  
  286. Index: src/datatypes.h
  287. *** src/datatypes.h.old    Mon Nov 20 13:10:46 1989
  288. --- src/datatypes.h    Mon Nov 20 13:10:47 1989
  289. ***************
  290. *** 18,24
  291.    * name of the person performing the modification, the date of modification,
  292.    * and the reason for such modification.
  293.    *
  294. !  * $Id: datatypes.h,v 3.0 89/10/27 02:05:49 craig Exp $
  295.    *
  296.    * $Log:    datatypes.h,v $
  297.    * Revision 3.0  89/10/27  02:05:49  craig
  298.  
  299. --- 18,24 -----
  300.    * name of the person performing the modification, the date of modification,
  301.    * and the reason for such modification.
  302.    *
  303. !  * $Id: datatypes.h,v 3.0.1.1 89/11/16 20:41:39 craig Exp Locker: craig $
  304.    *
  305.    * $Log:    datatypes.h,v $
  306.    * Revision 3.0.1.1  89/11/16  20:41:39  craig
  307. ***************
  308. *** 21,26
  309.    * $Id: datatypes.h,v 3.0 89/10/27 02:05:49 craig Exp $
  310.    *
  311.    * $Log:    datatypes.h,v $
  312.    * Revision 3.0  89/10/27  02:05:49  craig
  313.    * Baseline for first official release.
  314.    * 
  315.  
  316. --- 21,29 -----
  317.    * $Id: datatypes.h,v 3.0.1.1 89/11/16 20:41:39 craig Exp Locker: craig $
  318.    *
  319.    * $Log:    datatypes.h,v $
  320. +  * Revision 3.0.1.1  89/11/16  20:41:39  craig
  321. +  * patch1: Moved atmospheric declarations to atmosphere.h.
  322. +  * 
  323.    * Revision 3.0  89/10/27  02:05:49  craig
  324.    * Baseline for first official release.
  325.    * 
  326. ***************
  327. *** 129,142
  328.       Trans *trans;        /* Transformation matrices. */
  329.       struct Texture *next;    /* Pointer to next texture. */
  330.   } Texture;
  331. - typedef struct {
  332. -     Color color;
  333. -     double trans;
  334. - } Fog;
  335. - typedef struct {
  336. -     Color color;        /* Mist color */
  337. -     Color trans;        /* R, G, B trans. */
  338. -     double scale, zero;    /* Height scale, start Z */
  339. - } Mist;
  340.  
  341. --- 132,134 -----
  342.       Trans *trans;        /* Transformation matrices. */
  343.       struct Texture *next;    /* Pointer to next texture. */
  344.   } Texture;
  345.  
  346. Index: src/hf.c
  347. *** src/hf.c.old    Mon Nov 20 13:10:52 1989
  348. --- src/hf.c    Mon Nov 20 13:10:53 1989
  349. ***************
  350. *** 18,24
  351.    * name of the person performing the modification, the date of modification,
  352.    * and the reason for such modification.
  353.    *
  354. !  * $Id: hf.c,v 3.0 89/10/27 02:05:51 craig Exp $
  355.    *
  356.    * $Log:    hf.c,v $
  357.    * Revision 3.0  89/10/27  02:05:51  craig
  358.  
  359. --- 18,24 -----
  360.    * name of the person performing the modification, the date of modification,
  361.    * and the reason for such modification.
  362.    *
  363. !  * $Id: hf.c,v 3.0.1.1 89/11/16 20:44:28 craig Exp Locker: craig $
  364.    *
  365.    * $Log:    hf.c,v $
  366.    * Revision 3.0.1.1  89/11/16  20:44:28  craig
  367. ***************
  368. *** 21,26
  369.    * $Id: hf.c,v 3.0 89/10/27 02:05:51 craig Exp $
  370.    *
  371.    * $Log:    hf.c,v $
  372.    * Revision 3.0  89/10/27  02:05:51  craig
  373.    * Baseline for first official release.
  374.    * 
  375.  
  376. --- 21,29 -----
  377.    * $Id: hf.c,v 3.0.1.1 89/11/16 20:44:28 craig Exp Locker: craig $
  378.    *
  379.    * $Log:    hf.c,v $
  380. +  * Revision 3.0.1.1  89/11/16  20:44:28  craig
  381. +  * patch1: Fixed typos in code comments.
  382. +  * 
  383.    * Revision 3.0  89/10/27  02:05:51  craig
  384.    * Baseline for first official release.
  385.    * 
  386. ***************
  387. *** 58,64
  388.    *      |  \   |
  389.    *      |   \  |
  390.    *    |    \ |
  391. !  *      |TRI2 \|    TRI2 == c-->a-->b-->d
  392.    *      b------c
  393.    */
  394.   #define TRI1            1
  395.  
  396. --- 61,67 -----
  397.    *      |  \   |
  398.    *      |   \  |
  399.    *    |    \ |
  400. !  *      |TRI2 \|    TRI2 == c-->a-->b-->c
  401.    *      b------c
  402.    */
  403.   #define TRI1            1
  404. ***************
  405. *** 229,236
  406.       } else
  407.           hitpos = *pos;
  408.       /*
  409. !      * Find out which cell "hitpoint" is in.  This could be
  410. !      * causing problems!
  411.        */
  412.       if (equal(hitpos.x, 1.))
  413.           hitpos.x -= EPSILON;
  414.  
  415. --- 232,238 -----
  416.       } else
  417.           hitpos = *pos;
  418.       /*
  419. !      * Find out in which cell "hitpoint" is.
  420.        */
  421.       if (equal(hitpos.x, 1.))
  422.           hitpos.x -= EPSILON;
  423.  
  424. Index: src/input_yacc.y
  425. *** src/input_yacc.y.old    Mon Nov 20 13:10:58 1989
  426. --- src/input_yacc.y    Mon Nov 20 13:10:59 1989
  427. ***************
  428. *** 17,23
  429.   /* name of the person performing the modification, the date of modification,*/
  430.   /* and the reason for such modification.                    */
  431.   /*                                        */
  432. ! /* $Id: input_yacc.y,v 3.0 89/10/27 02:05:53 craig Exp $ */
  433.   %{
  434.   #include <stdio.h>
  435.   #include "constants.h"
  436.  
  437. --- 17,23 -----
  438.   /* name of the person performing the modification, the date of modification,*/
  439.   /* and the reason for such modification.                    */
  440.   /*                                        */
  441. ! /* $Id: input_yacc.y,v 3.0.1.3 89/11/20 13:05:33 craig Exp Locker: craig $ */
  442.   %{
  443.   #include <stdio.h>
  444.   #include "constants.h"
  445. ***************
  446. *** 24,29
  447.   #include "typedefs.h"
  448.   #include "funcdefs.h"
  449.   #include "texture.h"
  450.   
  451.   int Npoints=0, CurXSize, CurYSize, CurZSize;
  452.   Object *LastObj = (Object *)0;
  453.  
  454. --- 24,30 -----
  455.   #include "typedefs.h"
  456.   #include "funcdefs.h"
  457.   #include "texture.h"
  458. + #include "atmosphere.h"
  459.   
  460.   int Npoints=0, CurXSize, CurYSize, CurZSize;
  461.   Object *LastObj = (Object *)0;
  462. ***************
  463. *** 36,41
  464.   extern Object *World;
  465.   extern int WorldXSize, WorldYSize, WorldZSize, nlight, Xres, Yres, maxlevel;
  466.   extern int yylineno, Jittered, JitSamples, pixel_div;
  467.   extern double hfov, vfov, RedContrast, GreenContrast, BlueContrast;
  468.   extern double TreeCutoff;
  469.   extern Vector eyep, lookp, up;
  470.  
  471. --- 37,44 -----
  472.   extern Object *World;
  473.   extern int WorldXSize, WorldYSize, WorldZSize, nlight, Xres, Yres, maxlevel;
  474.   extern int yylineno, Jittered, JitSamples, pixel_div;
  475. + extern int ResolutionSet, ContrastSet, SamplesSet, CutoffSet;
  476. + extern int AdaptiveSet, JitteredSet;
  477.   extern double hfov, vfov, RedContrast, GreenContrast, BlueContrast;
  478.   extern double TreeCutoff;
  479.   extern Vector eyep, lookp, up;
  480. ***************
  481. *** 354,360
  482.           {
  483.               if (CurTrans == (TransInfo *)0)
  484.                   CurTrans = new_transinfo();
  485. !             translate(CurTrans, &($2));
  486.           }
  487.           | tROTATE Vector Fnumber
  488.           {
  489.  
  490. --- 357,363 -----
  491.           {
  492.               if (CurTrans == (TransInfo *)0)
  493.                   CurTrans = new_transinfo();
  494. !             RS_translate(CurTrans, &($2));
  495.           }
  496.           | tROTATE Vector Fnumber
  497.           {
  498. ***************
  499. *** 361,367
  500.               if (CurTrans == (TransInfo *)0)
  501.                   CurTrans = new_transinfo();
  502.   
  503. !             rotate(CurTrans, &($2), deg2rad($3));
  504.           }
  505.           | tSCALE Fnumber Fnumber Fnumber
  506.           {
  507.  
  508. --- 364,370 -----
  509.               if (CurTrans == (TransInfo *)0)
  510.                   CurTrans = new_transinfo();
  511.   
  512. !             RS_rotate(CurTrans, &($2), deg2rad($3));
  513.           }
  514.           | tSCALE Fnumber Fnumber Fnumber
  515.           {
  516. ***************
  517. *** 367,373
  518.           {
  519.               if (CurTrans == (TransInfo *)0)
  520.                   CurTrans = new_transinfo();
  521. !             scale(CurTrans, $2, $3, $4);
  522.           }
  523.           | tTRANSFORM Fnumber Fnumber Fnumber
  524.                   Fnumber Fnumber Fnumber
  525.  
  526. --- 370,376 -----
  527.           {
  528.               if (CurTrans == (TransInfo *)0)
  529.                   CurTrans = new_transinfo();
  530. !             RS_scale(CurTrans, $2, $3, $4);
  531.           }
  532.           | tTRANSFORM Fnumber Fnumber Fnumber
  533.                   Fnumber Fnumber Fnumber
  534. ***************
  535. *** 422,428
  536.           ;
  537.   Samples        : tSAMPLES tINT
  538.           {
  539. !             if (JitSamples == UNSET)
  540.                   JitSamples = $2;
  541.           }
  542.           ;
  543.  
  544. --- 425,431 -----
  545.           ;
  546.   Samples        : tSAMPLES tINT
  547.           {
  548. !             if (!SamplesSet)
  549.                   JitSamples = $2;
  550.           }
  551.           ;
  552. ***************
  553. *** 428,434
  554.           ;
  555.   Adaptive    : tADAPTIVE tINT
  556.           {
  557. !             if (pixel_div == UNSET && !Jittered)
  558.                   pixel_div = $2;
  559.           }
  560.           ;
  561.  
  562. --- 431,437 -----
  563.           ;
  564.   Adaptive    : tADAPTIVE tINT
  565.           {
  566. !             if (!AdaptiveSet && !JitteredSet)
  567.                   pixel_div = $2;
  568.           }
  569.           ;
  570. ***************
  571. *** 434,442
  572.           ;
  573.   Contrast    : tCONTRAST Fnumber Fnumber Fnumber
  574.           {
  575. !             if (RedContrast == UNSET ||
  576. !                 GreenContrast == UNSET ||
  577. !                 BlueContrast == UNSET) {
  578.                   RedContrast = $2;
  579.                   GreenContrast = $3;
  580.                   BlueContrast = $4;
  581.  
  582. --- 437,443 -----
  583.           ;
  584.   Contrast    : tCONTRAST Fnumber Fnumber Fnumber
  585.           {
  586. !             if (!ContrastSet) {
  587.                   RedContrast = $2;
  588.                   GreenContrast = $3;
  589.                   BlueContrast = $4;
  590. ***************
  591. *** 445,451
  592.           ;
  593.   Cutoff        : tCUTOFF Fnumber
  594.           {
  595. !             if (TreeCutoff == UNSET)
  596.                   TreeCutoff = $2;
  597.           }
  598.           ;
  599.  
  600. --- 446,452 -----
  601.           ;
  602.   Cutoff        : tCUTOFF Fnumber
  603.           {
  604. !             if (!CutoffSet)
  605.                   TreeCutoff = $2;
  606.           }
  607.           ;
  608. ***************
  609. *** 451,457
  610.           ;
  611.   Jittered    : tJITTERED
  612.           {
  613. !             if (pixel_div == UNSET)
  614.                   Jittered = TRUE;
  615.           }
  616.           ;
  617.  
  618. --- 452,458 -----
  619.           ;
  620.   Jittered    : tJITTERED
  621.           {
  622. !             if (!AdaptiveSet)
  623.                   Jittered = TRUE;
  624.           }
  625.           ;
  626. ***************
  627. *** 457,463
  628.           ;
  629.   Screen        : tSCREEN tINT tINT
  630.           {
  631. !             if (Xres == UNSET || Yres == UNSET) {
  632.                   Xres = $2;
  633.                   Yres = $3;
  634.               }
  635.  
  636. --- 458,464 -----
  637.           ;
  638.   Screen        : tSCREEN tINT tINT
  639.           {
  640. !             if (!ResolutionSet) {
  641.                   Xres = $2;
  642.                   Yres = $3;
  643.               }
  644. ***************
  645. *** 464,470
  646.           }
  647.           | tRESOLUTION tINT tINT
  648.           {
  649. !             if (Xres == UNSET || Yres == UNSET) {
  650.                   Xres = $2;
  651.                   Yres = $3;
  652.               }
  653.  
  654. --- 465,471 -----
  655.           }
  656.           | tRESOLUTION tINT tINT
  657.           {
  658. !             if (!ResolutionSet) {
  659.                   Xres = $2;
  660.                   Yres = $3;
  661.               }
  662.  
  663. Index: src/main.c
  664. *** src/main.c.old    Mon Nov 20 13:11:04 1989
  665. --- src/main.c    Mon Nov 20 13:11:05 1989
  666. ***************
  667. *** 1,5
  668.   char rcsid[] =
  669. !     "$Id: main.c,v 3.0 89/10/27 17:05:45 craig Exp $";
  670.   /*
  671.    * main.c
  672.    *
  673.  
  674. --- 1,5 -----
  675.   char rcsid[] =
  676. !     "$Id: main.c,v 3.0.1.1 89/11/16 18:28:21 craig Exp Locker: craig $";
  677.   /*
  678.    * main.c
  679.    *
  680. ***************
  681. *** 21,26
  682.    * and the reason for such modification.
  683.    *
  684.    * $Log:    main.c,v $
  685.    * Revision 3.0  89/10/27  17:05:45  craig
  686.    * Baseline for first official release.
  687.    * 
  688.  
  689. --- 21,29 -----
  690.    * and the reason for such modification.
  691.    *
  692.    * $Log:    main.c,v $
  693. +  * Revision 3.0.1.1  89/11/16  18:28:21  craig
  694. +  * patch1: Statistics are now reported in Linda implementation.
  695. +  * 
  696.    * Revision 3.0  89/10/27  17:05:45  craig
  697.    * Baseline for first official release.
  698.    * 
  699. ***************
  700. *** 49,54
  701.           BVTests,    /* # of bounding volume tests. */
  702.           SuperSampled;    /* # of supersampled pixels. */
  703.   double        ftmp;        /* Used by fabs() macro. */
  704.   FILE        *fstats;    /* Statistics file */
  705.   
  706.   /*
  707.  
  708. --- 52,58 -----
  709.           BVTests,    /* # of bounding volume tests. */
  710.           SuperSampled;    /* # of supersampled pixels. */
  711.   double        ftmp;        /* Used by fabs() macro. */
  712. + double        utime, stime;    /* user, system CPU time */
  713.   FILE        *fstats;    /* Statistics file */
  714.   
  715.   /*
  716. ***************
  717. *** 62,68
  718.   int argc;
  719.   char **argv;
  720.   {
  721. -     double utime, stime;
  722.       unsigned long TotalRays;
  723.       extern int Verbose, Cache;
  724.       extern unsigned long CacheWorked, CacheFailed, ShadowHits;
  725.  
  726. --- 66,71 -----
  727.   int argc;
  728.   char **argv;
  729.   {
  730.       unsigned long TotalRays;
  731.       extern int Verbose, Cache, Workers, Jittered;
  732.       extern unsigned long CacheWorked, CacheFailed, ShadowHits;
  733. ***************
  734. *** 64,70
  735.   {
  736.       double utime, stime;
  737.       unsigned long TotalRays;
  738. !     extern int Verbose, Cache;
  739.       extern unsigned long CacheWorked, CacheFailed, ShadowHits;
  740.   
  741.       /*
  742.  
  743. --- 67,73 -----
  744.   char **argv;
  745.   {
  746.       unsigned long TotalRays;
  747. !     extern int Verbose, Cache, Workers, Jittered;
  748.       extern unsigned long CacheWorked, CacheFailed, ShadowHits;
  749.   
  750.       /*
  751. ***************
  752. *** 116,122
  753.        * Close the image file.
  754.        */
  755.       endpic();
  756.       get_cpu_time(&utime, &stime);
  757.   
  758.   #ifndef LINDA
  759.  
  760. --- 119,125 -----
  761.        * Close the image file.
  762.        */
  763.       endpic();
  764. ! #ifndef LINDA
  765.       get_cpu_time(&utime, &stime);
  766.   #endif
  767.   
  768. ***************
  769. *** 118,123
  770.       endpic();
  771.   
  772.       get_cpu_time(&utime, &stime);
  773.   
  774.   #ifndef LINDA
  775.       TotalRays = EyeRays + ShadowRays + ReflectRays + RefractRays;
  776.  
  777. --- 121,127 -----
  778.       endpic();
  779.   #ifndef LINDA
  780.       get_cpu_time(&utime, &stime);
  781. + #endif
  782.   
  783.       TotalRays = EyeRays + ShadowRays + ReflectRays + RefractRays;
  784.       ShadowHits += CacheWorked;
  785. ***************
  786. *** 119,125
  787.   
  788.       get_cpu_time(&utime, &stime);
  789.   
  790. - #ifndef LINDA
  791.       TotalRays = EyeRays + ShadowRays + ReflectRays + RefractRays;
  792.       ShadowHits += CacheWorked;
  793.       HitRays += ShadowHits;
  794.  
  795. --- 123,128 -----
  796.       get_cpu_time(&utime, &stime);
  797.   #endif
  798.   
  799.       TotalRays = EyeRays + ShadowRays + ReflectRays + RefractRays;
  800.       ShadowHits += CacheWorked;
  801.       HitRays += ShadowHits;
  802. ***************
  803. *** 123,128
  804.       TotalRays = EyeRays + ShadowRays + ReflectRays + RefractRays;
  805.       ShadowHits += CacheWorked;
  806.       HitRays += ShadowHits;
  807.       fprintf(fstats,"Eye rays:\t\t\t%ld\n", EyeRays);
  808.       fprintf(fstats,"Shadow rays:\t\t\t%ld\n",ShadowRays);
  809.       fprintf(fstats,"Reflected rays:\t\t\t%ld\n",ReflectRays);
  810.  
  811. --- 126,134 -----
  812.       TotalRays = EyeRays + ShadowRays + ReflectRays + RefractRays;
  813.       ShadowHits += CacheWorked;
  814.       HitRays += ShadowHits;
  815. + #ifdef LINDA
  816. +     fprintf(fstats,"Workers:\t\t\t%d\n",Workers);
  817. + #endif
  818.       fprintf(fstats,"Eye rays:\t\t\t%ld\n", EyeRays);
  819.       fprintf(fstats,"Shadow rays:\t\t\t%ld\n",ShadowRays);
  820.       fprintf(fstats,"Reflected rays:\t\t\t%ld\n",ReflectRays);
  821. ***************
  822. *** 138,144
  823.           fprintf(fstats,"Total shadow hits:\t\t%ld (%3.3f%%)\n",
  824.               ShadowHits, 100.*(float)ShadowHits / (float)ShadowRays);
  825.       }
  826. !     fprintf(fstats,"Supersampled pixels:\t\t%ld\n",SuperSampled);
  827.       fprintf(fstats,"B.V. intersection tests:\t%ld\n", BVTests);
  828.       print_prim_stats();
  829.   #endif
  830.  
  831. --- 144,151 -----
  832.           fprintf(fstats,"Total shadow hits:\t\t%ld (%3.3f%%)\n",
  833.               ShadowHits, 100.*(float)ShadowHits / (float)ShadowRays);
  834.       }
  835. !     if (!Jittered)
  836. !         fprintf(fstats,"Supersampled pixels:\t\t%ld\n",SuperSampled);
  837.       fprintf(fstats,"B.V. intersection tests:\t%ld\n", BVTests);
  838.       print_prim_stats();
  839.   #ifdef LINDA
  840. ***************
  841. *** 141,147
  842.       fprintf(fstats,"Supersampled pixels:\t\t%ld\n",SuperSampled);
  843.       fprintf(fstats,"B.V. intersection tests:\t%ld\n", BVTests);
  844.       print_prim_stats();
  845. ! #endif
  846.       fprintf(fstats,"Total CPU time (sec):\t\t");
  847.       fprintf(fstats,"%2.2lf (%2.2lfu + %2.2lfs)\n",utime+stime, utime, stime);
  848.   #ifndef LINDA
  849.  
  850. --- 148,156 -----
  851.           fprintf(fstats,"Supersampled pixels:\t\t%ld\n",SuperSampled);
  852.       fprintf(fstats,"B.V. intersection tests:\t%ld\n", BVTests);
  853.       print_prim_stats();
  854. ! #ifdef LINDA
  855. !     fprintf(fstats,"Average CPU time/processor:\t");
  856. ! #else
  857.       fprintf(fstats,"Total CPU time (sec):\t\t");
  858.   #endif
  859.       fprintf(fstats,"%2.2lf (%2.2lfu + %2.2lfs)\n",utime+stime, utime, stime);
  860. ***************
  861. *** 143,148
  862.       print_prim_stats();
  863.   #endif
  864.       fprintf(fstats,"Total CPU time (sec):\t\t");
  865.       fprintf(fstats,"%2.2lf (%2.2lfu + %2.2lfs)\n",utime+stime, utime, stime);
  866.   #ifndef LINDA
  867.       if (TotalRays != 0.)
  868.  
  869. --- 152,158 -----
  870.       fprintf(fstats,"Average CPU time/processor:\t");
  871.   #else
  872.       fprintf(fstats,"Total CPU time (sec):\t\t");
  873. + #endif
  874.       fprintf(fstats,"%2.2lf (%2.2lfu + %2.2lfs)\n",utime+stime, utime, stime);
  875.       if (TotalRays != 0.)
  876.           fprintf(fstats,"Seconds / ray:\t\t\t%4.4lf\n",
  877. ***************
  878. *** 144,150
  879.   #endif
  880.       fprintf(fstats,"Total CPU time (sec):\t\t");
  881.       fprintf(fstats,"%2.2lf (%2.2lfu + %2.2lfs)\n",utime+stime, utime, stime);
  882. - #ifndef LINDA
  883.       if (TotalRays != 0.)
  884.           fprintf(fstats,"Seconds / ray:\t\t\t%4.4lf\n",
  885.                   (utime + stime) / (double)TotalRays);
  886.  
  887. --- 154,159 -----
  888.       fprintf(fstats,"Total CPU time (sec):\t\t");
  889.   #endif
  890.       fprintf(fstats,"%2.2lf (%2.2lfu + %2.2lfs)\n",utime+stime, utime, stime);
  891.       if (TotalRays != 0.)
  892.           fprintf(fstats,"Seconds / ray:\t\t\t%4.4lf\n",
  893.                   (utime + stime) / (double)TotalRays);
  894. ***************
  895. *** 151,157
  896.       if (HitRays != 0.)
  897.           fprintf(fstats, "Seconds / intersecting ray:\t%4.4lf\n",
  898.                   (utime + stime) / (double)HitRays);
  899. - #endif
  900.       PrintMemoryStats();
  901.       exit(0);
  902.   }
  903.  
  904. --- 160,165 -----
  905.       if (HitRays != 0.)
  906.           fprintf(fstats, "Seconds / intersecting ray:\t%4.4lf\n",
  907.                   (utime + stime) / (double)HitRays);
  908.       PrintMemoryStats();
  909.       exit(0);
  910.   }
  911.  
  912. Index: src/matrix.c
  913. *** src/matrix.c.old    Mon Nov 20 13:11:10 1989
  914. --- src/matrix.c    Mon Nov 20 13:11:11 1989
  915. ***************
  916. *** 18,24
  917.    * name of the person performing the modification, the date of modification,
  918.    * and the reason for such modification.
  919.    *
  920. !  * $Id: matrix.c,v 3.0 89/10/27 02:05:56 craig Exp $
  921.    *
  922.    * $Log:    matrix.c,v $
  923.    * Revision 3.0  89/10/27  02:05:56  craig
  924.  
  925. --- 18,24 -----
  926.    * name of the person performing the modification, the date of modification,
  927.    * and the reason for such modification.
  928.    *
  929. !  * $Id: matrix.c,v 3.0.1.1 89/11/18 14:05:11 craig Exp Locker: craig $
  930.    *
  931.    * $Log:    matrix.c,v $
  932.    * Revision 3.0.1.1  89/11/18  14:05:11  craig
  933. ***************
  934. *** 21,26
  935.    * $Id: matrix.c,v 3.0 89/10/27 02:05:56 craig Exp $
  936.    *
  937.    * $Log:    matrix.c,v $
  938.    * Revision 3.0  89/10/27  02:05:56  craig
  939.    * Baseline for first official release.
  940.    * 
  941.  
  942. --- 21,30 -----
  943.    * $Id: matrix.c,v 3.0.1.1 89/11/18 14:05:11 craig Exp Locker: craig $
  944.    *
  945.    * $Log:    matrix.c,v $
  946. +  * Revision 3.0.1.1  89/11/18  14:05:11  craig
  947. +  * patch1: Renamed rotate(), translate() and scale() to avoid problems
  948. +  * patch1: with external libraries.
  949. +  * 
  950.    * Revision 3.0  89/10/27  02:05:56  craig
  951.    * Baseline for first official release.
  952.    * 
  953. ***************
  954. *** 100,106
  955.   /*
  956.    * Apply translation by (vec) to trans.
  957.    */
  958. ! translate(trans, vec)
  959.   TransInfo *trans;
  960.   Vector *vec;
  961.   {
  962.  
  963. --- 104,110 -----
  964.   /*
  965.    * Apply translation by (vec) to trans.
  966.    */
  967. ! RS_translate(trans, vec)
  968.   TransInfo *trans;
  969.   Vector *vec;
  970.   {
  971. ***************
  972. *** 112,118
  973.   /*
  974.    * Apply rotation about (dir) to matrix.
  975.    */
  976. ! rotate(trans, dir, radians)
  977.   TransInfo *trans;
  978.   double radians;
  979.   Vector *dir;
  980.  
  981. --- 116,122 -----
  982.   /*
  983.    * Apply rotation about (dir) to matrix.
  984.    */
  985. ! RS_rotate(trans, dir, radians)
  986.   TransInfo *trans;
  987.   double radians;
  988.   Vector *dir;
  989. ***************
  990. *** 126,132
  991.   /*
  992.    * Apply scale of (x, y, z) to trans.
  993.    */
  994. ! scale(trans, x, y, z)
  995.   TransInfo *trans;
  996.   double x, y, z;
  997.   {
  998.  
  999. --- 130,136 -----
  1000.   /*
  1001.    * Apply scale of (x, y, z) to trans.
  1002.    */
  1003. ! RS_scale(trans, x, y, z)
  1004.   TransInfo *trans;
  1005.   double x, y, z;
  1006.   {
  1007.  
  1008. Index: src/ray_options.c
  1009. *** src/ray_options.c.old    Mon Nov 20 13:11:22 1989
  1010. --- src/ray_options.c    Mon Nov 20 13:11:23 1989
  1011. ***************
  1012. *** 18,24
  1013.    * name of the person performing the modification, the date of modification,
  1014.    * and the reason for such modification.
  1015.    *
  1016. !  * $Id: ray_options.c,v 3.0 89/10/27 02:06:00 craig Exp $
  1017.    *
  1018.    * $Log:    ray_options.c,v $
  1019.    * Revision 3.0  89/10/27  02:06:00  craig
  1020.  
  1021. --- 18,24 -----
  1022.    * name of the person performing the modification, the date of modification,
  1023.    * and the reason for such modification.
  1024.    *
  1025. !  * $Id: ray_options.c,v 3.0.1.2 89/11/20 13:02:22 craig Exp Locker: craig $
  1026.    *
  1027.    * $Log:    ray_options.c,v $
  1028.    * Revision 3.0.1.2  89/11/20  13:02:22  craig
  1029. ***************
  1030. *** 21,26
  1031.    * $Id: ray_options.c,v 3.0 89/10/27 02:06:00 craig Exp $
  1032.    *
  1033.    * $Log:    ray_options.c,v $
  1034.    * Revision 3.0  89/10/27  02:06:00  craig
  1035.    * Baseline for first official release.
  1036.    * 
  1037.  
  1038. --- 21,32 -----
  1039.    * $Id: ray_options.c,v 3.0.1.2 89/11/20 13:02:22 craig Exp Locker: craig $
  1040.    *
  1041.    * $Log:    ray_options.c,v $
  1042. +  * Revision 3.0.1.2  89/11/20  13:02:22  craig
  1043. +  * patch1: Fixed problems involving overriding values on the command line.
  1044. +  * 
  1045. +  * Revision 3.0.1.1  89/11/16  18:28:38  craig
  1046. +  * patch1: Added -w option.
  1047. +  * 
  1048.    * Revision 3.0  89/10/27  02:06:00  craig
  1049.    * Baseline for first official release.
  1050.    * 
  1051. ***************
  1052. *** 39,44
  1053.   int Quiet;            /* Don't be so verbose flag */
  1054.   char *progname;            /* argv[0] */
  1055.   
  1056.   #ifdef LINDA
  1057.   int Workers;            /* # of workers */
  1058.   #endif
  1059.  
  1060. --- 45,55 -----
  1061.   int Quiet;            /* Don't be so verbose flag */
  1062.   char *progname;            /* argv[0] */
  1063.   
  1064. + /*
  1065. +  * Flags indicating that options were set on the command line.
  1066. +  */
  1067. + int ResolutionSet, ContrastSet, SamplesSet, CutoffSet, AdaptiveSet, JitteredSet;
  1068.   #ifdef LINDA
  1069.   int Workers;            /* # of workers */
  1070.   int VerboseWorker;
  1071. ***************
  1072. *** 41,46
  1073.   
  1074.   #ifdef LINDA
  1075.   int Workers;            /* # of workers */
  1076.   #endif
  1077.   
  1078.   parse_options(argc, argv)
  1079.  
  1080. --- 52,58 -----
  1081.   
  1082.   #ifdef LINDA
  1083.   int Workers;            /* # of workers */
  1084. + int VerboseWorker;
  1085.   #endif
  1086.   
  1087.   parse_options(argc, argv)
  1088. ***************
  1089. *** 67,72
  1090.                   RedContrast = atof(argv[1]);
  1091.                   GreenContrast = atof(argv[2]);
  1092.                   BlueContrast = atof(argv[3]);
  1093.                   argv += 3;
  1094.                   argc -= 3;
  1095.                   break;
  1096.  
  1097. --- 79,85 -----
  1098.                   RedContrast = atof(argv[1]);
  1099.                   GreenContrast = atof(argv[2]);
  1100.                   BlueContrast = atof(argv[3]);
  1101. +                 ContrastSet = TRUE;
  1102.                   argv += 3;
  1103.                   argc -= 3;
  1104.                   break;
  1105. ***************
  1106. *** 83,88
  1107.                   break;
  1108.               case 'j':
  1109.                   Jittered = TRUE;
  1110.                   break;
  1111.               case 'L':
  1112.                   StartLine = atoi(argv[1]);
  1113.  
  1114. --- 96,102 -----
  1115.                   break;
  1116.               case 'j':
  1117.                   Jittered = TRUE;
  1118. +                 JitteredSet = TRUE;
  1119.                   break;
  1120.               case 'L':
  1121.                   StartLine = atoi(argv[1]);
  1122. ***************
  1123. *** 104,109
  1124.                   pixel_div = atoi(argv[1]);
  1125.                   if(pixel_div < 0)
  1126.                       pixel_div = 0;
  1127.                   argv++;
  1128.                   argc--;
  1129.                   break;
  1130.  
  1131. --- 118,124 -----
  1132.                   pixel_div = atoi(argv[1]);
  1133.                   if(pixel_div < 0)
  1134.                       pixel_div = 0;
  1135. +                 AdaptiveSet = TRUE;
  1136.                   argv++;
  1137.                   argc--;
  1138.                   break;
  1139. ***************
  1140. *** 116,121
  1141.               case 'R':
  1142.                   Xres = atoi(argv[1]);
  1143.                   Yres = atoi(argv[2]);
  1144.                   argv += 2;
  1145.                   argc -= 2;
  1146.                   break;
  1147.  
  1148. --- 131,137 -----
  1149.               case 'R':
  1150.                   Xres = atoi(argv[1]);
  1151.                   Yres = atoi(argv[2]);
  1152. +                 ResolutionSet = TRUE;
  1153.                   argv += 2;
  1154.                   argc -= 2;
  1155.                   break;
  1156. ***************
  1157. *** 126,131
  1158.                   JitSamples = atoi(argv[1]);
  1159.                   if (JitSamples < 1)
  1160.                       JitSamples = 1;
  1161.                   argv++; argc--;
  1162.                   break;
  1163.               case 's':
  1164.  
  1165. --- 142,148 -----
  1166.                   JitSamples = atoi(argv[1]);
  1167.                   if (JitSamples < 1)
  1168.                       JitSamples = 1;
  1169. +                 SamplesSet = TRUE;
  1170.                   argv++; argc--;
  1171.                   break;
  1172.               case 's':
  1173. ***************
  1174. *** 133,138
  1175.                   break;
  1176.               case 'T':
  1177.                   TreeCutoff = atof(argv[1]);
  1178.                   argv++; argc--;
  1179.                   break;
  1180.               case 'v':
  1181.  
  1182. --- 150,156 -----
  1183.                   break;
  1184.               case 'T':
  1185.                   TreeCutoff = atof(argv[1]);
  1186. +                 CutoffSet = TRUE;
  1187.                   argv++; argc--;
  1188.                   break;
  1189.               case 'v':
  1190. ***************
  1191. *** 164,169
  1192.                       exit(3);
  1193.                   }
  1194.                   argv++; argc--;
  1195.                   break;
  1196.   #endif
  1197.               default:
  1198.  
  1199. --- 182,190 -----
  1200.                       exit(3);
  1201.                   }
  1202.                   argv++; argc--;
  1203. +                 break;
  1204. +             case 'w':
  1205. +                 VerboseWorker = !VerboseWorker;
  1206.                   break;
  1207.   #endif
  1208.               default:
  1209.  
  1210. Index: doc/rayshade.1
  1211. *** doc/rayshade.1.old    Mon Nov 20 13:10:22 1989
  1212. --- doc/rayshade.1    Mon Nov 20 13:10:24 1989
  1213. ***************
  1214. *** 1,6
  1215.   .\" Manual page for rayshade, 'troff -man' format.
  1216.   .\"
  1217. ! .\" $Id: rayshade.1,v 3.0 89/10/27 16:55:22 craig Exp $
  1218.   .\"
  1219.   .\" $Log:    rayshade.1,v $
  1220.   .\" Revision 3.0  89/10/27  16:55:22  craig
  1221.  
  1222. --- 1,6 -----
  1223.   .\" Manual page for rayshade, 'troff -man' format.
  1224.   .\"
  1225. ! .\" $Id: rayshade.1,v 3.0.1.1 89/11/17 16:57:19 craig Exp Locker: craig $
  1226.   .\"
  1227.   .\" $Log:    rayshade.1,v $
  1228.   .\" Revision 3.0.1.1  89/11/17  16:57:19  craig
  1229. ***************
  1230. *** 3,8
  1231.   .\" $Id: rayshade.1,v 3.0 89/10/27 16:55:22 craig Exp $
  1232.   .\"
  1233.   .\" $Log:    rayshade.1,v $
  1234.   .\" Revision 3.0  89/10/27  16:55:22  craig
  1235.   .\" Baseline for first official release.
  1236.   .\" 
  1237.  
  1238. --- 3,11 -----
  1239.   .\" $Id: rayshade.1,v 3.0.1.1 89/11/17 16:57:19 craig Exp Locker: craig $
  1240.   .\"
  1241.   .\" $Log:    rayshade.1,v $
  1242. + .\" Revision 3.0.1.1  89/11/17  16:57:19  craig
  1243. + .\" patch1: Documented new -w option.
  1244. + .\" 
  1245.   .\" Revision 3.0  89/10/27  16:55:22  craig
  1246.   .\" Baseline for first official release.
  1247.   .\" 
  1248. ***************
  1249. *** 83,88
  1250.   .TP
  1251.   .B \-v
  1252.   Write verbose output to standard output.
  1253.   .TP
  1254.   .B \-W \fIworkers\fR
  1255.   Specify number of worker processes (Linda implementation only).
  1256.  
  1257. --- 86,94 -----
  1258.   .TP
  1259.   .B \-v
  1260.   Write verbose output to standard output.
  1261. + .TP
  1262. + .B \-w
  1263. + Write verbose worker information to the standard error.
  1264.   .TP
  1265.   .B \-W \fIworkers\fR
  1266.   Specify number of worker processes (Linda implementation only).
  1267.  
  1268. Index: src/raytrace.c
  1269. *** src/raytrace.c.old    Mon Nov 20 13:11:27 1989
  1270. --- src/raytrace.c    Mon Nov 20 13:11:28 1989
  1271. ***************
  1272. *** 18,24
  1273.    * name of the person performing the modification, the date of modification,
  1274.    * and the reason for such modification.
  1275.    *
  1276. !  * $Id: raytrace.c,v 3.0 89/10/27 02:06:02 craig Exp $
  1277.    *
  1278.    * $Log:    raytrace.c,v $
  1279.    * Revision 3.0  89/10/27  02:06:02  craig
  1280.  
  1281. --- 18,24 -----
  1282.    * name of the person performing the modification, the date of modification,
  1283.    * and the reason for such modification.
  1284.    *
  1285. !  * $Id: raytrace.c,v 3.0.1.2 89/11/16 20:35:30 craig Exp Locker: craig $
  1286.    *
  1287.    * $Log:    raytrace.c,v $
  1288.    * Revision 3.0.1.2  89/11/16  20:35:30  craig
  1289. ***************
  1290. *** 21,26
  1291.    * $Id: raytrace.c,v 3.0 89/10/27 02:06:02 craig Exp $
  1292.    *
  1293.    * $Log:    raytrace.c,v $
  1294.    * Revision 3.0  89/10/27  02:06:02  craig
  1295.    * Baseline for first official release.
  1296.    * 
  1297.  
  1298. --- 21,33 -----
  1299.    * $Id: raytrace.c,v 3.0.1.2 89/11/16 20:35:30 craig Exp Locker: craig $
  1300.    *
  1301.    * $Log:    raytrace.c,v $
  1302. +  * Revision 3.0.1.2  89/11/16  20:35:30  craig
  1303. +  * patch1: ShadeRay is now called on background rays.
  1304. +  * 
  1305. +  * Revision 3.0.1.1  89/11/16  18:27:38  craig
  1306. +  * patch1: Workers now report statistics to supervisor.
  1307. +  * patch1: Linda syntax is more up-to-date.
  1308. +  * 
  1309.    * Revision 3.0  89/10/27  02:06:02  craig
  1310.    * Baseline for first official release.
  1311.    * 
  1312. ***************
  1313. *** 83,88
  1314.   
  1315.   raytrace()
  1316.   {
  1317.       /*
  1318.        * The top-level ray TopRay always has as its origin the
  1319.        * eye position and as its medium NULL, indicating that it
  1320.  
  1321. --- 90,109 -----
  1322.   
  1323.   raytrace()
  1324.   {
  1325. + #ifdef LINDA
  1326. +     extern unsigned long primtests[], primhits[];
  1327. +     extern double utime, stime;
  1328. +     extern unsigned long EyeRays, ShadowRays, ReflectRays, RefractRays,
  1329. +             CacheWorked, CacheFailed, ShadowHits, SuperSampled,
  1330. +             BVTests, HitRays;
  1331. +     unsigned long eyerays, shadowrays, reflectrays, refractrays,
  1332. +             cacheworked, cachefailed, shadowhits, supersampled,
  1333. +             bvtests, hitrays;
  1334. +     unsigned long primtmp[PRIMTYPES], hittmp[PRIMTYPES];
  1335. +     double utmp, stmp;
  1336. +     int i, j;
  1337. +     extern FILE *fstats;
  1338. + #endif
  1339.       /*
  1340.        * The top-level ray TopRay always has as its origin the
  1341.        * eye position and as its medium NULL, indicating that it
  1342. ***************
  1343. *** 99,104
  1344.           distributed_trace();
  1345.       else
  1346.           adaptive_trace();
  1347.   }
  1348.   
  1349.   /*
  1350.  
  1351. --- 120,153 -----
  1352.           distributed_trace();
  1353.       else
  1354.           adaptive_trace();
  1355. + #ifdef LINDA
  1356. +     /*
  1357. +      * In statistics & workers.
  1358. +      */
  1359. +     for (i = 0; i < Workers; i++) {
  1360. +         in ("statistics", ? eyerays, ? shadowrays, ? reflectrays,
  1361. +             ? refractrays, ? cacheworked, ? cachefailed,
  1362. +             ? shadowhits, ? supersampled, ? bvtests, ? hitrays);
  1363. +         EyeRays += eyerays;
  1364. +         ShadowRays += shadowrays;
  1365. +         ReflectRays += reflectrays;
  1366. +         RefractRays += refractrays;
  1367. +         CacheWorked += cacheworked;
  1368. +         ShadowHits += shadowhits;
  1369. +         SuperSampled += supersampled;
  1370. +         BVTests += bvtests;
  1371. +         HitRays += hitrays;
  1372. +         in ("counts", ? primtmp, ? hittmp);
  1373. +         for (j = 0; j < PRIMTYPES; j++) {
  1374. +             primtests[j] += primtmp[j];
  1375. +             primhits[j] += hittmp[j];
  1376. +         }
  1377. +         in ("timing", ? utmp, ? stmp);
  1378. +         utime += utmp / (double)Workers;
  1379. +         stime += stmp / (double)Workers;
  1380. +         in("worker", ? int);
  1381. +     }
  1382. + #endif
  1383.   }
  1384.   
  1385.   /*
  1386. ***************
  1387. *** 109,115
  1388.       register int y;
  1389.       extern FILE *fstats;
  1390.       extern unsigned long EyeRays;
  1391. !     extern int Verbose;
  1392.   
  1393.       switch (JitSamples) {
  1394.           case 1:
  1395.  
  1396. --- 158,166 -----
  1397.       register int y;
  1398.       extern FILE *fstats;
  1399.       extern unsigned long EyeRays;
  1400. ! #ifdef LINDA
  1401. !     extern int VerboseWorker;
  1402. ! #endif
  1403.   
  1404.       switch (JitSamples) {
  1405.           case 1:
  1406. ***************
  1407. *** 146,151
  1408.        * the output file.
  1409.        */
  1410.       fprintf(fstats,"Using %d workers.\n",Workers);
  1411.       out("scaninfo", StartLine);
  1412.       for (y = 0; y < Workers; y++)
  1413.           eval("worker", dist_worker());
  1414.  
  1415. --- 197,203 -----
  1416.        * the output file.
  1417.        */
  1418.       fprintf(fstats,"Using %d workers.\n",Workers);
  1419. +     fflush(fstats);
  1420.       out("scaninfo", StartLine);
  1421.       for (y = 0; y < Workers; y++)
  1422.           eval("worker", dist_worker());
  1423. ***************
  1424. *** 150,157
  1425.       for (y = 0; y < Workers; y++)
  1426.           eval("worker", dist_worker());
  1427.       for (y = StartLine; y >= 0 ; y--) {
  1428. !         in("result", y, ? out_buf);
  1429. !         if (Verbose)
  1430.               fprintf(stderr,"Supervisor: inned %d\n",y);
  1431.           if (y % 10 == 0)
  1432.               fprintf(fstats, "Finished line %d.\n",y);
  1433.  
  1434. --- 202,209 -----
  1435.       for (y = 0; y < Workers; y++)
  1436.           eval("worker", dist_worker());
  1437.       for (y = StartLine; y >= 0 ; y--) {
  1438. !         in("result", y, ? out_buf:);
  1439. !         if (VerboseWorker)
  1440.               fprintf(stderr,"Supervisor: inned %d\n",y);
  1441.           if (y % 10 == 0)
  1442.               fprintf(fstats, "Finished line %d.\n",y);
  1443. ***************
  1444. *** 155,160
  1445.               fprintf(stderr,"Supervisor: inned %d\n",y);
  1446.           if (y % 10 == 0)
  1447.               fprintf(fstats, "Finished line %d.\n",y);
  1448.           outline(out_buf);
  1449.       }
  1450.       for (y = 0; y < Workers; y++)
  1451.  
  1452. --- 207,213 -----
  1453.               fprintf(stderr,"Supervisor: inned %d\n",y);
  1454.           if (y % 10 == 0)
  1455.               fprintf(fstats, "Finished line %d.\n",y);
  1456. +         fflush(fstats);
  1457.           outline(out_buf);
  1458.       }
  1459.   #else
  1460. ***************
  1461. *** 157,164
  1462.               fprintf(fstats, "Finished line %d.\n",y);
  1463.           outline(out_buf);
  1464.       }
  1465. -     for (y = 0; y < Workers; y++)
  1466. -         in("worker", ? int);
  1467.   #else
  1468.       /*
  1469.        * Trace each scanline, writing results to output file.
  1470.  
  1471. --- 210,215 -----
  1472.           fflush(fstats);
  1473.           outline(out_buf);
  1474.       }
  1475.   #else
  1476.       /*
  1477.        * Trace each scanline, writing results to output file.
  1478. ***************
  1479. *** 217,223
  1480.   {
  1481.       register int line;
  1482.       extern unsigned long EyeRays;
  1483. -     extern int maxlevel, Verbose;
  1484.       extern FILE *fstats;
  1485.   
  1486.       /*
  1487.  
  1488. --- 268,273 -----
  1489.   {
  1490.       register int line;
  1491.       extern unsigned long EyeRays;
  1492.       extern FILE *fstats;
  1493.   #ifdef LINDA
  1494.       extern int maxlevel, VerboseWorker;
  1495. ***************
  1496. *** 219,224
  1497.       extern unsigned long EyeRays;
  1498.       extern int maxlevel, Verbose;
  1499.       extern FILE *fstats;
  1500.   
  1501.       /*
  1502.        * In the adaptive supersampling case, Jitter, JitterWeight,
  1503.  
  1504. --- 269,277 -----
  1505.       register int line;
  1506.       extern unsigned long EyeRays;
  1507.       extern FILE *fstats;
  1508. + #ifdef LINDA
  1509. +     extern int maxlevel, VerboseWorker;
  1510. + #endif
  1511.   
  1512.       /*
  1513.        * In the adaptive supersampling case, Jitter, JitterWeight,
  1514. ***************
  1515. *** 269,274
  1516.        * is still working on it.)
  1517.        */
  1518.       fprintf(fstats,"Using %d workers.\n",Workers);
  1519.       out("scaninfo", StartLine+1, StartLine+2);
  1520.       for (line = 0; line < Workers; line++)
  1521.           eval("worker", adapt_worker());
  1522.  
  1523. --- 322,328 -----
  1524.        * is still working on it.)
  1525.        */
  1526.       fprintf(fstats,"Using %d workers.\n",Workers);
  1527. +     fflush(fstats);
  1528.       out("scaninfo", StartLine+1, StartLine+2);
  1529.       for (line = 0; line < Workers; line++)
  1530.           eval("worker", adapt_worker());
  1531. ***************
  1532. *** 281,288
  1533.       for (line = StartLine; line >= 0;) {
  1534.           if (!adapt_job(TRUE))
  1535.               sleep(5);
  1536. !         while (inp("result", line, ? out_buf)) {
  1537. !             if (Verbose)
  1538.                   fprintf(stderr,"Supervisor: inned %d\n",line);
  1539.               if (line % 10 == 0)
  1540.                   fprintf(fstats, "Finished line %d.\n",line);
  1541.  
  1542. --- 335,342 -----
  1543.       for (line = StartLine; line >= 0;) {
  1544.           if (!adapt_job(TRUE))
  1545.               sleep(5);
  1546. !         while (inp("result", line, ? out_buf:)) {
  1547. !             if (VerboseWorker)
  1548.                   fprintf(stderr,"Supervisor: inned %d\n",line);
  1549.               if (line % 10 == 0)
  1550.                   fprintf(fstats, "Finished line %d.\n",line);
  1551. ***************
  1552. *** 286,291
  1553.                   fprintf(stderr,"Supervisor: inned %d\n",line);
  1554.               if (line % 10 == 0)
  1555.                   fprintf(fstats, "Finished line %d.\n",line);
  1556.               outline(out_buf);
  1557.               if (--line < 0)
  1558.                   break;
  1559.  
  1560. --- 340,346 -----
  1561.                   fprintf(stderr,"Supervisor: inned %d\n",line);
  1562.               if (line % 10 == 0)
  1563.                   fprintf(fstats, "Finished line %d.\n",line);
  1564. +             fflush(fstats);
  1565.               outline(out_buf);
  1566.               if (--line < 0)
  1567.                   break;
  1568. ***************
  1569. *** 291,300
  1570.                   break;
  1571.           }
  1572.       }
  1573. -     if (Verbose)
  1574. -         fprintf(stderr,"Finished -- inning workers.\n");
  1575. -     for (line = 0; line < Workers; line++)
  1576. -         in("worker", ? int);
  1577.   #else
  1578.       line = StartLine + 1;
  1579.       trace_line(line, &pixel_buf[line & 01][0]);
  1580.  
  1581. --- 346,351 -----
  1582.                   break;
  1583.           }
  1584.       }
  1585.   #else
  1586.       line = StartLine + 1;
  1587.       trace_line(line, &pixel_buf[line & 01][0]);
  1588. ***************
  1589. *** 465,478
  1590.        * Do the actual ray trace.
  1591.        */
  1592.       dist = TraceRay((Primitive *)NULL, &TopRay, &hitinfo);
  1593. !     if (dist > 0.)
  1594. !         /*
  1595. !          * There was a valid intersection.
  1596. !          */
  1597. !         ShadeRay(&hitinfo, &TopRay, dist, &background, color, 1.0);
  1598. !     else
  1599. !         /* Use background color */
  1600. !         *color = background;
  1601.   }
  1602.   
  1603.   /*
  1604.  
  1605. --- 516,522 -----
  1606.        * Do the actual ray trace.
  1607.        */
  1608.       dist = TraceRay((Primitive *)NULL, &TopRay, &hitinfo);
  1609. !     ShadeRay(&hitinfo, &TopRay, dist, &background, color, 1.0);
  1610.   }
  1611.   
  1612.   /*
  1613. ***************
  1614. *** 514,519
  1615.   #ifdef LINDA
  1616.   dist_worker()
  1617.   {
  1618.       while (dist_job())
  1619.           ;
  1620.       return;
  1621.  
  1622. --- 558,571 -----
  1623.   #ifdef LINDA
  1624.   dist_worker()
  1625.   {
  1626. +     extern unsigned long EyeRays, ShadowRays, ReflectRays, RefractRays;
  1627. +     extern unsigned long CacheWorked, CacheFailed, ShadowHits;
  1628. +     extern unsigned long SuperSampled, BVTests, HitRays;
  1629. +     extern unsigned long primtests[PRIMTYPES], primhits[PRIMTYPES];
  1630. +     extern int VerboseWorker;
  1631. +     extern FILE *fstats;
  1632. +     double user, sys;
  1633.       while (dist_job())
  1634.           ;
  1635.       /*
  1636. ***************
  1637. *** 516,521
  1638.   {
  1639.       while (dist_job())
  1640.           ;
  1641.       return;
  1642.   }
  1643.   
  1644.  
  1645. --- 568,588 -----
  1646.   
  1647.       while (dist_job())
  1648.           ;
  1649. +     /*
  1650. +      * Out statistics.
  1651. +      */
  1652. +     out ("statistics", EyeRays, ShadowRays, ReflectRays, RefractRays,
  1653. +         CacheWorked, CacheFailed, ShadowHits, SuperSampled, BVTests,
  1654. +         HitRays);
  1655. +     /*
  1656. +      * Out ray/primitive intersection counts.
  1657. +      */
  1658. +     out ("counts", primtests, primhits);
  1659. +     /*
  1660. +      * Compute running time.
  1661. +      */
  1662. +     get_cpu_time(&user, &sys);
  1663. +     out ("timing", user, sys);
  1664.       return;
  1665.   }
  1666.   
  1667. ***************
  1668. *** 525,531
  1669.   dist_job()
  1670.   {
  1671.       int y;
  1672. !     extern int Verbose;
  1673.   
  1674.       in("scaninfo", ? y);
  1675.       if (y < 0) {
  1676.  
  1677. --- 592,598 -----
  1678.   dist_job()
  1679.   {
  1680.       int y;
  1681. !     extern int VerboseWorker;
  1682.   
  1683.       in("scaninfo", ? y);
  1684.       if (y < 0) {
  1685. ***************
  1686. *** 532,538
  1687.           out("scaninfo", y);
  1688.           return 0;
  1689.       }
  1690. !     if (Verbose)
  1691.           fprintf(stderr,"Worker: inned %d\n",y);
  1692.       out("scaninfo", y-1);
  1693.       trace_jit_line(y, out_buf);
  1694.  
  1695. --- 599,605 -----
  1696.           out("scaninfo", y);
  1697.           return 0;
  1698.       }
  1699. !     if (VerboseWorker)
  1700.           fprintf(stderr,"Worker: inned %d\n",y);
  1701.       out("scaninfo", y-1);
  1702.       trace_jit_line(y, out_buf);
  1703. ***************
  1704. *** 536,542
  1705.           fprintf(stderr,"Worker: inned %d\n",y);
  1706.       out("scaninfo", y-1);
  1707.       trace_jit_line(y, out_buf);
  1708. !     if (Verbose)
  1709.           fprintf(stderr,"Worker: outing %d\n",y);
  1710.       out("result", y, out_buf : Xres);
  1711.       return 1;
  1712.  
  1713. --- 603,609 -----
  1714.           fprintf(stderr,"Worker: inned %d\n",y);
  1715.       out("scaninfo", y-1);
  1716.       trace_jit_line(y, out_buf);
  1717. !     if (VerboseWorker)
  1718.           fprintf(stderr,"Worker: outing %d\n",y);
  1719.       out("result", y, out_buf : Xres);
  1720.       return 1;
  1721. ***************
  1722. *** 544,549
  1723.   
  1724.   adapt_worker()
  1725.   {
  1726.       while (adapt_job(FALSE))
  1727.           ;
  1728.       return;
  1729.  
  1730. --- 611,623 -----
  1731.   
  1732.   adapt_worker()
  1733.   {
  1734. +     extern unsigned long EyeRays, ShadowRays, ReflectRays, RefractRays;
  1735. +     extern unsigned long CacheWorked, CacheFailed, ShadowHits;
  1736. +     extern unsigned long SuperSampled, BVTests, HitRays;
  1737. +     extern unsigned long primtests[PRIMTYPES], primhits[PRIMTYPES];
  1738. +     double user, sys;
  1739.       while (adapt_job(FALSE))
  1740.           ;
  1741.       /*
  1742. ***************
  1743. *** 546,551
  1744.   {
  1745.       while (adapt_job(FALSE))
  1746.           ;
  1747.       return;
  1748.   }
  1749.   
  1750.  
  1751. --- 620,642 -----
  1752.   
  1753.       while (adapt_job(FALSE))
  1754.           ;
  1755. +     /*
  1756. +      * Out statistics.
  1757. +      */
  1758. +     out ("statistics", EyeRays, ShadowRays, ReflectRays, RefractRays,
  1759. +         CacheWorked, CacheFailed, ShadowHits, SuperSampled, BVTests,
  1760. +         HitRays);
  1761. +     /*
  1762. +      * Out ray/primitive intersection counts.
  1763. +      */
  1764. +     out ("counts", primtests, primhits);
  1765. +     /*
  1766. +      * Compute running time.
  1767. +      */
  1768. +     get_cpu_time(&user, &sys);
  1769. +     out ("timing", user, sys);
  1770.       return;
  1771.   }
  1772.   
  1773. ***************
  1774. *** 553,559
  1775.   int supervisor;
  1776.   {
  1777.       int lastpix, lastscan;
  1778. !     extern int Verbose;
  1779.   
  1780.       in("scaninfo", ? lastpix, ? lastscan);
  1781.       if (lastpix <= 0) {
  1782.  
  1783. --- 644,650 -----
  1784.   int supervisor;
  1785.   {
  1786.       int lastpix, lastscan;
  1787. !     extern int VerboseWorker;
  1788.   
  1789.       in("scaninfo", ? lastpix, ? lastscan);
  1790.       if (lastpix <= 0) {
  1791. ***************
  1792. *** 558,564
  1793.       in("scaninfo", ? lastpix, ? lastscan);
  1794.       if (lastpix <= 0) {
  1795.           out("scaninfo", lastpix, lastscan);
  1796. !         if (Verbose)
  1797.               fprintf(stderr,"Worker:  all finished!\n");
  1798.           return FALSE;
  1799.       }
  1800.  
  1801. --- 649,655 -----
  1802.       in("scaninfo", ? lastpix, ? lastscan);
  1803.       if (lastpix <= 0) {
  1804.           out("scaninfo", lastpix, lastscan);
  1805. !         if (VerboseWorker)
  1806.               fprintf(stderr,"Worker:  all finished!\n");
  1807.           return FALSE;
  1808.       }
  1809. ***************
  1810. *** 563,570
  1811.           return FALSE;
  1812.       }
  1813.   
  1814. !     if (rdp("scanline", lastpix -1, ? pixel_buf[0]) &&
  1815. !         inp("scanline", lastpix, ? pixel_buf[1])) {
  1816.           lastpix--;
  1817.           out("scaninfo", lastpix, lastscan);
  1818.           if (Verbose)
  1819.  
  1820. --- 654,661 -----
  1821.           return FALSE;
  1822.       }
  1823.   
  1824. !     if (rdp("scanline", lastpix -1, ? pixel_buf[0]:) &&
  1825. !         inp("scanline", lastpix, ? pixel_buf[1]:)) {
  1826.           lastpix--;
  1827.           out("scaninfo", lastpix, lastscan);
  1828.           if (VerboseWorker)
  1829. ***************
  1830. *** 567,573
  1831.           inp("scanline", lastpix, ? pixel_buf[1])) {
  1832.           lastpix--;
  1833.           out("scaninfo", lastpix, lastscan);
  1834. !         if (Verbose)
  1835.               fprintf(stderr,"%s: doing pixline %d\n",
  1836.                   supervisor ? "Supervisor" : "Worker",
  1837.                       lastpix);
  1838.  
  1839. --- 658,664 -----
  1840.           inp("scanline", lastpix, ? pixel_buf[1]:)) {
  1841.           lastpix--;
  1842.           out("scaninfo", lastpix, lastscan);
  1843. !         if (VerboseWorker)
  1844.               fprintf(stderr,"%s: doing pixline %d\n",
  1845.                   supervisor ? "Supervisor" : "Worker",
  1846.                       lastpix);
  1847. ***************
  1848. *** 581,587
  1849.            * a long, long time, causing tuple-space to get
  1850.            * jammed with finished pixlines, and...
  1851.            */
  1852. !         if (Verbose)
  1853.               fprintf(stderr,"Supervisor: nothing to do...\n");
  1854.           out ("scaninfo", lastpix, lastscan);
  1855.           return FALSE;
  1856.  
  1857. --- 672,678 -----
  1858.            * a long, long time, causing tuple-space to get
  1859.            * jammed with finished pixlines, and...
  1860.            */
  1861. !         if (VerboseWorker)
  1862.               fprintf(stderr,"Supervisor: nothing to do...\n");
  1863.           out ("scaninfo", lastpix, lastscan);
  1864.           return FALSE;
  1865. ***************
  1866. *** 588,594
  1867.       } else if (lastscan > 0) {
  1868.           lastscan--;
  1869.           out("scaninfo", lastpix, lastscan);
  1870. !         if (Verbose)
  1871.               fprintf(stderr,"Worker: doing scan %d\n",
  1872.                       lastscan);
  1873.           trace_line(lastscan, pixel_buf[0]);
  1874.  
  1875. --- 679,685 -----
  1876.       } else if (lastscan > 0) {
  1877.           lastscan--;
  1878.           out("scaninfo", lastpix, lastscan);
  1879. !         if (VerboseWorker)
  1880.               fprintf(stderr,"Worker: doing scan %d\n",
  1881.                       lastscan);
  1882.           trace_line(lastscan, pixel_buf[0]);
  1883. ***************
  1884. *** 597,603
  1885.           /*
  1886.            * Nothing to do until somebody finishes a scanline.
  1887.            */
  1888. !         if (Verbose) {
  1889.               fprintf(stderr,"Worker idle... ");
  1890.               fprintf(stderr,"pix = %d, scan = %d\n",
  1891.                       lastpix, lastscan);
  1892.  
  1893. --- 688,694 -----
  1894.           /*
  1895.            * Nothing to do until somebody finishes a scanline.
  1896.            */
  1897. !         if (VerboseWorker) {
  1898.               fprintf(stderr,"Worker idle... ");
  1899.               fprintf(stderr,"pix = %d, scan = %d\n",
  1900.                       lastpix, lastscan);
  1901.  
  1902. Index: src/shade.c
  1903. *** src/shade.c.old    Mon Nov 20 13:11:33 1989
  1904. --- src/shade.c    Mon Nov 20 13:11:34 1989
  1905. ***************
  1906. *** 18,24
  1907.    * name of the person performing the modification, the date of modification,
  1908.    * and the reason for such modification.
  1909.    *
  1910. !  * $Id: shade.c,v 3.0 89/10/27 02:06:03 craig Exp $
  1911.    *
  1912.    * $Log:    shade.c,v $
  1913.    * Revision 3.0  89/10/27  02:06:03  craig
  1914.  
  1915. --- 18,24 -----
  1916.    * name of the person performing the modification, the date of modification,
  1917.    * and the reason for such modification.
  1918.    *
  1919. !  * $Id: shade.c,v 3.0.1.1 89/11/16 20:34:42 craig Exp Locker: craig $
  1920.    *
  1921.    * $Log:    shade.c,v $
  1922.    * Revision 3.0.1.1  89/11/16  20:34:42  craig
  1923. ***************
  1924. *** 21,26
  1925.    * $Id: shade.c,v 3.0 89/10/27 02:06:03 craig Exp $
  1926.    *
  1927.    * $Log:    shade.c,v $
  1928.    * Revision 3.0  89/10/27  02:06:03  craig
  1929.    * Baseline for first official release.
  1930.    * 
  1931.  
  1932. --- 21,29 -----
  1933.    * $Id: shade.c,v 3.0.1.1 89/11/16 20:34:42 craig Exp Locker: craig $
  1934.    *
  1935.    * $Log:    shade.c,v $
  1936. +  * Revision 3.0.1.1  89/11/16  20:34:42  craig
  1937. +  * patch1: Atmospheric effects are now applied to background rays.
  1938. +  * 
  1939.    * Revision 3.0  89/10/27  02:06:03  craig
  1940.    * Baseline for first official release.
  1941.    * 
  1942. ***************
  1943. *** 30,35
  1944.   #include "constants.h"
  1945.   #include "typedefs.h"
  1946.   #include "funcdefs.h"
  1947.   
  1948.   int    level, maxlevel;    /* Current tree depth, max depth */
  1949.   double    DefIndex = 1.0;        /* Default index of refraction. */
  1950.  
  1951. --- 33,39 -----
  1952.   #include "constants.h"
  1953.   #include "typedefs.h"
  1954.   #include "funcdefs.h"
  1955. + #include "atmosphere.h"
  1956.   
  1957.   int    level, maxlevel;    /* Current tree depth, max depth */
  1958.   double    DefIndex = 1.0;        /* Default index of refraction. */
  1959. ***************
  1960. *** 47,52
  1961.   double contrib;            /* Contribution of this ray to final color */
  1962.   {
  1963.       Vector hit;
  1964.       extern unsigned long HitRays;
  1965.       extern Fog *GlobalFog;
  1966.       extern Mist *GlobalMist;
  1967.  
  1968. --- 51,57 -----
  1969.   double contrib;            /* Contribution of this ray to final color */
  1970.   {
  1971.       Vector hit;
  1972. +     double realdist;
  1973.       extern unsigned long HitRays;
  1974.       extern Fog *GlobalFog;
  1975.       extern Mist *GlobalMist;
  1976. ***************
  1977. *** 51,60
  1978.       extern Fog *GlobalFog;
  1979.       extern Mist *GlobalMist;
  1980.   
  1981. !     /*
  1982. !      * If we got here, then a ray hit something, so...
  1983. !      */
  1984. !     HitRays++;
  1985.   
  1986.       (void)normalize(&hitinfo->norm);
  1987.       /*
  1988.  
  1989. --- 56,75 -----
  1990.       extern Fog *GlobalFog;
  1991.       extern Mist *GlobalMist;
  1992.   
  1993. !     if (dist <= 0.) {
  1994. !         /*
  1995. !          * No valid intersection.  Set distance for atmospheric
  1996. !          * effects and set color of ray to background.
  1997. !          */
  1998. !         realdist = FAR_AWAY;
  1999. !         *color = *back;
  2000. !         addscaledvec(ray->pos, realdist, ray->dir, &hit);
  2001. !     } else {
  2002. !         realdist = dist;
  2003. !         /*
  2004. !          * If we got here, then a ray hit something, so...
  2005. !          */
  2006. !         HitRays++;
  2007.   
  2008.           (void)normalize(&hitinfo->norm);
  2009.           /*
  2010. ***************
  2011. *** 56,71
  2012.        */
  2013.       HitRays++;
  2014.   
  2015. !     (void)normalize(&hitinfo->norm);
  2016. !     /*
  2017. !       * "hit" is the location of intersection in world space.
  2018. !      * hitinfo->pos is the intersection point in object space.
  2019. !      */
  2020. !     addscaledvec(ray->pos, dist, ray->dir, &hit);
  2021. !     /*
  2022. !      * Calculate ray color.
  2023. !      */
  2024. !     shade(&hit, ray, &hitinfo->norm, hitinfo->prim, &hitinfo->surf,
  2025.               back, color, contrib);
  2026.       /*
  2027.        * If fog or mist is present, modify computed color.
  2028.  
  2029. --- 71,86 -----
  2030.            */
  2031.           HitRays++;
  2032.   
  2033. !         (void)normalize(&hitinfo->norm);
  2034. !         /*
  2035. !           * "hit" is the location of intersection in world space.
  2036. !          * hitinfo->pos is the intersection point in object space.
  2037. !          */
  2038. !         addscaledvec(ray->pos, dist, ray->dir, &hit);
  2039. !         /*
  2040. !          * Calculate ray color.
  2041. !          */
  2042. !         shade(&hit, ray, &hitinfo->norm, hitinfo->prim, &hitinfo->surf,
  2043.               back, color, contrib);
  2044.       }
  2045.       /*
  2046. ***************
  2047. *** 67,72
  2048.        */
  2049.       shade(&hit, ray, &hitinfo->norm, hitinfo->prim, &hitinfo->surf,
  2050.               back, color, contrib);
  2051.       /*
  2052.        * If fog or mist is present, modify computed color.
  2053.        */
  2054.  
  2055. --- 82,88 -----
  2056.            */
  2057.           shade(&hit, ray, &hitinfo->norm, hitinfo->prim, &hitinfo->surf,
  2058.               back, color, contrib);
  2059. +     }
  2060.       /*
  2061.        * If fog or mist is present, modify computed color.
  2062.        */
  2063. ***************
  2064. *** 71,77
  2065.        * If fog or mist is present, modify computed color.
  2066.        */
  2067.       if (GlobalFog)
  2068. !         ComputeFog(GlobalFog, dist, color);
  2069.       if (GlobalMist)
  2070.           ComputeMist(GlobalMist, &ray->pos, &hit, dist, color);
  2071.   }
  2072.  
  2073. --- 87,93 -----
  2074.        * If fog or mist is present, modify computed color.
  2075.        */
  2076.       if (GlobalFog)
  2077. !         ComputeFog(GlobalFog, realdist, color);
  2078.       if (GlobalMist)
  2079.           ComputeMist(GlobalMist, &ray->pos, &hit, realdist, color);
  2080.   }
  2081. ***************
  2082. *** 73,79
  2083.       if (GlobalFog)
  2084.           ComputeFog(GlobalFog, dist, color);
  2085.       if (GlobalMist)
  2086. !         ComputeMist(GlobalMist, &ray->pos, &hit, dist, color);
  2087.   }
  2088.   
  2089.   shade(pos, ray, nrm, prim, surf, back, color, contrib)
  2090.  
  2091. --- 89,95 -----
  2092.       if (GlobalFog)
  2093.           ComputeFog(GlobalFog, realdist, color);
  2094.       if (GlobalMist)
  2095. !         ComputeMist(GlobalMist, &ray->pos, &hit, realdist, color);
  2096.   }
  2097.   
  2098.   shade(pos, ray, nrm, prim, surf, back, color, contrib)
  2099. ***************
  2100. *** 136,147
  2101.           NewRay.media = ray->media;    /* Medium == old medium */
  2102.           ReflectRays++;
  2103.           dist = TraceRay(prim, &NewRay, &hitinfo);
  2104. !         if (dist > EPSILON) {
  2105. !             ShadeRay(&hitinfo, &NewRay, dist, back, &newcol,
  2106. !                     contrib*surf->refl);
  2107. !             AddScaledColor(*color, surf->refl, newcol, color);
  2108. !         } else
  2109. !             AddScaledColor(*color, surf->refl, *back, color);
  2110.           level--;
  2111.       }
  2112.       /*
  2113.  
  2114. --- 152,160 -----
  2115.           NewRay.media = ray->media;    /* Medium == old medium */
  2116.           ReflectRays++;
  2117.           dist = TraceRay(prim, &NewRay, &hitinfo);
  2118. !         ShadeRay(&hitinfo, &NewRay, dist, back, &newcol,
  2119. !                 contrib*surf->refl);
  2120. !         AddScaledColor(*color, surf->refl, newcol, color);
  2121.           level--;
  2122.       }
  2123.       /*
  2124. ***************
  2125. *** 185,192
  2126.           level++;
  2127.           RefractRays++;
  2128.           dist = TraceRay((Primitive *)NULL, &NewRay, &hitinfo);
  2129. !         if (dist > EPSILON) {
  2130. !             ShadeRay(&hitinfo, &NewRay, dist, back, &newcol,
  2131.                   contrib * surf->transp);
  2132.               AddScaledColor(*color, surf->transp, newcol, color);
  2133.           } else
  2134.  
  2135. --- 198,204 -----
  2136.           level++;
  2137.           RefractRays++;
  2138.           dist = TraceRay((Primitive *)NULL, &NewRay, &hitinfo);
  2139. !         ShadeRay(&hitinfo, &NewRay, dist, back, &newcol,
  2140.                   contrib * surf->transp);
  2141.           AddScaledColor(*color, surf->transp, newcol, color);
  2142.           if (entering)
  2143. ***************
  2144. *** 188,196
  2145.           if (dist > EPSILON) {
  2146.               ShadeRay(&hitinfo, &NewRay, dist, back, &newcol,
  2147.                   contrib * surf->transp);
  2148. !             AddScaledColor(*color, surf->transp, newcol, color);
  2149. !         } else
  2150. !             AddScaledColor(*color, surf->transp, *back, color);
  2151.           if (entering)
  2152.               free((char *)NewRay.media);
  2153.           level--;
  2154.  
  2155. --- 200,206 -----
  2156.           dist = TraceRay((Primitive *)NULL, &NewRay, &hitinfo);
  2157.           ShadeRay(&hitinfo, &NewRay, dist, back, &newcol,
  2158.                   contrib * surf->transp);
  2159. !         AddScaledColor(*color, surf->transp, newcol, color);
  2160.           if (entering)
  2161.               free((char *)NewRay.media);
  2162.           level--;
  2163.  
  2164. Index: src/viewing.c
  2165. *** src/viewing.c.old    Mon Nov 20 13:11:42 1989
  2166. --- src/viewing.c    Mon Nov 20 13:11:43 1989
  2167. ***************
  2168. *** 18,24
  2169.    * name of the person performing the modification, the date of modification,
  2170.    * and the reason for such modification.
  2171.    *
  2172. !  * $Id: viewing.c,v 3.0 89/10/27 02:06:08 craig Exp $
  2173.    *
  2174.    * $Log:    viewing.c,v $
  2175.    * Revision 3.0  89/10/27  02:06:08  craig
  2176.  
  2177. --- 18,24 -----
  2178.    * name of the person performing the modification, the date of modification,
  2179.    * and the reason for such modification.
  2180.    *
  2181. !  * $Id: viewing.c,v 3.0.1.1 89/11/16 18:24:30 craig Exp Locker: craig $
  2182.    *
  2183.    * $Log:    viewing.c,v $
  2184.    * Revision 3.0.1.1  89/11/16  18:24:30  craig
  2185. ***************
  2186. *** 21,26
  2187.    * $Id: viewing.c,v 3.0 89/10/27 02:06:08 craig Exp $
  2188.    *
  2189.    * $Log:    viewing.c,v $
  2190.    * Revision 3.0  89/10/27  02:06:08  craig
  2191.    * Baseline for first official release.
  2192.    * 
  2193.  
  2194. --- 21,29 -----
  2195.    * $Id: viewing.c,v 3.0.1.1 89/11/16 18:24:30 craig Exp Locker: craig $
  2196.    *
  2197.    * $Log:    viewing.c,v $
  2198. +  * Revision 3.0.1.1  89/11/16  18:24:30  craig
  2199. +  * patch1: Fixed calculation of dist in Stereo mode.
  2200. +  * 
  2201.    * Revision 3.0  89/10/27  02:06:08  craig
  2202.    * Baseline for first official release.
  2203.    * 
  2204. ***************
  2205. *** 60,66
  2206.           eyep.z += magnitude * scrnx.z;
  2207.           vecsub(lookp, eyep, &firstray);
  2208.           gaze = firstray;
  2209. !         dist = normalize(&gaze);
  2210.           (void)crossp(&scrnx, &gaze, &up);
  2211.           (void)crossp(&scrny, &scrnx, &gaze);
  2212.       }
  2213.  
  2214. --- 63,69 -----
  2215.           eyep.z += magnitude * scrnx.z;
  2216.           vecsub(lookp, eyep, &firstray);
  2217.           gaze = firstray;
  2218. !         dist = 2. * normalize(&gaze);
  2219.           (void)crossp(&scrnx, &gaze, &up);
  2220.           (void)crossp(&scrny, &scrnx, &gaze);
  2221.       }
  2222.  
  2223. Index: src/atmosphere.h
  2224. *** /dev/null    Mon Nov 20 13:14:20 1989
  2225. --- src/atmosphere.h    Thu Nov 16 20:40:54 1989
  2226. ***************
  2227. *** 0 ****
  2228. --- 1,36 ----
  2229. + /*
  2230. +  * Copyright (C) 1989, Craig E. Kolb
  2231. +  *
  2232. +  * This software may be freely copied, modified, and redistributed,
  2233. +  * provided that this copyright notice is preserved on all copies.
  2234. +  * 
  2235. +  * There is no warranty or other guarantee of fitness for this software,
  2236. +  * it is provided solely "as is".  Bug reports or fixes may be sent
  2237. +  * to the author, who may or may not act on them as he desires.
  2238. +  *
  2239. +  * You may not include this software in a program or other software product
  2240. +  * without supplying the source, or without informing the end-user that the 
  2241. +  * source is available for no extra charge.
  2242. +  *
  2243. +  * If you modify this software, you should include a notice giving the
  2244. +  * name of the person performing the modification, the date of modification,
  2245. +  * and the reason for such modification.
  2246. +  *
  2247. +  * $Id: atmosphere.h,v 3.0 89/11/16 20:40:53 craig Exp Locker: craig $
  2248. +  *
  2249. +  * $Log:    atmosphere.h,v $
  2250. +  * Revision 3.0  89/11/16  20:40:53  craig
  2251. +  * Initial version.
  2252. +  * 
  2253. +  */
  2254. + typedef struct {
  2255. +     Color color;        /* Fog color */
  2256. +     double trans;        /* Fog transmissivity */
  2257. + } Fog;
  2258. + typedef struct {
  2259. +     Color color;        /* Mist color */
  2260. +     Color trans;        /* R, G, B transmissivity */
  2261. +     double scale, zero;    /* Height scale, start Z */
  2262. + } Mist;
  2263.  
  2264.  
  2265.