svn merge -r 13452:14721 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender-staging.git] / source / blender / blenkernel / intern / scene.c
1 /*  scene.c
2  *  
3  * 
4  * $Id$
5  *
6  * ***** BEGIN GPL LICENSE BLOCK *****
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  *
22  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23  * All rights reserved.
24  *
25  * The Original Code is: all of this file.
26  *
27  * Contributor(s): none yet.
28  *
29  * ***** END GPL LICENSE BLOCK *****
30  */
31
32 #include <stdio.h>
33 #include <string.h>
34
35 #ifdef HAVE_CONFIG_H
36 #include <config.h>
37 #endif
38
39 #ifndef WIN32 
40 #include <unistd.h>
41 #else
42 #include <io.h>
43 #endif
44 #include "MEM_guardedalloc.h"
45
46 #include "DNA_armature_types.h" 
47 #include "DNA_color_types.h"
48 #include "DNA_constraint_types.h"
49 #include "DNA_curve_types.h"
50 #include "DNA_group_types.h"
51 #include "DNA_lamp_types.h"
52 #include "DNA_material_types.h"
53 #include "DNA_meta_types.h"
54 #include "DNA_object_types.h"
55 #include "DNA_scene_types.h"
56 #include "DNA_scriptlink_types.h"
57 #include "DNA_texture_types.h"
58 #include "DNA_userdef_types.h"
59
60 #include "BKE_action.h"                 
61 #include "BKE_anim.h"
62 #include "BKE_armature.h"               
63 #include "BKE_bad_level_calls.h"
64 #include "BKE_colortools.h"
65 #include "BKE_constraint.h"
66 #include "BKE_depsgraph.h"
67 #include "BKE_global.h"
68 #include "BKE_group.h"
69 #include "BKE_ipo.h"
70 #include "BKE_image.h"
71 #include "BKE_key.h"
72 #include "BKE_library.h"
73 #include "BKE_main.h"
74 #include "BKE_node.h"
75 #include "BKE_object.h"
76 #include "BKE_scene.h"
77 #include "BKE_sculpt.h"
78 #include "BKE_world.h"
79 #include "BKE_utildefines.h"
80
81 #include "BIF_previewrender.h"
82 #include "BIF_editseq.h"
83
84 #include "BPY_extern.h"
85 #include "BLI_arithb.h"
86 #include "BLI_blenlib.h"
87
88 #include "nla.h"
89
90 #ifdef WIN32
91 #else
92 #include <sys/time.h>
93 #endif
94
95 void free_avicodecdata(AviCodecData *acd)
96 {
97         if (acd) {
98                 if (acd->lpFormat){
99                         MEM_freeN(acd->lpFormat);
100                         acd->lpFormat = NULL;
101                         acd->cbFormat = 0;
102                 }
103                 if (acd->lpParms){
104                         MEM_freeN(acd->lpParms);
105                         acd->lpParms = NULL;
106                         acd->cbParms = 0;
107                 }
108         }
109 }
110
111 void free_qtcodecdata(QuicktimeCodecData *qcd)
112 {
113         if (qcd) {
114                 if (qcd->cdParms){
115                         MEM_freeN(qcd->cdParms);
116                         qcd->cdParms = NULL;
117                         qcd->cdSize = 0;
118                 }
119         }
120 }
121
122 /* copy_scene moved to src/header_info.c... should be back */
123
124 /* do not free scene itself */
125 void free_scene(Scene *sce)
126 {
127         Base *base;
128
129         base= sce->base.first;
130         while(base) {
131                 base->object->id.us--;
132                 base= base->next;
133         }
134         /* do not free objects! */
135
136         BLI_freelistN(&sce->base);
137         free_editing(sce->ed);
138         if(sce->radio) MEM_freeN(sce->radio);
139         sce->radio= 0;
140         
141         BPY_free_scriptlink(&sce->scriptlink);
142         if (sce->r.avicodecdata) {
143                 free_avicodecdata(sce->r.avicodecdata);
144                 MEM_freeN(sce->r.avicodecdata);
145                 sce->r.avicodecdata = NULL;
146         }
147         if (sce->r.qtcodecdata) {
148                 free_qtcodecdata(sce->r.qtcodecdata);
149                 MEM_freeN(sce->r.qtcodecdata);
150                 sce->r.qtcodecdata = NULL;
151         }
152         
153         BLI_freelistN(&sce->markers);
154         BLI_freelistN(&sce->transform_spaces);
155         BLI_freelistN(&sce->r.layers);
156         
157         if(sce->toolsettings){
158                 MEM_freeN(sce->toolsettings);
159                 sce->toolsettings = NULL;       
160         }
161         
162         if (sce->theDag) {
163                 free_forest(sce->theDag);
164                 MEM_freeN(sce->theDag);
165         }
166         
167         if(sce->nodetree) {
168                 ntreeFreeTree(sce->nodetree);
169                 MEM_freeN(sce->nodetree);
170         }
171
172         sculptdata_free(sce);
173 }
174
175 Scene *add_scene(char *name)
176 {
177         Scene *sce;
178         ParticleEditSettings *pset;
179         int a;
180
181         sce= alloc_libblock(&G.main->scene, ID_SCE, name);
182         sce->lay= 1;
183         sce->selectmode= SCE_SELECT_VERTEX;
184         sce->editbutsize= 0.1;
185         
186         sce->r.mode= R_GAMMA;
187         sce->r.cfra= 1;
188         sce->r.sfra= 1;
189         sce->r.efra= 250;
190         sce->r.xsch= 320;
191         sce->r.ysch= 256;
192         sce->r.xasp= 1;
193         sce->r.yasp= 1;
194         sce->r.xparts= 4;
195         sce->r.yparts= 4;
196         sce->r.size= 100;
197         sce->r.planes= 24;
198         sce->r.quality= 90;
199         sce->r.framapto= 100;
200         sce->r.images= 100;
201         sce->r.framelen= 1.0;
202         sce->r.frs_sec= 25;
203         sce->r.frs_sec_base= 1;
204         sce->r.ocres = 128;
205         
206         sce->r.bake_mode= 1;    /* prevent to include render stuff here */
207         sce->r.bake_filter= 2;
208         sce->r.bake_osa= 5;
209         sce->r.bake_flag= R_BAKE_CLEAR;
210         sce->r.bake_normal_space= R_BAKE_SPACE_TANGENT;
211         
212         sce->r.xplay= 640;
213         sce->r.yplay= 480;
214         sce->r.freqplay= 60;
215         sce->r.depth= 32;
216         
217         sce->r.threads= 1;
218         
219         sce->r.stereomode = 1;  // no stereo
220
221         sce->r.simplify_subsurf= 6;
222         sce->r.simplify_particles= 1.0f;
223         sce->r.simplify_shadowsamples= 16;
224         sce->r.simplify_aosss= 1.0f;
225
226         sce->r.cineonblack= 95;
227         sce->r.cineonwhite= 685;
228         sce->r.cineongamma= 1.7f;
229         
230         sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings),"Tool Settings Struct");
231         sce->toolsettings->cornertype=1;
232         sce->toolsettings->degr = 90; 
233         sce->toolsettings->step = 9;
234         sce->toolsettings->turn = 1;                            
235         sce->toolsettings->extr_offs = 1; 
236         sce->toolsettings->doublimit = 0.001;
237         sce->toolsettings->segments = 32;
238         sce->toolsettings->rings = 32;
239         sce->toolsettings->vertices = 32;
240         sce->toolsettings->editbutflag = 1;
241         sce->toolsettings->uvcalc_radius = 1.0f;
242         sce->toolsettings->uvcalc_cubesize = 1.0f;
243         sce->toolsettings->uvcalc_mapdir = 1;
244         sce->toolsettings->uvcalc_mapalign = 1;
245         sce->toolsettings->unwrapper = 1;
246         sce->toolsettings->select_thresh= 0.01f;
247         sce->toolsettings->jointrilimit = 0.8f;
248
249         pset= &sce->toolsettings->particle;
250         pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER;
251         pset->emitterdist= 0.25f;
252         pset->totrekey= 5;
253         pset->totaddkey= 5;
254         pset->brushtype= PE_BRUSH_NONE;
255         for(a=0; a<PE_TOT_BRUSH; a++) {
256                 pset->brush[a].strength= 50;
257                 pset->brush[a].size= 50;
258                 pset->brush[a].step= 10;
259         }
260         pset->brush[PE_BRUSH_CUT].strength= 100;
261         
262         sce->jumpframe = 10;
263         sce->audio.mixrate = 44100;
264
265         strcpy(sce->r.backbuf, "//backbuf");
266         strcpy(sce->r.pic, U.renderdir);
267
268         BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f);
269         sce->r.osa= 8;
270
271         sculptdata_init(sce);
272
273         /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */
274         scene_add_render_layer(sce);
275         
276         return sce;
277 }
278
279 Base *object_in_scene(Object *ob, Scene *sce)
280 {
281         Base *base;
282         
283         base= sce->base.first;
284         while(base) {
285                 if(base->object == ob) return base;
286                 base= base->next;
287         }
288         return NULL;
289 }
290
291 void set_scene_bg(Scene *sce)
292 {
293         Base *base;
294         Object *ob;
295         Group *group;
296         GroupObject *go;
297         int flag;
298         
299         // Note: this here is defined in editseq.c (BIF_editseq.h), NOT in blenkernel! 
300         set_last_seq(NULL);
301         
302         G.scene= sce;
303         
304         /* check for cyclic sets, for reading old files but also for definite security (py?) */
305         scene_check_setscene(G.scene);
306         
307         /* deselect objects (for dataselect) */
308         for(ob= G.main->object.first; ob; ob= ob->id.next)
309                 ob->flag &= ~(SELECT|OB_FROMGROUP);
310
311         /* group flags again */
312         for(group= G.main->group.first; group; group= group->id.next) {
313                 go= group->gobject.first;
314                 while(go) {
315                         if(go->ob) go->ob->flag |= OB_FROMGROUP;
316                         go= go->next;
317                 }
318         }
319
320         /* sort baselist */
321         DAG_scene_sort(sce);
322         
323         /* ensure dags are built for sets */
324         for(sce= sce->set; sce; sce= sce->set)
325                 if(sce->theDag==NULL)
326                         DAG_scene_sort(sce);
327
328         /* copy layers and flags from bases to objects */
329         for(base= G.scene->base.first; base; base= base->next) {
330                 ob= base->object;
331                 ob->lay= base->lay;
332                 
333                 /* group patch... */
334                 base->flag &= ~(OB_FROMGROUP);
335                 flag= ob->flag & (OB_FROMGROUP);
336                 base->flag |= flag;
337                 
338                 /* not too nice... for recovering objects with lost data */
339                 if(ob->pose==NULL) base->flag &= ~OB_POSEMODE;
340                 ob->flag= base->flag;
341                 
342                 ob->ctime= -1234567.0;  /* force ipo to be calculated later */
343         }
344         /* no full animation update, this to enable render code to work (render code calls own animation updates) */
345         
346         /* do we need FRAMECHANGED in set_scene? */
347 //      if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED);
348 }
349
350 /* called from creator.c */
351 void set_scene_name(char *name)
352 {
353         Scene *sce;
354
355         for (sce= G.main->scene.first; sce; sce= sce->id.next) {
356                 if (BLI_streq(name, sce->id.name+2)) {
357                         set_scene_bg(sce);
358                         return;
359                 }
360         }
361         
362         error("Can't find scene: %s", name);
363 }
364
365 /* used by metaballs
366  * doesnt return the original duplicated object, only dupli's
367  */
368 int next_object(int val, Base **base, Object **ob)
369 {
370         static ListBase *duplilist= NULL;
371         static DupliObject *dupob;
372         static int fase;
373         int run_again=1;
374         
375         /* init */
376         if(val==0) {
377                 fase= F_START;
378                 dupob= NULL;
379         }
380         else {
381
382                 /* run_again is set when a duplilist has been ended */
383                 while(run_again) {
384                         run_again= 0;
385
386                         /* the first base */
387                         if(fase==F_START) {
388                                 *base= G.scene->base.first;
389                                 if(*base) {
390                                         *ob= (*base)->object;
391                                         fase= F_SCENE;
392                                 }
393                                 else {
394                                     /* exception: empty scene */
395                                         if(G.scene->set && G.scene->set->base.first) {
396                                                 *base= G.scene->set->base.first;
397                                                 *ob= (*base)->object;
398                                                 fase= F_SET;
399                                         }
400                                 }
401                         }
402                         else {
403                                 if(*base && fase!=F_DUPLI) {
404                                         *base= (*base)->next;
405                                         if(*base) *ob= (*base)->object;
406                                         else {
407                                                 if(fase==F_SCENE) {
408                                                         /* scene is finished, now do the set */
409                                                         if(G.scene->set && G.scene->set->base.first) {
410                                                                 *base= G.scene->set->base.first;
411                                                                 *ob= (*base)->object;
412                                                                 fase= F_SET;
413                                                         }
414                                                 }
415                                         }
416                                 }
417                         }
418                         
419                         if(*base == NULL) fase= F_START;
420                         else {
421                                 if(fase!=F_DUPLI) {
422                                         if( (*base)->object->transflag & OB_DUPLI) {
423                                                 /* groups cannot be duplicated for mballs yet, 
424                                                 this enters eternal loop because of 
425                                                 makeDispListMBall getting called inside of group_duplilist */
426                                                 if((*base)->object->dup_group == NULL) {
427                                                         duplilist= object_duplilist(G.scene, (*base)->object);
428                                                         
429                                                         dupob= duplilist->first;
430
431                                                         if(!dupob)
432                                                                 free_object_duplilist(duplilist);
433                                                 }
434                                         }
435                                 }
436                                 /* handle dupli's */
437                                 if(dupob) {
438                                         
439                                         Mat4CpyMat4(dupob->ob->obmat, dupob->mat);
440                                         
441                                         (*base)->flag |= OB_FROMDUPLI;
442                                         *ob= dupob->ob;
443                                         fase= F_DUPLI;
444                                         
445                                         dupob= dupob->next;
446                                 }
447                                 else if(fase==F_DUPLI) {
448                                         fase= F_SCENE;
449                                         (*base)->flag &= ~OB_FROMDUPLI;
450                                         
451                                         for(dupob= duplilist->first; dupob; dupob= dupob->next) {
452                                                 Mat4CpyMat4(dupob->ob->obmat, dupob->omat);
453                                         }
454                                         
455                                         free_object_duplilist(duplilist);
456                                         duplilist= NULL;
457                                         run_again= 1;
458                                 }
459                         }
460                 }
461         }
462         
463         return fase;
464 }
465
466 Object *scene_find_camera(Scene *sc)
467 {
468         Base *base;
469         
470         for (base= sc->base.first; base; base= base->next)
471                 if (base->object->type==OB_CAMERA)
472                         return base->object;
473
474         return NULL;
475 }
476
477
478 Base *scene_add_base(Scene *sce, Object *ob)
479 {
480         Base *b= MEM_callocN(sizeof(*b), "scene_add_base");
481         BLI_addhead(&sce->base, b);
482
483         b->object= ob;
484         b->flag= ob->flag;
485         b->lay= ob->lay;
486
487         return b;
488 }
489
490 void scene_deselect_all(Scene *sce)
491 {
492         Base *b;
493
494         for (b= sce->base.first; b; b= b->next) {
495                 b->flag&= ~SELECT;
496                 b->object->flag= b->flag;
497         }
498 }
499
500 void scene_select_base(Scene *sce, Base *selbase)
501 {
502         scene_deselect_all(sce);
503
504         selbase->flag |= SELECT;
505         selbase->object->flag= selbase->flag;
506
507         sce->basact= selbase;
508 }
509
510 /* checks for cycle, returns 1 if it's all OK */
511 int scene_check_setscene(Scene *sce)
512 {
513         Scene *scene;
514         int a, totscene;
515         
516         if(sce->set==NULL) return 1;
517         
518         totscene= 0;
519         for(scene= G.main->scene.first; scene; scene= scene->id.next)
520                 totscene++;
521         
522         for(a=0, scene=sce; scene->set; scene=scene->set, a++) {
523                 /* more iterations than scenes means we have a cycle */
524                 if(a > totscene) {
525                         /* the tested scene gets zero'ed, that's typically current scene */
526                         sce->set= NULL;
527                         return 0;
528                 }
529         }
530
531         return 1;
532 }
533
534 static void scene_update(Scene *sce, unsigned int lay)
535 {
536         Base *base;
537         Object *ob;
538         
539         if(sce->theDag==NULL)
540                 DAG_scene_sort(sce);
541         
542         DAG_scene_update_flags(sce, lay);   // only stuff that moves or needs display still
543         
544         for(base= sce->base.first; base; base= base->next) {
545                 ob= base->object;
546                 
547                 object_handle_update(ob);   // bke_object.h
548                 
549                 /* only update layer when an ipo */
550                 if(ob->ipo && has_ipo_code(ob->ipo, OB_LAY) ) {
551                         base->lay= ob->lay;
552                 }
553         }
554 }
555
556 /* applies changes right away, does all sets too */
557 void scene_update_for_newframe(Scene *sce, unsigned int lay)
558 {
559         Scene *scene= sce;
560         
561         /* clears all BONE_UNKEYED flags for every pose's pchans */
562         framechange_poses_clear_unkeyed();
563         
564         /* object ipos are calculated in where_is_object */
565         do_all_data_ipos();
566         
567         if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED);
568         
569         /* sets first, we allow per definition current scene to have dependencies on sets */
570         for(sce= sce->set; sce; sce= sce->set)
571                 scene_update(sce, lay);
572
573         scene_update(scene, lay);
574 }
575
576 /* return default layer, also used to patch old files */
577 void scene_add_render_layer(Scene *sce)
578 {
579         SceneRenderLayer *srl;
580         int tot= 1 + BLI_countlist(&sce->r.layers);
581         
582         srl= MEM_callocN(sizeof(SceneRenderLayer), "new render layer");
583         sprintf(srl->name, "%d RenderLayer", tot);
584         BLI_addtail(&sce->r.layers, srl);
585
586         /* note, this is also in render, pipeline.c, to make layer when scenedata doesnt have it */
587         srl->lay= (1<<20) -1;
588         srl->layflag= 0x7FFF;   /* solid ztra halo edge strand */
589         srl->passflag= SCE_PASS_COMBINED|SCE_PASS_Z;
590 }
591
592 /* Initialize 'permanent' sculpt data that is saved with file kept after
593    switching out of sculptmode. */
594 void sculptdata_init(Scene *sce)
595 {
596         SculptData *sd;
597
598         if(!sce)
599                 return;
600
601         sd= &sce->sculptdata;
602
603         if(sd->cumap) {
604                 curvemapping_free(sd->cumap);
605                 sd->cumap = NULL;
606         }
607
608         memset(sd, 0, sizeof(SculptData));
609
610         sd->drawbrush.size = sd->smoothbrush.size = sd->pinchbrush.size =
611                 sd->inflatebrush.size = sd->grabbrush.size =
612                 sd->layerbrush.size = sd->flattenbrush.size = 50;
613         sd->drawbrush.strength = sd->smoothbrush.strength =
614                 sd->pinchbrush.strength = sd->inflatebrush.strength =
615                 sd->grabbrush.strength = sd->layerbrush.strength =
616                 sd->flattenbrush.strength = 25;
617         sd->drawbrush.dir = sd->pinchbrush.dir = sd->inflatebrush.dir = sd->layerbrush.dir= 1;
618         sd->drawbrush.flag = sd->smoothbrush.flag =
619                 sd->pinchbrush.flag = sd->inflatebrush.flag =
620                 sd->layerbrush.flag = sd->flattenbrush.flag = 0;
621         sd->drawbrush.view= 0;
622         sd->brush_type= DRAW_BRUSH;
623         sd->texact= -1;
624         sd->texfade= 1;
625         sd->averaging= 1;
626         sd->texsep= 0;
627         sd->texrept= SCULPTREPT_DRAG;
628         sd->flags= SCULPT_DRAW_BRUSH;
629         sd->tablet_size=3;
630         sd->tablet_strength=10;
631         sd->rake=0;
632         sculpt_reset_curve(sd);
633 }
634
635 void sculptdata_free(Scene *sce)
636 {
637         SculptData *sd= &sce->sculptdata;
638         int a;
639
640         sculptsession_free(sce);
641
642         for(a=0; a<MAX_MTEX; a++) {
643                 MTex *mtex= sd->mtex[a];
644                 if(mtex) {
645                         if(mtex->tex) mtex->tex->id.us--;
646                         MEM_freeN(mtex);
647                 }
648         }
649
650         curvemapping_free(sd->cumap);
651         sd->cumap = NULL;
652 }
653
654 void sculpt_vertexusers_free(SculptSession *ss)
655 {
656         if(ss && ss->vertex_users){
657                 MEM_freeN(ss->vertex_users);
658                 MEM_freeN(ss->vertex_users_mem);
659                 ss->vertex_users= NULL;
660                 ss->vertex_users_mem= NULL;
661                 ss->vertex_users_size= 0;
662         }
663 }
664
665 void sculptsession_free(Scene *sce)
666 {
667         SculptSession *ss= sce->sculptdata.session;
668         if(ss) {
669                 if(ss->projverts)
670                         MEM_freeN(ss->projverts);
671                 if(ss->mats)
672                         MEM_freeN(ss->mats);
673
674                 if(ss->radialcontrol)
675                         MEM_freeN(ss->radialcontrol);
676
677                 sculpt_vertexusers_free(ss);
678                 if(ss->texcache)
679                         MEM_freeN(ss->texcache);
680                 MEM_freeN(ss);
681                 sce->sculptdata.session= NULL;
682         }
683 }
684
685 /*  Default curve approximates 0.5 * (cos(pi * x) + 1), with 0 <= x <= 1 */
686 void sculpt_reset_curve(SculptData *sd)
687 {
688         CurveMap *cm = NULL;
689
690         if(!sd->cumap)
691                 sd->cumap = curvemapping_add(1, 0, 0, 1, 1);
692
693         cm = sd->cumap->cm;
694
695         if(cm->curve)
696                 MEM_freeN(cm->curve);
697         cm->curve= MEM_callocN(6*sizeof(CurveMapPoint), "curve points");
698         cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
699         cm->totpoint= 6;
700         cm->curve[0].x= 0;
701         cm->curve[0].y= 1;
702         cm->curve[1].x= 0.1;
703         cm->curve[1].y= 0.97553;
704         cm->curve[2].x= 0.3;
705         cm->curve[2].y= 0.79389;
706         cm->curve[3].x= 0.9;
707         cm->curve[3].y= 0.02447;
708         cm->curve[4].x= 0.7;
709         cm->curve[4].y= 0.20611;
710         cm->curve[5].x= 1;
711         cm->curve[5].y= 0;
712
713         curvemapping_changed(sd->cumap, 0);
714 }
715
716 /* render simplification */
717
718 int get_render_subsurf_level(RenderData *r, int lvl)
719 {
720         if(G.rt == 1 && (r->mode & R_SIMPLIFY))
721                 return MIN2(r->simplify_subsurf, lvl);
722         else
723                 return lvl;
724 }
725
726 int get_render_child_particle_number(RenderData *r, int num)
727 {
728         if(G.rt == 1 && (r->mode & R_SIMPLIFY))
729                 return (int)(r->simplify_particles*num);
730         else
731                 return num;
732 }
733
734 int get_render_shadow_samples(RenderData *r, int samples)
735 {
736         if(G.rt == 1 && (r->mode & R_SIMPLIFY) && samples > 0)
737                 return MIN2(r->simplify_shadowsamples, samples);
738         else
739                 return samples;
740 }
741
742 float get_render_aosss_error(RenderData *r, float error)
743 {
744         if(G.rt == 1 && (r->mode & R_SIMPLIFY))
745                 return ((1.0f-r->simplify_aosss)*10.0f + 1.0f)*error;
746         else
747                 return error;
748 }
749