home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume21 / rayshade / patch5 < prev    next >
Encoding:
Text File  |  1990-04-11  |  49.3 KB  |  1,965 lines

  1. System: rayshade version 3.0
  2. Patch #: 5
  3. Priority: HIGH
  4. Subject: Patch #5
  5.  
  6. Description:
  7.  
  8.     Rayshade assumed that a freed pointer could be safely
  9.     dereferenced up until the next call to malloc().  It
  10.     is now assumed that free() is destructive.
  11.  
  12.     Pointers were being freed twice in several places.
  13.  
  14.     The test for edge-on intersection with planar primitives
  15.     was not particularly robust.  In particular, near edge-on
  16.     intersections with textured planes caused TLOSS errors under
  17.     certain circumstances.
  18.  
  19.     HUGE was too huge for some machines.  FAR_AWAY is used instead.
  20.  
  21.     The matrices to transform cylinders and cones to their canonical
  22.     forms were applied as if they were user-specified.  This caused
  23.     cylinders and cones to be always textured in "canonical"
  24.     space.  The matrices are now stored and applied locally to the
  25.     cylinder/cone routines.
  26.  
  27.     Simplified cone and cylinder intersection routines by making
  28.     canonical primitives truly canonical.
  29.  
  30.     It was possible to divide by zero when rendering cones.
  31.  
  32.     The validity of colormap entires was not checked.
  33.  
  34.     times() is (void) on some SYSV systems and (long) on others.
  35.     Removed checking of its return value altogether.
  36.  
  37.     Various pieces of lint removed throughout the code.
  38.  
  39.     Replaced outdated code in primitive tutorial.
  40.  
  41.  
  42. Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your top-level
  43.     rayshade source directory.  Outside of rn, say
  44.     "cd DIR; patch -p -N <thisarticle".
  45.     If you don't have the patch program, apply the following by hand,
  46.     or get patch (version 2.0, latest patchlevel).
  47.  
  48.     After patching:
  49.         make depend
  50.         make
  51.         make install
  52.  
  53.     If patch indicates that patchlevel is the wrong version, you may need
  54.     to apply one or more previous patches, or the patch may already
  55.     have been applied.  See the patchlevel.h file to find out what has or
  56.     has not been applied.  In any event, don't continue with the patch.
  57.  
  58.     If you are missing previous patches they can be obtained via anonymous
  59.     ftp from weedeater.math.yale.edu (130.132.23.17).
  60.  
  61.     Craig Kolb
  62.     kolb@yale.edu
  63.  
  64.  
  65. Index: src/patchlevel.h
  66. Prereq: 4
  67. 1c1
  68. < #define PATCHLEVEL 4
  69. ---
  70. > #define PATCHLEVEL 5
  71.  
  72. Index: Changes
  73. *** Changes.old    Tue Apr 10 16:50:08 1990
  74. --- Changes    Tue Apr 10 16:50:09 1990
  75. ***************
  76. *** 1,3 ****
  77. --- 1,15 ----
  78. + Patch #5:
  79. + ---------
  80. + Changes to reflect that free() may be destructive.
  81. + Fixed several other free()-related bugs.
  82. + Cylinders and cones were always textured in canonical cylinder/cone space.
  83. + Fixed divide by zero bug in cylinder code.
  84. + Optimizations in cylinder and cone code.
  85. + HUGE in bounds.c was too huge for some machines.  Replaced by FAR_AWAY.
  86. + Improved handling of near edge-on intersection with triangles and planes.
  87. + Added check for invalid colormap entries.
  88. + Lint removal.
  89.   Patch #4:
  90.   ---------
  91.   Added gloss texture.
  92.  
  93. Index: src/bounds.c
  94. *** src/bounds.c.old    Tue Apr 10 16:47:54 1990
  95. --- src/bounds.c    Tue Apr 10 16:47:54 1990
  96. ***************
  97. *** 18,26 ****
  98.    * name of the person performing the modification, the date of modification,
  99.    * and the reason for such modification.
  100.    *
  101. !  * $Id: bounds.c,v 3.0 89/10/27 02:05:46 craig Exp $
  102.    *
  103.    * $Log:    bounds.c,v $
  104.    * Revision 3.0  89/10/27  02:05:46  craig
  105.    * Baseline for first official release.
  106.    * 
  107. --- 18,29 ----
  108.    * name of the person performing the modification, the date of modification,
  109.    * and the reason for such modification.
  110.    *
  111. !  * $Id: bounds.c,v 3.0.1.1 90/04/04 19:03:47 craig Exp $
  112.    *
  113.    * $Log:    bounds.c,v $
  114. +  * Revision 3.0.1.1  90/04/04  19:03:47  craig
  115. +  * patch5: Substituded FAR_AWAY for HUGE in bounds initialization routines.
  116. +  * 
  117.    * Revision 3.0  89/10/27  02:05:46  craig
  118.    * Baseline for first official release.
  119.    * 
  120. ***************
  121. *** 31,40 ****
  122.   #include "typedefs.h"
  123.   #include "funcdefs.h"
  124.   
  125. - #ifndef HUGE
  126. - #define HUGE    1.701411e38
  127. - #endif
  128.   /*
  129.    * Ray-bounding box intersection test.
  130.    */
  131. --- 34,39 ----
  132. ***************
  133. *** 188,195 ****
  134.   init_bounds(bounds)
  135.   double bounds[2][3];
  136.   {
  137. !     bounds[LOW][X] = bounds[LOW][Y] = bounds[LOW][Z] = HUGE;
  138. !     bounds[HIGH][X] = bounds[HIGH][Y] = bounds[HIGH][Z] = -HUGE;
  139.   }
  140.   
  141.   /*
  142. --- 187,194 ----
  143.   init_bounds(bounds)
  144.   double bounds[2][3];
  145.   {
  146. !     bounds[LOW][X] = bounds[LOW][Y] = bounds[LOW][Z] = FAR_AWAY;
  147. !     bounds[HIGH][X] = bounds[HIGH][Y] = bounds[HIGH][Z] = -FAR_AWAY;
  148.   }
  149.   
  150.   /*
  151.  
  152. Index: src/cone.c
  153. *** src/cone.c.old    Tue Apr 10 16:47:59 1990
  154. --- src/cone.c    Tue Apr 10 16:48:00 1990
  155. ***************
  156. *** 18,26 ****
  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.1.3 90/02/12 13:20:58 craig Exp $
  161.    *
  162.    * $Log:    cone.c,v $
  163.    * Revision 3.0.1.3  90/02/12  13:20:58  craig
  164.    * patch4: Changes to avoid rotation about null axis.
  165.    * 
  166. --- 18,33 ----
  167.    * name of the person performing the modification, the date of modification,
  168.    * and the reason for such modification.
  169.    *
  170. !  * $Id: cone.c,v 3.0.1.5 90/04/09 14:30:08 craig Exp $
  171.    *
  172.    * $Log:    cone.c,v $
  173. +  * Revision 3.0.1.5  90/04/09  14:30:08  craig
  174. +  * patch5: Transformation information now stored locally.
  175. +  * patch5: Canonical cone now truly canonical.
  176. +  * 
  177. +  * Revision 3.0.1.4  90/04/04  14:51:25  craig
  178. +  * patch5: Fixed divide by zero problem in intcone().
  179. +  * 
  180.    * Revision 3.0.1.3  90/02/12  13:20:58  craig
  181.    * patch4: Changes to avoid rotation about null axis.
  182.    * 
  183. ***************
  184. *** 41,56 ****
  185.   #include "constants.h"
  186.   
  187.   Object *
  188. ! makcone(surf, cent, ax, br, ar, trans)
  189.   char *surf;
  190.   Vector *cent, *ax;
  191.   double br, ar;
  192. - TransInfo *trans;
  193.   {
  194.       Cone *cone;
  195.       Primitive *prim;
  196.       Object *newobj;
  197. !     double len, dtmp;
  198.       Vector axis, base, tmp;
  199.   
  200.       prim = mallocprim();
  201. --- 48,62 ----
  202.   #include "constants.h"
  203.   
  204.   Object *
  205. ! makcone(surf, cent, ax, br, ar)
  206.   char *surf;
  207.   Vector *cent, *ax;
  208.   double br, ar;
  209.   {
  210.       Cone *cone;
  211.       Primitive *prim;
  212.       Object *newobj;
  213. !     double tantheta, lprime, tlen, len, dtmp;
  214.       Vector axis, base, tmp;
  215.   
  216.       prim = mallocprim();
  217. ***************
  218. *** 61,78 ****
  219.       prim->objpnt.p_cone = cone;
  220.   
  221.       /*
  222. !      * Cones are defined by a basepoint, an apex point, and
  223. !      * base and apex radii.  The cone is stored as
  224. !      * the origin of the cone, the change in radius per
  225. !      * unit distance from the origin of the cone, the maximum z-value
  226. !      * of the cone, and "start_pos",
  227. !      * the distance along the axis from the cone origin where
  228. !      * the first endcap appears (where the passed "basepoint"
  229. !      * appears).
  230.        *
  231. !      * The intcone() routine intersects a ray with a cone aligned
  232. !      * along the Z axis.  Thus, we must define a transformation
  233. !      * matrix which will transform an axis-aligned cone to the desired.
  234.        */
  235.   
  236.       /*
  237. --- 67,78 ----
  238.       prim->objpnt.p_cone = cone;
  239.   
  240.       /*
  241. !      * To render a cone, we transform the desired cone into
  242. !      * a canonical, Z-axis aligned, unit length, unit radius
  243. !      * at the apex cone.
  244.        *
  245. !      * Here, we construct the transformation matrix to map
  246. !      * from cone<-->world space.
  247.        */
  248.   
  249.       /*
  250. ***************
  251. *** 93,99 ****
  252.            * If the base and apex radii are equal, then we
  253.            * can treat the cone as a cylinder.
  254.            */
  255. !         return makcyl(surf, cent, ax, br, trans);
  256.       }
  257.       /*
  258.        * Find the axis and axis length.
  259. --- 93,99 ----
  260.            * If the base and apex radii are equal, then we
  261.            * can treat the cone as a cylinder.
  262.            */
  263. !         return makcyl(surf, cent, ax, br);
  264.       }
  265.       /*
  266.        * Find the axis and axis length.
  267. ***************
  268. *** 107,135 ****
  269.           free((char *)newobj);
  270.           return (Object *)0;
  271.       }
  272. -     cone->apex_rad = ar;
  273.       /*
  274.        * "tantheta" is the change in radius per unit length along
  275.        * the cone axis.
  276.        */
  277. !     cone->tantheta = (ar - br) / len;
  278.       /*
  279. !      * Start pos defines the point along the axis where the first
  280.        * endcap should be placed.
  281.        */
  282. !     cone->start_pos = br / cone->tantheta;
  283.       /*
  284.        * Find the true base (origin) of the cone.
  285.        */
  286. !     scalar_prod(-cone->start_pos, axis, &base);
  287.       vecadd(base, *cent, &base);
  288.       /*
  289. !      * The apex endcap is placed cone->len units from the cone
  290. !      * origin.
  291.        */
  292. !     cone->end_pos = cone->start_pos + len;
  293.       /*
  294. !      * Calculate rotation matrix to map from world space to cone space.
  295.        */
  296.       if (abs(axis.z) == 1.) {
  297.           tmp.x = 1;
  298. --- 107,138 ----
  299.           free((char *)newobj);
  300.           return (Object *)0;
  301.       }
  302.       /*
  303.        * "tantheta" is the change in radius per unit length along
  304.        * the cone axis.
  305.        */
  306. !     tantheta = (ar - br) / len;
  307.       /*
  308. !      * lprime defines the distance along the axis where the first
  309.        * endcap should be placed.
  310.        */
  311. !     lprime = br / tantheta;
  312.       /*
  313.        * Find the true base (origin) of the cone.
  314.        */
  315. !     scalar_prod(-lprime, axis, &base);
  316.       vecadd(base, *cent, &base);
  317.       /*
  318. !      * tlen is the total length of the cone.
  319. !      */
  320. !     tlen = lprime + len;
  321. !     /*
  322. !      * start_dist is the distance from the origin of the canonical
  323. !      * cone at which the first endcap appears.
  324.        */
  325. !     cone->start_dist = lprime / tlen;
  326.       /*
  327. !      * Calculate transformation to map from cone space to world space.
  328.        */
  329.       if (abs(axis.z) == 1.) {
  330.           tmp.x = 1;
  331. ***************
  332. *** 139,147 ****
  333.           tmp.y = -axis.x;
  334.           tmp.z = 0.;
  335.       }
  336. !     RS_rotate(trans, &tmp, acos(axis.z));
  337. !     RS_translate(trans, &base);
  338. !     cone->tantheta *= cone->tantheta;
  339.   
  340.       return newobj;
  341.   }
  342. --- 142,152 ----
  343.           tmp.y = -axis.x;
  344.           tmp.z = 0.;
  345.       }
  346. !     init_trans(&cone->trans.obj2world);
  347. !     RS_scale(&cone->trans.obj2world, ar, ar, tlen);
  348. !     RS_rotate(&cone->trans.obj2world, &tmp, acos(axis.z));
  349. !     RS_translate(&cone->trans.obj2world, &base);
  350. !     invert_trans(&cone->trans.world2obj, &cone->trans.obj2world);
  351.   
  352.       return newobj;
  353.   }
  354. ***************
  355. *** 156,162 ****
  356.   Primitive       *obj;
  357.   {
  358.       double t1, t2, a, b, c, disc, zpos, et1, et2;
  359. !     double x, y;
  360.       extern unsigned long primtests[];
  361.       Cone *cone;
  362.   
  363. --- 161,170 ----
  364.   Primitive       *obj;
  365.   {
  366.       double t1, t2, a, b, c, disc, zpos, et1, et2;
  367. !     double x, y, distfact;
  368. !     Ray newray;
  369. !     Vector nray, npos;
  370. !     extern double TransformRay();
  371.       extern unsigned long primtests[];
  372.       Cone *cone;
  373.   
  374. ***************
  375. *** 164,183 ****
  376.       cone = obj->objpnt.p_cone;
  377.   
  378.       /*
  379. !      * Recall that 'tantheta' is really tantheta^2.
  380.        */
  381. !     a = ray->x * ray->x + ray->y * ray->y - ray->z*ray->z*cone->tantheta;
  382. !     b = ray->x * pos->x + ray->y * pos->y - cone->tantheta*ray->z*pos->z;
  383. !     c = pos->x*pos->x + pos->y*pos->y - cone->tantheta*pos->z*pos->z;
  384.   
  385.       if (equal(a, 0.)) {
  386.           /*
  387.            * Only one intersection point...
  388.            */
  389.           t1 = -c / b;
  390. !         zpos = pos->z + t1 * ray->z;
  391. !         if (t1 < EPSILON || zpos < cone->start_pos ||
  392. !             zpos > cone->end_pos)
  393.               t1 = FAR_AWAY;
  394.           t2 = FAR_AWAY;
  395.       } else {
  396. --- 172,196 ----
  397.       cone = obj->objpnt.p_cone;
  398.   
  399.       /*
  400. !      * Transform ray from world to cone space.
  401.        */
  402. !     newray.pos = *pos;
  403. !     newray.dir = *ray;
  404. !     distfact = TransformRay(&newray, &cone->trans.world2obj);
  405. !     nray = newray.dir;
  406. !     npos = newray.pos;
  407.   
  408. +     a = nray.x * nray.x + nray.y * nray.y - nray.z*nray.z;
  409. +     b = nray.x * npos.x + nray.y * npos.y - nray.z*npos.z;
  410. +     c = npos.x*npos.x + npos.y*npos.y - npos.z*npos.z;
  411.       if (equal(a, 0.)) {
  412.           /*
  413.            * Only one intersection point...
  414.            */
  415.           t1 = -c / b;
  416. !         zpos = npos.z + t1 * nray.z;
  417. !         if (t1 < EPSILON || zpos < cone->start_dist || zpos > 1.)
  418.               t1 = FAR_AWAY;
  419.           t2 = FAR_AWAY;
  420.       } else {
  421. ***************
  422. *** 190,220 ****
  423.           /*
  424.            * Clip intersection points.
  425.            */
  426. !         zpos = pos->z + t1 * ray->z;
  427. !         if (t1 < EPSILON || zpos < cone->start_pos ||
  428. !             zpos > cone->end_pos)
  429.               t1 = FAR_AWAY;
  430. !         zpos = pos->z + t2 * ray->z;
  431. !         if (t2 < EPSILON || zpos < cone->start_pos ||
  432. !             zpos > cone->end_pos)
  433.               t2 = FAR_AWAY;
  434.       }
  435.       /*
  436.        * Find t for both endcaps.
  437.        */
  438. !     et1 = (cone->start_pos - pos->z) / ray->z;
  439. !     x = pos->x + et1 * ray->x;
  440. !     y = pos->y + et1 * ray->y;
  441. !     if (x*x + y*y > cone->start_pos*cone->start_pos*cone->tantheta)
  442.           et1 = FAR_AWAY;
  443. !     et2 = (cone->end_pos - pos->z) / ray->z;
  444. !     x = pos->x + et2 * ray->x;
  445. !     y = pos->y + et2 * ray->y;
  446. !     if (x*x + y*y > cone->end_pos*cone->end_pos*cone->tantheta)
  447.           et2 = FAR_AWAY;
  448.   
  449.       t1 = min(t1, min(t2, min(et1, et2)));
  450. !     return (t1 == FAR_AWAY ? 0. : t1);
  451.   }
  452.   
  453.   /*
  454. --- 203,237 ----
  455.           /*
  456.            * Clip intersection points.
  457.            */
  458. !         zpos = npos.z + t1 * nray.z;
  459. !         if (t1 < EPSILON || zpos < cone->start_dist || zpos > 1.)
  460.               t1 = FAR_AWAY;
  461. !         zpos = npos.z + t2 * nray.z;
  462. !         if (t2 < EPSILON || zpos < cone->start_dist || zpos > 1.)
  463.               t2 = FAR_AWAY;
  464.       }
  465. +     if (equal(nray.z, 0.)) {
  466. +         t1 = min(t1, t2);
  467. +         return (t1 == FAR_AWAY ? 0. : t1 / distfact);
  468. +     }
  469.       /*
  470.        * Find t for both endcaps.
  471.        */
  472. !     et1 = (cone->start_dist - npos.z) / nray.z;
  473. !     x = npos.x + et1 * nray.x;
  474. !     y = npos.y + et1 * nray.y;
  475. !     if (x*x + y*y > cone->start_dist*cone->start_dist)
  476.           et1 = FAR_AWAY;
  477. !     et2 = (1. - npos.z) / nray.z;
  478. !     x = npos.x + et2 * nray.x;
  479. !     y = npos.y + et2 * nray.y;
  480. !     if (x*x + y*y > 1.)
  481.           et2 = FAR_AWAY;
  482.   
  483.       t1 = min(t1, min(t2, min(et1, et2)));
  484. !     return (t1 == FAR_AWAY ? 0. : t1 / distfact);
  485.   }
  486.   
  487.   /*
  488. ***************
  489. *** 225,237 ****
  490.   Primitive *obj;
  491.   {
  492.       Cone *cone;
  493.   
  494.       cone = obj->objpnt.p_cone;
  495.   
  496. !     if (equal(pos->z, cone->start_pos)) {
  497.           nrm->x = nrm->y = 0.;
  498.           nrm->z = -1.;
  499. !     } else if (equal(pos->z, cone->end_pos)) {
  500.           nrm->x = nrm->y = 0.;
  501.           nrm->z = 1.;
  502.       } else {
  503. --- 242,261 ----
  504.   Primitive *obj;
  505.   {
  506.       Cone *cone;
  507. +     Vector npos;
  508.   
  509.       cone = obj->objpnt.p_cone;
  510.   
  511. !     /*
  512. !      * Transform intersection point to cone space.
  513. !      */
  514. !     npos = *pos;
  515. !     transform_point(&npos, &cone->trans.world2obj);
  516. !     
  517. !     if (equal(npos.z, cone->start_dist)) {
  518.           nrm->x = nrm->y = 0.;
  519.           nrm->z = -1.;
  520. !     } else if (equal(npos.z, 1)) {
  521.           nrm->x = nrm->y = 0.;
  522.           nrm->z = 1.;
  523.       } else {
  524. ***************
  525. *** 239,248 ****
  526.            * The following is equal to
  527.            * (pos X (0, 0, 1)) X pos
  528.            */
  529. !         nrm->x = pos->x * pos->z;
  530. !         nrm->y = pos->y * pos->z;
  531. !         nrm->z = -pos->x * pos->x - pos->y * pos->y;
  532.       }
  533.   }
  534.   
  535.   /*
  536. --- 263,276 ----
  537.            * The following is equal to
  538.            * (pos X (0, 0, 1)) X pos
  539.            */
  540. !         nrm->x = npos.x * npos.z;
  541. !         nrm->y = npos.y * npos.z;
  542. !         nrm->z = -npos.x * npos.x - npos.y * npos.y;
  543.       }
  544. +     /*
  545. +      * Transform normal back to world space.
  546. +      */
  547. +     TransformNormal(nrm, &cone->trans.world2obj);
  548.   }
  549.   
  550.   /*
  551. ***************
  552. *** 256,263 ****
  553.   
  554.       cone = o->objpnt.p_cone;
  555.   
  556. !     bounds[LOW][X] = bounds[LOW][Y] = -cone->apex_rad;
  557. !     bounds[HIGH][X] = bounds[HIGH][Y] = cone->apex_rad;
  558. !     bounds[LOW][Z] = cone->start_pos;
  559. !     bounds[HIGH][Z] = cone->end_pos;
  560.   }
  561. --- 284,295 ----
  562.   
  563.       cone = o->objpnt.p_cone;
  564.   
  565. !     bounds[LOW][X] = bounds[LOW][Y] = -1;
  566. !     bounds[HIGH][X] = bounds[HIGH][Y] = 1;
  567. !     bounds[LOW][Z] = cone->start_dist;
  568. !     bounds[HIGH][Z] = 1;
  569. !     /*
  570. !      * Transform bounding box to world space.
  571. !      */
  572. !     transform_bounds(&cone->trans.obj2world, bounds);
  573.   }
  574.  
  575. Index: src/cylinder.c
  576. *** src/cylinder.c.old    Tue Apr 10 16:48:04 1990
  577. --- src/cylinder.c    Tue Apr 10 16:48:05 1990
  578. ***************
  579. *** 18,26 ****
  580.    * name of the person performing the modification, the date of modification,
  581.    * and the reason for such modification.
  582.    *
  583. !  * $Id: cylinder.c,v 3.0.1.4 90/03/07 22:43:04 craig Exp $
  584.    *
  585.    * $Log:    cylinder.c,v $
  586.    * Revision 3.0.1.4  90/03/07  22:43:04  craig
  587.    * patch4: Fixed typo in previous fix.
  588.    * 
  589. --- 18,30 ----
  590.    * name of the person performing the modification, the date of modification,
  591.    * and the reason for such modification.
  592.    *
  593. !  * $Id: cylinder.c,v 3.0.1.5 90/04/09 14:29:43 craig Exp $
  594.    *
  595.    * $Log:    cylinder.c,v $
  596. +  * Revision 3.0.1.5  90/04/09  14:29:43  craig
  597. +  * patch5: Transformation information now stored locally.
  598. +  * patch5: Canonical cylinder now truly canonical.
  599. +  * 
  600.    * Revision 3.0.1.4  90/03/07  22:43:04  craig
  601.    * patch4: Fixed typo in previous fix.
  602.    * 
  603. ***************
  604. *** 44,54 ****
  605.   #include "constants.h"
  606.   
  607.   Object *
  608. ! makcyl(surf, cent, ax, r, trans)
  609.   char *surf;
  610.   Vector *cent, *ax;
  611.   double r;
  612. - TransInfo *trans;
  613.   {
  614.       Cylinder *cyl;
  615.       Primitive *prim;
  616. --- 48,57 ----
  617.   #include "constants.h"
  618.   
  619.   Object *
  620. ! makcyl(surf, cent, ax, r)
  621.   char *surf;
  622.   Vector *cent, *ax;
  623.   double r;
  624.   {
  625.       Cylinder *cyl;
  626.       Primitive *prim;
  627. ***************
  628. *** 80,89 ****
  629.           return (Object *)0;
  630.       }
  631.   
  632. -     cyl->rad = r*r;
  633. -     cyl->len = len;
  634.       /*
  635. !      * Define matrix to transform from axis-aligned to desired cylinder.
  636.        */
  637.       if (abs(axis.z) == 1.) {
  638.           dir.x = 1.;
  639. --- 83,91 ----
  640.           return (Object *)0;
  641.       }
  642.   
  643.       /*
  644. !      * Define matrix to transform from Z axis aligned unit cylinder
  645. !      * to desired cylinder.
  646.        */
  647.       if (abs(axis.z) == 1.) {
  648.           dir.x = 1.;
  649. ***************
  650. *** 93,101 ****
  651.           dir.y = -axis.x;
  652.           dir.z = 0.;
  653.       }
  654. !     RS_rotate(trans, &dir, acos(axis.z));
  655. !     RS_translate(trans, cent);
  656.       return newobj;
  657.   }
  658.   
  659. --- 95,105 ----
  660.           dir.y = -axis.x;
  661.           dir.z = 0.;
  662.       }
  663. !     init_trans(&cyl->trans.obj2world);
  664. !     RS_scale(&cyl->trans.obj2world, r, r, len);
  665. !     RS_rotate(&cyl->trans.obj2world, &dir, acos(axis.z));
  666. !     RS_translate(&cyl->trans.obj2world, cent);
  667. !     invert_trans(&cyl->trans.world2obj, &cyl->trans.obj2world);
  668.       return newobj;
  669.   }
  670.   
  671. ***************
  672. *** 108,131 ****
  673.   Primitive       *obj;
  674.   {
  675.       double t1, t2, a, b, c, zpos1, zpos2, et1, et2, x, y, disc;
  676.       extern unsigned long primtests[];
  677.       Cylinder *cyl;
  678.   
  679.       primtests[CYL]++;
  680.       cyl = obj->objpnt.p_cylinder;
  681.   
  682. !     a = ray->x * ray->x + ray->y * ray->y;
  683. !     c = pos->x*pos->x + pos->y*pos->y - cyl->rad;
  684.   
  685. !     if (a < EPSILON*EPSILON) {    /* |ray->z| == 1. */
  686.           if(c < EPSILON*EPSILON)    /* Within endcap */
  687.               /* Wrong if origin is inside cylinder. */
  688. !             return min(-pos->z / ray->z,
  689. !                   (cyl->len - pos->z) / ray->z);
  690.           return 0.;
  691.       }
  692.   
  693. !     b = ray->x * pos->x + ray->y * pos->y;
  694.       disc = b*b - a*c;
  695.       if(disc < 0.)
  696.           return 0.;
  697. --- 112,148 ----
  698.   Primitive       *obj;
  699.   {
  700.       double t1, t2, a, b, c, zpos1, zpos2, et1, et2, x, y, disc;
  701. +     double distfact;
  702.       extern unsigned long primtests[];
  703. +     extern double TransformRay();
  704. +     Ray newray;
  705. +     Vector nray, npos;
  706.       Cylinder *cyl;
  707.   
  708.       primtests[CYL]++;
  709.       cyl = obj->objpnt.p_cylinder;
  710.   
  711. !     /*
  712. !      * Transform ray into canonical cylinder space.
  713. !      */
  714. !     newray.dir = *ray;
  715. !     newray.pos = *pos;
  716. !     distfact = TransformRay(&newray, &cyl->trans.world2obj);
  717. !     nray = newray.dir;
  718. !     npos = newray.pos;
  719. !     a = nray.x * nray.x + nray.y * nray.y;
  720. !     c = npos.x*npos.x + npos.y*npos.y - 1;
  721.   
  722. !     if (a < EPSILON*EPSILON) {    /* |nray.z| == 1. */
  723.           if(c < EPSILON*EPSILON)    /* Within endcap */
  724.               /* Wrong if origin is inside cylinder. */
  725. !             return min(-npos.z / nray.z,
  726. !                   (1. - npos.z) / nray.z) / distfact;
  727.           return 0.;
  728.       }
  729.   
  730. !     b = nray.x * npos.x + nray.y * npos.y;
  731.       disc = b*b - a*c;
  732.       if(disc < 0.)
  733.           return 0.;
  734. ***************
  735. *** 134,142 ****
  736.       t2 = (-b - disc) / a;
  737.       if(t1 < EPSILON && t2 < EPSILON)
  738.           return 0.;
  739. !     zpos1 = pos->z + t1 * ray->z;
  740. !     zpos2 = pos->z + t2 * ray->z;
  741. !     if ((zpos1 > cyl->len && zpos2 > cyl->len) ||
  742.           (zpos1 < 0. && zpos2 < 0.))
  743.           return 0.;
  744.       if (t1 < EPSILON)
  745. --- 151,159 ----
  746.       t2 = (-b - disc) / a;
  747.       if(t1 < EPSILON && t2 < EPSILON)
  748.           return 0.;
  749. !     zpos1 = npos.z + t1 * nray.z;
  750. !     zpos2 = npos.z + t2 * nray.z;
  751. !     if ((zpos1 > 1 && zpos2 > 1) ||
  752.           (zpos1 < 0. && zpos2 < 0.))
  753.           return 0.;
  754.       if (t1 < EPSILON)
  755. ***************
  756. *** 143,176 ****
  757.           t1 = FAR_AWAY;
  758.       if (t2 < EPSILON)
  759.           t2 = FAR_AWAY;
  760. -     if (t1 == FAR_AWAY && t2 == FAR_AWAY)
  761. -         return 0.;
  762.       /*
  763.        * Don't bother checking endcaps if both intersection points
  764.        * are on the cylinder.
  765.        */
  766. !     if ((zpos1 > 0. && zpos1 < cyl->len && zpos2 > 0. && zpos2 < cyl->len))
  767. !         return min(t1, t2);
  768.       /*
  769.         * It's possible to get rid of the ray-disc intersection tests
  770.        * (by looking at t1, t2 and zpos1, zpos), but the code gets messy.
  771.        */
  772. !     if (zpos1 < 0. || zpos1 > cyl->len)
  773.           t1 = FAR_AWAY;
  774. !     if (zpos2 < 0. || zpos2 > cyl->len)
  775.           t2 = FAR_AWAY;
  776. !     et1 = -pos->z / ray->z;
  777. !     x = pos->x + et1 * ray->x;
  778. !     y = pos->y + et1 * ray->y;
  779. !     if (x*x + y*y > cyl->rad)
  780.           et1 = FAR_AWAY;
  781. !     et2 = (cyl->len - pos->z) / ray->z;
  782. !     x = pos->x + et2 * ray->x;
  783. !     y = pos->y + et2 * ray->y;
  784. !     if (x*x + y*y > cyl->rad)
  785.           et2 = FAR_AWAY;
  786.       t1 = min(t1, min(t2, min(et1, et2)));
  787. !     return (t1 == FAR_AWAY ? 0. : t1);
  788.   }
  789.   
  790.   nrmcyl(pos, obj, nrm)
  791. --- 160,191 ----
  792.           t1 = FAR_AWAY;
  793.       if (t2 < EPSILON)
  794.           t2 = FAR_AWAY;
  795.       /*
  796.        * Don't bother checking endcaps if both intersection points
  797.        * are on the cylinder.
  798.        */
  799. !     if ((zpos1 > 0. && zpos1 < 1. && zpos2 > 0. && zpos2 < 1.))
  800. !         return min(t1, t2) / distfact;
  801.       /*
  802.         * It's possible to get rid of the ray-disc intersection tests
  803.        * (by looking at t1, t2 and zpos1, zpos), but the code gets messy.
  804.        */
  805. !     if (zpos1 < 0. || zpos1 > 1.)
  806.           t1 = FAR_AWAY;
  807. !     if (zpos2 < 0. || zpos2 > 1.)
  808.           t2 = FAR_AWAY;
  809. !     et1 = -npos.z / nray.z;
  810. !     x = npos.x + et1 * nray.x;
  811. !     y = npos.y + et1 * nray.y;
  812. !     if (x*x + y*y > 1.)
  813.           et1 = FAR_AWAY;
  814. !     et2 = (1. - npos.z) / nray.z;
  815. !     x = npos.x + et2 * nray.x;
  816. !     y = npos.y + et2 * nray.y;
  817. !     if (x*x + y*y > 1.)
  818.           et2 = FAR_AWAY;
  819.       t1 = min(t1, min(t2, min(et1, et2)));
  820. !     return (t1 == FAR_AWAY ? 0. : t1 / distfact);
  821.   }
  822.   
  823.   nrmcyl(pos, obj, nrm)
  824. ***************
  825. *** 178,190 ****
  826.   Primitive *obj;
  827.   {
  828.       Cylinder *cyl;
  829.       double dist;
  830.   
  831.       cyl = obj->objpnt.p_cylinder;
  832.   
  833. !     dist = pos->x*pos->x + pos->y*pos->y;
  834. !     if (dist+EPSILON < cyl->rad) {
  835. !         if (equal(pos->z,0.)) {
  836.               /*
  837.                * Hit on lower endcap.
  838.                */
  839. --- 193,212 ----
  840.   Primitive *obj;
  841.   {
  842.       Cylinder *cyl;
  843. +     Vector npos;
  844.       double dist;
  845.   
  846.       cyl = obj->objpnt.p_cylinder;
  847.   
  848. !     /*
  849. !      * Transform position into cylinder space.
  850. !      */
  851. !     npos = *pos;
  852. !     transform_point(&npos, &cyl->trans.world2obj);
  853. !     dist = npos.x*npos.x + npos.y*npos.y;
  854. !     if (dist+EPSILON < 1) {
  855. !         if (equal(npos.z,0.)) {
  856.               /*
  857.                * Hit on lower endcap.
  858.                */
  859. ***************
  860. *** 198,208 ****
  861.               nrm->z = 1.;
  862.           }
  863.       } else {    /* Hit along cylinder. */
  864. !         nrm->x = pos->x;
  865. !         nrm->y = pos->y;
  866.           nrm->z = 0.;
  867.           /* Will be normalized by ShadeRay(). */
  868.       }
  869.   }
  870.   
  871.   cylextent(o, bounds)
  872. --- 220,235 ----
  873.               nrm->z = 1.;
  874.           }
  875.       } else {    /* Hit along cylinder. */
  876. !         nrm->x = npos.x;
  877. !         nrm->y = npos.y;
  878.           nrm->z = 0.;
  879.           /* Will be normalized by ShadeRay(). */
  880.       }
  881. +     /*
  882. +      * Tranform normal back to world space.
  883. +      */
  884. +     TransformNormal(nrm, &cyl->trans.world2obj);
  885.   }
  886.   
  887.   cylextent(o, bounds)
  888. ***************
  889. *** 210,221 ****
  890.   double bounds[2][3];
  891.   {
  892.       Cylinder *cyl;
  893. !     double r;
  894.       cyl = o->objpnt.p_cylinder;
  895.   
  896. !     r = sqrt(cyl->rad);
  897. !     bounds[LOW][X] = bounds[LOW][Y] = -r;
  898. !     bounds[HIGH][X] = bounds[HIGH][Y] = r;
  899.       bounds[LOW][Z] = 0.;
  900. !     bounds[HIGH][Z] = cyl->len;
  901.   }
  902. --- 237,251 ----
  903.   double bounds[2][3];
  904.   {
  905.       Cylinder *cyl;
  906.       cyl = o->objpnt.p_cylinder;
  907.   
  908. !     bounds[LOW][X] = bounds[LOW][Y] = -1;
  909. !     bounds[HIGH][X] = bounds[HIGH][Y] = 1;
  910.       bounds[LOW][Z] = 0.;
  911. !     bounds[HIGH][Z] = 1;
  912. !     /*
  913. !      * Transform bounding box to world space.
  914. !      */
  915. !     transform_bounds(&cyl->trans.obj2world, bounds);
  916.   }
  917.  
  918. Index: src/hf.c
  919. *** src/hf.c.old    Tue Apr 10 16:48:12 1990
  920. --- src/hf.c    Tue Apr 10 16:48:13 1990
  921. ***************
  922. *** 18,26 ****
  923.    * name of the person performing the modification, the date of modification,
  924.    * and the reason for such modification.
  925.    *
  926. !  * $Id: hf.c,v 3.0.1.3 90/02/12 13:30:14 craig Exp $
  927.    *
  928.    * $Log:    hf.c,v $
  929.    * Revision 3.0.1.3  90/02/12  13:30:14  craig
  930.    * patch4: Fixed bug involving computation of hf->lsize[i]
  931.    * 
  932. --- 18,29 ----
  933.    * name of the person performing the modification, the date of modification,
  934.    * and the reason for such modification.
  935.    *
  936. !  * $Id: hf.c,v 3.0.1.4 90/04/04 14:52:30 craig Exp $
  937.    *
  938.    * $Log:    hf.c,v $
  939. +  * Revision 3.0.1.4  90/04/04  14:52:30  craig
  940. +  * patch5: Lint removal.
  941. +  * 
  942.    * Revision 3.0.1.3  90/02/12  13:30:14  craig
  943.    * patch4: Fixed bug involving computation of hf->lsize[i]
  944.    * 
  945. ***************
  946. *** 118,124 ****
  947.       /*
  948.        * Get HF size.
  949.        */
  950. !     if (fread(&hf->size, sizeof(int), 1, fp) == 0)
  951.           yyerror("Cannot read height field size.");
  952.   
  953.       hf->data = (float **)share_malloc(hf->size * sizeof(float *));
  954. --- 121,127 ----
  955.       /*
  956.        * Get HF size.
  957.        */
  958. !     if (fread((char *)&hf->size, sizeof(int), 1, fp) == 0)
  959.           yyerror("Cannot read height field size.");
  960.   
  961.       hf->data = (float **)share_malloc(hf->size * sizeof(float *));
  962. ***************
  963. *** 127,133 ****
  964.           /*
  965.            * Read in row of HF data.
  966.            */
  967. !         if (fread(hf->data[i],sizeof(float),hf->size,fp) != hf->size)
  968.               yyerror("Not enough heightfield data.");
  969.           for (j = 0; j < hf->size; j++) {
  970.               val = hf->data[i][j];
  971. --- 130,136 ----
  972.           /*
  973.            * Read in row of HF data.
  974.            */
  975. !         if (fread((char *)hf->data[i],sizeof(float),hf->size,fp) != hf->size)
  976.               yyerror("Not enough heightfield data.");
  977.           for (j = 0; j < hf->size; j++) {
  978.               val = hf->data[i][j];
  979. ***************
  980. *** 145,151 ****
  981.                   hf->minz = val;
  982.           }
  983.       }
  984. !     fclose(fp);
  985.       /*
  986.        * Allocate levels of grid.  hf->levels = log base BestSize of hf->size
  987.        */
  988. --- 148,154 ----
  989.                   hf->minz = val;
  990.           }
  991.       }
  992. !     (void)fclose(fp);
  993.       /*
  994.        * Allocate levels of grid.  hf->levels = log base BestSize of hf->size
  995.        */
  996. ***************
  997. *** 154,160 ****
  998.               ;
  999.       hf->levels++;
  1000.       hf->qsize = CACHESIZE;
  1001. !     hf->q = (hfTri **)Calloc(hf->qsize, sizeof(hfTri *));
  1002.       hf->qtail = 0;
  1003.   
  1004.       hf->lsize = (int *)share_malloc(hf->levels * sizeof(int));
  1005. --- 157,163 ----
  1006.               ;
  1007.       hf->levels++;
  1008.       hf->qsize = CACHESIZE;
  1009. !     hf->q = (hfTri **)Calloc((unsigned)hf->qsize, sizeof(hfTri *));
  1010.       hf->qtail = 0;
  1011.   
  1012.       hf->lsize = (int *)share_malloc(hf->levels * sizeof(int));
  1013. ***************
  1014. *** 563,568 ****
  1015. --- 566,572 ----
  1016.   /*
  1017.    * Compute normal to height field.
  1018.    */
  1019. + /*ARGSUSED*/
  1020.   nrmhf(pos, prim, nrm)
  1021.   Vector *pos, *nrm;
  1022.   Primitive *prim;
  1023.  
  1024. Index: src/input_yacc.y
  1025. *** src/input_yacc.y.old    Tue Apr 10 16:48:20 1990
  1026. --- src/input_yacc.y    Tue Apr 10 16:48:23 1990
  1027. ***************
  1028. *** 17,23 ****
  1029.   /* name of the person performing the modification, the date of modification,*/
  1030.   /* and the reason for such modification.                    */
  1031.   /*                                        */
  1032. ! /* $Id: input_yacc.y,v 3.0.1.8 90/03/07 21:26:42 craig Exp $ */
  1033.   %{
  1034.   #include <stdio.h>
  1035.   #include "constants.h"
  1036. --- 17,23 ----
  1037.   /* name of the person performing the modification, the date of modification,*/
  1038.   /* and the reason for such modification.                    */
  1039.   /*                                        */
  1040. ! /* $Id: input_yacc.y,v 3.0.1.9 90/04/04 18:58:50 craig Exp $ */
  1041.   %{
  1042.   #include <stdio.h>
  1043.   #include "constants.h"
  1044. ***************
  1045. *** 196,203 ****
  1046.           {
  1047.               CurObj->data->texture = CurText;
  1048.               CurText = (Texture *)0;
  1049.               free((char *)CurObj);
  1050. !             CurObj = CurObj->next;
  1051.           }
  1052.           ;
  1053.   Objectdef    : Startdef Objdefs tENDDEF
  1054. --- 196,204 ----
  1055.           {
  1056.               CurObj->data->texture = CurText;
  1057.               CurText = (Texture *)0;
  1058. +             ListTmp = CurObj->next;
  1059.               free((char *)CurObj);
  1060. !             CurObj = ListTmp;
  1061.           }
  1062.           ;
  1063.   Objectdef    : Startdef Objdefs tENDDEF
  1064.  
  1065. Index: src/main.c
  1066. *** src/main.c.old    Tue Apr 10 16:48:29 1990
  1067. --- src/main.c    Tue Apr 10 16:48:30 1990
  1068. ***************
  1069. *** 1,5 ****
  1070.   char rcsid[] =
  1071. !     "$Id: main.c,v 3.0.1.3 90/03/07 21:33:09 craig Exp $";
  1072.   /*
  1073.    * main.c
  1074.    *
  1075. --- 1,5 ----
  1076.   char rcsid[] =
  1077. !     "$Id: main.c,v 3.0.1.4 90/04/04 14:50:44 craig Exp $";
  1078.   /*
  1079.    * main.c
  1080.    *
  1081. ***************
  1082. *** 21,26 ****
  1083. --- 21,29 ----
  1084.    * and the reason for such modification.
  1085.    *
  1086.    * $Log:    main.c,v $
  1087. +  * Revision 3.0.1.4  90/04/04  14:50:44  craig
  1088. +  * patch5: Removed check of return value of times().
  1089. +  * 
  1090.    * Revision 3.0.1.3  90/03/07  21:33:09  craig
  1091.    * patch4: Return value of times() is now checked.
  1092.    * patch4: Workers is externed iff LINDA is defined.
  1093. ***************
  1094. *** 179,188 ****
  1095.   double *usertime, *systime;
  1096.   {
  1097.       struct tms time;
  1098. -     long times();
  1099.   
  1100. !     if (times(&time) < 0)
  1101. !         RSwarning("Cannot get cpu time?!\n");
  1102.       *usertime = (double)time.tms_utime / (double)HZ;
  1103.       *systime = (double)time.tms_stime / (double)HZ;
  1104.   }
  1105. --- 182,189 ----
  1106.   double *usertime, *systime;
  1107.   {
  1108.       struct tms time;
  1109.   
  1110. !     (void)times(&time);
  1111.       *usertime = (double)time.tms_utime / (double)HZ;
  1112.       *systime = (double)time.tms_stime / (double)HZ;
  1113.   }
  1114.  
  1115. Index: src/memory.c
  1116. *** src/memory.c.old    Tue Apr 10 16:48:33 1990
  1117. --- src/memory.c    Tue Apr 10 16:48:33 1990
  1118. ***************
  1119. *** 18,26 ****
  1120.    * name of the person performing the modification, the date of modification,
  1121.    * and the reason for such modification.
  1122.    *
  1123. !  * $Id: memory.c,v 3.0.1.1 89/12/06 16:33:59 craig Exp $
  1124.    *
  1125.    * $Log:    memory.c,v $
  1126.    * Revision 3.0.1.1  89/12/06  16:33:59  craig
  1127.    * patch2: Added calls to new error/warning routines.
  1128.    * 
  1129. --- 18,29 ----
  1130.    * name of the person performing the modification, the date of modification,
  1131.    * and the reason for such modification.
  1132.    *
  1133. !  * $Id: memory.c,v 3.0.1.2 90/04/04 18:56:08 craig Exp $
  1134.    *
  1135.    * $Log:    memory.c,v $
  1136. +  * Revision 3.0.1.2  90/04/04  18:56:08  craig
  1137. +  * patch5: Lint removal.
  1138. +  * 
  1139.    * Revision 3.0.1.1  89/12/06  16:33:59  craig
  1140.    * patch2: Added calls to new error/warning routines.
  1141.    * 
  1142. ***************
  1143. *** 29,34 ****
  1144. --- 32,40 ----
  1145.    * 
  1146.    */
  1147.   #include <stdio.h>
  1148. + #ifdef SYSV
  1149. + #include <memory.h>
  1150. + #endif
  1151.   #include "typedefs.h"
  1152.   #include "funcdefs.h"
  1153.   
  1154. ***************
  1155. *** 56,64 ****
  1156.   
  1157.       res = Malloc(nelem*elen);
  1158.   #ifdef SYSV
  1159. !     memset(res, (char)0, nelem*elen);
  1160.   #else
  1161. !     bzero(res, nelem*elen);
  1162.   #endif
  1163.       return res;
  1164.   }
  1165. --- 62,70 ----
  1166.   
  1167.       res = Malloc(nelem*elen);
  1168.   #ifdef SYSV
  1169. !     (void)memset(res, (char)0, (int)(nelem*elen));
  1170.   #else
  1171. !     bzero(res, (int)nelem*elen);
  1172.   #endif
  1173.       return res;
  1174.   }
  1175.  
  1176. Index: src/noise.c
  1177. *** src/noise.c.old    Tue Apr 10 16:48:36 1990
  1178. --- src/noise.c    Tue Apr 10 16:48:36 1990
  1179. ***************
  1180. *** 18,26 ****
  1181.    * name of the person performing the modification, the date of modification,
  1182.    * and the reason for such modification.
  1183.    *
  1184. !  * $Id: noise.c,v 3.0 89/10/27 02:05:57 craig Exp $
  1185.    *
  1186.    * $Log:    noise.c,v $
  1187.    * Revision 3.0  89/10/27  02:05:57  craig
  1188.    * Baseline for first official release.
  1189.    * 
  1190. --- 18,29 ----
  1191.    * name of the person performing the modification, the date of modification,
  1192.    * and the reason for such modification.
  1193.    *
  1194. !  * $Id: noise.c,v 3.0.1.1 90/04/04 18:59:22 craig Exp $
  1195.    *
  1196.    * $Log:    noise.c,v $
  1197. +  * Revision 3.0.1.1  90/04/04  18:59:22  craig
  1198. +  * patch5: Lint removal.
  1199. +  * 
  1200.    * Revision 3.0  89/10/27  02:05:57  craig
  1201.    * Baseline for first official release.
  1202.    * 
  1203. ***************
  1204. *** 100,106 ****
  1205.       (void)srandom(0);
  1206.   #endif
  1207.   
  1208. !     hashTable = (short int *) malloc(4096*sizeof(short int));
  1209.       for (i = 0; i < 4096; i++)
  1210.           hashTable[i] = i;
  1211.       for (i = 4095; i > 0; i--) {
  1212. --- 103,109 ----
  1213.       (void)srandom(0);
  1214.   #endif
  1215.   
  1216. !     hashTable = (short *) Malloc(4096*sizeof(short int));
  1217.       for (i = 0; i < 4096; i++)
  1218.           hashTable[i] = i;
  1219.       for (i = 4095; i > 0; i--) {
  1220.  
  1221. Index: src/outputp.c
  1222. *** src/outputp.c.old    Tue Apr 10 16:48:40 1990
  1223. --- src/outputp.c    Tue Apr 10 16:48:40 1990
  1224. ***************
  1225. *** 18,26 ****
  1226.    * name of the person performing the modification, the date of modification,
  1227.    * and the reason for such modification.
  1228.    *
  1229. !  * $Id: outputp.c,v 3.0.1.2 90/02/12 16:09:05 craig Exp $
  1230.    *
  1231.    * $Log:    outputp.c,v $
  1232.    * Revision 3.0.1.2  90/02/12  16:09:05  craig
  1233.    * patch4: Fixed bug with duplicate headers in mtv files when Appending.
  1234.    * 
  1235. --- 18,29 ----
  1236.    * name of the person performing the modification, the date of modification,
  1237.    * and the reason for such modification.
  1238.    *
  1239. !  * $Id: outputp.c,v 3.0.1.3 90/04/04 14:53:04 craig Exp $
  1240.    *
  1241.    * $Log:    outputp.c,v $
  1242. +  * Revision 3.0.1.3  90/04/04  14:53:04  craig
  1243. +  * patch5: Lint removal.
  1244. +  * 
  1245.    * Revision 3.0.1.2  90/02/12  16:09:05  craig
  1246.    * patch4: Fixed bug with duplicate headers in mtv files when Appending.
  1247.    * 
  1248. ***************
  1249. *** 101,107 ****
  1250.       buffer[1]=(unsigned char *)Malloc(sizeof(unsigned char)*(unsigned)Xres);
  1251.       buffer[2]=(unsigned char *)Malloc(sizeof(unsigned char)*(unsigned)Xres);
  1252.       if (Appending)
  1253. !         fseek(imgfile, 0L, 2);        /* Go to end of file */
  1254.   }
  1255.   
  1256.   
  1257. --- 104,110 ----
  1258.       buffer[1]=(unsigned char *)Malloc(sizeof(unsigned char)*(unsigned)Xres);
  1259.       buffer[2]=(unsigned char *)Malloc(sizeof(unsigned char)*(unsigned)Xres);
  1260.       if (Appending)
  1261. !         (void)fseek(imgfile, 0L, 2);    /* Go to end of file */
  1262.   }
  1263.   
  1264.   
  1265. ***************
  1266. *** 134,140 ****
  1267.   endpic()
  1268.   {
  1269.       sv_puteof(&sv_globals);
  1270. !     fclose(imgfile);
  1271.   }
  1272.   
  1273.   #else /* NORLE */
  1274. --- 137,143 ----
  1275.   endpic()
  1276.   {
  1277.       sv_puteof(&sv_globals);
  1278. !     (void)fclose(imgfile);
  1279.   }
  1280.   
  1281.   #else /* NORLE */
  1282. ***************
  1283. *** 166,174 ****
  1284.       extern int Xres;
  1285.   
  1286.       for (i = 0; i < Xres; i++) {
  1287. !         fputc(correct(255.*buf[i].r), imgfile);
  1288. !         fputc(correct(255.*buf[i].g), imgfile);
  1289. !         fputc(correct(255.*buf[i].b), imgfile);
  1290.       }
  1291.       fflush(imgfile);
  1292.   }
  1293. --- 169,177 ----
  1294.       extern int Xres;
  1295.   
  1296.       for (i = 0; i < Xres; i++) {
  1297. !         (void)fputc(correct(255.*buf[i].r), imgfile);
  1298. !         (void)fputc(correct(255.*buf[i].g), imgfile);
  1299. !         (void)fputc(correct(255.*buf[i].b), imgfile);
  1300.       }
  1301.       fflush(imgfile);
  1302.   }
  1303. ***************
  1304. *** 175,181 ****
  1305.   
  1306.   endpic()
  1307.   {
  1308. !     fclose(imgfile);
  1309.   }
  1310.   #endif /* NORLE */
  1311.   
  1312. --- 178,184 ----
  1313.   
  1314.   endpic()
  1315.   {
  1316. !     (void)fclose(imgfile);
  1317.   }
  1318.   #endif /* NORLE */
  1319.   
  1320.  
  1321. Index: src/plane.c
  1322. *** src/plane.c.old    Tue Apr 10 16:48:43 1990
  1323. --- src/plane.c    Tue Apr 10 16:48:44 1990
  1324. ***************
  1325. *** 18,26 ****
  1326.    * name of the person performing the modification, the date of modification,
  1327.    * and the reason for such modification.
  1328.    *
  1329. !  * $Id: plane.c,v 3.0.1.1 89/12/06 16:34:03 craig Exp $
  1330.    *
  1331.    * $Log:    plane.c,v $
  1332.    * Revision 3.0.1.1  89/12/06  16:34:03  craig
  1333.    * patch2: Added calls to new error/warning routines.
  1334.    * 
  1335. --- 18,29 ----
  1336.    * name of the person performing the modification, the date of modification,
  1337.    * and the reason for such modification.
  1338.    *
  1339. !  * $Id: plane.c,v 3.0.1.2 90/04/04 19:02:42 craig Exp $
  1340.    *
  1341.    * $Log:    plane.c,v $
  1342. +  * Revision 3.0.1.2  90/04/04  19:02:42  craig
  1343. +  * patch5: Test for edge-on intersection more robust.
  1344. +  * 
  1345.    * Revision 3.0.1.1  89/12/06  16:34:03  craig
  1346.    * patch2: Added calls to new error/warning routines.
  1347.    * 
  1348. ***************
  1349. *** 77,83 ****
  1350.       plane = obj->objpnt.p_plane;
  1351.   
  1352.       denom = dotp(&plane->norm, ray);
  1353. !     if (denom == 0.)
  1354.           return 0.;
  1355.       dist = (plane->d - dotp(&plane->norm, pos)) / denom;
  1356.       return (dist > FAR_AWAY ? 0. : dist);
  1357. --- 80,86 ----
  1358.       plane = obj->objpnt.p_plane;
  1359.   
  1360.       denom = dotp(&plane->norm, ray);
  1361. !     if (equal(denom, 0.))
  1362.           return 0.;
  1363.       dist = (plane->d - dotp(&plane->norm, pos)) / denom;
  1364.       return (dist > FAR_AWAY ? 0. : dist);
  1365.  
  1366. Index: src/poly.c
  1367. *** src/poly.c.old    Tue Apr 10 16:48:47 1990
  1368. --- src/poly.c    Tue Apr 10 16:48:47 1990
  1369. ***************
  1370. *** 18,26 ****
  1371.    * name of the person performing the modification, the date of modification,
  1372.    * and the reason for such modification.
  1373.    *
  1374. !  * $Id: poly.c,v 3.0.1.1 89/12/06 16:33:38 craig Exp $
  1375.    *
  1376.    * $Log:    poly.c,v $
  1377.    * Revision 3.0.1.1  89/12/06  16:33:38  craig
  1378.    * patch2: Added calls to new error/warning routines.
  1379.    * 
  1380. --- 18,29 ----
  1381.    * name of the person performing the modification, the date of modification,
  1382.    * and the reason for such modification.
  1383.    *
  1384. !  * $Id: poly.c,v 3.0.1.2 90/04/04 19:01:19 craig Exp $
  1385.    *
  1386.    * $Log:    poly.c,v $
  1387. +  * Revision 3.0.1.2  90/04/04  19:01:19  craig
  1388. +  * patch5: Corrected free()-related problems.
  1389. +  * 
  1390.    * Revision 3.0.1.1  89/12/06  16:33:38  craig
  1391.    * patch2: Added calls to new error/warning routines.
  1392.    * 
  1393. ***************
  1394. *** 49,55 ****
  1395.       Object *newobj;
  1396.       double indexval;
  1397.       Vector edge1, edge2, anorm;
  1398. !     PointList *cur;
  1399.       int i;
  1400.       extern int TrashBadPoly;
  1401.   
  1402. --- 52,58 ----
  1403.       Object *newobj;
  1404.       double indexval;
  1405.       Vector edge1, edge2, anorm;
  1406. !     PointList *cur, *pltmp;
  1407.       int i;
  1408.       extern int TrashBadPoly;
  1409.   
  1410. ***************
  1411. *** 71,81 ****
  1412.        * to worry about doing so.
  1413.        */
  1414.       i = npoints -1;
  1415. !     for(cur = plist;cur;cur = cur->next) {
  1416.           poly->points[i--] = cur->vec;
  1417.           free((char *)cur);
  1418.       }
  1419. -     free((char *)plist);
  1420.   
  1421.       /*
  1422.        * Find normal to polygon.  Check all edges before giving
  1423. --- 74,84 ----
  1424.        * to worry about doing so.
  1425.        */
  1426.       i = npoints -1;
  1427. !     for(cur = plist; cur != (PointList *)0; cur = pltmp) {
  1428.           poly->points[i--] = cur->vec;
  1429. +         pltmp = cur->next;
  1430.           free((char *)cur);
  1431.       }
  1432.   
  1433.       /*
  1434.        * Find normal to polygon.  Check all edges before giving
  1435.  
  1436. Index: src/primobj.h
  1437. *** src/primobj.h.old    Tue Apr 10 16:48:50 1990
  1438. --- src/primobj.h    Tue Apr 10 16:48:50 1990
  1439. ***************
  1440. *** 18,26 ****
  1441.    * name of the person performing the modification, the date of modification,
  1442.    * and the reason for such modification.
  1443.    *
  1444. !  * $Id: primobj.h,v 3.0 89/10/27 02:06:00 craig Exp $
  1445.    *
  1446.    * $Log:    primobj.h,v $
  1447.    * Revision 3.0  89/10/27  02:06:00  craig
  1448.    * Baseline for first official release.
  1449.    * 
  1450. --- 18,29 ----
  1451.    * name of the person performing the modification, the date of modification,
  1452.    * and the reason for such modification.
  1453.    *
  1454. !  * $Id: primobj.h,v 3.0.1.1 90/04/09 13:39:59 craig Exp $
  1455.    *
  1456.    * $Log:    primobj.h,v $
  1457. +  * Revision 3.0.1.1  90/04/09  13:39:59  craig
  1458. +  * patch5: New Cylinder and Cone types.
  1459. +  * 
  1460.    * Revision 3.0  89/10/27  02:06:00  craig
  1461.    * Baseline for first official release.
  1462.    * 
  1463. ***************
  1464. *** 30,41 ****
  1465.    * Cylinder
  1466.    */
  1467.   typedef struct cylinder    {
  1468. !     double rad, len;        /* Radius and length. */
  1469.   } Cylinder;
  1470.   
  1471.   typedef struct cone {
  1472. !     double start_pos, end_pos, apex_rad;    /* End cap Z positions */
  1473. !     double tantheta;            /* "slope" */
  1474.   } Cone;
  1475.   
  1476.   /*
  1477. --- 33,44 ----
  1478.    * Cylinder
  1479.    */
  1480.   typedef struct cylinder    {
  1481. !     Trans trans;
  1482.   } Cylinder;
  1483.   
  1484.   typedef struct cone {
  1485. !     double start_dist;
  1486. !     Trans trans;
  1487.   } Cone;
  1488.   
  1489.   /*
  1490.  
  1491. Index: src/setup.c
  1492. *** src/setup.c.old    Tue Apr 10 16:48:55 1990
  1493. --- src/setup.c    Tue Apr 10 16:48:56 1990
  1494. ***************
  1495. *** 18,26 ****
  1496.    * name of the person performing the modification, the date of modification,
  1497.    * and the reason for such modification.
  1498.    *
  1499. !  * $Id: setup.c,v 3.0.1.2 90/02/12 13:26:49 craig Exp $
  1500.    *
  1501.    * $Log:    setup.c,v $
  1502.    * Revision 3.0.1.2  90/02/12  13:26:49  craig
  1503.    * patch4: Added calls to new error/warning routines.
  1504.    * patch4: Attempting to render empty scene now results in an error message.
  1505. --- 18,29 ----
  1506.    * name of the person performing the modification, the date of modification,
  1507.    * and the reason for such modification.
  1508.    *
  1509. !  * $Id: setup.c,v 3.0.1.3 90/04/04 19:00:19 craig Exp $
  1510.    *
  1511.    * $Log:    setup.c,v $
  1512. +  * Revision 3.0.1.3  90/04/04  19:00:19  craig
  1513. +  * patch5: Lint removal.
  1514. +  * 
  1515.    * Revision 3.0.1.2  90/02/12  13:26:49  craig
  1516.    * patch4: Added calls to new error/warning routines.
  1517.    * patch4: Attempting to render empty scene now results in an error message.
  1518. ***************
  1519. *** 178,184 ****
  1520.        * transformation.
  1521.        */
  1522.       for (i = 0; i < nlight; i++) {
  1523. !         light[i].cache = (Primitive **)Calloc(maxlevel+1,
  1524.                       sizeof(Primitive *));
  1525.           light[i].trans = (TransInfo *)Malloc((maxlevel+1)*
  1526.                       sizeof(TransInfo));
  1527. --- 181,187 ----
  1528.        * transformation.
  1529.        */
  1530.       for (i = 0; i < nlight; i++) {
  1531. !         light[i].cache = (Primitive **)Calloc((unsigned)maxlevel+1,
  1532.                       sizeof(Primitive *));
  1533.           light[i].trans = (TransInfo *)Malloc((maxlevel+1)*
  1534.                       sizeof(TransInfo));
  1535.  
  1536. Index: src/shade.c
  1537. *** src/shade.c.old    Tue Apr 10 16:49:00 1990
  1538. --- src/shade.c    Tue Apr 10 16:49:02 1990
  1539. ***************
  1540. *** 18,26 ****
  1541.    * name of the person performing the modification, the date of modification,
  1542.    * and the reason for such modification.
  1543.    *
  1544. !  * $Id: shade.c,v 3.0.1.2 90/03/07 21:31:21 craig Exp $
  1545.    *
  1546.    * $Log:    shade.c,v $
  1547.    * Revision 3.0.1.2  90/03/07  21:31:21  craig
  1548.    * patch4: Replaced call to LightCoordSys() with call to VectCoordSys().
  1549.    * 
  1550. --- 18,29 ----
  1551.    * name of the person performing the modification, the date of modification,
  1552.    * and the reason for such modification.
  1553.    *
  1554. !  * $Id: shade.c,v 3.0.1.3 90/04/04 19:04:19 craig Exp $
  1555.    *
  1556.    * $Log:    shade.c,v $
  1557. +  * Revision 3.0.1.3  90/04/04  19:04:19  craig
  1558. +  * patch5: Corrected free()-related problems.
  1559. +  * 
  1560.    * Revision 3.0.1.2  90/03/07  21:31:21  craig
  1561.    * patch4: Replaced call to LightCoordSys() with call to VectCoordSys().
  1562.    * 
  1563. ***************
  1564. *** 180,186 ****
  1565.                    * of two refracting surfaces. Skip it.
  1566.                    */
  1567.                   return;
  1568. -             free((char *)NewRay.media);
  1569.               NewRay.media = NewRay.media->next;
  1570.               if (refract(&NewRay.dir, surf->kref,
  1571.                   NewRay.media ? NewRay.media->surf->kref :
  1572. --- 183,188 ----
  1573.  
  1574. Index: src/texture.c
  1575. *** src/texture.c.old    Tue Apr 10 16:49:06 1990
  1576. --- src/texture.c    Tue Apr 10 16:49:08 1990
  1577. ***************
  1578. *** 18,26 ****
  1579.    * name of the person performing the modification, the date of modification,
  1580.    * and the reason for such modification.
  1581.    *
  1582. !  * $Id: texture.c,v 3.0.1.3 90/03/07 21:30:22 craig Exp $
  1583.    *
  1584.    * $Log:    texture.c,v $
  1585.    * Revision 3.0.1.3  90/03/07  21:30:22  craig
  1586.    * patch4: Fixed thresholding bug in fBmText().
  1587.    * patch4: Colormap is now set to NULL in new_texture().
  1588. --- 18,29 ----
  1589.    * name of the person performing the modification, the date of modification,
  1590.    * and the reason for such modification.
  1591.    *
  1592. !  * $Id: texture.c,v 3.0.1.4 90/04/04 17:22:39 craig Exp $
  1593.    *
  1594.    * $Log:    texture.c,v $
  1595. +  * Revision 3.0.1.4  90/04/04  17:22:39  craig
  1596. +  * patch5: Added checking for invalid colormap entries.
  1597. +  * 
  1598.    * Revision 3.0.1.3  90/03/07  21:30:22  craig
  1599.    * patch4: Fixed thresholding bug in fBmText().
  1600.    * patch4: Colormap is now set to NULL in new_texture().
  1601. ***************
  1602. *** 114,119 ****
  1603. --- 117,123 ----
  1604.       return text;
  1605.   }
  1606.   
  1607. + /*ARGSUSED*/
  1608.   WoodText(text, pos, norm, surf)
  1609.   Texture *text;
  1610.   Vector *pos, *norm;
  1611. ***************
  1612. *** 120,126 ****
  1613.   Surface *surf;
  1614.   {
  1615.       double red, grn, blu;
  1616. !     double chaos, midBrown, brownLayer, greenLayer;
  1617.       double perturb, brownPerturb, greenPerturb, grnPerturb;
  1618.       double t;
  1619.   
  1620. --- 124,130 ----
  1621.   Surface *surf;
  1622.   {
  1623.       double red, grn, blu;
  1624. !     double chaos, brownLayer, greenLayer;
  1625.       double perturb, brownPerturb, greenPerturb, grnPerturb;
  1626.       double t;
  1627.   
  1628. ***************
  1629. *** 265,270 ****
  1630. --- 269,275 ----
  1631.   /*
  1632.    * Apply "blotch" texture.
  1633.    */
  1634. + /*ARGSUSED*/
  1635.   BlotchText(text, pos, norm, surf)
  1636.   Texture *text;
  1637.   Vector *pos, *norm;
  1638. ***************
  1639. *** 282,287 ****
  1640. --- 287,293 ----
  1641.       }
  1642.   }
  1643.   
  1644. + /*ARGSUSED*/
  1645.   fBmText(text, pos, norm, surf)
  1646.   Texture *text;
  1647.   Vector *pos, *norm;
  1648. ***************
  1649. *** 314,319 ****
  1650. --- 320,326 ----
  1651.   /*
  1652.    * Apply a "checker" texture.
  1653.    */
  1654. + /*ARGSUSED*/
  1655.   CheckerText(text, pos, norm, surf)
  1656.   Texture *text;
  1657.   Vector *pos, *norm;
  1658. ***************
  1659. *** 330,335 ****
  1660. --- 337,343 ----
  1661.       /* else surface stays the same. */
  1662.   }
  1663.   
  1664. + /*ARGSUSED*/
  1665.   fBmBumpText(text, pos, norm, surf)
  1666.   Texture *text;
  1667.   Vector *pos, *norm;
  1668. ***************
  1669. *** 348,353 ****
  1670. --- 356,362 ----
  1671.   /*
  1672.    * Apply a "bump" texture.
  1673.    */
  1674. + /*ARGSUSED*/
  1675.   BumpText(text, pos, norm, surf)
  1676.   Texture *text;
  1677.   Vector *pos, *norm;
  1678. ***************
  1679. *** 362,367 ****
  1680. --- 371,377 ----
  1681.       (void)normalize(norm);
  1682.   }
  1683.   
  1684. + /*ARGSUSED*/
  1685.   MarbleText(text, pos, norm, surf)
  1686.   Texture *text;
  1687.   Vector *pos, *norm;
  1688. ***************
  1689. *** 385,390 ****
  1690. --- 395,401 ----
  1691.       }
  1692.   }
  1693.   
  1694. + /*ARGSUSED*/
  1695.   GlossText(text, pos, norm, surf)
  1696.   Texture *text;
  1697.   Vector *pos, *norm;
  1698. ***************
  1699. *** 420,426 ****
  1700.       FILE *fp;
  1701.       Color *map;
  1702.       char buf[BUFSIZ];
  1703. !     int i;
  1704.   
  1705.       fp = fopen(filename, "r");
  1706.       if (fp == (FILE *)NULL)
  1707. --- 431,437 ----
  1708.       FILE *fp;
  1709.       Color *map;
  1710.       char buf[BUFSIZ];
  1711. !     int i, num;
  1712.   
  1713.       fp = fopen(filename, "r");
  1714.       if (fp == (FILE *)NULL)
  1715. ***************
  1716. *** 429,436 ****
  1717.       map = (Color *)Calloc(256, sizeof(Color));
  1718.   
  1719.       for (i = 0; fgets(buf,BUFSIZ,fp) != NULL && i < 256; i++) {
  1720. !         sscanf(buf,"%lf %lf %lf",&map[i].r, &map[i].g, &map[i].b);
  1721.           ScaleColor(1. / 255., map[i], &map[i]);
  1722.       }
  1723.       return map;
  1724.   }
  1725. --- 440,452 ----
  1726.       map = (Color *)Calloc(256, sizeof(Color));
  1727.   
  1728.       for (i = 0; fgets(buf,BUFSIZ,fp) != NULL && i < 256; i++) {
  1729. !         num = sscanf(buf,"%lf %lf %lf",&map[i].r, &map[i].g, &map[i].b);
  1730. !         if (num != 3) {
  1731. !             RSerror("%s, line %d:  Bad color specification.\n",
  1732. !                 filename, i+1);
  1733. !         }
  1734.           ScaleColor(1. / 255., map[i], &map[i]);
  1735.       }
  1736. +     (void)fclose(fp);
  1737.       return map;
  1738.   }
  1739.  
  1740. Index: src/triangle.c
  1741. *** src/triangle.c.old    Tue Apr 10 16:49:11 1990
  1742. --- src/triangle.c    Tue Apr 10 16:49:13 1990
  1743. ***************
  1744. *** 18,26 ****
  1745.    * name of the person performing the modification, the date of modification,
  1746.    * and the reason for such modification.
  1747.    *
  1748. !  * $Id: triangle.c,v 3.0.1.1 89/12/06 16:33:32 craig Exp $
  1749.    *
  1750.    * $Log:    triangle.c,v $
  1751.    * Revision 3.0.1.1  89/12/06  16:33:32  craig
  1752.    * patch2: Added calls to new error/warning routines.
  1753.    * 
  1754. --- 18,30 ----
  1755.    * name of the person performing the modification, the date of modification,
  1756.    * and the reason for such modification.
  1757.    *
  1758. !  * $Id: triangle.c,v 3.0.1.2 90/04/04 18:55:45 craig Exp $
  1759.    *
  1760.    * $Log:    triangle.c,v $
  1761. +  * Revision 3.0.1.2  90/04/04  18:55:45  craig
  1762. +  * patch5: Test for edge-on intersection is more robust.
  1763. +  * patch5: Lint removal.
  1764. +  * 
  1765.    * Revision 3.0.1.1  89/12/06  16:33:32  craig
  1766.    * patch2: Added calls to new error/warning routines.
  1767.    * 
  1768. ***************
  1769. *** 146,152 ****
  1770.        * Plane intersection.
  1771.        */
  1772.       k = dotp(&triangle->nrm, ray);
  1773. !     if (k == 0.)
  1774.           return 0.;
  1775.       s = (triangle->d - dotp(&triangle->nrm, pos)) / k;
  1776.       if (s <= 0.)
  1777. --- 150,156 ----
  1778.        * Plane intersection.
  1779.        */
  1780.       k = dotp(&triangle->nrm, ray);
  1781. !     if (equal(k, 0.))
  1782.           return 0.;
  1783.       s = (triangle->d - dotp(&triangle->nrm, pos)) / k;
  1784.       if (s <= 0.)
  1785. ***************
  1786. *** 211,216 ****
  1787. --- 215,221 ----
  1788.       return s;
  1789.   }
  1790.   
  1791. + /*ARGSUSED*/
  1792.   nrmtri(pos, obj, nrm)
  1793.   Vector           *pos, *nrm;
  1794.   Primitive       *obj;
  1795.  
  1796. Index: src/viewing.c
  1797. *** src/viewing.c.old    Tue Apr 10 16:49:17 1990
  1798. --- src/viewing.c    Tue Apr 10 16:49:17 1990
  1799. ***************
  1800. *** 18,26 ****
  1801.    * name of the person performing the modification, the date of modification,
  1802.    * and the reason for such modification.
  1803.    *
  1804. !  * $Id: viewing.c,v 3.0.1.3 89/12/02 14:38:37 craig Exp $
  1805.    *
  1806.    * $Log:    viewing.c,v $
  1807.    * Revision 3.0.1.3  89/12/02  14:38:37  craig
  1808.    * patch2: Added depth of field code, courtesy of Rodney G. Bogart.
  1809.    * 
  1810. --- 18,29 ----
  1811.    * name of the person performing the modification, the date of modification,
  1812.    * and the reason for such modification.
  1813.    *
  1814. !  * $Id: viewing.c,v 3.0.1.4 90/04/04 18:59:54 craig Exp $
  1815.    *
  1816.    * $Log:    viewing.c,v $
  1817. +  * Revision 3.0.1.4  90/04/04  18:59:54  craig
  1818. +  * patch5: Lint removal.
  1819. +  * 
  1820.    * Revision 3.0.1.3  89/12/02  14:38:37  craig
  1821.    * patch2: Added depth of field code, courtesy of Rodney G. Bogart.
  1822.    * 
  1823. ***************
  1824. *** 126,132 ****
  1825.       vecadd(aperture_inc, eyep, &(ray->pos));
  1826.       scalar_prod(focaldist, ray->dir, &(ray->dir));
  1827.       vecsub(ray->dir, aperture_inc, &(ray->dir));
  1828. !     normalize(&ray->dir);
  1829.   }
  1830.   
  1831.   /*
  1832. --- 129,135 ----
  1833.       vecadd(aperture_inc, eyep, &(ray->pos));
  1834.       scalar_prod(focaldist, ray->dir, &(ray->dir));
  1835.       vecsub(ray->dir, aperture_inc, &(ray->dir));
  1836. !     (void)normalize(&ray->dir);
  1837.   }
  1838.   
  1839.   /*
  1840.  
  1841. Index: src/voxels.c
  1842. *** src/voxels.c.old    Tue Apr 10 16:49:21 1990
  1843. --- src/voxels.c    Tue Apr 10 16:49:21 1990
  1844. ***************
  1845. *** 18,26 ****
  1846.    * name of the person performing the modification, the date of modification,
  1847.    * and the reason for such modification.
  1848.    *
  1849. !  * $Id: voxels.c,v 3.0.1.2 90/02/12 13:19:50 craig Exp $
  1850.    *
  1851.    * $Log:    voxels.c,v $
  1852.    * Revision 3.0.1.2  90/02/12  13:19:50  craig
  1853.    * patch4: Added reporting of total number of primitives.
  1854.    * 
  1855. --- 18,29 ----
  1856.    * name of the person performing the modification, the date of modification,
  1857.    * and the reason for such modification.
  1858.    *
  1859. !  * $Id: voxels.c,v 3.0.1.3 90/04/04 19:05:23 craig Exp $
  1860.    *
  1861.    * $Log:    voxels.c,v $
  1862. +  * Revision 3.0.1.3  90/04/04  19:05:23  craig
  1863. +  * patch5: Changes to reflect that free() may be destructive.
  1864. +  * 
  1865.    * Revision 3.0.1.2  90/02/12  13:19:50  craig
  1866.    * patch4: Added reporting of total number of primitives.
  1867.    * 
  1868. ***************
  1869. *** 152,158 ****
  1870.   {
  1871.       Grid *grid;
  1872.       Object *otmp;
  1873. !     ObjList *ltmp;
  1874.       int x, y, i;
  1875.       extern ObjList *find_bounds();
  1876.   
  1877. --- 155,161 ----
  1878.   {
  1879.       Grid *grid;
  1880.       Object *otmp;
  1881. !     ObjList *ltmp, *nltmp;
  1882.       int x, y, i;
  1883.       extern ObjList *find_bounds();
  1884.   
  1885. ***************
  1886. *** 190,199 ****
  1887.       /*
  1888.        * obj->data now holds a linked list of bounded objects.
  1889.        */
  1890. !     for(ltmp = (ObjList *)obj->data; ltmp; ltmp = ltmp->next) {
  1891.           otmp = ltmp->data;
  1892.           engrid(otmp, grid);
  1893. !         free(ltmp);
  1894.       }
  1895.       obj->type = GRID;
  1896.       obj->data = (char *)grid;
  1897. --- 193,203 ----
  1898.       /*
  1899.        * obj->data now holds a linked list of bounded objects.
  1900.        */
  1901. !     for(ltmp = (ObjList *)obj->data; ltmp != (ObjList *)0; ltmp = nltmp) {
  1902.           otmp = ltmp->data;
  1903.           engrid(otmp, grid);
  1904. !         nltmp = ltmp->next;
  1905. !         free((char *)ltmp);
  1906.       }
  1907.       obj->type = GRID;
  1908.       obj->data = (char *)grid;
  1909.  
  1910. Index: doc/primitive.ms
  1911. *** doc/primitive.ms.old    Tue Apr 10 17:22:56 1990
  1912. --- doc/primitive.ms    Tue Apr 10 17:22:57 1990
  1913. ***************
  1914. *** 3,11 ****
  1915.   .\" Brief tutorial on adding new primitives to rayshade.
  1916.   .\" Craig Kolb 10/89
  1917.   .\"
  1918. ! .\" $Id: primitive.ms,v 3.0 89/10/24 18:07:30 craig Exp $
  1919.   .\"
  1920.   .\" $Log:    primitive.ms,v $
  1921.   .\" Revision 3.0  89/10/24  18:07:30  craig
  1922.   .\" Baseline for first official release.
  1923.   .\" 
  1924. --- 3,14 ----
  1925.   .\" Brief tutorial on adding new primitives to rayshade.
  1926.   .\" Craig Kolb 10/89
  1927.   .\"
  1928. ! .\" $Id: primitive.ms,v 3.0.1.1 90/04/10 17:22:36 craig Exp $
  1929.   .\"
  1930.   .\" $Log:    primitive.ms,v $
  1931. + .\" Revision 3.0.1.1  90/04/10  17:22:36  craig
  1932. + .\" patch5: addscaledvec() no longer returns a structure...
  1933. + .\" 
  1934.   .\" Revision 3.0  89/10/24  18:07:30  craig
  1935.   .\" Baseline for first official release.
  1936.   .\" 
  1937. ***************
  1938. *** 505,511 ****
  1939.           /*
  1940.            *  Find difference between point of intersection and center of disc.
  1941.            */
  1942. !         vecsub(addscaledvec(*pos, dist, *ray), disc->center, &hit);
  1943.           /*
  1944.            * If hit point is <= disc->radius from center, we've hit the disc.
  1945.            */
  1946. --- 508,515 ----
  1947.           /*
  1948.            *  Find difference between point of intersection and center of disc.
  1949.            */
  1950. !         addscaledvec(*pos, dist, *ray, &hit);
  1951. !         vecsub(hit, disc->center, &hit);
  1952.           /*
  1953.            * If hit point is <= disc->radius from center, we've hit the disc.
  1954.            */
  1955.