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.6 by greg, Sat Feb 22 02:07:29 2003 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 + /* ====================================================================
11 + * The Radiance Software License, Version 1.0
12 + *
13 + * Copyright (c) 1990 - 2002 The Regents of the University of California,
14 + * through Lawrence Berkeley National Laboratory.   All rights reserved.
15 + *
16 + * Redistribution and use in source and binary forms, with or without
17 + * modification, are permitted provided that the following conditions
18 + * are met:
19 + *
20 + * 1. Redistributions of source code must retain the above copyright
21 + *         notice, this list of conditions and the following disclaimer.
22 + *
23 + * 2. Redistributions in binary form must reproduce the above copyright
24 + *       notice, this list of conditions and the following disclaimer in
25 + *       the documentation and/or other materials provided with the
26 + *       distribution.
27 + *
28 + * 3. The end-user documentation included with the redistribution,
29 + *           if any, must include the following acknowledgment:
30 + *             "This product includes Radiance software
31 + *                 (http://radsite.lbl.gov/)
32 + *                 developed by the Lawrence Berkeley National Laboratory
33 + *               (http://www.lbl.gov/)."
34 + *       Alternately, this acknowledgment may appear in the software itself,
35 + *       if and wherever such third-party acknowledgments normally appear.
36 + *
37 + * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
38 + *       and "The Regents of the University of California" must
39 + *       not be used to endorse or promote products derived from this
40 + *       software without prior written permission. For written
41 + *       permission, please contact [email protected].
42 + *
43 + * 5. Products derived from this software may not be called "Radiance",
44 + *       nor may "Radiance" appear in their name, without prior written
45 + *       permission of Lawrence Berkeley National Laboratory.
46 + *
47 + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
48 + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 + * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
51 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
52 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
53 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
54 + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
55 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
56 + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
57 + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 + * SUCH DAMAGE.
59 + * ====================================================================
60 + *
61 + * This software consists of voluntary contributions made by many
62 + * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
63 + * information on Lawrence Berkeley National Laboratory, please see
64 + * <http://www.lbl.gov/>.
65 + */
66 +
67   #include "standard.h"
68   #include "octree.h"
69   #include "object.h"
70   #include "otypes.h"
71   #include "face.h"
72   #include "cone.h"
73 + #include "instance.h"
74 + #include "color.h"
75 + #include "data.h"
76  
77  
78 + /* KEEP THIS ROUTINE CONSISTENT WITH THE DIFFERENT OBJECT FUNCTIONS! */
79 +
80 +
81   int
82   load_os(op)                     /* load associated data for object */
83   register OBJREC *op;
84   {
85 +        DATARRAY  *dp;
86 +
87          switch (op->otype) {
88          case OBJ_FACE:          /* polygon */
89                  getface(op);
# Line 34 | Line 98 | register OBJREC        *op;
98          case OBJ_INSTANCE:      /* octree instance */
99                  getinstance(op, IO_ALL);
100                  return(1);
101 <        default:                /* don't bother */
102 <                return(0);
101 >        case PAT_CPICT:         /* color picture */
102 >                if (op->oargs.nsargs < 4)
103 >                        goto sargerr;
104 >                getpict(op->oargs.sarg[3]);
105 >                getfunc(op, 4, 0x3<<5, 0);
106 >                return(1);
107 >        case PAT_CDATA:         /* color data */
108 >                dp = getdata(op->oargs.sarg[3]);
109 >                getdata(op->oargs.sarg[4]);
110 >                getdata(op->oargs.sarg[5]);
111 >                getfunc(op, 6, ((1<<dp->nd)-1)<<7, 0);
112 >                return(1);
113 >        case PAT_BDATA:         /* brightness data */
114 >                if (op->oargs.nsargs < 2)
115 >                        goto sargerr;
116 >                dp = getdata(op->oargs.sarg[1]);
117 >                getfunc(op, 2, ((1<<dp->nd)-1)<<3, 0);
118 >                return(1);
119 >        case PAT_BFUNC:         /* brightness function */
120 >                getfunc(op, 1, 0x1, 0);
121 >                return(1);
122 >        case PAT_CFUNC:         /* color function */
123 >                getfunc(op, 3, 0x7, 0);
124 >                return(1);
125 >        case TEX_DATA:          /* texture data */
126 >                if (op->oargs.nsargs < 6)
127 >                        goto sargerr;
128 >                dp = getdata(op->oargs.sarg[3]);
129 >                getdata(op->oargs.sarg[4]);
130 >                getdata(op->oargs.sarg[5]);
131 >                getfunc(op, 6, ((1<<dp->nd)-1)<<7, 1);
132 >                return(1);
133 >        case TEX_FUNC:          /* texture function */
134 >                getfunc(op, 3, 0x7, 1);
135 >                return(1);
136 >        case MIX_DATA:          /* mixture data */
137 >                dp = getdata(op->oargs.sarg[3]);
138 >                getfunc(op, 4, ((1<<dp->nd)-1)<<5, 0);
139 >                return(1);
140 >        case MIX_PICT:          /* mixture picture */
141 >                getpict(op->oargs.sarg[3]);
142 >                getfunc(op, 4, 0x3<<5, 0);
143 >                return(1);
144 >        case MIX_FUNC:          /* mixture function */
145 >                getfunc(op, 3, 0x4, 0);
146 >                return(1);
147 >        case MAT_PLASTIC2:      /* anisotropic plastic */
148 >        case MAT_METAL2:        /* anisotropic metal */
149 >                getfunc(op, 3, 0x7, 1);
150 >                return(1);
151 >        case MAT_BRTDF:         /* BRDTfunc material */
152 >                getfunc(op, 9, 0x3f, 0);
153 >                return(1);
154 >        case MAT_PDATA:         /* plastic BRDF data */
155 >        case MAT_MDATA:         /* metal BRDF data */
156 >        case MAT_TDATA:         /* trans BRDF data */
157 >                if (op->oargs.nsargs < 2)
158 >                        goto sargerr;
159 >                getdata(op->oargs.sarg[1]);
160 >                getfunc(op, 2, 0, 0);
161 >                return(1);
162 >        case MAT_PFUNC:         /* plastic BRDF func */
163 >        case MAT_MFUNC:         /* metal BRDF func */
164 >        case MAT_TFUNC:         /* trans BRDF func */
165 >                getfunc(op, 1, 0, 0);
166 >                return(1);
167 >        case MAT_DIRECT1:       /* prism1 material */
168 >                getfunc(op, 4, 0xf, 1);
169 >                return(1);
170 >        case MAT_DIRECT2:       /* prism2 material */
171 >                getfunc(op, 8, 0xff, 1);
172 >                return(1);
173          }
174 +                        /* nothing to load for the remaining types */
175 +        return(0);
176 + sargerr:
177 +        objerror(op, USER, "too few string arguments");
178   }
179  
180  
181 + void
182   preload_objs()          /* preload object data structures */
183   {
184          register OBJECT on;
185 <                                /* note that nobjects may change during */
185 >                                /* note that nobjects may change during loop */
186          for (on = 0; on < nobjects; on++)
187                  load_os(objptr(on));
188   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines