7 |
|
* External symbols declared in rpaint.h |
8 |
|
*/ |
9 |
|
|
10 |
< |
/* ==================================================================== |
11 |
< |
* The Radiance Software License, Version 1.0 |
12 |
< |
* |
13 |
< |
* Copyright (c) 1990 - 2002 The Regents of the University of California, |
14 |
< |
* through Lawrence Berkeley National Laboratory. All rights reserved. |
15 |
< |
* |
16 |
< |
* Redistribution and use in source and binary forms, with or without |
17 |
< |
* modification, are permitted provided that the following conditions |
18 |
< |
* are met: |
19 |
< |
* |
20 |
< |
* 1. Redistributions of source code must retain the above copyright |
21 |
< |
* notice, this list of conditions and the following disclaimer. |
22 |
< |
* |
23 |
< |
* 2. Redistributions in binary form must reproduce the above copyright |
24 |
< |
* notice, this list of conditions and the following disclaimer in |
25 |
< |
* the documentation and/or other materials provided with the |
26 |
< |
* distribution. |
27 |
< |
* |
28 |
< |
* 3. The end-user documentation included with the redistribution, |
29 |
< |
* if any, must include the following acknowledgment: |
30 |
< |
* "This product includes Radiance software |
31 |
< |
* (http://radsite.lbl.gov/) |
32 |
< |
* developed by the Lawrence Berkeley National Laboratory |
33 |
< |
* (http://www.lbl.gov/)." |
34 |
< |
* Alternately, this acknowledgment may appear in the software itself, |
35 |
< |
* if and wherever such third-party acknowledgments normally appear. |
36 |
< |
* |
37 |
< |
* 4. The names "Radiance," "Lawrence Berkeley National Laboratory" |
38 |
< |
* and "The Regents of the University of California" must |
39 |
< |
* not be used to endorse or promote products derived from this |
40 |
< |
* software without prior written permission. For written |
41 |
< |
* permission, please contact [email protected]. |
42 |
< |
* |
43 |
< |
* 5. Products derived from this software may not be called "Radiance", |
44 |
< |
* nor may "Radiance" appear in their name, without prior written |
45 |
< |
* permission of Lawrence Berkeley National Laboratory. |
46 |
< |
* |
47 |
< |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
48 |
< |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
49 |
< |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
50 |
< |
* DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR |
51 |
< |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
52 |
< |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
53 |
< |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
54 |
< |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
55 |
< |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
56 |
< |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
57 |
< |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
58 |
< |
* SUCH DAMAGE. |
59 |
< |
* ==================================================================== |
60 |
< |
* |
61 |
< |
* This software consists of voluntary contributions made by many |
62 |
< |
* individuals on behalf of Lawrence Berkeley National Laboratory. For more |
63 |
< |
* information on Lawrence Berkeley National Laboratory, please see |
64 |
< |
* <http://www.lbl.gov/>. |
65 |
< |
*/ |
10 |
> |
#include "copyright.h" |
11 |
|
|
12 |
< |
#include "ray.h" |
12 |
> |
#include <string.h> |
13 |
|
|
14 |
+ |
#include "ray.h" |
15 |
|
#include "rpaint.h" |
70 |
– |
|
16 |
|
#include "random.h" |
17 |
|
|
18 |
|
#ifndef WFLUSH |
19 |
< |
#ifdef SPEED |
75 |
< |
#define WFLUSH (5*SPEED) |
76 |
< |
#else |
77 |
< |
#define WFLUSH 100 /* flush after this many rays */ |
19 |
> |
#define WFLUSH 64 /* flush after this many rays */ |
20 |
|
#endif |
79 |
– |
#endif |
21 |
|
|
22 |
|
#ifdef SMLFLT |
23 |
|
#define sscanvec(s,v) (sscanf(s,"%f %f %f",v,v+1,v+2)==3) |
25 |
|
#define sscanvec(s,v) (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3) |
26 |
|
#endif |
27 |
|
|
28 |
+ |
static unsigned long niflush; /* flushes since newimage() */ |
29 |
|
|
30 |
|
int |
31 |
< |
getrect(s, r) /* get a box */ |
32 |
< |
char *s; |
33 |
< |
register RECT *r; |
31 |
> |
getrect( /* get a box */ |
32 |
> |
char *s, |
33 |
> |
RECT *r |
34 |
> |
) |
35 |
|
{ |
36 |
|
int x0, y0, x1, y1; |
37 |
|
|
76 |
|
|
77 |
|
|
78 |
|
int |
79 |
< |
getinterest(s, direc, vec, mp) /* get area of interest */ |
80 |
< |
char *s; |
81 |
< |
int direc; |
82 |
< |
FVECT vec; |
83 |
< |
double *mp; |
79 |
> |
getinterest( /* get area of interest */ |
80 |
> |
char *s, |
81 |
> |
int direc, |
82 |
> |
FVECT vec, |
83 |
> |
double *mp |
84 |
> |
) |
85 |
|
{ |
86 |
|
int x, y; |
87 |
|
RAY thisray; |
88 |
< |
register int i; |
88 |
> |
int i; |
89 |
|
|
90 |
|
if (sscanf(s, "%lf", mp) != 1) |
91 |
|
*mp = 1.0; |
107 |
|
return(-1); |
108 |
|
} |
109 |
|
if (!direc || ourview.type == VT_PAR) { |
110 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
110 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
111 |
|
if (!localhit(&thisray, &thescene)) { |
112 |
|
error(COMMAND, "not a local object"); |
113 |
|
return(-1); |
121 |
|
VCOPY(vec, thisray.rdir); |
122 |
|
else |
123 |
|
VCOPY(vec, thisray.rop); |
124 |
< |
} else if (direc) |
125 |
< |
for (i = 0; i < 3; i++) |
126 |
< |
vec[i] -= ourview.vp[i]; |
124 |
> |
} else if (direc) { |
125 |
> |
for (i = 0; i < 3; i++) |
126 |
> |
vec[i] -= ourview.vp[i]; |
127 |
> |
if (normalize(vec) == 0.0) { |
128 |
> |
error(COMMAND, "point at view origin"); |
129 |
> |
return(-1); |
130 |
> |
} |
131 |
> |
} |
132 |
|
return(0); |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
float * /* keep consistent with COLOR typedef */ |
137 |
< |
greyof(col) /* convert color to greyscale */ |
138 |
< |
register COLOR col; |
137 |
> |
greyof( /* convert color to greyscale */ |
138 |
> |
COLOR col |
139 |
> |
) |
140 |
|
{ |
141 |
|
static COLOR gcol; |
142 |
|
double b; |
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
< |
void |
151 |
< |
paint(p, xmin, ymin, xmax, ymax) /* compute and paint a rectangle */ |
152 |
< |
register PNODE *p; |
153 |
< |
int xmin, ymin, xmax, ymax; |
150 |
> |
int |
151 |
> |
paint( /* compute and paint a rectangle */ |
152 |
> |
PNODE *p |
153 |
> |
) |
154 |
|
{ |
155 |
+ |
extern int ray_pnprocs; |
156 |
|
static unsigned long lastflush = 0; |
157 |
|
static RAY thisray; |
158 |
+ |
int flushintvl; |
159 |
|
double h, v; |
160 |
|
|
161 |
< |
if (xmax - xmin <= 0 || ymax - ymin <= 0) { /* empty */ |
162 |
< |
p->x = xmin; |
163 |
< |
p->y = ymin; |
161 |
> |
if (p->xmax - p->xmin <= 0 || p->ymax - p->ymin <= 0) { /* empty */ |
162 |
> |
p->x = p->xmin; |
163 |
> |
p->y = p->ymin; |
164 |
|
setcolor(p->v, 0.0, 0.0, 0.0); |
165 |
< |
return; |
165 |
> |
return(0); |
166 |
|
} |
167 |
|
/* jitter ray direction */ |
168 |
< |
h = xmin + (xmax-xmin)*frandom(); |
169 |
< |
v = ymin + (ymax-ymin)*frandom(); |
168 |
> |
p->x = h = p->xmin + (p->xmax-p->xmin)*frandom(); |
169 |
> |
p->y = v = p->ymin + (p->ymax-p->ymin)*frandom(); |
170 |
|
|
171 |
|
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview, |
172 |
|
h/hresolu, v/vresolu)) < -FTINY) { |
173 |
|
setcolor(thisray.rcol, 0.0, 0.0, 0.0); |
174 |
|
} else { |
175 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
176 |
< |
samplendx++; |
177 |
< |
rayvalue(&thisray); |
175 |
> |
int rval; |
176 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
177 |
> |
thisray.rno = (unsigned long)p; |
178 |
> |
rval = ray_pqueue(&thisray); |
179 |
> |
if (!rval) |
180 |
> |
return(0); |
181 |
> |
if (rval < 0) |
182 |
> |
return(-1); |
183 |
> |
p = (PNODE *)thisray.rno; |
184 |
|
} |
185 |
|
|
228 |
– |
p->x = h; |
229 |
– |
p->y = v; |
186 |
|
copycolor(p->v, thisray.rcol); |
187 |
|
scalecolor(p->v, exposure); |
188 |
|
|
189 |
< |
(*dev->paintr)(greyscale?greyof(p->v):p->v, xmin, ymin, xmax, ymax); |
189 |
> |
while (p->kid != NULL) { /* need to propogate down */ |
190 |
> |
int mx = (p->xmin + p->xmax) >> 1; |
191 |
> |
int my = (p->ymin + p->ymax) >> 1; |
192 |
> |
int ki; |
193 |
> |
if (p->x >= mx) |
194 |
> |
ki = (p->y >= my) ? UR : DR; |
195 |
> |
else |
196 |
> |
ki = (p->y >= my) ? UL : DL; |
197 |
> |
pcopy(p, p->kid+ki); |
198 |
> |
p = p->kid + ki; |
199 |
> |
} |
200 |
|
|
201 |
< |
if (dev->flush != NULL && nrays - lastflush >= WFLUSH) { |
202 |
< |
lastflush = nrays; |
201 |
> |
(*dev->paintr)(greyscale?greyof(p->v):p->v, |
202 |
> |
p->xmin, p->ymin, p->xmax, p->ymax); |
203 |
> |
|
204 |
> |
if (ambounce <= 0) /* shall we check for input? */ |
205 |
> |
flushintvl = ray_pnprocs*WFLUSH; |
206 |
> |
else if (niflush < WFLUSH) |
207 |
> |
flushintvl = ray_pnprocs*niflush/(ambounce+1); |
208 |
> |
else |
209 |
> |
flushintvl = ray_pnprocs*WFLUSH/(ambounce+1); |
210 |
> |
|
211 |
> |
if (dev->flush != NULL && raynum - lastflush >= flushintvl) { |
212 |
> |
lastflush = raynum; |
213 |
|
(*dev->flush)(); |
214 |
+ |
niflush++; |
215 |
|
} |
216 |
+ |
return(1); |
217 |
|
} |
218 |
|
|
219 |
|
|
220 |
+ |
int |
221 |
+ |
waitrays(void) /* finish up pending rays */ |
222 |
+ |
{ |
223 |
+ |
int nwaited = 0; |
224 |
+ |
int rval; |
225 |
+ |
RAY raydone; |
226 |
+ |
|
227 |
+ |
while ((rval = ray_presult(&raydone, 0)) > 0) { |
228 |
+ |
PNODE *p = (PNODE *)raydone.rno; |
229 |
+ |
copycolor(p->v, raydone.rcol); |
230 |
+ |
scalecolor(p->v, exposure); |
231 |
+ |
(*dev->paintr)(greyscale?greyof(p->v):p->v, |
232 |
+ |
p->xmin, p->ymin, p->xmax, p->ymax); |
233 |
+ |
nwaited++; |
234 |
+ |
} |
235 |
+ |
if (rval < 0) |
236 |
+ |
return(-1); |
237 |
+ |
return(nwaited); |
238 |
+ |
} |
239 |
+ |
|
240 |
+ |
|
241 |
|
void |
242 |
< |
newimage() /* start a new image */ |
242 |
> |
newimage( /* start a new image */ |
243 |
> |
char *s |
244 |
> |
) |
245 |
|
{ |
246 |
+ |
int newnp; |
247 |
+ |
/* change in nproc? */ |
248 |
+ |
if (s != NULL && sscanf(s, "%d", &newnp) == 1 && newnp > 0) { |
249 |
+ |
if (!newparam) { |
250 |
+ |
if (newnp < nproc) |
251 |
+ |
ray_pclose(nproc - newnp); |
252 |
+ |
else |
253 |
+ |
ray_popen(newnp - nproc); |
254 |
+ |
} |
255 |
+ |
nproc = newnp; |
256 |
+ |
} |
257 |
|
/* free old image */ |
258 |
|
freepkids(&ptrunk); |
247 |
– |
/* save reserve memory */ |
248 |
– |
fillreserves(); |
259 |
|
/* compute resolution */ |
260 |
|
hresolu = dev->xsiz; |
261 |
|
vresolu = dev->ysiz; |
262 |
|
normaspect(viewaspect(&ourview), &dev->pixaspect, &hresolu, &vresolu); |
263 |
< |
pframe.l = pframe.d = 0; |
264 |
< |
pframe.r = hresolu; pframe.u = vresolu; |
263 |
> |
ptrunk.xmin = ptrunk.ymin = pframe.l = pframe.d = 0; |
264 |
> |
ptrunk.xmax = pframe.r = hresolu; |
265 |
> |
ptrunk.ymax = pframe.u = vresolu; |
266 |
|
pdepth = 0; |
267 |
|
/* clear device */ |
268 |
|
(*dev->clear)(hresolu, vresolu); |
269 |
< |
/* get first value */ |
270 |
< |
paint(&ptrunk, 0, 0, hresolu, vresolu); |
269 |
> |
|
270 |
> |
if (newparam) { /* (re)start rendering procs */ |
271 |
> |
ray_pclose(0); |
272 |
> |
ray_popen(nproc); |
273 |
> |
newparam = 0; |
274 |
> |
} |
275 |
> |
niflush = 0; /* get first value */ |
276 |
> |
paint(&ptrunk); |
277 |
|
} |
278 |
|
|
279 |
|
|
280 |
|
void |
281 |
< |
redraw() /* redraw the image */ |
281 |
> |
redraw(void) /* redraw the image */ |
282 |
|
{ |
283 |
|
(*dev->clear)(hresolu, vresolu); |
284 |
|
(*dev->comout)("redrawing...\n"); |
288 |
|
|
289 |
|
|
290 |
|
void |
291 |
< |
repaint(xmin, ymin, xmax, ymax) /* repaint a region */ |
292 |
< |
int xmin, ymin, xmax, ymax; |
291 |
> |
repaint( /* repaint a region */ |
292 |
> |
int xmin, |
293 |
> |
int ymin, |
294 |
> |
int xmax, |
295 |
> |
int ymax |
296 |
> |
) |
297 |
|
{ |
298 |
|
RECT reg; |
299 |
|
|
300 |
|
reg.l = xmin; reg.r = xmax; |
301 |
|
reg.d = ymin; reg.u = ymax; |
302 |
|
|
303 |
< |
paintrect(&ptrunk, 0, 0, hresolu, vresolu, ®); |
303 |
> |
paintrect(&ptrunk, ®); |
304 |
|
} |
305 |
|
|
306 |
|
|
307 |
|
void |
308 |
< |
paintrect(p, xmin, ymin, xmax, ymax, r) /* paint picture rectangle */ |
309 |
< |
register PNODE *p; |
310 |
< |
int xmin, ymin, xmax, ymax; |
311 |
< |
register RECT *r; |
308 |
> |
paintrect( /* paint picture rectangle */ |
309 |
> |
PNODE *p, |
310 |
> |
RECT *r |
311 |
> |
) |
312 |
|
{ |
313 |
|
int mx, my; |
314 |
|
|
315 |
< |
if (xmax - xmin <= 0 || ymax - ymin <= 0) |
315 |
> |
if (p->xmax - p->xmin <= 0 || p->ymax - p->ymin <= 0) |
316 |
|
return; |
317 |
|
|
318 |
|
if (p->kid == NULL) { |
319 |
|
(*dev->paintr)(greyscale?greyof(p->v):p->v, |
320 |
< |
xmin, ymin, xmax, ymax); /* do this */ |
320 |
> |
p->xmin, p->ymin, p->xmax, p->ymax); /* do this */ |
321 |
|
return; |
322 |
|
} |
323 |
< |
mx = (xmin + xmax) >> 1; /* do kids */ |
324 |
< |
my = (ymin + ymax) >> 1; |
323 |
> |
mx = (p->xmin + p->xmax) >> 1; /* do kids */ |
324 |
> |
my = (p->ymin + p->ymax) >> 1; |
325 |
|
if (mx > r->l) { |
326 |
|
if (my > r->d) |
327 |
< |
paintrect(p->kid+DL, xmin, ymin, mx, my, r); |
327 |
> |
paintrect(p->kid+DL, r); |
328 |
|
if (my < r->u) |
329 |
< |
paintrect(p->kid+UL, xmin, my, mx, ymax, r); |
329 |
> |
paintrect(p->kid+UL, r); |
330 |
|
} |
331 |
|
if (mx < r->r) { |
332 |
|
if (my > r->d) |
333 |
< |
paintrect(p->kid+DR, mx, ymin, xmax, my, r); |
333 |
> |
paintrect(p->kid+DR, r); |
334 |
|
if (my < r->u) |
335 |
< |
paintrect(p->kid+UR, mx, my, xmax, ymax, r); |
335 |
> |
paintrect(p->kid+UR, r); |
336 |
|
} |
337 |
|
} |
338 |
|
|
339 |
|
|
340 |
|
PNODE * |
341 |
< |
findrect(x, y, p, r, pd) /* find a rectangle */ |
342 |
< |
int x, y; |
343 |
< |
register PNODE *p; |
344 |
< |
register RECT *r; |
345 |
< |
int pd; |
341 |
> |
findrect( /* find a rectangle */ |
342 |
> |
int x, |
343 |
> |
int y, |
344 |
> |
PNODE *p, |
345 |
> |
int pd |
346 |
> |
) |
347 |
|
{ |
348 |
|
int mx, my; |
349 |
|
|
350 |
|
while (p->kid != NULL && pd--) { |
351 |
|
|
352 |
< |
mx = (r->l + r->r) >> 1; |
353 |
< |
my = (r->d + r->u) >> 1; |
352 |
> |
mx = (p->xmin + p->xmax) >> 1; |
353 |
> |
my = (p->ymin + p->ymax) >> 1; |
354 |
|
|
355 |
|
if (x < mx) { |
334 |
– |
r->r = mx; |
356 |
|
if (y < my) { |
336 |
– |
r->u = my; |
357 |
|
p = p->kid+DL; |
358 |
|
} else { |
339 |
– |
r->d = my; |
359 |
|
p = p->kid+UL; |
360 |
|
} |
361 |
|
} else { |
343 |
– |
r->l = mx; |
362 |
|
if (y < my) { |
345 |
– |
r->u = my; |
363 |
|
p = p->kid+DR; |
364 |
|
} else { |
348 |
– |
r->d = my; |
365 |
|
p = p->kid+UR; |
366 |
|
} |
367 |
|
} |
371 |
|
|
372 |
|
|
373 |
|
void |
374 |
< |
scalepict(p, sf) /* scale picture values */ |
375 |
< |
register PNODE *p; |
376 |
< |
double sf; |
374 |
> |
scalepict( /* scale picture values */ |
375 |
> |
PNODE *p, |
376 |
> |
double sf |
377 |
> |
) |
378 |
|
{ |
379 |
|
scalecolor(p->v, sf); /* do this node */ |
380 |
|
|
389 |
|
|
390 |
|
|
391 |
|
void |
392 |
< |
getpictcolrs(yoff, scan, p, xsiz, ysiz) /* get scanline from picture */ |
393 |
< |
int yoff; |
394 |
< |
register COLR *scan; |
395 |
< |
register PNODE *p; |
396 |
< |
int xsiz, ysiz; |
392 |
> |
getpictcolrs( /* get scanline from picture */ |
393 |
> |
int yoff, |
394 |
> |
COLR *scan, |
395 |
> |
PNODE *p, |
396 |
> |
int xsiz, |
397 |
> |
int ysiz |
398 |
> |
) |
399 |
|
{ |
400 |
< |
register int mx; |
400 |
> |
int mx; |
401 |
|
int my; |
402 |
|
|
403 |
|
if (p->kid == NULL) { /* do this node */ |
422 |
|
|
423 |
|
|
424 |
|
void |
425 |
< |
freepkids(p) /* free pnode's children */ |
426 |
< |
register PNODE *p; |
425 |
> |
freepkids( /* free pnode's children */ |
426 |
> |
PNODE *p |
427 |
> |
) |
428 |
|
{ |
429 |
|
if (p->kid == NULL) |
430 |
|
return; |
438 |
|
|
439 |
|
|
440 |
|
void |
441 |
< |
newview(vp) /* change viewing parameters */ |
442 |
< |
register VIEW *vp; |
441 |
> |
newview( /* change viewing parameters */ |
442 |
> |
VIEW *vp |
443 |
> |
) |
444 |
|
{ |
445 |
|
char *err; |
446 |
|
|
447 |
|
if ((err = setview(vp)) != NULL) { |
448 |
|
sprintf(errmsg, "view not set - %s", err); |
449 |
|
error(COMMAND, errmsg); |
450 |
< |
} else if (bcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) { |
451 |
< |
copystruct(&oldview, &ourview); |
452 |
< |
copystruct(&ourview, vp); |
453 |
< |
newimage(); |
450 |
> |
} else if (memcmp((char *)vp, (char *)&ourview, sizeof(VIEW))) { |
451 |
> |
oldview = ourview; |
452 |
> |
ourview = *vp; |
453 |
> |
newimage(NULL); |
454 |
|
} |
455 |
|
} |
456 |
|
|
457 |
|
|
458 |
|
void |
459 |
< |
moveview(angle, elev, mag, vc) /* move viewpoint */ |
460 |
< |
double angle, elev, mag; |
461 |
< |
FVECT vc; |
459 |
> |
moveview( /* move viewpoint */ |
460 |
> |
double angle, |
461 |
> |
double elev, |
462 |
> |
double mag, |
463 |
> |
FVECT vc |
464 |
> |
) |
465 |
|
{ |
466 |
|
double d; |
467 |
|
FVECT v1; |
468 |
< |
VIEW nv; |
469 |
< |
register int i; |
468 |
> |
VIEW nv = ourview; |
469 |
> |
int i; |
470 |
|
|
447 |
– |
VCOPY(nv.vup, ourview.vup); |
448 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
471 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
472 |
|
if (elev != 0.0) { |
473 |
|
fcross(v1, ourview.vup, nv.vdir); |
474 |
|
normalize(v1); |
475 |
|
spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); |
476 |
|
} |
477 |
< |
if ((nv.type = ourview.type) == VT_PAR) { |
478 |
< |
nv.horiz = ourview.horiz / mag; |
479 |
< |
nv.vert = ourview.vert / mag; |
477 |
> |
if (nv.type == VT_PAR) { |
478 |
> |
nv.horiz /= mag; |
479 |
> |
nv.vert /= mag; |
480 |
|
d = 0.0; /* don't move closer */ |
481 |
|
for (i = 0; i < 3; i++) |
482 |
|
d += (vc[i] - ourview.vp[i])*ourview.vdir[i]; |
461 |
– |
nv.vfore = ourview.vfore; |
462 |
– |
nv.vaft = ourview.vaft; |
483 |
|
} else { |
464 |
– |
nv.horiz = ourview.horiz; |
465 |
– |
nv.vert = ourview.vert; |
484 |
|
d = sqrt(dist2(ourview.vp, vc)) / mag; |
485 |
< |
if ((nv.vfore = ourview.vfore) > FTINY) { |
485 |
> |
if (nv.vfore > FTINY) { |
486 |
|
nv.vfore += d - d*mag; |
487 |
|
if (nv.vfore < 0.0) nv.vfore = 0.0; |
488 |
|
} |
489 |
< |
if ((nv.vaft = ourview.vaft) > FTINY) { |
489 |
> |
if (nv.vaft > FTINY) { |
490 |
|
nv.vaft += d - d*mag; |
491 |
|
if (nv.vaft <= nv.vfore) nv.vaft = 0.0; |
492 |
|
} |
493 |
+ |
nv.vdist /= mag; |
494 |
|
} |
495 |
|
for (i = 0; i < 3; i++) |
496 |
|
nv.vp[i] = vc[i] - d*nv.vdir[i]; |
499 |
|
|
500 |
|
|
501 |
|
void |
502 |
< |
pcopy(p1, p2) /* copy paint node p1 into p2 */ |
503 |
< |
register PNODE *p1, *p2; |
502 |
> |
pcopy( /* copy paint node p1 into p2 */ |
503 |
> |
PNODE *p1, |
504 |
> |
PNODE *p2 |
505 |
> |
) |
506 |
|
{ |
507 |
|
copycolor(p2->v, p1->v); |
508 |
|
p2->x = p1->x; |
511 |
|
|
512 |
|
|
513 |
|
void |
514 |
< |
zoomview(vp, zf) /* zoom in or out */ |
515 |
< |
register VIEW *vp; |
516 |
< |
double zf; |
514 |
> |
zoomview( /* zoom in or out */ |
515 |
> |
VIEW *vp, |
516 |
> |
double zf |
517 |
> |
) |
518 |
|
{ |
519 |
|
switch (vp->type) { |
520 |
|
case VT_PAR: /* parallel view */ |
528 |
|
vp->vert /= zf; |
529 |
|
if (vp->vert > 360.) |
530 |
|
vp->vert = 360.; |
531 |
+ |
return; |
532 |
+ |
case VT_PLS: /* planisphere fisheye */ |
533 |
+ |
vp->horiz = sin((PI/180./2.)*vp->horiz) / |
534 |
+ |
(1.0 + cos((PI/180./2.)*vp->horiz)) / zf; |
535 |
+ |
vp->horiz *= vp->horiz; |
536 |
+ |
vp->horiz = (2.*180./PI)*acos((1. - vp->horiz) / |
537 |
+ |
(1. + vp->horiz)); |
538 |
+ |
vp->vert = sin((PI/180./2.)*vp->vert) / |
539 |
+ |
(1.0 + cos((PI/180./2.)*vp->vert)) / zf; |
540 |
+ |
vp->vert *= vp->vert; |
541 |
+ |
vp->vert = (2.*180./PI)*acos((1. - vp->vert) / |
542 |
+ |
(1. + vp->vert)); |
543 |
|
return; |
544 |
|
case VT_CYL: /* cylindrical panorama */ |
545 |
|
vp->horiz /= zf; |