~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: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

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.55 2007/02/11 14:59:01 halley Exp $
 
5
 * $Id: material.c,v 1.59 2007/05/03 21:37:51 blendix Exp $
6
6
 *
7
7
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
8
8
 *
144
144
        ma->pr_lamp= 3;                 /* two lamps, is bits */
145
145
        ma->pr_type= MA_SPHERE;
146
146
 
 
147
        ma->sss_radius[0]= 1.0f;
 
148
        ma->sss_radius[1]= 1.0f;
 
149
        ma->sss_radius[2]= 1.0f;
 
150
        ma->sss_col[0]= 0.8f;
 
151
        ma->sss_col[1]= 0.8f;
 
152
        ma->sss_col[2]= 0.8f;
 
153
        ma->sss_error= 0.05f;
 
154
        ma->sss_scale= 0.1f;
 
155
        ma->sss_ior= 1.3f;
 
156
        ma->sss_colfac= 1.0f;
 
157
        ma->sss_texfac= 0.0f;
 
158
        ma->sss_front= 1.0f;
 
159
        ma->sss_back= 1.0f;
 
160
 
147
161
        ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RADIO|MA_RAYBIAS|MA_TANGENT_STR;
148
162
}
149
163
 
166
180
        man= copy_libblock(ma);
167
181
        
168
182
        id_us_plus((ID *)man->ipo);
 
183
        id_us_plus((ID *)man->group);
 
184
        
169
185
        
170
186
        for(a=0; a<MAX_MTEX; a++) {
171
187
                if(ma->mtex[a]) {
366
382
                mb= ob->data;
367
383
                return &(mb->mat);
368
384
        }
369
 
        return 0;
 
385
        return NULL;
370
386
}
371
387
 
372
388
short *give_totcolp(Object *ob)
387
403
                mb= ob->data;
388
404
                return &(mb->totcol);
389
405
        }
390
 
        return 0;
 
406
        return NULL;
391
407
}
392
408
 
393
409
Material *give_current_material(Object *ob, int act)
394
410
{
395
411
        Material ***matarar, *ma;
396
 
        
397
 
        if(ob==NULL) return 0;
398
 
        if(ob->totcol==0) return 0;
 
412
        short *totcolp;
 
413
        
 
414
        if(ob==NULL) return NULL;
 
415
        
 
416
        /* if object cannot have material, totcolp==NULL */
 
417
        totcolp= give_totcolp(ob);
 
418
        if(totcolp==NULL || ob->totcol==0) return NULL;
399
419
        
400
420
        if(act>ob->totcol) act= ob->totcol;
401
421
        else if(act<=0) act= 1;
404
424
                ma= ob->mat[act-1];
405
425
        }
406
426
        else {                                                          /* in data */
407
 
                short *totcolp= give_totcolp(ob);
408
427
 
409
428
                /* check for inconsistancy */
410
429
                if(*totcolp < ob->totcol)
559
578
        if(ob->totcol>=MAXMAT) return;
560
579
        
561
580
        ma= give_current_material(ob, ob->actcol);
562
 
        if(ma==0) {
 
581
        if(ma==NULL)
563
582
                ma= add_material("Material");
564
 
                ma->id.us= 0;
565
 
        }
 
583
        else
 
584
                ma= copy_material(ma);
 
585
        
 
586
        ma->id.us= 0; /* eeh... */
566
587
        
567
588
        if(ob->actcol) {
568
589
                if( BTST(ob->colbits, ob->actcol-1) ) {
695
716
                        end_render_material(ma);
696
717
}
697
718
 
 
719
static int material_in_nodetree(bNodeTree *ntree, Material *mat)
 
720
{
 
721
        bNode *node;
 
722
 
 
723
        for(node=ntree->nodes.first; node; node= node->next) {
 
724
                if(node->id && GS(node->id->name)==ID_MA) {
 
725
                        if(node->id==(ID*)mat)
 
726
                                return 1;
 
727
                }
 
728
                else if(node->type==NODE_GROUP)
 
729
                        if(material_in_nodetree((bNodeTree*)node->id, mat))
 
730
                                return 1;
 
731
        }
 
732
 
 
733
        return 0;
 
734
}
 
735
 
 
736
int material_in_material(Material *parmat, Material *mat)
 
737
{
 
738
        if(parmat==mat)
 
739
                return 1;
 
740
        else if(parmat->nodetree && parmat->use_nodes)
 
741
                return material_in_nodetree(parmat->nodetree, mat);
 
742
        else
 
743
                return 0;
 
744
}
 
745
        
698
746
/* ****************** */
699
747
 
700
748
char colname_array[125][20]= {