diff options
author | Nick Samarin <nicks1987@bigmir.net> | 2011-02-16 20:07:18 +0300 |
---|---|---|
committer | Nick Samarin <nicks1987@bigmir.net> | 2011-02-16 20:07:18 +0300 |
commit | c5f6a01dd5998976addd2085470bb73a150579e5 (patch) | |
tree | 42b3345fb3ea2e7607a6d1eec379b8ce23b5ffbc /source/blender/blenkernel/intern/scene.c | |
parent | 4cf62f1e7e2bb28b47f79e4bd7c1482ab742ebbd (diff) | |
parent | 9e9e028f059f29d493dc020dda965a9bea8ffd6b (diff) |
synched with trunk at revision 34793
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 160 |
1 files changed, 120 insertions, 40 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 84be9bfcfe2..e6a7d714cd0 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -39,6 +39,8 @@ #include <io.h> #endif +#include "MEM_guardedalloc.h" + #include "DNA_anim_types.h" #include "DNA_group_types.h" #include "DNA_object_types.h" @@ -46,7 +48,9 @@ #include "DNA_screen_types.h" #include "DNA_sequence_types.h" -#include "MEM_guardedalloc.h" +#include "BLI_math.h" +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_anim.h" #include "BKE_animsys.h" @@ -63,15 +67,12 @@ #include "BKE_scene.h" #include "BKE_sequencer.h" #include "BKE_world.h" -#include "BKE_utildefines.h" + #include "BKE_sound.h" //XXX #include "BIF_previewrender.h" //XXX #include "BIF_editseq.h" -#include "BLI_math.h" -#include "BLI_blenlib.h" - //XXX #include "nla.h" #ifdef WIN32 @@ -106,7 +107,7 @@ void free_qtcodecdata(QuicktimeCodecData *qcd) } } -Scene *copy_scene(Main *bmain, Scene *sce, int type) +Scene *copy_scene(Scene *sce, int type) { Scene *scen; ToolSettings *ts; @@ -128,7 +129,6 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) id_us_plus((ID *)scen->world); id_us_plus((ID *)scen->set); - id_us_plus((ID *)scen->ima); id_us_plus((ID *)scen->gm.dome.warptext); scen->ed= NULL; @@ -171,7 +171,7 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); if(sce->nodetree) { - scen->nodetree= ntreeCopyTree(sce->nodetree, 0); + scen->nodetree= ntreeCopyTree(sce->nodetree); /* copies actions */ ntreeSwitchID(scen->nodetree, &sce->id, &scen->id); } @@ -210,23 +210,26 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) if(type == SCE_COPY_LINK_DATA || type == SCE_COPY_FULL) { ID_NEW(scen->camera); } + + /* before scene copy */ + sound_create_scene(scen); /* world */ if(type == SCE_COPY_FULL) { + BKE_copy_animdata_id_action((ID *)scen); if(scen->world) { id_us_plus((ID *)scen->world); scen->world= copy_world(scen->world); + BKE_copy_animdata_id_action((ID *)scen->world); } if(sce->ed) { scen->ed= MEM_callocN( sizeof(Editing), "addseq"); scen->ed->seqbasep= &scen->ed->seqbase; - seqbase_dupli_recursive(sce, &scen->ed->seqbase, &sce->ed->seqbase, SEQ_DUPE_ALL); + seqbase_dupli_recursive(sce, scen, &scen->ed->seqbase, &sce->ed->seqbase, SEQ_DUPE_ALL); } } - sound_create_scene(scen); - return scen; } @@ -315,7 +318,7 @@ void free_scene(Scene *sce) sound_destroy_scene(sce); } -Scene *add_scene(char *name) +Scene *add_scene(const char *name) { Main *bmain= G.main; Scene *sce; @@ -336,26 +339,42 @@ Scene *add_scene(char *name) sce->r.yasp= 1; sce->r.xparts= 8; sce->r.yparts= 8; - sce->r.size= 25; + sce->r.mblur_samples= 1; + sce->r.filtertype= R_FILTER_MITCH; + sce->r.size= 50; sce->r.planes= 24; + sce->r.imtype= R_PNG; sce->r.quality= 90; + sce->r.displaymode= R_OUTPUT_AREA; sce->r.framapto= 100; sce->r.images= 100; sce->r.framelen= 1.0; - sce->r.frs_sec= 25; + sce->r.blurfac= 0.5; + sce->r.frs_sec= 24; sce->r.frs_sec_base= 1; + sce->r.edgeint= 10; sce->r.ocres = 128; sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT; + sce->r.gauss= 1.0; + + /* deprecated but keep for upwards compat */ + sce->r.postgamma= 1.0; + sce->r.posthue= 0.0; + sce->r.postsat= 1.0; sce->r.bake_mode= 1; /* prevent to include render stuff here */ - sce->r.bake_filter= 8; + sce->r.bake_filter= 2; sce->r.bake_osa= 5; sce->r.bake_flag= R_BAKE_CLEAR; sce->r.bake_normal_space= R_BAKE_SPACE_TANGENT; - sce->r.scemode= R_DOCOMP|R_DOSEQ|R_EXTENSION; - sce->r.stamp= R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_SCENE|R_STAMP_CAMERA|R_STAMP_RENDERTIME; + sce->r.stamp= R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_CAMERA|R_STAMP_SCENE|R_STAMP_FILENAME|R_STAMP_RENDERTIME; sce->r.stamp_font_id= 12; + sce->r.fg_stamp[0]= sce->r.fg_stamp[1]= sce->r.fg_stamp[2]= 0.8f; + sce->r.fg_stamp[3]= 1.0f; + sce->r.bg_stamp[0]= sce->r.bg_stamp[1]= sce->r.bg_stamp[2]= 0.0f; + sce->r.bg_stamp[3]= 0.25f; + sce->r.raytrace_options = R_RAYTRACE_USE_INSTANCES; sce->r.seq_prev_type= OB_SOLID; sce->r.seq_rend_type= OB_SOLID; @@ -441,9 +460,11 @@ Scene *add_scene(char *name) pset->brush[a].count= 10; } pset->brush[PE_BRUSH_CUT].strength= 100; - - sce->jumpframe = 10; + sce->r.ffcodecdata.audio_mixrate = 44100; + sce->r.ffcodecdata.audio_volume = 1.0f; + + BLI_strncpy(sce->r.engine, "BLENDER_RENDER", sizeof(sce->r.engine)); sce->audio.distance_model = 2.0; sce->audio.doppler_factor = 1.0; @@ -469,8 +490,8 @@ Scene *add_scene(char *name) sce->gm.dome.resbuf = 1.0f; sce->gm.dome.tilt = 0; - sce->gm.xplay= 800; - sce->gm.yplay= 600; + sce->gm.xplay= 640; + sce->gm.yplay= 480; sce->gm.freqplay= 60; sce->gm.depth= 32; @@ -577,16 +598,16 @@ void set_scene_bg(Main *bmain, Scene *scene) } /* called from creator.c */ -Scene *set_scene_name(Main *bmain, char *name) +Scene *set_scene_name(Main *bmain, const char *name) { Scene *sce= (Scene *)find_id("SC", name); if(sce) { set_scene_bg(bmain, sce); - printf("Scene switch: '%s' in file: '%s'\n", name, G.sce); + printf("Scene switch: '%s' in file: '%s'\n", name, G.main->name); return sce; } - printf("Can't find scene: '%s' in file: '%s'\n", name, G.sce); + printf("Can't find scene: '%s' in file: '%s'\n", name, G.main->name); return NULL; } @@ -857,6 +878,21 @@ int scene_marker_tfm_extend(Scene *scene, int delta, int flag, int frame, char s return tot; } +int scene_marker_tfm_scale(struct Scene *scene, float value, int flag) +{ + TimeMarker *marker; + int tot= 0; + + for (marker= scene->markers.first; marker; marker= marker->next) { + if ((marker->flag & flag) == flag) { + marker->frame= CFRA + (int)floorf(((float)(marker->frame - CFRA) * value) + 0.5f); + tot++; + } + } + + return tot; +} + Base *scene_add_base(Scene *sce, Object *ob) { Base *b= MEM_callocN(sizeof(*b), "scene_add_base"); @@ -926,31 +962,75 @@ float BKE_curframe(Scene *scene) return ctime; } +/* drivers support/hacks + * - this method is called from scene_update_tagged_recursive(), so gets included in viewport + render + * - these are always run since the depsgraph can't handle non-object data + * - these happen after objects are all done so that we can read in their final transform values, + * though this means that objects can't refer to scene info for guidance... + */ +static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene) +{ + float ctime = BKE_curframe(scene); + + /* scene itself */ + if (scene->adt && scene->adt->drivers.first) { + BKE_animsys_evaluate_animdata(&scene->id, scene->adt, ctime, ADT_RECALC_DRIVERS); + } + + /* world */ + // TODO: what about world textures? but then those have nodes too... + if (scene->world) { + ID *wid = (ID *)scene->world; + AnimData *adt= BKE_animdata_from_id(wid); + + if (adt && adt->drivers.first) + BKE_animsys_evaluate_animdata(wid, adt, ctime, ADT_RECALC_DRIVERS); + } + + /* nodes */ + if (scene->nodetree) { + ID *nid = (ID *)scene->nodetree; + AnimData *adt= BKE_animdata_from_id(nid); + + if (adt && adt->drivers.first) + BKE_animsys_evaluate_animdata(nid, adt, ctime, ADT_RECALC_DRIVERS); + } +} + static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scene_parent) { Base *base; + + + scene->customdata_mask= scene_parent->customdata_mask; /* sets first, we allow per definition current scene to have dependencies on sets, but not the other way around. */ - if(scene->set) + if (scene->set) scene_update_tagged_recursive(bmain, scene->set, scene_parent); - - for(base= scene->base.first; base; base= base->next) { + + /* scene objects */ + for (base= scene->base.first; base; base= base->next) { Object *ob= base->object; - + object_handle_update(scene_parent, ob); - + if(ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) group_handle_recalc_and_update(scene_parent, ob, ob->dup_group); /* always update layer, so that animating layers works */ base->lay= ob->lay; } + + /* scene drivers... */ + scene_update_drivers(bmain, scene); } /* this is called in main loop, doing tagged updates before redraw */ void scene_update_tagged(Main *bmain, Scene *scene) { + DAG_ids_flush_tagged(bmain); + scene->physics_settings.quick_cache_step= 0; /* update all objects: drivers, matrices, displists, etc. flags set @@ -960,14 +1040,14 @@ void scene_update_tagged(Main *bmain, Scene *scene) /* recalc scene animation data here (for sequencer) */ { - float ctime = BKE_curframe(scene); AnimData *adt= BKE_animdata_from_id(&scene->id); - - if(adt && (adt->recalc & ADT_RECALC_ANIM)) + float ctime = BKE_curframe(scene); + + if (adt && (adt->recalc & ADT_RECALC_ANIM)) BKE_animsys_evaluate_animdata(&scene->id, adt, ctime, 0); } - - if(scene->physics_settings.quick_cache_step) + + if (scene->physics_settings.quick_cache_step) BKE_ptcache_quick_cache_all(bmain, scene); /* in the future this should handle updates for all datablocks, not @@ -991,7 +1071,7 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) /* Following 2 functions are recursive * so dont call within 'scene_update_tagged_recursive' */ - DAG_scene_update_flags(bmain, sce, lay); // only stuff that moves or needs display still + DAG_scene_update_flags(bmain, sce, lay, TRUE); // 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 @@ -1058,20 +1138,20 @@ float get_render_aosss_error(RenderData *r, float error) } /* helper function for the SETLOOPER macro */ -Base *_setlooper_base_step(Scene **sce, Base *base) +Base *_setlooper_base_step(Scene **sce_iter, Base *base) { if(base && base->next) { /* common case, step to the next */ return base->next; } - else if(base==NULL && (*sce)->base.first) { + else if(base==NULL && (*sce_iter)->base.first) { /* first time looping, return the scenes first base */ - return (Base *)(*sce)->base.first; + return (Base *)(*sce_iter)->base.first; } else { /* reached the end, get the next base in the set */ - while((*sce= (*sce)->set)) { - base= (Base *)(*sce)->base.first; + while((*sce_iter= (*sce_iter)->set)) { + base= (Base *)(*sce_iter)->base.first; if(base) { return base; } |