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