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

Comparing ray/src/hd/sm_samp.c (file contents):
Revision 3.6 by gwlarson, Thu Jun 10 15:22:24 1999 UTC vs.
Revision 3.8 by greg, Fri Jun 20 00:25:49 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   * sm_samp.c
6   */
# Line 12 | Line 9 | static char SCCSid[] = "$SunId$ SGI";
9   #include "rhd_sample.h"
10  
11   SAMP rsL;
12 < int4 *samp_flag=NULL;
12 > int32 *samp_flag=NULL;
13  
14   /* Each sample has a world coord point, and direction, brightness,chrominance,
15     and RGB triples
16   */
17  
18   #define TMSIZE sizeof(TMbright)
19 < #define SAMPSIZ (3*sizeof(SFLOAT)+sizeof(int4)+ 6*sizeof(BYTE) + TMSIZE + 2*sizeof(int))
19 > #define SAMPSIZ (3*sizeof(SFLOAT)+sizeof(int32)+ 6*sizeof(BYTE) + TMSIZE + 2*sizeof(int))
20  
21   /* Extra points world space point, vert flag and qt flag */
22   #define POINTSIZ (3*sizeof(SFLOAT) + 2*sizeof(int))
# Line 75 | Line 72 | int *nptr,extra_points;
72    /* get number of samples that fit in block */
73    n = (i - 8 - extra_points*POINTSIZ) / SAMPSIZ;        
74  
75 +  /* Must make sure n + extra_points can fit in a S_ID identifier */
76 +  if ( n > (S_ID_MAX - extra_points))
77 +    n = (S_ID_MAX - extra_points);
78 +
79    S_BASE(s) = (char *)malloc(n*SAMPSIZ + extra_points*POINTSIZ);
80    if (!S_BASE(s))
81      error(SYSTEM,"sAlloc(): Unable to allocate memory");
82  
83    /* assign larger alignment types earlier */
84    S_W_PT(s) = (SFLOAT(*)[3])S_BASE(s);
85 <  S_W_DIR(s) = (int4 *)(S_W_PT(s) + n + extra_points);
85 >  S_W_DIR(s) = (int32 *)(S_W_PT(s) + n + extra_points);
86    S_BRT(s) = (TMbright *)(S_W_DIR(s) + n);
87    S_CHR(s) = (BYTE (*)[3])(S_BRT(s) + n);
88    S_RGB(s) = (BYTE (*)[3])(S_CHR(s) + n);
# Line 91 | Line 92 | int *nptr,extra_points;
92    S_MAX_BASE_PT(s) = n + extra_points;
93  
94    /* Allocate memory for a per/sample bit flag */
95 <  if(!(samp_flag = (int4 *)malloc(FLAG_BYTES(n+extra_points))))
95 >  if(!(samp_flag = (int32 *)malloc(FLAG_BYTES(n+extra_points))))
96      error(SYSTEM,"sAlloc(): Unable to allocate flag memory");
97    sInit(s);
98    sClear_all_flags(s);
# Line 106 | Line 107 | int *nptr,extra_points;
107     is added: These points are not displayed-they are used to form the
108     initial mesh
109   */
110 < int
110 > S_ID
111   sAdd_base_point(s,v)
112       SAMP *s;
113       FVECT v;
114   {
115 <    int id;
115 >    S_ID id;
116  
117      /* Get pointer to next available point */
118      id = S_NEXT_BASE_PT(s);
# Line 132 | Line 133 | sAdd_base_point(s,v)
133   int
134   sCopy_samp(s,n_id,id)
135     SAMP *s;
136 <   int n_id,id;
136 >   S_ID n_id,id;
137   {
138  
139   #ifdef DEBUG
# Line 165 | Line 166 | sCopy_samp(s,n_id,id)
166   void
167   sInit_samp(s,id,c,d,p,o_id)
168     SAMP *s;
169 <   int id;
169 >   S_ID id;
170     COLR c;
171     FVECT d,p;
172 <   int o_id;
172 >   S_ID o_id;
173   {
174  
175    if(o_id != INVALID)
# Line 185 | Line 186 | sInit_samp(s,id,c,d,p,o_id)
186      /* calculate the brightness and chrominance,RGB will be set by
187         tonemapping
188         */
188 #ifndef TEST_DRIVER
189      tmCvColrs(&S_NTH_BRT(s,id),S_NTH_CHR(s,id),c,1);
190 #endif
190    }
191      /* Set ACTIVE bit upon creation */
192    S_SET_FLAG(id);
# Line 197 | Line 196 | sInit_samp(s,id,c,d,p,o_id)
196  
197  
198   /* Allocate a new sample. If an existing sample was replaced: set flag */
199 < int
199 > S_ID
200   sAlloc_samp(s,replaced)
201     SAMP *s;
202     int *replaced;
203    
204   {
205 <    int id;
205 >    S_ID id;
206  
207      /* First check if there are any freed sample available */
208      if((id = S_FREE_SAMP(s)) != INVALID)
# Line 251 | Line 250 | sAlloc_samp(s,replaced)
250      *replaced = 1;
251      return(id);
252   }
253 +
254 +
255 +
256 +
257 +
258 +
259  
260  
261  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines