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