small merge needed for testing new animsys in 2.5 BGE, mixing own changes with merge...
[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_anim_types.h"
47 #include "DNA_armature_types.h" 
48 #include "DNA_color_types.h"
49 #include "DNA_constraint_types.h"
50 #include "DNA_curve_types.h"
51 #include "DNA_group_types.h"
52 #include "DNA_lamp_types.h"
53 #include "DNA_material_types.h"
54 #include "DNA_meta_types.h"
55 #include "DNA_object_types.h"
56 #include "DNA_scene_types.h"
57 #include "DNA_scriptlink_types.h"
58 #include "DNA_texture_types.h"
59 #include "DNA_userdef_types.h"
60
61 #include "BKE_action.h"                 
62 #include "BKE_anim.h"
63 #include "BKE_animsys.h"
64 #include "BKE_armature.h"               
65 #include "BKE_colortools.h"
66 #include "BKE_colortools.h"
67 #include "BKE_constraint.h"
68 #include "BKE_depsgraph.h"
69 #include "BKE_global.h"
70 #include "BKE_group.h"
71 #include "BKE_ipo.h"
72 #include "BKE_idprop.h"
73 #include "BKE_image.h"
74 #include "BKE_key.h"
75 #include "BKE_library.h"
76 #include "BKE_main.h"
77 #include "BKE_node.h"
78 #include "BKE_object.h"
79 #include "BKE_scene.h"
80 #include "BKE_sculpt.h"
81 #include "BKE_sequence.h"
82 #include "BKE_world.h"
83 #include "BKE_utildefines.h"
84
85 //XXX #include "BIF_previewrender.h"
86 //XXX #include "BIF_editseq.h"
87
88 #ifndef DISABLE_PYTHON
89 #include "BPY_extern.h"
90 #endif
91
92 #include "BLI_arithb.h"
93 #include "BLI_blenlib.h"
94
95 //XXX #include "nla.h"
96
97 #ifdef WIN32
98 #else
99 #include <sys/time.h>
100 #endif
101
102 void free_avicodecdata(AviCodecData *acd)
103 {
104         if (acd) {
105                 if (acd->lpFormat){
106                         MEM_freeN(acd->lpFormat);
107                         acd->lpFormat = NULL;
108                         acd->cbFormat = 0;
109                 }
110                 if (acd->lpParms){
111                         MEM_freeN(acd->lpParms);
112                         acd->lpParms = NULL;
113                         acd->cbParms = 0;
114                 }
115         }
116 }
117
118 void free_qtcodecdata(QuicktimeCodecData *qcd)
119 {
120         if (qcd) {
121                 if (qcd->cdParms){
122                         MEM_freeN(qcd->cdParms);
123                         qcd->cdParms = NULL;
124                         qcd->cdSize = 0;
125                 }
126         }
127 }
128
129 /* copy_scene moved to src/header_info.c... should be back */
130
131 /* do not free scene itself */
132 void free_scene(Scene *sce)
133 {
134         Base *base;
135
136         base= sce->base.first;
137         while(base) {
138                 base->object->id.us--;
139                 base= base->next;
140         }
141         /* do not free objects! */
142
143         BLI_freelistN(&sce->base);
144         seq_free_editing(sce->ed);
145         if(sce->radio) MEM_freeN(sce->radio);
146         sce->radio= 0;
147         
148 #ifndef DISABLE_PYTHON
149         BPY_free_scriptlink(&sce->scriptlink);
150 #endif
151
152         BKE_free_animdata((ID *)sce);
153         BKE_keyingsets_free(&sce->keyingsets);
154         
155         if (sce->r.avicodecdata) {
156                 free_avicodecdata(sce->r.avicodecdata);
157                 MEM_freeN(sce->r.avicodecdata);
158                 sce->r.avicodecdata = NULL;
159         }
160         if (sce->r.qtcodecdata) {
161                 free_qtcodecdata(sce->r.qtcodecdata);
162                 MEM_freeN(sce->r.qtcodecdata);
163                 sce->r.qtcodecdata = NULL;
164         }
165         if (sce->r.ffcodecdata.properties) {
166                 IDP_FreeProperty(sce->r.ffcodecdata.properties);
167                 MEM_freeN(sce->r.ffcodecdata.properties);
168                 sce->r.ffcodecdata.properties = NULL;
169         }
170         
171         BLI_freelistN(&sce->markers);
172         BLI_freelistN(&sce->transform_spaces);
173         BLI_freelistN(&sce->r.layers);
174         
175         if(sce->toolsettings) {
176                 if(sce->toolsettings->vpaint)
177                         MEM_freeN(sce->toolsettings->vpaint);
178                 if(sce->toolsettings->wpaint)
179                         MEM_freeN(sce->toolsettings->wpaint);
180                 if(sce->toolsettings->sculpt) {
181                         sculptsession_free(sce->toolsettings->sculpt);
182                         MEM_freeN(sce->toolsettings->sculpt);
183                 }
184                 
185                 MEM_freeN(sce->toolsettings);
186                 sce->toolsettings = NULL;       
187         }
188         
189         if (sce->theDag) {
190                 free_forest(sce->theDag);
191                 MEM_freeN(sce->theDag);
192         }
193         
194         if(sce->nodetree) {
195                 ntreeFreeTree(sce->nodetree);
196                 MEM_freeN(sce->nodetree);
197         }
198 }
199
200 Scene *add_scene(char *name)
201 {
202         Scene *sce;
203         ParticleEditSettings *pset;
204         int a;
205
206         sce= alloc_libblock(&G.main->scene, ID_SCE, name);
207         sce->lay= 1;
208         sce->selectmode= SCE_SELECT_VERTEX;
209         sce->editbutsize= 0.1;
210         sce->autokey_mode= U.autokey_mode;
211         
212         sce->r.mode= R_GAMMA;
213         sce->r.cfra= 1;
214         sce->r.sfra= 1;
215         sce->r.efra= 250;
216         sce->r.xsch= 320;
217         sce->r.ysch= 256;
218         sce->r.xasp= 1;
219         sce->r.yasp= 1;
220         sce->r.xparts= 4;
221         sce->r.yparts= 4;
222         sce->r.size= 100;
223         sce->r.planes= 24;
224         sce->r.quality= 90;
225         sce->r.framapto= 100;
226         sce->r.images= 100;
227         sce->r.framelen= 1.0;
228         sce->r.frs_sec= 25;
229         sce->r.frs_sec_base= 1;
230         sce->r.ocres = 128;
231         
232         sce->r.bake_mode= 1;    /* prevent to include render stuff here */
233         sce->r.bake_filter= 2;
234         sce->r.bake_osa= 5;
235         sce->r.bake_flag= R_BAKE_CLEAR;
236         sce->r.bake_normal_space= R_BAKE_SPACE_TANGENT;
237         
238         sce->r.xplay= 640;
239         sce->r.yplay= 480;
240         sce->r.freqplay= 60;
241         sce->r.depth= 32;
242         
243         sce->r.threads= 1;
244         
245         sce->r.stereomode = 1;  // no stereo
246         sce->r.domeangle = 180;
247         sce->r.domemode = 1;
248         sce->r.domeres = 4;
249         sce->r.domeresbuf = 1.0f;
250         sce->r.dometilt = 0;
251
252         sce->r.simplify_subsurf= 6;
253         sce->r.simplify_particles= 1.0f;
254         sce->r.simplify_shadowsamples= 16;
255         sce->r.simplify_aosss= 1.0f;
256
257         sce->r.cineonblack= 95;
258         sce->r.cineonwhite= 685;
259         sce->r.cineongamma= 1.7f;
260         
261         sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings),"Tool Settings Struct");
262         sce->toolsettings->cornertype=1;
263         sce->toolsettings->degr = 90; 
264         sce->toolsettings->step = 9;
265         sce->toolsettings->turn = 1;                            
266         sce->toolsettings->extr_offs = 1; 
267         sce->toolsettings->doublimit = 0.001;
268         sce->toolsettings->segments = 32;
269         sce->toolsettings->rings = 32;
270         sce->toolsettings->vertices = 32;
271         sce->toolsettings->editbutflag = 1;
272         sce->toolsettings->uvcalc_radius = 1.0f;
273         sce->toolsettings->uvcalc_cubesize = 1.0f;
274         sce->toolsettings->uvcalc_mapdir = 1;
275         sce->toolsettings->uvcalc_mapalign = 1;
276         sce->toolsettings->unwrapper = 1;
277         sce->toolsettings->select_thresh= 0.01f;
278         sce->toolsettings->jointrilimit = 0.8f;
279
280         sce->toolsettings->skgen_resolution = 100;
281         sce->toolsettings->skgen_threshold_internal     = 0.01f;
282         sce->toolsettings->skgen_threshold_external     = 0.01f;
283         sce->toolsettings->skgen_angle_limit                    = 45.0f;
284         sce->toolsettings->skgen_length_ratio                   = 1.3f;
285         sce->toolsettings->skgen_length_limit                   = 1.5f;
286         sce->toolsettings->skgen_correlation_limit              = 0.98f;
287         sce->toolsettings->skgen_symmetry_limit                 = 0.1f;
288         sce->toolsettings->skgen_postpro = SKGEN_SMOOTH;
289         sce->toolsettings->skgen_postpro_passes = 1;
290         sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_FILTER_SMART|SKGEN_HARMONIC|SKGEN_SUB_CORRELATION|SKGEN_STICK_TO_EMBEDDING;
291         sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION;
292         sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH;
293         sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE;
294
295         sce->toolsettings->proportional_size = 1.0f;
296
297         pset= &sce->toolsettings->particle;
298         pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER;
299         pset->emitterdist= 0.25f;
300         pset->totrekey= 5;
301         pset->totaddkey= 5;
302         pset->brushtype= PE_BRUSH_NONE;
303         for(a=0; a<PE_TOT_BRUSH; a++) {
304                 pset->brush[a].strength= 50;
305                 pset->brush[a].size= 50;
306                 pset->brush[a].step= 10;
307         }
308         pset->brush[PE_BRUSH_CUT].strength= 100;
309         
310         sce->jumpframe = 10;
311         sce->audio.mixrate = 44100;
312
313         strcpy(sce->r.backbuf, "//backbuf");
314         strcpy(sce->r.pic, U.renderdir);
315
316         BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f);
317         sce->r.osa= 8;
318
319         /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */
320         scene_add_render_layer(sce);
321         
322         return sce;
323 }
324
325 Base *object_in_scene(Object *ob, Scene *sce)
326 {
327         Base *base;
328         
329         base= sce->base.first;
330         while(base) {
331                 if(base->object == ob) return base;
332                 base= base->next;
333         }
334         return NULL;
335 }
336
337 void set_scene_bg(Scene *scene)
338 {
339         Scene *sce;
340         Base *base;
341         Object *ob;
342         Group *group;
343         GroupObject *go;
344         int flag;
345         
346         /* check for cyclic sets, for reading old files but also for definite security (py?) */
347         scene_check_setscene(scene);
348         
349         /* deselect objects (for dataselect) */
350         for(ob= G.main->object.first; ob; ob= ob->id.next)
351                 ob->flag &= ~(SELECT|OB_FROMGROUP);
352
353         /* group flags again */
354         for(group= G.main->group.first; group; group= group->id.next) {
355                 go= group->gobject.first;
356                 while(go) {
357                         if(go->ob) go->ob->flag |= OB_FROMGROUP;
358                         go= go->next;
359                 }
360         }
361
362         /* sort baselist */
363         DAG_scene_sort(scene);
364         
365         /* ensure dags are built for sets */
366         for(sce= scene->set; sce; sce= sce->set)
367                 if(sce->theDag==NULL)
368                         DAG_scene_sort(sce);
369
370         /* copy layers and flags from bases to objects */
371         for(base= scene->base.first; base; base= base->next) {
372                 ob= base->object;
373                 ob->lay= base->lay;
374                 
375                 /* group patch... */
376                 base->flag &= ~(OB_FROMGROUP);
377                 flag= ob->flag & (OB_FROMGROUP);
378                 base->flag |= flag;
379                 
380                 /* not too nice... for recovering objects with lost data */
381                 if(ob->pose==NULL) base->flag &= ~OB_POSEMODE;
382                 ob->flag= base->flag;
383                 
384                 ob->ctime= -1234567.0;  /* force ipo to be calculated later */
385         }
386         /* no full animation update, this to enable render code to work (render code calls own animation updates) */
387         
388         /* do we need FRAMECHANGED in set_scene? */
389 //      if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED, 0);
390 }
391
392 /* called from creator.c */
393 void set_scene_name(char *name)
394 {
395         Scene *sce;
396
397         for (sce= G.main->scene.first; sce; sce= sce->id.next) {
398                 if (BLI_streq(name, sce->id.name+2)) {
399                         set_scene_bg(sce);
400                         return;
401                 }
402         }
403         
404         //XXX error("Can't find scene: %s", name);
405 }
406
407 /* used by metaballs
408  * doesnt return the original duplicated object, only dupli's
409  */
410 int next_object(Scene *scene, int val, Base **base, Object **ob)
411 {
412         static ListBase *duplilist= NULL;
413         static DupliObject *dupob;
414         static int fase= F_START, in_next_object= 0;
415         int run_again=1;
416         
417         /* init */
418         if(val==0) {
419                 fase= F_START;
420                 dupob= NULL;
421                 
422                 /* XXX particle systems with metas+dupligroups call this recursively */
423                 /* see bug #18725 */
424                 if(in_next_object) {
425                         printf("ERROR: MetaBall generation called recursively, not supported\n");
426                         
427                         return F_ERROR;
428                 }
429         }
430         else {
431                 in_next_object= 1;
432                 
433                 /* run_again is set when a duplilist has been ended */
434                 while(run_again) {
435                         run_again= 0;
436
437                         /* the first base */
438                         if(fase==F_START) {
439                                 *base= scene->base.first;
440                                 if(*base) {
441                                         *ob= (*base)->object;
442                                         fase= F_SCENE;
443                                 }
444                                 else {
445                                     /* exception: empty scene */
446                                         if(scene->set && scene->set->base.first) {
447                                                 *base= scene->set->base.first;
448                                                 *ob= (*base)->object;
449                                                 fase= F_SET;
450                                         }
451                                 }
452                         }
453                         else {
454                                 if(*base && fase!=F_DUPLI) {
455                                         *base= (*base)->next;
456                                         if(*base) *ob= (*base)->object;
457                                         else {
458                                                 if(fase==F_SCENE) {
459                                                         /* scene is finished, now do the set */
460                                                         if(scene->set && scene->set->base.first) {
461                                                                 *base= scene->set->base.first;
462                                                                 *ob= (*base)->object;
463                                                                 fase= F_SET;
464                                                         }
465                                                 }
466                                         }
467                                 }
468                         }
469                         
470                         if(*base == NULL) fase= F_START;
471                         else {
472                                 if(fase!=F_DUPLI) {
473                                         if( (*base)->object->transflag & OB_DUPLI) {
474                                                 /* groups cannot be duplicated for mballs yet, 
475                                                 this enters eternal loop because of 
476                                                 makeDispListMBall getting called inside of group_duplilist */
477                                                 if((*base)->object->dup_group == NULL) {
478                                                         duplilist= object_duplilist(scene, (*base)->object);
479                                                         
480                                                         dupob= duplilist->first;
481
482                                                         if(!dupob)
483                                                                 free_object_duplilist(duplilist);
484                                                 }
485                                         }
486                                 }
487                                 /* handle dupli's */
488                                 if(dupob) {
489                                         
490                                         Mat4CpyMat4(dupob->ob->obmat, dupob->mat);
491                                         
492                                         (*base)->flag |= OB_FROMDUPLI;
493                                         *ob= dupob->ob;
494                                         fase= F_DUPLI;
495                                         
496                                         dupob= dupob->next;
497                                 }
498                                 else if(fase==F_DUPLI) {
499                                         fase= F_SCENE;
500                                         (*base)->flag &= ~OB_FROMDUPLI;
501                                         
502                                         for(dupob= duplilist->first; dupob; dupob= dupob->next) {
503                                                 Mat4CpyMat4(dupob->ob->obmat, dupob->omat);
504                                         }
505                                         
506                                         free_object_duplilist(duplilist);
507                                         duplilist= NULL;
508                                         run_again= 1;
509                                 }
510                         }
511                 }
512         }
513         
514         /* reset recursion test */
515         in_next_object= 0;
516         
517         return fase;
518 }
519
520 Object *scene_find_camera(Scene *sc)
521 {
522         Base *base;
523         
524         for (base= sc->base.first; base; base= base->next)
525                 if (base->object->type==OB_CAMERA)
526                         return base->object;
527
528         return NULL;
529 }
530
531
532 Base *scene_add_base(Scene *sce, Object *ob)
533 {
534         Base *b= MEM_callocN(sizeof(*b), "scene_add_base");
535         BLI_addhead(&sce->base, b);
536
537         b->object= ob;
538         b->flag= ob->flag;
539         b->lay= ob->lay;
540
541         return b;
542 }
543
544 void scene_deselect_all(Scene *sce)
545 {
546         Base *b;
547
548         for (b= sce->base.first; b; b= b->next) {
549                 b->flag&= ~SELECT;
550                 b->object->flag= b->flag;
551         }
552 }
553
554 void scene_select_base(Scene *sce, Base *selbase)
555 {
556         scene_deselect_all(sce);
557
558         selbase->flag |= SELECT;
559         selbase->object->flag= selbase->flag;
560
561         sce->basact= selbase;
562 }
563
564 /* checks for cycle, returns 1 if it's all OK */
565 int scene_check_setscene(Scene *sce)
566 {
567         Scene *scene;
568         int a, totscene;
569         
570         if(sce->set==NULL) return 1;
571         
572         totscene= 0;
573         for(scene= G.main->scene.first; scene; scene= scene->id.next)
574                 totscene++;
575         
576         for(a=0, scene=sce; scene->set; scene=scene->set, a++) {
577                 /* more iterations than scenes means we have a cycle */
578                 if(a > totscene) {
579                         /* the tested scene gets zero'ed, that's typically current scene */
580                         sce->set= NULL;
581                         return 0;
582                 }
583         }
584
585         return 1;
586 }
587
588 /* This (evil) function is needed to cope with two legacy Blender rendering features
589 * mblur (motion blur that renders 'subframes' and blurs them together), and fields 
590 * rendering. Thus, the use of ugly globals from object.c
591 */
592 // BAD... EVIL... JUJU...!!!!
593 // XXX moved here temporarily
594 float frame_to_float (Scene *scene, int cfra)           /* see also bsystem_time in object.c */
595 {
596         extern float bluroffs;  /* bad stuff borrowed from object.c */
597         extern float fieldoffs;
598         float ctime;
599         
600         ctime= (float)cfra;
601         ctime+= bluroffs+fieldoffs;
602         ctime*= scene->r.framelen;
603         
604         return ctime;
605 }
606
607 static void scene_update(Scene *sce, unsigned int lay)
608 {
609         Base *base;
610         Object *ob;
611         float ctime = frame_to_float(sce, sce->r.cfra); 
612         
613         if(sce->theDag==NULL)
614                 DAG_scene_sort(sce);
615         
616         DAG_scene_update_flags(sce, lay);   // only stuff that moves or needs display still
617         
618         /* All 'standard' (i.e. without any dependencies) animation is handled here,
619                 * with an 'local' to 'macro' order of evaluation. This should ensure that
620                 * settings stored nestled within a hierarchy (i.e. settings in a Texture block
621             * can be overridden by settings from Scene, which owns the Texture through a hierarchy 
622             * such as Scene->World->MTex/Texture) can still get correctly overridden.
623                 */
624         BKE_animsys_evaluate_all_animation(G.main, ctime);
625         
626         for(base= sce->base.first; base; base= base->next) {
627                 ob= base->object;
628                 
629                 object_handle_update(sce, ob);   // bke_object.h
630                 
631                 /* only update layer when an ipo */
632                         // XXX old animation system
633                 //if(ob->ipo && has_ipo_code(ob->ipo, OB_LAY) ) {
634                 //      base->lay= ob->lay;
635                 //}
636         }
637 }
638
639
640 /* applies changes right away, does all sets too */
641 void scene_update_for_newframe(Scene *sce, unsigned int lay)
642 {
643         Scene *scene= sce;
644         
645         /* clear animation overrides */
646         // XXX TODO...
647         
648 #ifndef DISABLE_PYTHON
649         if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED, 0);
650 #endif
651         /* sets first, we allow per definition current scene to have dependencies on sets */
652         for(sce= sce->set; sce; sce= sce->set)
653                 scene_update(sce, lay);
654
655         scene_update(scene, lay);
656 }
657
658 /* return default layer, also used to patch old files */
659 void scene_add_render_layer(Scene *sce)
660 {
661         SceneRenderLayer *srl;
662         int tot= 1 + BLI_countlist(&sce->r.layers);
663         
664         srl= MEM_callocN(sizeof(SceneRenderLayer), "new render layer");
665         sprintf(srl->name, "%d RenderLayer", tot);
666         BLI_addtail(&sce->r.layers, srl);
667
668         /* note, this is also in render, pipeline.c, to make layer when scenedata doesnt have it */
669         srl->lay= (1<<20) -1;
670         srl->layflag= 0x7FFF;   /* solid ztra halo edge strand */
671         srl->passflag= SCE_PASS_COMBINED|SCE_PASS_Z;
672 }
673
674 void sculptsession_free(Sculpt *sculpt)
675 {
676         SculptSession *ss= sculpt->session;
677         if(ss) {
678                 if(ss->projverts)
679                         MEM_freeN(ss->projverts);
680
681                 if(ss->fmap)
682                         MEM_freeN(ss->fmap);
683
684                 if(ss->fmap_mem)
685                         MEM_freeN(ss->fmap_mem);
686
687                 if(ss->texcache)
688                         MEM_freeN(ss->texcache);
689                 MEM_freeN(ss);
690                 sculpt->session= NULL;
691         }
692 }
693
694 /* render simplification */
695
696 int get_render_subsurf_level(RenderData *r, int lvl)
697 {
698         if(G.rt == 1 && (r->mode & R_SIMPLIFY))
699                 return MIN2(r->simplify_subsurf, lvl);
700         else
701                 return lvl;
702 }
703
704 int get_render_child_particle_number(RenderData *r, int num)
705 {
706         if(G.rt == 1 && (r->mode & R_SIMPLIFY))
707                 return (int)(r->simplify_particles*num);
708         else
709                 return num;
710 }
711
712 int get_render_shadow_samples(RenderData *r, int samples)
713 {
714         if(G.rt == 1 && (r->mode & R_SIMPLIFY) && samples > 0)
715                 return MIN2(r->simplify_shadowsamples, samples);
716         else
717                 return samples;
718 }
719
720 float get_render_aosss_error(RenderData *r, float error)
721 {
722         if(G.rt == 1 && (r->mode & R_SIMPLIFY))
723                 return ((1.0f-r->simplify_aosss)*10.0f + 1.0f)*error;
724         else
725                 return error;
726 }
727
728 void free_dome_warp_text(struct Text *txt)
729 {
730         Scene *scene;
731
732         scene = G.main->scene.first;
733         while(scene) {
734                 if (scene->r.dometext == txt)
735                         scene->r.dometext = NULL;
736                 scene = scene->id.next;
737         }
738 }