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

Comparing ray/src/rt/preload.c (file contents):
Revision 2.1 by greg, Wed Jan 20 15:19:17 1993 UTC vs.
Revision 2.9 by greg, Thu Sep 15 18:06:23 2005 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1993 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Preload associated object structures to maximize memory sharing.
6 + *
7 + *  External symbols declared in ray.h
8   */
9  
10 + #include "copyright.h"
11 +
12   #include "standard.h"
13   #include "octree.h"
14   #include "object.h"
15   #include "otypes.h"
16   #include "face.h"
17   #include "cone.h"
18 + #include "instance.h"
19 + #include "mesh.h"
20 + #include "color.h"
21 + #include "data.h"
22 + #include "func.h"
23 + #include "ray.h"
24  
25  
26 < int
27 < load_os(op)                     /* load associated data for object */
28 < register OBJREC *op;
26 > /* KEEP THIS ROUTINE CONSISTENT WITH THE DIFFERENT OBJECT FUNCTIONS! */
27 >
28 >
29 > extern int
30 > load_os(                        /* load associated data for object */
31 >        register OBJREC *op
32 > )
33   {
34 +        DATARRAY  *dp;
35 +
36          switch (op->otype) {
37          case OBJ_FACE:          /* polygon */
38                  getface(op);
# Line 34 | Line 47 | register OBJREC        *op;
47          case OBJ_INSTANCE:      /* octree instance */
48                  getinstance(op, IO_ALL);
49                  return(1);
50 <        default:                /* don't bother */
51 <                return(0);
50 >        case OBJ_MESH:          /* mesh instance */
51 >                getmeshinst(op, IO_ALL);
52 >                return(1);
53 >        case PAT_CPICT:         /* color picture */
54 >                if (op->oargs.nsargs < 4)
55 >                        goto sargerr;
56 >                getpict(op->oargs.sarg[3]);
57 >                getfunc(op, 4, 0x3<<5, 0);
58 >                return(1);
59 >        case PAT_CDATA:         /* color data */
60 >                dp = getdata(op->oargs.sarg[3]);
61 >                getdata(op->oargs.sarg[4]);
62 >                getdata(op->oargs.sarg[5]);
63 >                getfunc(op, 6, ((1<<dp->nd)-1)<<7, 0);
64 >                return(1);
65 >        case PAT_BDATA:         /* brightness data */
66 >                if (op->oargs.nsargs < 2)
67 >                        goto sargerr;
68 >                dp = getdata(op->oargs.sarg[1]);
69 >                getfunc(op, 2, ((1<<dp->nd)-1)<<3, 0);
70 >                return(1);
71 >        case PAT_BFUNC:         /* brightness function */
72 >                getfunc(op, 1, 0x1, 0);
73 >                return(1);
74 >        case PAT_CFUNC:         /* color function */
75 >                getfunc(op, 3, 0x7, 0);
76 >                return(1);
77 >        case TEX_DATA:          /* texture data */
78 >                if (op->oargs.nsargs < 6)
79 >                        goto sargerr;
80 >                dp = getdata(op->oargs.sarg[3]);
81 >                getdata(op->oargs.sarg[4]);
82 >                getdata(op->oargs.sarg[5]);
83 >                getfunc(op, 6, ((1<<dp->nd)-1)<<7, 1);
84 >                return(1);
85 >        case TEX_FUNC:          /* texture function */
86 >                getfunc(op, 3, 0x7, 1);
87 >                return(1);
88 >        case MIX_DATA:          /* mixture data */
89 >                dp = getdata(op->oargs.sarg[3]);
90 >                getfunc(op, 4, ((1<<dp->nd)-1)<<5, 0);
91 >                return(1);
92 >        case MIX_PICT:          /* mixture picture */
93 >                getpict(op->oargs.sarg[3]);
94 >                getfunc(op, 4, 0x3<<5, 0);
95 >                return(1);
96 >        case MIX_FUNC:          /* mixture function */
97 >                getfunc(op, 3, 0x4, 0);
98 >                return(1);
99 >        case MAT_PLASTIC2:      /* anisotropic plastic */
100 >        case MAT_METAL2:        /* anisotropic metal */
101 >                getfunc(op, 3, 0x7, 1);
102 >                return(1);
103 >        case MAT_BRTDF:         /* BRDTfunc material */
104 >                getfunc(op, 9, 0x3f, 0);
105 >                return(1);
106 >        case MAT_PDATA:         /* plastic BRDF data */
107 >        case MAT_MDATA:         /* metal BRDF data */
108 >        case MAT_TDATA:         /* trans BRDF data */
109 >                if (op->oargs.nsargs < 2)
110 >                        goto sargerr;
111 >                getdata(op->oargs.sarg[1]);
112 >                getfunc(op, 2, 0, 0);
113 >                return(1);
114 >        case MAT_PFUNC:         /* plastic BRDF func */
115 >        case MAT_MFUNC:         /* metal BRDF func */
116 >        case MAT_TFUNC:         /* trans BRDF func */
117 >                getfunc(op, 1, 0, 0);
118 >                return(1);
119 >        case MAT_DIRECT1:       /* prism1 material */
120 >                getfunc(op, 4, 0xf, 1);
121 >                return(1);
122 >        case MAT_DIRECT2:       /* prism2 material */
123 >                getfunc(op, 8, 0xff, 1);
124 >                return(1);
125          }
126 +                        /* nothing to load for the remaining types */
127 +        return(0);
128 + sargerr:
129 +        objerror(op, USER, "too few string arguments");
130 +        return 0; /* pro forma return */
131   }
132  
133  
134 < preload_objs()          /* preload object data structures */
134 > extern void
135 > preload_objs(void)              /* preload object data structures */
136   {
137          register OBJECT on;
138 <                                /* note that nobjects may change during */
138 >                                /* note that nobjects may change during loop */
139          for (on = 0; on < nobjects; on++)
140                  load_os(objptr(on));
141   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines