~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/render/intern/source/zbufferdatastruct.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
2
 * zbufferdatastruct.c
3
3
 *
4
 
 * $Id: zbufferdatastruct.c,v 1.3 2002/11/25 12:02:03 mein Exp $
 
4
 * $Id: zbufferdatastruct.c,v 1.9 2005/04/23 20:49:23 ton Exp $
5
5
 *
6
6
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
7
7
 *
61
61
 
62
62
#include "MEM_guardedalloc.h"
63
63
#include "zbufferdatastruct.h"
 
64
#include "vanillaRenderPipe_types.h"
64
65
#include "render.h"
65
 
#include "render_intern.h"
66
66
 
67
67
#ifdef HAVE_CONFIG_H
68
68
#include <config.h>
70
70
 
71
71
/* if defined: all jittersamples are stored individually. _very_ serious     */
72
72
/* performance hit ! also gives some buffer size problems in big scenes      */
73
 
/* #define RE_INDIVIDUAL_SUBPIXELS */
 
73
#define RE_INDIVIDUAL_SUBPIXELS
74
74
 
75
75
/* ------------------------------------------------------------------------- */
76
76
 
175
175
/* ------------------------------------------------------------------------- */
176
176
 
177
177
void insertObject(int apteller,
178
 
/*                                int opaque, */
179
178
                                  int obindex,
180
179
                                  int obtype, 
181
180
                                  int dist, 
183
182
{
184
183
        /* Guard the insertion if needed? */
185
184
        RE_APixstrExt* apn = &APixbufExt[apteller]; 
 
185
        int all_subpixels= 0;   // not used now... (ton)
186
186
        
187
187
        while(apn) {
 
188
                
188
189
                if(apn->t[0] == RE_NONE) {
189
190
                        apn->p[0] = obindex; apn->t[0] = obtype;
190
191
                        apn->zmin[0] = dist; apn->zmax[0] = dist;
191
192
                        apn->mask[0] = mask;   
192
193
                        break; 
193
194
                }
194
 
#ifndef RE_INDIVIDUAL_SUBPIXELS
195
 
                if((apn->p[0] == obindex) && (apn->t[0] & obtype)) {
196
 
                        if(dist < apn->zmin[0]) apn->zmin[0] = dist;
197
 
                        else if(dist > apn->zmax[0]) apn->zmax[0] = dist;
198
 
                        apn->mask[0]|= mask; 
199
 
                        break; 
200
 
                } 
201
 
#endif
 
195
                else if(all_subpixels==0) {
 
196
                        if((apn->p[0] == obindex) && (apn->t[0] & obtype)) {
 
197
                                if(dist < apn->zmin[0]) apn->zmin[0] = dist;
 
198
                                else if(dist > apn->zmax[0]) apn->zmax[0] = dist;
 
199
                                apn->mask[0]|= mask; 
 
200
                                break; 
 
201
                        } 
 
202
                }
 
203
                
202
204
                if(apn->t[1] == RE_NONE) {
203
205
                        apn->p[1] = obindex; apn->t[1] = obtype;
204
206
                        apn->zmin[1] = dist; apn->zmax[1] = dist;
205
207
                        apn->mask[1] = mask;   
206
208
                        break; 
207
209
                }
208
 
#ifndef RE_INDIVIDUAL_SUBPIXELS
209
 
                if((apn->p[1] == obindex) && (apn->t[1] & obtype)) {
210
 
                        if(dist < apn->zmin[1]) apn->zmin[1] = dist;
211
 
                        else if(dist > apn->zmax[1]) apn->zmax[1] = dist;
212
 
                        apn->mask[1]|= mask; 
213
 
                        break; 
214
 
                } 
215
 
#endif
 
210
                else if(all_subpixels==0) {
 
211
                        if((apn->p[1] == obindex) && (apn->t[1] & obtype)) {
 
212
                                if(dist < apn->zmin[1]) apn->zmin[1] = dist;
 
213
                                else if(dist > apn->zmax[1]) apn->zmax[1] = dist;
 
214
                                apn->mask[1]|= mask; 
 
215
                                break; 
 
216
                        } 
 
217
                }
 
218
                
216
219
                if(apn->t[2] == RE_NONE) {
217
220
                        apn->p[2] = obindex; apn->t[2] = obtype;
218
221
                        apn->zmin[2] = dist; apn->zmax[2] = dist;
219
222
                        apn->mask[2] = mask;   
220
223
                        break; 
221
224
                }
222
 
#ifndef RE_INDIVIDUAL_SUBPIXELS
223
 
                if((apn->p[2] == obindex) && (apn->t[2] & obtype)) {
224
 
                        if(dist < apn->zmin[2]) apn->zmin[2] = dist;
225
 
                        else if(dist > apn->zmax[2]) apn->zmax[2] = dist;
226
 
                        apn->mask[2]|= mask; 
227
 
                        break; 
228
 
                } 
229
 
#endif
 
225
                else if(all_subpixels==0) {
 
226
                        if((apn->p[2] == obindex) && (apn->t[2] & obtype)) {
 
227
                                if(dist < apn->zmin[2]) apn->zmin[2] = dist;
 
228
                                else if(dist > apn->zmax[2]) apn->zmax[2] = dist;
 
229
                                apn->mask[2]|= mask; 
 
230
                                break; 
 
231
                        } 
 
232
                }
 
233
                
230
234
                if(apn->t[3] == RE_NONE) {
231
235
                        apn->p[3] = obindex; apn->t[3] = obtype;
232
236
                        apn->zmin[3] = dist; apn->zmax[3] = dist;
233
237
                        apn->mask[3] = mask;   
234
238
                        break; 
235
239
                }
236
 
#ifndef RE_INDIVIDUAL_SUBPIXELS
237
 
                if((apn->p[3] == obindex) && (apn->t[3] & obtype)) {
238
 
                        if(dist < apn->zmin[3]) apn->zmin[3] = dist;
239
 
                        else if(dist > apn->zmax[3]) apn->zmax[3] = dist;
240
 
                        apn->mask[3]|= mask; 
241
 
                        break; 
242
 
                } 
243
 
#endif
 
240
                else if(all_subpixels==0) {
 
241
                        if((apn->p[3] == obindex) && (apn->t[3] & obtype)) {
 
242
                                if(dist < apn->zmin[3]) apn->zmin[3] = dist;
 
243
                                else if(dist > apn->zmax[3]) apn->zmax[3] = dist;
 
244
                                apn->mask[3]|= mask; 
 
245
                                break; 
 
246
                        } 
 
247
                }
 
248
                
244
249
                if(apn->next==0) apn->next= addpseA();
245
250
                apn= apn->next;
246
251
        }                               
247
 
} /* end of insertObject(RE_APixstrExt*, int, int, int, int) */
248
 
 
249
 
/* ------------------------------------------------------------------------- */
250
 
 
251
 
void insertFlatObject(RE_APixstrExt *apn, int obindex, int obtype, int dist, int mask)
252
 
{
253
 
        while(apn) {
254
 
                if(apn->t[0] == RE_NONE) {
255
 
                        apn->p[0] = obindex; apn->zmin[0] = dist; 
256
 
                        apn->zmax[0] = dist; apn->mask[0] = mask; 
257
 
                        apn->t[0] = obtype;  
258
 
                        break; 
259
 
                }
260
 
#ifndef RE_INDIVIDUAL_SUBPIXELS
261
 
                if( (apn->t[0] & obtype) && (apn->p[0] == obindex)) {
262
 
                        apn->mask[0]|= mask; break; 
263
 
                }
264
 
#endif
265
 
                if(apn->t[1] == RE_NONE) {
266
 
                        apn->p[1] = obindex; apn->zmin[1] = dist; 
267
 
                        apn->zmax[1] = dist; apn->mask[1] = mask; 
268
 
                        apn->t[1] = obtype;  
269
 
                        break;
270
 
                }
271
 
#ifndef RE_INDIVIDUAL_SUBPIXELS
272
 
                if( (apn->t[1] & obtype) && (apn->p[1] == obindex)) {
273
 
                        apn->mask[1]|= mask; break; 
274
 
                }
275
 
#endif
276
 
                if(apn->t[2] == RE_NONE) {
277
 
                        apn->p[2] = obindex; apn->zmin[2] = dist; 
278
 
                        apn->zmax[2] = dist; apn->mask[2] = mask; 
279
 
                        apn->t[2] = obtype;  
280
 
                        break;
281
 
                }
282
 
#ifndef RE_INDIVIDUAL_SUBPIXELS
283
 
                if( (apn->t[2] & obtype) && (apn->p[2] == obindex)) {
284
 
                        apn->mask[2]|= mask; break; 
285
 
                }
286
 
#endif
287
 
                if(apn->t[3] == RE_NONE) {
288
 
                        apn->p[3] = obindex; apn->zmin[3] = dist; 
289
 
                        apn->zmax[3] = dist; apn->mask[3] = mask; 
290
 
                        apn->t[3] = obtype;  
291
 
                        break;
292
 
                }
293
 
#ifndef RE_INDIVIDUAL_SUBPIXELS
294
 
                if( (apn->t[3] & obtype) && (apn->p[3] == obindex)) {
295
 
                        apn->mask[3]|= mask; break; 
296
 
                }
297
 
#endif
298
 
                if(apn->next==0) apn->next= addpseA();
299
 
                apn= apn->next;
300
 
        };                    
301
 
} /* end of void insertFlatObject(RE_APixstrExt, int, int, int, int)*/
302
 
 
303
 
/* ------------------------------------------------------------------------- */
 
252
}
 
