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.24 by greg, Sat Jun 7 05:09:46 2025 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 "paths.h"
23 > #include "platform.h"
24   #include "ranimove.h"
25 + #include "func.h"
26  
27   int             NVARS = NV_INIT; /* total number of variables */
28  
# Line 81 | Line 82 | main(
82          int     explicate = 0;
83          char    *cfname;
84          int     i;
85 <
86 <        progname = argv[0];                     /* get arguments */
85 >                                                /* set global progname */
86 >        fixargv0(argv[0]);
87 >                                                /* initialize calcomp */
88 >        initfunc();
89          gargc = argc;
90          gargv = argv;
91          for (i = 1; i < argc && argv[i][0] == '-'; i++)
# Line 169 | Line 172 | userr:
172  
173   void
174   eputs(                          /* put string to stderr */
175 <        register char  *s
175 >        const char  *s
176   )
177   {
178          static int  midline = 0;
# Line 188 | Line 191 | eputs(                         /* put string to stderr */
191   }
192  
193  
194 + void
195 + quit(int ec)                    /* make sure exit is called */
196 + {
197 +        if (ray_pnprocs > 0)    /* close children if any */
198 +                ray_pclose(0);
199 +        else if (ray_pnprocs < 0)
200 +                _exit(ec);      /* avoid flush in child */
201 +        exit(ec);
202 + }
203 +
204 +
205   static void
206   setdefaults(void)                       /* set default values */
207   {
# Line 339 | Line 353 | setrendparams( /* set global rendering parameters */
353          av[ac=0] = NULL;
354                                  /* load options from file, first */
355          if (optf != NULL && *optf) {
356 <                ac = wordfile(av, optf);
356 >                ac = wordfile(av, 1024, optf);
357                  if (ac < 0) {
358                          sprintf(errmsg, "cannot load options file \"%s\"",
359                                          optf);
# Line 348 | Line 362 | setrendparams( /* set global rendering parameters */
362          }
363                                  /* then from options string */
364          if (qval != NULL && qval[0] == '-')
365 <                ac += wordstring(av+ac, qval);
365 >                ac += wordstring(av+ac, 1024-ac, qval);
366  
367                                  /* restore default parameters */
368          ray_restore(NULL);
# Line 381 | Line 395 | getradfile(            /* run rad and get needed variables */
395   {
396          static short    mvar[] = {OCONV,OCTREEF,RESOLUTION,EXPOSURE,-1};
397          char    combuf[256];
398 <        register int    i;
399 <        register char   *cp;
398 >        int     i;
399 >        char    *cp;
400          char    *pippt = NULL;
401                                          /* create rad command */
402          strcpy(lorendoptf, "ranim0.opt");
# Line 458 | Line 472 | animate(void)                  /* run through animation */
472   }
473  
474  
475 < extern VIEW *
475 > VIEW *
476   getview(                        /* get view number n */
477          int     n
478   )
# Line 493 | Line 507 | getview(                       /* get view number n */
507                  viewnum = 0;
508          }
509          if (n < 0) {                            /* get next view */
510 <                register int    c = getc(viewfp);
510 >                int     c = getc(viewfp);
511                  if (c == EOF)
512                          return(NULL);                   /* that's it */
513                  ungetc(c, viewfp);
# Line 522 | Line 536 | countviews(void)                       /* count views in view file */
536   }
537  
538  
539 < extern char *
539 > char *
540   getexp(                 /* get exposure for nth frame */
541          int     n
542   )
543   {
530        extern char     *fskip();
544          static char     expval[32];
545          static FILE     *expfp = NULL;
546          static int      curfrm = 0;
547 <        register char   *cp;
547 >        char    *cp;
548  
549          if (n == 0) {                           /* signal to close file */
550                  if (expfp != NULL) {
# Line 581 | Line 594 | formerr:
594   }
595  
596  
597 < extern double
597 > double
598   expspec_val(                    /* get exposure value from spec. */
599          char    *s
600   )
# Line 598 | Line 611 | expspec_val(                   /* get exposure value from spec. */
611   }
612  
613  
614 < extern char *
614 > char *
615   getoctspec(                     /* get octree for the given frame */
616          int     n
617   )
618   {
619          static char     combuf[1024];
620 <        int             cfm = 0;
620 >        static int      cfm = 0;
621          int     uses_inline;
622          FILE    *fp;
623          int     i;
624                                          /* is octree static? */
625          if (!vdef(MOVE))
626                  return(vval(OCTREEF));
627 <                                        /* done already */
627 >                                        /* done already? */
628          if (n == cfm)
629                  return(combuf);
630                                          /* else create object file */
631 <        strcpy(objtmpf, "movinobj.rad");
619 <        fp = fopen(objtmpf, "w");
631 >        fp = fopen(mktemp(strcpy(objtmpf, TEMPLATE)), "w");
632          if (fp == NULL) {
633                  sprintf(errmsg, "cannot write to moving objects file '%s'",
634                                  objtmpf);
# Line 647 | Line 659 | getoctspec(                    /* get octree for the given frame */
659                                  vdef(OCONV) ? vval(OCONV) : "",
660                                  vval(OCTREEF), objtmpf);
661          else
662 <                sprintf(combuf, "!xform -f %s | oconv -f -i '%s' -",
663 <                                objtmpf, vval(OCTREEF));
662 >                sprintf(combuf, "!xform -f %s | oconv %s -f -i '%s' -",
663 >                                objtmpf, vdef(OCONV) ? vval(OCONV) : "",
664 >                                vval(OCTREEF));
665          return(combuf);
666   }
667  
668  
669   static char *
670   getobjname(                     /* get fully qualified object name */
671 <        register struct ObjMove *om
671 >        struct ObjMove  *om
672   )
673   {
674          static char     objName[512];
675 <        register char   *cp = objName;
675 >        char    *cp = objName;
676          
677          strcpy(cp, om->name);
678          while (om->parent >= 0) {
# Line 674 | Line 687 | getobjname(                    /* get fully qualified object name */
687  
688   static char *
689   getxf(                  /* get total transform for object */
690 <        register struct ObjMove *om,
690 >        struct ObjMove  *om,
691          int     n
692   )
693   {
# Line 687 | Line 700 | getxf(                 /* get total transform for object */
700          char            *av[64];
701          int             ac;
702          int             i;
703 <        register char   *cp;
703 >        char    *cp;
704                                          /* get parent transform, first */
705          if (om->parent >= 0)
706                  xfp = getxf(&obj_move[om->parent], n);
# Line 795 | Line 808 | getxf(                 /* get total transform for object */
808   }
809  
810  
811 < extern int
811 > int
812   getmove(                                /* find matching move object */
813          OBJECT  obj
814   )
# Line 804 | Line 817 | getmove(                               /* find matching move object */
817          static OBJECT   lasto = OVOID;
818          char    *onm, *objnm;
819          int     len, len2;
820 <        register int    i;
820 >        int     i;
821  
822          if (obj == OVOID)
823                  return(-1);
# Line 829 | Line 842 | getmove(                               /* find matching move object */
842   }
843  
844  
845 < extern double
845 > double
846   obj_prio(                       /* return priority for object */
847          OBJECT  obj
848   )
# Line 842 | Line 855 | obj_prio(                      /* return priority for object */
855   }
856  
857  
858 < extern double
858 > #if defined(_WIN32) || defined(_WIN64)
859 >                                /* replacement function for Windoze */
860 > static int
861 > gettimeofday(struct timeval *tp, void *dummy)
862 > {
863 >    FILETIME        ft;
864 >    LARGE_INTEGER   li;
865 >    __int64         t;
866 >
867 >        SYSTEMTIME              st;
868 >        FILETIME                ft2;
869 >        LARGE_INTEGER   li2;
870 >        __int64                 t2;
871 >
872 >        st.wYear = 1970;
873 >        st.wHour = 0;
874 >        st.wMinute = 0;
875 >        st.wSecond = 0;
876 >        st.wMilliseconds = 1;
877 >
878 >        SystemTimeToFileTime(&st, &ft2);
879 >        li2.LowPart = ft2.dwLowDateTime;
880 >        li2.HighPart = ft2.dwHighDateTime;
881 >        t2 = li2.QuadPart;
882 >
883 >    GetSystemTimeAsFileTime(&ft);
884 >    li.LowPart  = ft.dwLowDateTime;
885 >    li.HighPart = ft.dwHighDateTime;
886 >    t  = li.QuadPart;      
887 >    t -= t2; // From 1970
888 >    t /= 10; // In microseconds
889 >    tp->tv_sec  = (long)(t / 1000000);
890 >    tp->tv_usec = (long)(t % 1000000);
891 >    return 0;
892 > }
893 >
894 > #endif
895 >
896 > double
897   getTime(void)                   /* get current time (CPU or real) */
898   {
899          struct timeval  time_now;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines