1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
26 |
|
|
27 |
|
int do_outside = 0; /* render from outside sections */ |
28 |
|
|
29 |
+ |
double eyesepdist = 1; /* eye separation distance */ |
30 |
+ |
|
31 |
|
char *progname; /* global argv[0] */ |
32 |
|
|
33 |
|
FILE *sstdin, *sstdout; /* server's standard input and output */ |
95 |
|
if (inp & DFL(DC_PAUSE)) |
96 |
|
pause = 1; |
97 |
|
if (inp & DFL(DC_REDRAW)) |
98 |
< |
imm_mode = beam_sync() > 0; |
98 |
> |
imm_mode = beam_sync(1) > 0; |
99 |
|
if (inp & DFL(DC_KILL)) { |
100 |
|
serv_request(DR_KILL, 0, NULL); |
101 |
|
pause = 0; |
161 |
|
n = odev.ifd+1; |
162 |
|
if (sstdin != NULL) { |
163 |
|
FD_SET(fileno(sstdin), &readset); |
164 |
+ |
FD_SET(fileno(sstdin), &errset); |
165 |
|
if (fileno(sstdin) >= n) |
166 |
|
n = fileno(sstdin) + 1; |
167 |
|
} |
176 |
|
flgs |= RDY_SRV; |
177 |
|
if (FD_ISSET(odev.ifd, &readset) || FD_ISSET(odev.ifd, &errset)) |
178 |
|
flgs |= RDY_DEV; |
179 |
< |
if (sstdin != NULL && FD_ISSET(fileno(sstdin), &readset)) |
179 |
> |
if (sstdin != NULL && (FD_ISSET(fileno(sstdin), &readset) || |
180 |
> |
FD_ISSET(fileno(sstdin), &errset))) |
181 |
|
flgs |= RDY_SIN; |
182 |
|
return(flgs); |
183 |
|
} |
234 |
|
for (i = p->nr; i--; ) { |
235 |
|
hdray(ro, rd, hdlist[p->hd], gc, packra(p)[i].r); |
236 |
|
d = hddepth(hdlist[p->hd], packra(p)[i].d); |
237 |
< |
VSUM(wp, ro, rd, d); /* might be behind viewpoint */ |
238 |
< |
dev_value(packra(p)[i].v, wp, rd); |
237 |
> |
if (d < .99*FHUGE) { |
238 |
> |
VSUM(wp, ro, rd, d); /* might be behind viewpoint */ |
239 |
> |
dev_value(packra(p)[i].v, rd, wp); |
240 |
> |
} else |
241 |
> |
dev_value(packra(p)[i].v, rd, NULL); |
242 |
|
} |
243 |
|
#ifdef DEBUG |
244 |
|
if (imm_mode) nimmrays += p->nr; |
252 |
|
{ |
253 |
|
static VIEW viewhist[VIEWHISTLEN]; |
254 |
|
static unsigned nhist; |
255 |
+ |
VIEW *dv; |
256 |
+ |
int i, res[2]; |
257 |
|
char *err; |
258 |
|
/* restore previous view? */ |
259 |
|
if (v == NULL) { |
273 |
|
error(COMMAND, "cannot handle parallel views"); |
274 |
|
return; |
275 |
|
} |
276 |
< |
if (!dev_view(v)) /* update display driver */ |
276 |
> |
if (!dev_view(v)) /* notify display driver */ |
277 |
|
goto again; |
278 |
|
dev_flush(); /* update screen */ |
279 |
< |
if (!beam_view(v)) /* update beam list */ |
280 |
< |
goto again; |
279 |
> |
beam_init(0); /* compute new beam set */ |
280 |
> |
for (i = 0; (dv = dev_auxview(i, res)) != NULL; i++) |
281 |
> |
if (!beam_view(dv, res[0], res[1])) { |
282 |
> |
if (!nhist) { |
283 |
> |
error(COMMAND, "invalid starting view"); |
284 |
> |
return; |
285 |
> |
} |
286 |
> |
copystruct(v, viewhist + ((nhist-1)%VIEWHISTLEN)); |
287 |
> |
goto again; |
288 |
> |
} |
289 |
> |
beam_sync(0); /* update server */ |
290 |
|
/* record new view */ |
291 |
|
if (v < viewhist || v >= viewhist+VIEWHISTLEN) { |
292 |
|
copystruct(viewhist + (nhist%VIEWHISTLEN), v); |
299 |
|
usr_input() /* get user input and process it */ |
300 |
|
{ |
301 |
|
VIEW vparams; |
302 |
< |
char cmd[128]; |
302 |
> |
char cmd[256]; |
303 |
|
register char *args; |
304 |
|
register int i; |
305 |
|
|
306 |
< |
if (fgets(cmd, sizeof(cmd), sstdin) == NULL) |
307 |
< |
return(DC_QUIT); |
306 |
> |
if (fgets(cmd, sizeof(cmd), sstdin) == NULL) { |
307 |
> |
fclose(sstdin); |
308 |
> |
sstdin = NULL; |
309 |
> |
return(-1); |
310 |
> |
} |
311 |
> |
if (!*cmd) |
312 |
> |
return(DC_RESUME); |
313 |
|
for (args = cmd; *args && !isspace(*args); args++) |
314 |
|
; |
315 |
|
while (isspace(*args)) |
316 |
|
*args++ = '\0'; |
294 |
– |
if (!*cmd) |
295 |
– |
return(DC_RESUME); |
317 |
|
if (*args && args[i=strlen(args)-1] == '\n') |
318 |
|
args[i] = '\0'; |
319 |
|
for (i = 0; i < DC_NCMDS; i++) |
320 |
|
if (!strcmp(cmd, cmdlist[i])) |
321 |
|
break; |
322 |
|
if (i >= DC_NCMDS) { |
323 |
< |
sprintf(errmsg, "unknown command: %s", cmd); |
303 |
< |
error(COMMAND, errmsg); |
323 |
> |
dev_auxcom(cmd, args); |
324 |
|
return(-1); |
325 |
|
} |
326 |
|
switch (i) { |
342 |
|
/* handled in main() */ |
343 |
|
break; |
344 |
|
case DC_REDRAW: /* redraw from server */ |
345 |
< |
imm_mode = beam_sync() > 0; |
345 |
> |
imm_mode = beam_sync(1) > 0; |
346 |
> |
dev_clear(); |
347 |
|
break; |
348 |
|
case DC_KILL: /* kill rtrace process(es) */ |
349 |
|
serv_request(DR_KILL, 0, NULL); |
409 |
|
break; |
410 |
|
case DS_OUTSECT: |
411 |
|
do_outside = 1; |
412 |
+ |
goto noargs; |
413 |
+ |
case DS_EYESEP: |
414 |
+ |
if (msg.nbytes <= 1 || (eyesepdist = atof(buf)) <= FTINY) |
415 |
+ |
error(INTERNAL, "bad eye separation from server"); |
416 |
|
break; |
417 |
|
case DS_STARTIMM: |
418 |
|
case DS_ENDIMM: |
425 |
|
} |
426 |
|
#endif |
427 |
|
imm_mode = msg.type==DS_STARTIMM; |
428 |
< |
/* fall through */ |
428 |
> |
goto noargs; |
429 |
|
case DS_ACKNOW: |
430 |
|
case DS_SHUTDOWN: |
431 |
< |
if (msg.nbytes) { |
407 |
< |
sprintf(errmsg, |
408 |
< |
"unexpected body with server message %d", |
409 |
< |
msg.type); |
410 |
< |
error(INTERNAL, errmsg); |
411 |
< |
} |
412 |
< |
break; |
431 |
> |
goto noargs; |
432 |
|
default: |
433 |
|
error(INTERNAL, "unrecognized result from server process"); |
434 |
|
} |
435 |
|
return(msg.type); /* return message type */ |
436 |
+ |
noargs: |
437 |
+ |
if (msg.nbytes) { |
438 |
+ |
sprintf(errmsg, "unexpected body with server message %d", |
439 |
+ |
msg.type); |
440 |
+ |
error(INTERNAL, errmsg); |
441 |
+ |
} |
442 |
+ |
return(msg.type); |
443 |
|
readerr: |
444 |
|
if (feof(stdin)) |
445 |
|
error(SYSTEM, "server process died"); |