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

Comparing ray/src/hd/rhdobj.c (file contents):
Revision 3.8 by gwlarson, Wed Dec 23 17:41:14 1998 UTC vs.
Revision 3.13 by schorsch, Thu Jun 26 00:58:10 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Routines for loading and displaying Radiance objects in rholo with GLX.
6   */
# Line 13 | Line 10 | static char SCCSid[] = "$SunId$ SGI";
10   #include "rhdisp.h"
11   #include "rhdriver.h"
12   #include "rhdobj.h"
13 + #include "rtprocess.h"
14  
15   extern FILE     *sstdout;               /* user standard output */
16  
# Line 53 | Line 51 | typedef struct dobject {
51          struct dobject  *next;          /* next object in list */
52          char    name[64];               /* object name */
53          FVECT   center;                 /* orig. object center */
54 <        FLOAT   radius;                 /* orig. object radius */
54 >        RREAL   radius;                 /* orig. object radius */
55          int     listid;                 /* GL display list identifier */
56 <        int     rtp[3];                 /* associated rtrace process */
56 >        int     nlists;                 /* number of lists allocated */
57 >        SUBPROC rtp;                    /* associated rtrace process */
58          DLIGHTS *ol;                    /* object lights */
59          FULLXF  xfb;                    /* coordinate transform */
60          short   drawcode;               /* drawing code */
# Line 119 | Line 118 | register DOBJECT       *op;
118          }
119          dobjects = ohead.next;
120          if (!foundlink) {
121 <                glDeleteLists(op->listid, 1);
122 <                close_process(op->rtp);
121 >                glDeleteLists(op->listid, op->nlists);
122 >                close_process(&(op->rtp));
123          }
124          while (op->xfac)
125                  freestr(op->xfav[--op->xfac]);
126 <        free((char *)op);
126 >        free((void *)op);
127          return(1);
128   }
129  
# Line 299 | Line 298 | ssph_compute()                 /* compute source set from sphere sam
298                                                  /* avg. reflected brightness */
299          d = AVGREFL / (double)ncells;  
300          scalecolor(csum, d);
301 <        if (tmCvColors(&dlightsets->larb, TM_NOCHROM, csum, 1) != TM_E_OK)
301 >        if (tmCvColors(&dlightsets->larb, TM_NOCHROM, &csum, 1) != TM_E_OK)
302                  error(CONSISTENCY, "tone mapping problem in ssph_compute");
303                                          /* greedy light source clustering */
304          while (dlightsets->nl < MAXLIGHTS) {
# Line 339 | Line 338 | ssph_compute()                 /* compute source set from sphere sam
338          d = 1.0/ncells;
339          scalecolor(dlightsets->lamb, d);
340   done:                                   /* clear sphere sample array */
341 <        bzero((char *)ssamp, sizeof(ssamp));
341 >        bzero((void *)ssamp, sizeof(ssamp));
342          return(ncells);
343   }
344  
# Line 406 | Line 405 | int    force;
405                          quit(0);
406          if (!ssph_compute()) {          /* compute light sources from sphere */
407                  dlightsets = dl->next;
408 <                free((char *)dl);
408 >                free((void *)dl);
409                  return(0);
410          }
411          op->ol = dl;
# Line 416 | Line 415 | memerr:
415   }
416  
417  
418 < static int
418 > static
419   cmderror(cn, err)               /* report command error */
420   int     cn;
421   char    *err;
422   {
423          sprintf(errmsg, "%s: %s", rhdcmd[cn], err);
424          error(COMMAND, errmsg);
426        return(cn);
425   }
426  
427  
# Line 433 | Line 431 | char   *cmd;
431   register char   *args;
432   {
433          int     somechange = 0;
436        VIEW    sameview;
434          int     cn, na, doxfm;
435          register int    nn;
436          char    *alist[MAXAC+1], *nm;
# Line 461 | Line 458 | register char  *args;
458                          dobj_load(alist[0], alist[0]);
459                  else if (na == 2)
460                          dobj_load(alist[0], alist[1]);
461 <                else
462 <                        return(cmderror(cn, "need octree [name]"));
461 >                else {
462 >                        cmderror(cn, "need octree [name]");
463 >                        return(0);
464 >                }
465                  break;
466          case DO_UNLOAD:                         /* clear an object */
467                  if (na > 1) goto toomany;
# Line 478 | Line 477 | register char  *args;
477                  } else {
478                          nm = curname; nn = 0;
479                  }
480 <                if (cn == DO_MOVE && nn >= na)
481 <                        return(cmderror(cn, "missing transform"));
480 >                if (cn == DO_MOVE && nn >= na) {
481 >                        cmderror(cn, "missing transform");
482 >                        return(0);
483 >                }
484                  somechange += dobj_xform(nm, cn==DO_MOVE, na-nn, alist+nn);
485                  break;
486          case DO_UNMOVE:                         /* undo last transform */
# Line 497 | Line 498 | register char  *args;
498                                  break;
499                  switch (nn) {
500                  case 0:
501 <                        return(cmderror(cn, "need new object name"));
501 >                        cmderror(cn, "need new object name");
502 >                        return(0);
503                  case 1:
504                          nm = curname;
505                          break;
# Line 525 | Line 527 | register char  *args;
527          default:
528                  error(CONSISTENCY, "bad command id in dobj_command");
529          }
530 <        if (somechange) {
529 <                copystruct(&sameview, &odev.v); /* make 'em think new view */
530 <                dev_view(&sameview);            /* redraw */
531 <        }
532 <        return(cn);
530 >        return(somechange);
531   toomany:
532          return(cmderror(cn, "too many arguments"));
533   }
# Line 538 | Line 536 | toomany:
536   dobj_load(oct, nam)             /* create/load an octree object */
537   char    *oct, *nam;
538   {
541        extern char     *getlibpath(), *getpath();
539          char    *fpp, fpath[128];
540          register DOBJECT        *op;
541                                          /* check arguments */
# Line 559 | Line 556 | char   *oct, *nam;
556                  return(0);
557          }
558                                          /* get octree path */
559 <        if ((fpp = getpath(oct, getlibpath(), R_OK)) == NULL) {
559 >        if ((fpp = getpath(oct, getrlibpath(), R_OK)) == NULL) {
560                  sprintf(errmsg, "cannot find octree \"%s\"", oct);
561                  error(COMMAND, errmsg);
562                  return(0);
# Line 578 | Line 575 | char   *oct, *nam;
575                                          /* load octree into display list */
576          dolights = 0;
577          domats = 1;
578 <        op->listid = rgl_octlist(fpath, op->center, &op->radius);
578 >        op->listid = rgl_octlist(fpath, op->center, &op->radius, &op->nlists);
579                                          /* start rtrace */
580          rtargv[RTARGC-1] = fpath;
581          rtargv[RTARGC] = NULL;
582 <        open_process(op->rtp, rtargv);
582 >        open_process(&(op->rtp), rtargv);
583                                          /* insert into main list */
584          op->next = dobjects;
585          curobj = dobjects = op;
# Line 615 | Line 612 | dobj_cleanup()                         /* free all resources */
612          savedxf(curobj = NULL);
613          while ((lp = dlightsets) != NULL) {
614                  dlightsets = lp->next;
615 <                free((char *)lp);
615 >                free((void *)lp);
616          }
617          return(1);
618   }
# Line 734 | Line 731 | dobj_unmove()                          /* undo last transform change */
731                  return(0);
732          }
733                                          /* hold last transform */
734 <        bcopy((char *)lastxfav, (char *)txfav,
734 >        bcopy((void *)lastxfav, (void *)txfav,
735                          (txfac=lastxfac)*sizeof(char *));
736                                          /* save this transform */
737 <        bcopy((char *)curobj->xfav, (char *)lastxfav,
737 >        bcopy((void *)curobj->xfav, (void *)lastxfav,
738                          (lastxfac=curobj->xfac)*sizeof(char *));
739                                          /* copy back last transform */
740 <        bcopy((char *)txfav, (char *)curobj->xfav,
740 >        bcopy((void *)txfav, (void *)curobj->xfav,
741                          (curobj->xfac=txfac)*sizeof(char *));
742                                          /* set matrices */
743          fullxf(&curobj->xfb, curobj->xfac, curobj->xfav);
# Line 863 | Line 860 | FVECT   rorg, rdir;
860                  VCOPY(darr, rorg); VCOPY(darr+3, rdir);
861          }
862                                  /* trace it */
863 <        if (process(op->rtp, darr, darr, sizeof(double),
863 >        if (process(&(op->rtp), (char *)darr, (char *)darr, sizeof(double),
864                          6*sizeof(double)) != sizeof(double))
865                  error(SYSTEM, "rtrace communication error");
866                                  /* return distance */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines