diff options
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 245 |
1 files changed, 97 insertions, 148 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 1727edc10fc..5c936c3ab39 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -43,6 +43,7 @@ #endif #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_color_types.h" #include "DNA_constraint_types.h" @@ -59,8 +60,9 @@ #include "BKE_action.h" #include "BKE_anim.h" +#include "BKE_animsys.h" #include "BKE_armature.h" -#include "BKE_bad_level_calls.h" +#include "BKE_colortools.h" #include "BKE_colortools.h" #include "BKE_constraint.h" #include "BKE_depsgraph.h" @@ -76,11 +78,12 @@ #include "BKE_object.h" #include "BKE_scene.h" #include "BKE_sculpt.h" +#include "BKE_sequence.h" #include "BKE_world.h" #include "BKE_utildefines.h" -#include "BIF_previewrender.h" -#include "BIF_editseq.h" +//XXX #include "BIF_previewrender.h" +//XXX #include "BIF_editseq.h" #ifndef DISABLE_PYTHON #include "BPY_extern.h" @@ -89,7 +92,7 @@ #include "BLI_arithb.h" #include "BLI_blenlib.h" -#include "nla.h" +//XXX #include "nla.h" #ifdef WIN32 #else @@ -138,13 +141,16 @@ void free_scene(Scene *sce) /* do not free objects! */ BLI_freelistN(&sce->base); - free_editing(sce->ed); + seq_free_editing(sce->ed); if(sce->radio) MEM_freeN(sce->radio); sce->radio= 0; #ifndef DISABLE_PYTHON BPY_free_scriptlink(&sce->scriptlink); #endif + + BKE_free_animdata((ID *)sce); + BKE_keyingsets_free(&sce->keyingsets); if (sce->r.avicodecdata) { free_avicodecdata(sce->r.avicodecdata); @@ -166,7 +172,16 @@ void free_scene(Scene *sce) BLI_freelistN(&sce->transform_spaces); BLI_freelistN(&sce->r.layers); - if(sce->toolsettings){ + if(sce->toolsettings) { + if(sce->toolsettings->vpaint) + MEM_freeN(sce->toolsettings->vpaint); + if(sce->toolsettings->wpaint) + MEM_freeN(sce->toolsettings->wpaint); + if(sce->toolsettings->sculpt) { + sculptsession_free(sce->toolsettings->sculpt); + MEM_freeN(sce->toolsettings->sculpt); + } + MEM_freeN(sce->toolsettings); sce->toolsettings = NULL; } @@ -180,8 +195,6 @@ void free_scene(Scene *sce) ntreeFreeTree(sce->nodetree); MEM_freeN(sce->nodetree); } - - sculptdata_free(sce); } Scene *add_scene(char *name) @@ -230,6 +243,11 @@ Scene *add_scene(char *name) sce->r.threads= 1; sce->r.stereomode = 1; // no stereo + sce->r.domeangle = 180; + sce->r.domemode = 1; + sce->r.domesize = 1.0f; + sce->r.domeres = 4; + sce->r.domeresbuf = 1.0f; sce->r.simplify_subsurf= 6; sce->r.simplify_particles= 1.0f; @@ -274,6 +292,8 @@ Scene *add_scene(char *name) sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH; sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE; + sce->toolsettings->proportional_size = 1.0f; + pset= &sce->toolsettings->particle; pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER; pset->emitterdist= 0.25f; @@ -296,8 +316,6 @@ Scene *add_scene(char *name) BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); sce->r.osa= 8; - sculptdata_init(sce); - /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */ scene_add_render_layer(sce); @@ -316,21 +334,17 @@ Base *object_in_scene(Object *ob, Scene *sce) return NULL; } -void set_scene_bg(Scene *sce) +void set_scene_bg(Scene *scene) { + Scene *sce; Base *base; Object *ob; Group *group; GroupObject *go; int flag; - // Note: this here is defined in editseq.c (BIF_editseq.h), NOT in blenkernel! - clear_last_seq(); - - G.scene= sce; - /* check for cyclic sets, for reading old files but also for definite security (py?) */ - scene_check_setscene(G.scene); + scene_check_setscene(scene); /* deselect objects (for dataselect) */ for(ob= G.main->object.first; ob; ob= ob->id.next) @@ -346,15 +360,15 @@ void set_scene_bg(Scene *sce) } /* sort baselist */ - DAG_scene_sort(sce); + DAG_scene_sort(scene); /* ensure dags are built for sets */ - for(sce= sce->set; sce; sce= sce->set) + for(sce= scene->set; sce; sce= sce->set) if(sce->theDag==NULL) DAG_scene_sort(sce); /* copy layers and flags from bases to objects */ - for(base= G.scene->base.first; base; base= base->next) { + for(base= scene->base.first; base; base= base->next) { ob= base->object; ob->lay= base->lay; @@ -387,13 +401,13 @@ void set_scene_name(char *name) } } - error("Can't find scene: %s", name); + //XXX error("Can't find scene: %s", name); } /* used by metaballs * doesnt return the original duplicated object, only dupli's */ -int next_object(int val, Base **base, Object **ob) +int next_object(Scene *scene, int val, Base **base, Object **ob) { static ListBase *duplilist= NULL; static DupliObject *dupob; @@ -413,15 +427,15 @@ int next_object(int val, Base **base, Object **ob) /* the first base */ if(fase==F_START) { - *base= G.scene->base.first; + *base= scene->base.first; if(*base) { *ob= (*base)->object; fase= F_SCENE; } else { /* exception: empty scene */ - if(G.scene->set && G.scene->set->base.first) { - *base= G.scene->set->base.first; + if(scene->set && scene->set->base.first) { + *base= scene->set->base.first; *ob= (*base)->object; fase= F_SET; } @@ -434,8 +448,8 @@ int next_object(int val, Base **base, Object **ob) else { if(fase==F_SCENE) { /* scene is finished, now do the set */ - if(G.scene->set && G.scene->set->base.first) { - *base= G.scene->set->base.first; + if(scene->set && scene->set->base.first) { + *base= scene->set->base.first; *ob= (*base)->object; fase= F_SET; } @@ -452,7 +466,7 @@ int next_object(int val, Base **base, Object **ob) this enters eternal loop because of makeDispListMBall getting called inside of group_duplilist */ if((*base)->object->dup_group == NULL) { - duplilist= object_duplilist(G.scene, (*base)->object); + duplilist= object_duplilist(scene, (*base)->object); dupob= duplilist->first; @@ -559,38 +573,66 @@ int scene_check_setscene(Scene *sce) return 1; } +/* This (evil) function is needed to cope with two legacy Blender rendering features +* mblur (motion blur that renders 'subframes' and blurs them together), and fields +* rendering. Thus, the use of ugly globals from object.c +*/ +// BAD... EVIL... JUJU...!!!! +// XXX moved here temporarily +float frame_to_float (Scene *scene, int cfra) /* see also bsystem_time in object.c */ +{ + extern float bluroffs; /* bad stuff borrowed from object.c */ + extern float fieldoffs; + float ctime; + + ctime= (float)cfra; + ctime+= bluroffs+fieldoffs; + ctime*= scene->r.framelen; + + return ctime; +} + static void scene_update(Scene *sce, unsigned int lay) { Base *base; Object *ob; + float ctime = frame_to_float(sce, sce->r.cfra); if(sce->theDag==NULL) DAG_scene_sort(sce); DAG_scene_update_flags(sce, lay); // only stuff that moves or needs display still + /* All 'standard' (i.e. without any dependencies) animation is handled here, + * with an 'local' to 'macro' order of evaluation. This should ensure that + * settings stored nestled within a hierarchy (i.e. settings in a Texture block + * can be overridden by settings from Scene, which owns the Texture through a hierarchy + * such as Scene->World->MTex/Texture) can still get correctly overridden. + */ + BKE_animsys_evaluate_all_animation(G.main, ctime); + for(base= sce->base.first; base; base= base->next) { ob= base->object; - object_handle_update(ob); // bke_object.h + object_handle_update(sce, ob); // bke_object.h /* only update layer when an ipo */ - if(ob->ipo && has_ipo_code(ob->ipo, OB_LAY) ) { - base->lay= ob->lay; - } + // XXX old animation system + //if(ob->ipo && has_ipo_code(ob->ipo, OB_LAY) ) { + // base->lay= ob->lay; + //} } } + /* applies changes right away, does all sets too */ void scene_update_for_newframe(Scene *sce, unsigned int lay) { Scene *scene= sce; - /* clears all BONE_UNKEYED flags for every pose's pchans */ - framechange_poses_clear_unkeyed(); + /* clear animation overrides */ + // XXX TODO... - /* object ipos are calculated in where_is_object */ - do_all_data_ipos(); #ifndef DISABLE_PYTHON if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED, 0); #endif @@ -617,130 +659,26 @@ void scene_add_render_layer(Scene *sce) srl->passflag= SCE_PASS_COMBINED|SCE_PASS_Z; } -/* Initialize 'permanent' sculpt data that is saved with file kept after - switching out of sculptmode. */ -void sculptdata_init(Scene *sce) -{ - SculptData *sd; - - if(!sce) - return; - - sd= &sce->sculptdata; - - if(sd->cumap) { - curvemapping_free(sd->cumap); - sd->cumap = NULL; - } - - memset(sd, 0, sizeof(SculptData)); - - sd->drawbrush.size = sd->smoothbrush.size = sd->pinchbrush.size = - sd->inflatebrush.size = sd->grabbrush.size = - sd->layerbrush.size = sd->flattenbrush.size = 50; - sd->drawbrush.strength = sd->smoothbrush.strength = - sd->pinchbrush.strength = sd->inflatebrush.strength = - sd->grabbrush.strength = sd->layerbrush.strength = - sd->flattenbrush.strength = 25; - sd->drawbrush.dir = sd->pinchbrush.dir = sd->inflatebrush.dir = sd->layerbrush.dir= 1; - sd->drawbrush.flag = sd->smoothbrush.flag = - sd->pinchbrush.flag = sd->inflatebrush.flag = - sd->layerbrush.flag = sd->flattenbrush.flag = 0; - sd->drawbrush.view= 0; - sd->brush_type= DRAW_BRUSH; - sd->texact= -1; - sd->texfade= 1; - sd->averaging= 1; - sd->texsep= 0; - sd->texrept= SCULPTREPT_DRAG; - sd->flags= SCULPT_DRAW_BRUSH; - sd->tablet_size=3; - sd->tablet_strength=10; - sd->rake=0; - sculpt_reset_curve(sd); -} - -void sculptdata_free(Scene *sce) -{ - SculptData *sd= &sce->sculptdata; - int a; - - sculptsession_free(sce); - - for(a=0; a<MAX_MTEX; a++) { - MTex *mtex= sd->mtex[a]; - if(mtex) { - if(mtex->tex) mtex->tex->id.us--; - MEM_freeN(mtex); - } - } - - curvemapping_free(sd->cumap); - sd->cumap = NULL; -} - -void sculpt_vertexusers_free(SculptSession *ss) +void sculptsession_free(Sculpt *sculpt) { - if(ss && ss->vertex_users){ - MEM_freeN(ss->vertex_users); - MEM_freeN(ss->vertex_users_mem); - ss->vertex_users= NULL; - ss->vertex_users_mem= NULL; - ss->vertex_users_size= 0; - } -} - -void sculptsession_free(Scene *sce) -{ - SculptSession *ss= sce->sculptdata.session; + SculptSession *ss= sculpt->session; if(ss) { if(ss->projverts) MEM_freeN(ss->projverts); - if(ss->mats) - MEM_freeN(ss->mats); - if(ss->radialcontrol) - MEM_freeN(ss->radialcontrol); + if(ss->fmap) + MEM_freeN(ss->fmap); + + if(ss->fmap_mem) + MEM_freeN(ss->fmap_mem); - sculpt_vertexusers_free(ss); if(ss->texcache) MEM_freeN(ss->texcache); MEM_freeN(ss); - sce->sculptdata.session= NULL; + sculpt->session= NULL; } } -/* Default curve approximates 0.5 * (cos(pi * x) + 1), with 0 <= x <= 1 */ -void sculpt_reset_curve(SculptData *sd) -{ - CurveMap *cm = NULL; - - if(!sd->cumap) - sd->cumap = curvemapping_add(1, 0, 0, 1, 1); - - cm = sd->cumap->cm; - - if(cm->curve) - MEM_freeN(cm->curve); - cm->curve= MEM_callocN(6*sizeof(CurveMapPoint), "curve points"); - cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; - cm->totpoint= 6; - cm->curve[0].x= 0; - cm->curve[0].y= 1; - cm->curve[1].x= 0.1; - cm->curve[1].y= 0.97553; - cm->curve[2].x= 0.3; - cm->curve[2].y= 0.79389; - cm->curve[3].x= 0.9; - cm->curve[3].y= 0.02447; - cm->curve[4].x= 0.7; - cm->curve[4].y= 0.20611; - cm->curve[5].x= 1; - cm->curve[5].y= 0; - - curvemapping_changed(sd->cumap, 0); -} - /* render simplification */ int get_render_subsurf_level(RenderData *r, int lvl) @@ -775,3 +713,14 @@ float get_render_aosss_error(RenderData *r, float error) return error; } +void free_dome_warp_text(struct Text *txt) +{ + Scene *scene; + + scene = G.main->scene.first; + while(scene) { + if (scene->r.dometext == txt) + scene->r.dometext = NULL; + scene = scene->id.next; + } +}
\ No newline at end of file |