5 |
|
* Rendering routines for rhpict. |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include <string.h> |
9 |
+ |
|
10 |
|
#include "holo.h" |
11 |
|
#include "view.h" |
12 |
|
#include "random.h" |
37 |
|
#define CLR4(f,i) FL4OP(f,i,&=~) |
38 |
|
#define TGL4(f,i) FL4OP(f,i,^=) |
39 |
|
#define FL4NELS(n) (((n)+0x1f)>>5) |
40 |
< |
#define CLR4ALL(f,n) bzero((char *)(f),FL4NELS(n)*sizeof(int32)) |
40 |
> |
#define CLR4ALL(f,n) memset((char *)(f),'\0',FL4NELS(n)*sizeof(int32)) |
41 |
|
#endif |
42 |
|
|
43 |
|
static int32 *pixFlags; /* pixel occupancy flags */ |
52 |
|
extern float *mydepth; /* depth values (visibility culling) */ |
53 |
|
extern int hres, vres; /* current horizontal and vertical res. */ |
54 |
|
|
55 |
+ |
extern void pixFinish(double ransamp); |
56 |
+ |
extern void pixBeam(BEAM *bp, HDBEAMI *hb); |
57 |
|
|
58 |
< |
pixBeam(bp, hb) /* render a particular beam */ |
59 |
< |
BEAM *bp; |
60 |
< |
register HDBEAMI *hb; |
58 |
> |
typedef int (sampfunc)(int h, int v, short nl[NNEIGH][2], int nd[NNEIGH], |
59 |
> |
int n, double *rf); |
60 |
> |
static sampfunc kill_occl; |
61 |
> |
static sampfunc smooth_samp; |
62 |
> |
static sampfunc random_samp; |
63 |
> |
static void meet_neighbors(int occ, sampfunc *nf, double *dp); |
64 |
> |
static void reset_flags(void); |
65 |
> |
static void init_wfunc(void); |
66 |
> |
static int findneigh(short nl[NNEIGH][2], int nd[NNEIGH], int h, int v, |
67 |
> |
register short (*rnl)[NNEIGH]); |
68 |
> |
|
69 |
> |
|
70 |
> |
extern void |
71 |
> |
pixBeam( /* render a particular beam */ |
72 |
> |
BEAM *bp, |
73 |
> |
register HDBEAMI *hb |
74 |
> |
) |
75 |
|
{ |
76 |
|
GCOORD gc[2]; |
77 |
|
register RAYVAL *rv; |
126 |
|
} |
127 |
|
|
128 |
|
|
129 |
< |
int |
130 |
< |
kill_occl(h, v, nl, nd, n) /* check for occlusion errors */ |
131 |
< |
int h, v; |
132 |
< |
register short nl[NNEIGH][2]; |
133 |
< |
int nd[NNEIGH]; |
134 |
< |
int n; |
129 |
> |
static int |
130 |
> |
kill_occl( /* check for occlusion errors */ |
131 |
> |
int h, |
132 |
> |
int v, |
133 |
> |
register short nl[NNEIGH][2], |
134 |
> |
int nd[NNEIGH], |
135 |
> |
int n, |
136 |
> |
double *rf |
137 |
> |
) |
138 |
|
{ |
139 |
|
short forequad[2][2]; |
140 |
|
int d; |
162 |
|
} |
163 |
|
|
164 |
|
|
165 |
< |
int |
166 |
< |
smooth_samp(h, v, nl, nd, n) /* grow sample point smoothly */ |
167 |
< |
int h, v; |
168 |
< |
register short nl[NNEIGH][2]; |
169 |
< |
int nd[NNEIGH]; |
170 |
< |
int n; |
165 |
> |
static int |
166 |
> |
smooth_samp( /* grow sample point smoothly */ |
167 |
> |
int h, |
168 |
> |
int v, |
169 |
> |
register short nl[NNEIGH][2], |
170 |
> |
int nd[NNEIGH], |
171 |
> |
int n, |
172 |
> |
double *rf |
173 |
> |
) |
174 |
|
{ |
175 |
|
int dis[NNEIGH], ndis; |
176 |
|
COLOR mykern[MAXRAD2]; |
227 |
|
} |
228 |
|
|
229 |
|
|
230 |
< |
int |
231 |
< |
random_samp(h, v, nl, nd, n, rf) /* gather samples randomly */ |
232 |
< |
int h, v; |
233 |
< |
register short nl[NNEIGH][2]; |
234 |
< |
int nd[NNEIGH]; |
235 |
< |
int n; |
236 |
< |
double *rf; |
230 |
> |
static int |
231 |
> |
random_samp( /* gather samples randomly */ |
232 |
> |
int h, |
233 |
> |
int v, |
234 |
> |
register short nl[NNEIGH][2], |
235 |
> |
int nd[NNEIGH], |
236 |
> |
int n, |
237 |
> |
double *rf |
238 |
> |
) |
239 |
|
{ |
240 |
|
float rnt[NNEIGH]; |
241 |
|
double rvar; |
263 |
|
} |
264 |
|
|
265 |
|
|
266 |
< |
pixFinish(ransamp) /* done with beams -- compute pixel values */ |
267 |
< |
double ransamp; |
266 |
> |
extern void |
267 |
> |
pixFinish( /* done with beams -- compute pixel values */ |
268 |
> |
double ransamp |
269 |
> |
) |
270 |
|
{ |
271 |
|
if (pixWeight[0] <= FTINY) |
272 |
|
init_wfunc(); /* initialize weighting function */ |
282 |
|
} |
283 |
|
|
284 |
|
|
285 |
< |
reset_flags() /* allocate/set/reset occupancy flags */ |
285 |
> |
static void |
286 |
> |
reset_flags(void) /* allocate/set/reset occupancy flags */ |
287 |
|
{ |
288 |
|
register int32 p; |
289 |
|
|
298 |
|
} |
299 |
|
|
300 |
|
|
301 |
< |
init_wfunc() /* initialize weighting function */ |
301 |
> |
static void |
302 |
> |
init_wfunc(void) /* initialize weighting function */ |
303 |
|
{ |
304 |
|
register int r2; |
305 |
|
register double d; |
314 |
|
} |
315 |
|
|
316 |
|
|
317 |
< |
int |
318 |
< |
findneigh(nl, nd, h, v, rnl) /* find NNEIGH neighbors for pixel */ |
319 |
< |
short nl[NNEIGH][2]; |
320 |
< |
int nd[NNEIGH]; |
321 |
< |
int h, v; |
322 |
< |
register short (*rnl)[NNEIGH]; |
317 |
> |
static int |
318 |
> |
findneigh( /* find NNEIGH neighbors for pixel */ |
319 |
> |
short nl[NNEIGH][2], |
320 |
> |
int nd[NNEIGH], |
321 |
> |
int h, |
322 |
> |
int v, |
323 |
> |
register short (*rnl)[NNEIGH] |
324 |
> |
) |
325 |
|
{ |
326 |
|
int nn = 0; |
327 |
|
int d, n, hoff; |
330 |
|
nd[NNEIGH-1] = MAXRAD2; |
331 |
|
for (hoff = 0; hoff < hres; hoff = (hoff<=0) - hoff) { |
332 |
|
h2 = h + hoff; |
333 |
< |
if (h2 < 0 | h2 >= hres) |
333 |
> |
if ((h2 < 0) | (h2 >= hres)) |
334 |
|
continue; |
335 |
|
if ((h2-h)*(h2-h) >= nd[NNEIGH-1]) |
336 |
|
break; |
337 |
|
for (n = 0; n < NNEIGH && rnl[h2][n] < NINF; n++) { |
338 |
|
d = (h2-h)*(h2-h) + (v-rnl[h2][n])*(v-rnl[h2][n]); |
339 |
< |
if (d == 0 | d >= nd[NNEIGH-1]) |
339 |
> |
if ((d == 0) | (d >= nd[NNEIGH-1])) |
340 |
|
continue; |
341 |
|
if (nn < NNEIGH) /* insert neighbor */ |
342 |
|
nn++; |
357 |
|
} |
358 |
|
|
359 |
|
|
360 |
< |
meet_neighbors(occ, nf, dp) /* run through samples and their neighbors */ |
361 |
< |
int occ; |
362 |
< |
int (*nf)(); |
363 |
< |
char *dp; |
360 |
> |
static void |
361 |
> |
meet_neighbors( /* run through samples and their neighbors */ |
362 |
> |
int occ, |
363 |
> |
sampfunc *nf, |
364 |
> |
double *dp |
365 |
> |
) |
366 |
|
{ |
367 |
|
short ln[NNEIGH][2]; |
368 |
|
int nd[NNEIGH]; |