253
 
 
254
/* ------------------------------------------------------------------------- */
 
255
 
 
256
/* ------------------------------------------------------------------------- */
 
257
 
304
258
/* This function might be helped by an end-of-list marker                    */
305
259
void insertFlatObjectNoOsa(RE_APixstrExt *ap, 
306
260
                                                   int obindex, 
308
262
                                                   int dist, 
309
263
                                                   int mask)
310
264
{
 
265
        int counter=0;
 
266
        
311
267
        while(ap) {
312
268
                if(ap->t[0] == RE_NONE) {
313
269
                        ap->p[0] = obindex; ap->zmin[0] = dist; 
315
271
                        ap->t[0] = obtype;  
316
272
                        break; 
317
273
                }
 
274
                else if(ap->t[0] & RE_SOLID) if( dist > ap->zmin[0] ) break;
318
275
 
319
276
                if(ap->t[1] == RE_NONE) {
320
277
                        ap->p[1] = obindex; ap->zmin[1] = dist; 
322
279
                        ap->t[1] = obtype;  
323
280
                        break;
324
281
                }
 
282
                else if(ap->t[1] & RE_SOLID) if( dist > ap->zmin[1] ) break;
325
283
 
326
284
                if(ap->t[2] == RE_NONE) {
327
285
                        ap->p[2] = obindex; ap->zmin[2] = dist; 
329
287
                        ap->t[2] = obtype;  
330
288
                        break;
331
289
                }
 
290
                else if(ap->t[2] & RE_SOLID) if( dist > ap->zmin[2] ) break;
332
291
 
333
292
                if(ap->t[3] == RE_NONE) {
334
293
                        ap->p[3] = obindex; ap->zmin[3] = dist; 
336
295
                        ap->t[3] = obtype;  
337
296
                        break;
338
297
                }
339
 
 
 
298
                else if(ap->t[3] & RE_SOLID) if( dist > ap->zmin[3] ) break;
 
299
                
 
300
                counter+= 4;
 
301
                if(counter > RE_MAX_FACES_PER_PIXEL) break;
 
302
                
340
303
                if(ap->next==0) ap->next= addpseA();
341
304
                ap= ap->next;
342
305
        };                    
343
 
} /* end of void insertFlatObjectNoOsa(RE_APixstrExt, int, int, int, int)*/
 
306
}
344
307
 
345
308
/* ------------------------------------------------------------------------- */
346
309