--- ray/src/util/ranimate.c 1996/05/20 11:50:19 2.12 +++ ray/src/util/ranimate.c 1996/07/03 15:26:44 2.17 @@ -482,9 +482,9 @@ animate() /* run animation */ i = sscanf(vval(RESOLUTION), "%d %d %f", &xres, &yres, &pa); mult = vflt(OVERSAMP); if (i == 3) { - sprintf(rresopt, "-x %d -y %d -pa %f", (int)(mult*xres), + sprintf(rresopt, "-x %d -y %d -pa %.3f", (int)(mult*xres), (int)(mult*yres), pa); - sprintf(fresopt, "-x %d -y %d -pa %f", xres, yres, pa); + sprintf(fresopt, "-x %d -y %d -pa %.3f", xres, yres, pa); } else if (i) { if (i == 1) yres = xres; sprintf(rresopt, "-x %d -y %d", (int)(mult*xres), @@ -512,7 +512,7 @@ animate() /* run animation */ /* figure # frames per batch */ d1 = mult*xres*mult*yres*4; /* space for orig. picture */ if ((i=vint(INTERP)) || atoi(vval(MBLUR))) - d1 += mult*xres*mult*yres*4; /* space for z-buffer */ + d1 += mult*xres*mult*yres*sizeof(float); /* Z-buffer */ d2 = xres*yres*4; /* space for final picture */ frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2); if (frames_batch < i+2) { @@ -841,7 +841,7 @@ int rvr; while (*arcnext) arcnext++; strcpy(arcnext, ".unf"); arcnext += 4; - if (usepinterp || vint(INTERP)) { /* and z-buf */ + if (usepinterp || vint(INTERP)) { /* and Z-buf */ *arcnext++ = ' '; sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1); @@ -987,7 +987,7 @@ int n; } while (n > viewnum) { /* scan to desired view */ if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL) - return(viewnum==1 ? &curview : NULL); + return(viewnum==1 ? &curview : (VIEW *)NULL); if (isview(linebuf) && sscanview(&curview, linebuf) > 0) viewnum++; } @@ -1020,10 +1020,12 @@ int n; if (n == 0) { /* signal to close file */ if (expfp != NULL) { fclose(expfp); + free((char *)exppos); expfp = NULL; } return(NULL); - } + } else if (n > vint(END)) /* request past end (error?) */ + return(NULL); if (!vdef(EXPOSURE)) /* no setting (auto) */ return(NULL); if (isflt(vval(EXPOSURE))) /* always the same */ @@ -1061,13 +1063,15 @@ int n; } curfrm++; cp = fskip(expval); /* check format */ - if (cp == NULL || *cp != '\n') { + if (cp != NULL) + while (isspace(*cp)) + *cp++ = '\0'; + if (cp == NULL || *cp) { fprintf(stderr, "%s: exposure format error on line %d\n", vval(EXPOSURE), curfrm); quit(1); } - *cp = '\0'; } return(expval); /* return value */ } @@ -1196,8 +1200,12 @@ int maxcopies; { int retstatus = 0; int hostcopies; - char com1buf[10240], *com1, *endcom1; + char buf[10240], *com1; + PSERVER *mps[64]; + int nmps = 0; int status; + int pfd; + register int n; register PSERVER *ps; if (!silent) @@ -1209,24 +1217,18 @@ int maxcopies; for (ps = pslist; ps != NULL; ps = ps->next) { hostcopies = 0; if (maxcopies > 1 && ps->nprocs > 1 && ppins != NULL) { - strcpy(com1=com1buf, com); /* build -PP command */ + strcpy(com1=buf, com); /* build -PP command */ sprintf(com1+(ppins-com), " -PP %s/%s.persist", vval(DIRECTORY), phostname(ps)); strcat(com1, ppins); - endcom1 = com1 + strlen(com1); - sprintf(endcom1, "; kill `sed -n '1s/^[^ ]* //p' %s/%s.persist`", - vval(DIRECTORY), phostname(ps)); - } else { + mps[nmps++] = ps; + } else com1 = com; - endcom1 = NULL; - } while (maxcopies > 0 && startjob(ps, savestr(com1), donecom) != -1) { - sleep(10); + sleep(60); hostcopies++; maxcopies--; - if (endcom1 != NULL) - *endcom1 = '\0'; } if (!silent && hostcopies) { if (hostcopies > 1) @@ -1241,6 +1243,21 @@ int maxcopies; while ((status = wait4job(NULL, -1)) != -1) if (status) retstatus += !serverdown(); /* check server */ + /* terminate parallel rpict's */ + while (nmps--) { + sprintf(buf, "%s/%s.persist", + vval(DIRECTORY), phostname(mps[nmps])); + if ((pfd = open(buf, O_RDONLY)) >= 0) { + n = read(pfd, buf, sizeof(buf)-1); /* get PID */ + buf[n] = '\0'; + close(pfd); + for (n = 0; buf[n] && !isspace(buf[n]); n++) + ; + /* terminate */ + sprintf(buf, "kill -ALRM %d", atoi(buf+n)); + wait4job(mps[nmps], startjob(mps[nmps], buf, NULL)); + } + } return(retstatus); }