21 |
|
|
22 |
|
#include "copyright.h" |
23 |
|
|
24 |
< |
#include "ray.h" |
24 |
> |
#include <string.h> |
25 |
|
|
26 |
+ |
#include "ray.h" |
27 |
|
#include "mesh.h" |
27 |
– |
|
28 |
|
#include "tmesh.h" |
29 |
+ |
#include "rtotypes.h" |
30 |
|
|
31 |
|
|
32 |
|
#define EDGE_CACHE_SIZ 251 /* length of mesh edge cache */ |
40 |
|
OBJREC *o; /* mesh object */ |
41 |
|
MESHINST *mi; /* current mesh instance */ |
42 |
|
struct EdgeSide { |
43 |
< |
int4 v1i, v2i; /* vertex indices (lowest first) */ |
43 |
> |
int32 v1i, v2i; /* vertex indices (lowest first) */ |
44 |
|
short signum; /* signed volume */ |
45 |
|
} cache[EDGE_CACHE_SIZ]; |
46 |
|
} edge_cache; |
53 |
|
/* get mesh instance */ |
54 |
|
edge_cache.mi = getmeshinst(edge_cache.o = o, IO_ALL); |
55 |
|
/* clear edge cache */ |
56 |
< |
bzero((void *)edge_cache.cache, sizeof(edge_cache.cache)); |
56 |
> |
memset((void *)edge_cache.cache, '\0', sizeof(edge_cache.cache)); |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
static int |
61 |
|
signed_volume(r, v1, v2) /* get signed volume for ray and edge */ |
62 |
|
register RAY *r; |
63 |
< |
int4 v1, v2; |
63 |
> |
int32 v1, v2; |
64 |
|
{ |
65 |
|
int reversed = 0; |
66 |
|
register struct EdgeSide *ecp; |
67 |
|
|
68 |
|
if (v1 > v2) { |
69 |
< |
int4 t = v2; v2 = v1; v1 = t; |
69 |
> |
int32 t = v2; v2 = v1; v1 = t; |
70 |
|
reversed = 1; |
71 |
|
} |
72 |
|
ecp = &edge_cache.cache[((v2<<11 ^ v1) & 0x7fffffff) % EDGE_CACHE_SIZ]; |
103 |
|
OBJECT *oset; |
104 |
|
RAY *r; |
105 |
|
{ |
106 |
< |
int4 tvi[3]; |
106 |
> |
int32 tvi[3]; |
107 |
|
int sv1, sv2, sv3; |
108 |
|
MESHVERT tv[3]; |
109 |
|
OBJECT tmod; |
145 |
|
} |
146 |
|
|
147 |
|
|
148 |
< |
int |
149 |
< |
o_mesh(o, r) /* compute ray intersection with a mesh */ |
150 |
< |
OBJREC *o; |
151 |
< |
register RAY *r; |
148 |
> |
extern int |
149 |
> |
o_mesh( /* compute ray intersection with a mesh */ |
150 |
> |
OBJREC *o, |
151 |
> |
register RAY *r |
152 |
> |
) |
153 |
|
{ |
154 |
|
RAY rcont; |
155 |
|
int flags; |
156 |
|
MESHVERT tv[3]; |
157 |
|
OBJECT tmod; |
158 |
< |
FLOAT wt[3]; |
158 |
> |
RREAL wt[3]; |
159 |
|
int i; |
160 |
|
/* get the mesh instance */ |
161 |
|
prep_edge_cache(o); |
162 |
|
/* copy and transform ray */ |
163 |
< |
copystruct(&rcont, r); |
163 |
> |
rcont = *r; |
164 |
|
multp3(rcont.rorg, r->rorg, curmi->x.b.xfm); |
165 |
|
multv3(rcont.rdir, r->rdir, curmi->x.b.xfm); |
166 |
|
for (i = 0; i < 3; i++) |