ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/ranimove.c
(Generate patch)

Comparing ray/src/util/ranimove.c (file contents):
Revision 3.12 by greg, Tue Sep 28 17:54:19 2004 UTC vs.
Revision 3.21 by greg, Wed Aug 21 16:18:54 2024 UTC

# Line 12 | Line 12 | static const char RCSid[] = "$Id$";
12   #include "copyright.h"
13  
14   #include <time.h>
15 < #ifdef _WIN32
15 > #if defined(_WIN32) || defined(_WIN64)
16    #include <winsock.h> /* struct timeval. XXX find a replacement? */
17   #else
18    #include <sys/time.h>
# Line 20 | Line 20 | static const char RCSid[] = "$Id$";
20   #include <ctype.h>
21   #include <string.h>
22  
23 + #include "platform.h"
24   #include "paths.h"
25   #include "ranimove.h"
26  
# Line 169 | Line 170 | userr:
170  
171   void
172   eputs(                          /* put string to stderr */
173 <        register char  *s
173 >        const char  *s
174   )
175   {
176          static int  midline = 0;
# Line 188 | Line 189 | eputs(                         /* put string to stderr */
189   }
190  
191  
192 + void
193 + quit(int ec)                    /* make sure exit is called */
194 + {
195 +        if (ray_pnprocs > 0)    /* close children if any */
196 +                ray_pclose(0);
197 +        else if (ray_pnprocs < 0)
198 +                _exit(ec);      /* avoid flush in child */
199 +        exit(ec);
200 + }
201 +
202 +
203   static void
204   setdefaults(void)                       /* set default values */
205   {
# Line 339 | Line 351 | setrendparams( /* set global rendering parameters */
351          av[ac=0] = NULL;
352                                  /* load options from file, first */
353          if (optf != NULL && *optf) {
354 <                ac = wordfile(av, optf);
354 >                ac = wordfile(av, 1024, optf);
355                  if (ac < 0) {
356                          sprintf(errmsg, "cannot load options file \"%s\"",
357                                          optf);
# Line 348 | Line 360 | setrendparams( /* set global rendering parameters */
360          }
361                                  /* then from options string */
362          if (qval != NULL && qval[0] == '-')
363 <                ac += wordstring(av+ac, qval);
363 >                ac += wordstring(av+ac, 1024-ac, qval);
364  
365                                  /* restore default parameters */
366          ray_restore(NULL);
# Line 381 | Line 393 | getradfile(            /* run rad and get needed variables */
393   {
394          static short    mvar[] = {OCONV,OCTREEF,RESOLUTION,EXPOSURE,-1};
395          char    combuf[256];
396 <        register int    i;
397 <        register char   *cp;
396 >        int     i;
397 >        char    *cp;
398          char    *pippt = NULL;
399                                          /* create rad command */
400          strcpy(lorendoptf, "ranim0.opt");
# Line 458 | Line 470 | animate(void)                  /* run through animation */
470   }
471  
472  
473 < extern VIEW *
473 > VIEW *
474   getview(                        /* get view number n */
475          int     n
476   )
# Line 493 | Line 505 | getview(                       /* get view number n */
505                  viewnum = 0;
506          }
507          if (n < 0) {                            /* get next view */
508 <                register int    c = getc(viewfp);
508 >                int     c = getc(viewfp);
509                  if (c == EOF)
510                          return(NULL);                   /* that's it */
511                  ungetc(c, viewfp);
# Line 522 | Line 534 | countviews(void)                       /* count views in view file */
534   }
535  
536  
537 < extern char *
537 > char *
538   getexp(                 /* get exposure for nth frame */
539          int     n
540   )
541   {
530        extern char     *fskip();
542          static char     expval[32];
543          static FILE     *expfp = NULL;
544          static int      curfrm = 0;
545 <        register char   *cp;
545 >        char    *cp;
546  
547          if (n == 0) {                           /* signal to close file */
548                  if (expfp != NULL) {
# Line 581 | Line 592 | formerr:
592   }
593  
594  
595 < extern double
595 > double
596   expspec_val(                    /* get exposure value from spec. */
597          char    *s
598   )
# Line 598 | Line 609 | expspec_val(                   /* get exposure value from spec. */
609   }
610  
611  
612 < extern char *
612 > char *
613   getoctspec(                     /* get octree for the given frame */
614          int     n
615   )
616   {
617          static char     combuf[1024];
618 <        int             cfm = 0;
618 >        static int      cfm = 0;
619          int     uses_inline;
620          FILE    *fp;
621          int     i;
622                                          /* is octree static? */
623          if (!vdef(MOVE))
624                  return(vval(OCTREEF));
625 <                                        /* done already */
625 >                                        /* done already? */
626          if (n == cfm)
627                  return(combuf);
628                                          /* else create object file */
629 <        strcpy(objtmpf, "movinobj.rad");
619 <        fp = fopen(objtmpf, "w");
629 >        fp = fopen(mktemp(strcpy(objtmpf, TEMPLATE)), "w");
630          if (fp == NULL) {
631                  sprintf(errmsg, "cannot write to moving objects file '%s'",
632                                  objtmpf);
# Line 647 | Line 657 | getoctspec(                    /* get octree for the given frame */
657                                  vdef(OCONV) ? vval(OCONV) : "",
658                                  vval(OCTREEF), objtmpf);
659          else
660 <                sprintf(combuf, "!xform -f %s | oconv -f -i '%s' -",
661 <                                objtmpf, vval(OCTREEF));
660 >                sprintf(combuf, "!xform -f %s | oconv %s -f -i '%s' -",
661 >                                objtmpf, vdef(OCONV) ? vval(OCONV) : "",
662 >                                vval(OCTREEF));
663          return(combuf);
664   }
665  
666  
667   static char *
668   getobjname(                     /* get fully qualified object name */
669 <        register struct ObjMove *om
669 >        struct ObjMove  *om
670   )
671   {
672          static char     objName[512];
673 <        register char   *cp = objName;
673 >        char    *cp = objName;
674          
675          strcpy(cp, om->name);
676          while (om->parent >= 0) {
# Line 674 | Line 685 | getobjname(                    /* get fully qualified object name */
685  
686   static char *
687   getxf(                  /* get total transform for object */
688 <        register struct ObjMove *om,
688 >        struct ObjMove  *om,
689          int     n
690   )
691   {
# Line 687 | Line 698 | getxf(                 /* get total transform for object */
698          char            *av[64];
699          int             ac;
700          int             i;
701 <        register char   *cp;
701 >        char    *cp;
702                                          /* get parent transform, first */
703          if (om->parent >= 0)
704                  xfp = getxf(&obj_move[om->parent], n);
# Line 795 | Line 806 | getxf(                 /* get total transform for object */
806   }
807  
808  
809 < extern int
809 > int
810   getmove(                                /* find matching move object */
811          OBJECT  obj
812   )
# Line 804 | Line 815 | getmove(                               /* find matching move object */
815          static OBJECT   lasto = OVOID;
816          char    *onm, *objnm;
817          int     len, len2;
818 <        register int    i;
818 >        int     i;
819  
820          if (obj == OVOID)
821                  return(-1);
# Line 829 | Line 840 | getmove(                               /* find matching move object */
840   }
841  
842  
843 < extern double
843 > double
844   obj_prio(                       /* return priority for object */
845          OBJECT  obj
846   )
# Line 842 | Line 853 | obj_prio(                      /* return priority for object */
853   }
854  
855  
856 < extern double
856 > #if defined(_WIN32) || defined(_WIN64)
857 >                                /* replacement function for Windoze */
858 > static int
859 > gettimeofday(struct timeval *tp, void *dummy)
860 > {
861 >    FILETIME        ft;
862 >    LARGE_INTEGER   li;
863 >    __int64         t;
864 >
865 >        SYSTEMTIME              st;
866 >        FILETIME                ft2;
867 >        LARGE_INTEGER   li2;
868 >        __int64                 t2;
869 >
870 >        st.wYear = 1970;
871 >        st.wHour = 0;
872 >        st.wMinute = 0;
873 >        st.wSecond = 0;
874 >        st.wMilliseconds = 1;
875 >
876 >        SystemTimeToFileTime(&st, &ft2);
877 >        li2.LowPart = ft2.dwLowDateTime;
878 >        li2.HighPart = ft2.dwHighDateTime;
879 >        t2 = li2.QuadPart;
880 >
881 >    GetSystemTimeAsFileTime(&ft);
882 >    li.LowPart  = ft.dwLowDateTime;
883 >    li.HighPart = ft.dwHighDateTime;
884 >    t  = li.QuadPart;      
885 >    t -= t2; // From 1970
886 >    t /= 10; // In microseconds
887 >    tp->tv_sec  = (long)(t / 1000000);
888 >    tp->tv_usec = (long)(t % 1000000);
889 >    return 0;
890 > }
891 >
892 > #endif
893 >
894 > double
895   getTime(void)                   /* get current time (CPU or real) */
896   {
897          struct timeval  time_now;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines