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

Comparing ray/src/ot/sphere.c (file contents):
Revision 1.1 by greg, Thu Feb 2 10:33:06 1989 UTC vs.
Revision 1.3 by greg, Wed May 22 17:01:43 1991 UTC

# Line 64 | Line 64 | register CUBE  *cu;
64   #define  cent           fa
65   #define  rad            fa[3]
66                                          /* get arguments */
67 +        if (o->oargs.nfargs != 4)
68 +                objerror(o, USER, "bad # arguments");
69          fa = o->oargs.farg;
70 <        if (o->oargs.nfargs != 4 || rad <= FTINY)
71 <                objerror(o, USER, "bad arguments");
70 >        if (rad < -FTINY) {
71 >                objerror(o, WARNING, "negative radius");
72 >                o->otype = o->otype == OBJ_SPHERE ?
73 >                                OBJ_BUBBLE : OBJ_SPHERE;
74 >                rad = -rad;
75 >        } else if (rad <= FTINY)
76 >                objerror(o, USER, "zero radius");
77  
78          d1 = ROOT3/2.0 * cu->cusize;    /* bounding radius for cube */
79  
# Line 76 | Line 83 | register CUBE  *cu;
83          d2 = DOT(v1,v1);
84  
85          if (d2 > (rad+d1+FTINY)*(rad+d1+FTINY)) /* quick test */
86 <                return(0);                      /* cube outside */
86 >                return(O_MISS);                 /* cube outside */
87          
88                                          /* check sphere interior */
89          if (d1 < rad) {
90                  if (d2 < (rad-d1-FTINY)*(rad-d1-FTINY))
91 <                        return(0);              /* cube inside sphere */
91 >                        return(O_MISS);         /* cube inside sphere */
92                  if (d2 < (rad+FTINY)*(rad+FTINY))
93 <                        return(1);              /* cube center inside */
93 >                        return(O_HIT);          /* cube center inside */
94          }
95                                          /* find closest distance */
96          for (i = 0; i < 3; i++)
# Line 95 | Line 102 | register CUBE  *cu;
102                          v1[i] = 0;
103                                          /* final intersection check */
104          if (DOT(v1,v1) <= (rad+FTINY)*(rad+FTINY))
105 <                return(1);
105 >                return(O_HIT);
106          else
107 <                return(0);
107 >                return(O_MISS);
108   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines