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

« back to all changes in this revision

Viewing changes to source/blender/blenkernel/intern/material.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:
2
2
/*  material.c
3
3
 *
4
4
 * 
5
 
 * $Id: material.c,v 1.18 2004/03/20 23:59:57 zuster Exp $
 
5
 * $Id: material.c,v 1.26 2005/04/17 17:43:06 ton Exp $
6
6
 *
7
7
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
8
8
 *
59
59
 
60
60
#include "BPY_extern.h"
61
61
 
62
 
#ifdef HAVE_CONFIG_H
63
 
#include <config.h>
64
 
#endif
65
 
 
66
62
void free_material(Material *ma)
67
63
{
68
64
        int a;
70
66
 
71
67
        BPY_free_scriptlink(&ma->scriptlink);
72
68
        
73
 
        if(ma->ren) MEM_freeN(ma->ren);
74
 
        ma->ren= 0;
75
 
        
76
 
        for(a=0; a<8; a++) {
 
69
        for(a=0; a<MAX_MTEX; a++) {
77
70
                mtex= ma->mtex[a];
78
71
                if(mtex && mtex->tex) mtex->tex->id.us--;
79
72
                if(mtex) MEM_freeN(mtex);
80
73
        }
 
74
        
 
75
        if(ma->ramp_col) MEM_freeN(ma->ramp_col);
 
76
        if(ma->ramp_spec) MEM_freeN(ma->ramp_spec);
81
77
}
82
78
 
83
79
void init_material(Material *ma)
104
100
        ma->param[1]= 0.1;
105
101
        ma->param[2]= 0.5;
106
102
        ma->param[3]= 0.1;
 
103
        ma->rms=0.1;
 
104
        ma->darkness=1.0;       
107
105
        
108
106
        ma->ang= 1.0;
109
107
        ma->ray_depth= 2;
113
111
        ma->fresnel_tra_i= 1.25;
114
112
        ma->fresnel_mir_i= 1.25;
115
113
        
 
114
        ma->rampfac_col= 1.0;
 
115
        ma->rampfac_spec= 1.0;
 
116
        ma->pr_lamp= 3; // two lamps, is bits
 
117
        
116
118
        ma->mode= MA_TRACEBLE+MA_SHADOW+MA_RADIO;       
117
119
}
118
120
 
136
138
        
137
139
        id_us_plus((ID *)man->ipo);
138
140
        
139
 
        for(a=0; a<8; a++) {
 
141
        for(a=0; a<MAX_MTEX; a++) {
140
142
                if(ma->mtex[a]) {
141
143
                        man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
142
144
                        memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex));
145
147
        }
146
148
        
147
149
        BPY_copy_scriptlink(&ma->scriptlink);
 
150
        if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col);
 
151
        if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec);
148
152
        
149
153
        return man;
150
154
}
168
172
                ma->id.lib= 0;
169
173
                ma->id.flag= LIB_LOCAL;
170
174
                new_id(0, (ID *)ma, 0);
171
 
                for(a=0; a<8; a++) {
 
175
                for(a=0; a<MAX_MTEX; a++) {
172
176
                        if(ma->mtex[a]) id_lib_extern((ID *)ma->mtex[a]->tex);
173
177
                }
174
178
                
232
236
                ma->id.lib= 0;
233
237
                ma->id.flag= LIB_LOCAL;
234
238
                
235
 
                for(a=0; a<8; a++) {
 
239
                for(a=0; a<MAX_MTEX; a++) {
236
240
                        if(ma->mtex[a]) id_lib_extern((ID *)ma->mtex[a]->tex);
237
241
                }
238
242
                
534
538
        MTex *mtex;
535
539
        int a, needuv=0;
536
540
        
537
 
        if(ma->ren) return;
538
 
 
539
541
        if(ma->flarec==0) ma->flarec= 1;
540
542
 
541
 
        ma->ren= MEM_mallocN(sizeof(Material), "initrendermaterial");
542
 
        memcpy(ma->ren, ma, sizeof(Material));
543
 
        
544
543
        /* add all texcoflags from mtex */
545
 
        ma= ma->ren;
546
544
        ma->texco= 0;
547
545
        ma->mapto= 0;
548
 
        for(a=0; a<8; a++) {
 
546
        for(a=0; a<MAX_MTEX; a++) {
549
547
                mtex= ma->mtex[a];
550
548
                if(mtex && mtex->tex) {
551
549
                        
563
561
        }
564
562
        if(ma->mode & MA_ZTRA) {
565
563
                /* if(ma->alpha==0.0 || ma->alpha==1.0) */
566
 
                R.flag |= R_ZTRA;
 
564
                if(R.flag & R_RENDERING) R.flag |= R_ZTRA;
567
565
        }
568
566
        if(ma->mode & MA_VERTEXCOLP) ma->mode |= MA_VERTEXCOL; 
569
567
        
574
572
                if(R.osa) ma->texco |= TEXCO_OSA;               /* for texfaces */
575
573
        }
576
574
        if(needuv) ma->texco |= NEED_UV;
577
 
 
 
575
        
578
576
        // since the raytracer doesnt recalc O structs for each ray, we have to preset them all
579
 
        if(ma->mode & (MA_RAYMIRROR|MA_RAYTRANSP)) { 
 
577
        if(ma->mode & (MA_RAYMIRROR|MA_RAYTRANSP|MA_SHADOW_TRA)) { 
580
578
                ma->texco |= NEED_UV|TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM;
581
579
                if(R.osa) ma->texco |= TEXCO_OSA;
582
580
        }
601
599
 
602
600
void end_render_material(Material *ma)
603
601
{
604
 
        
605
 
        if(ma->ren) MEM_freeN(ma->ren);
606
 
        ma->ren= 0;
607
 
 
 
602
        /* XXXX obsolete? check! */
608
603
        if(ma->mode & (MA_VERTEXCOLP|MA_FACETEXTURE)) {
609
604
                if( !(ma->mode & MA_HALO) ) {
610
605
                        ma->r= ma->g= ma->b= 1.0;
736
731
                }
737
732
                obt= obt->id.next;
738
733
        }
739
 
        allqueue(REDRAWBUTSMAT, 0);
740
 
        
741
734
 
742
735
        /* check indices from mesh */
743
736