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

Comparing ray/src/rt/o_mesh.c (file contents):
Revision 2.1 by greg, Tue Mar 11 17:08:55 2003 UTC vs.
Revision 2.4 by greg, Wed Mar 12 17:26:58 2003 UTC

# Line 28 | Line 28 | static const char RCSid[] = "$Id$";
28   #include  "tmesh.h"
29  
30  
31 < #define  EDGE_CACHE_SIZ         109     /* length of mesh edge cache */
31 > #define  EDGE_CACHE_SIZ         251     /* length of mesh edge cache */
32  
33   #define  curmi                  (edge_cache.mi)
34   #define  curmsh                 (curmi->msh)
# Line 68 | Line 68 | int4           v1, v2;
68                  int4    t = v2; v2 = v1; v1 = t;
69                  reversed = 1;
70          }
71 <        ecp = &edge_cache.cache[(v2<<11 ^ v1) % EDGE_CACHE_SIZ];
71 >        ecp = &edge_cache.cache[((v2<<11 ^ v1) & 0x7fffffff) % EDGE_CACHE_SIZ];
72          if (ecp->v1i != v1 || ecp->v2i != v2) {
73                  MESHVERT        tv1, tv2;       /* compute signed volume */
74 +                FVECT           v2d;
75                  double          vol;
76                  if (!getmeshvert(&tv1, edge_cache.mi->msh, v1, MT_V) ||
77 <                                !getmeshvert(&tv2, edge_cache.mi->msh, v2, MT_V))
77 >                            !getmeshvert(&tv2, edge_cache.mi->msh, v2, MT_V))
78                          objerror(edge_cache.o, INTERNAL,
79 <                                        "missing mesh vertex in signed_volume");
79 >                                "missing mesh vertex in signed_volume");
80 >                VSUB(v2d, tv2.v, r->rorg);
81                  vol = (tv1.v[0] - r->rorg[0]) *
82 <                                ( (tv2.v[1] - r->rorg[1])*r->rdir[2] -
81 <                                  (tv2.v[2] - r->rorg[2])*r->rdir[1] );
82 >                                (v2d[1]*r->rdir[2] - v2d[2]*r->rdir[1]);
83                  vol += (tv1.v[1] - r->rorg[1]) *
84 <                                ( (tv2.v[2] - r->rorg[2])*r->rdir[0] -
84 <                                  (tv2.v[0] - r->rorg[0])*r->rdir[2] );
84 >                                (v2d[2]*r->rdir[0] - v2d[0]*r->rdir[2]);
85                  vol += (tv1.v[2] - r->rorg[2]) *
86 <                                ( (tv2.v[0] - r->rorg[0])*r->rdir[1] -
87 <                                  (tv2.v[1] - r->rorg[1])*r->rdir[0] );
86 >                                (v2d[0]*r->rdir[1] - v2d[1]*r->rdir[0]);
87                  if (vol > .0)
88                          ecp->signum = 1;
89                  else if (vol < .0)
# Line 113 | Line 112 | RAY    *r;
112          for (i = oset[0]; i > 0; i--) {
113                  if (!getmeshtrivid(tvi, curmsh, oset[i]))
114                          objerror(edge_cache.o, INTERNAL,
115 <                                        "missing triangle vertices in mesh_hit");
115 >                                "missing triangle vertices in mesh_hit");
116                  sv1 = signed_volume(r, tvi[0], tvi[1]);
117                  sv2 = signed_volume(r, tvi[1], tvi[2]);
118                  sv3 = signed_volume(r, tvi[2], tvi[0]);
# Line 139 | Line 138 | RAY    *r;
138                  r->rot = d;
139                  VSUM(r->rop, r->rorg, r->rdir, d);
140                  VCOPY(r->ron, nrm);
141 <                /* normalize(r->ron) called in o_mesh() & rod set */
141 >                /* normalize(r->ron) called & r->rod set in o_mesh() */
142          }
143   }
144  
# Line 197 | Line 196 | register RAY   *r;
196                  if (normalize(r->pert) != 0.0)
197                          for (i = 0; i < 3; i++)
198                                  r->pert[i] -= r->ron[i];
199 <        }
199 >        } else
200 >                r->pert[0] = r->pert[1] = r->pert[2] = .0;
201 >
202          if (flags & MT_UV)              /* interpolate uv coordinates */
203                  for (i = 0; i < 2; i++)
204                          r->uv[i] = wt[0]*tv[0].uv[i] +
205                                          wt[1]*tv[1].uv[i] +
206                                          wt[2]*tv[2].uv[i];
207 +        else
208 +                r->uv[0] = r->uv[1] = .0;
209  
210                                          /* return hit */
211          return(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines