diff options
Diffstat (limited to 'source/blender/blenkernel')
40 files changed, 508 insertions, 158 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 71771b6077d..9b28f083a24 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 260 -#define BLENDER_SUBVERSION 0 +#define BLENDER_SUBVERSION 1 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index 3f9edf41e3c..c065a210a98 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -203,17 +203,17 @@ int CTX_data_dir(const char *member); /*void CTX_data_pointer_set(bContextDataResult *result, void *data); void CTX_data_list_add(bContextDataResult *result, void *data);*/ -#define CTX_DATA_BEGIN(C, Type, instance, member) \ - { \ - ListBase ctx_data_list; \ - CollectionPointerLink *ctx_link; \ - CTX_data_##member(C, &ctx_data_list); \ - for(ctx_link=ctx_data_list.first; ctx_link; ctx_link=ctx_link->next) { \ +#define CTX_DATA_BEGIN(C, Type, instance, member) \ + { \ + ListBase ctx_data_list; \ + CollectionPointerLink *ctx_link; \ + CTX_data_##member(C, &ctx_data_list); \ + for(ctx_link=ctx_data_list.first; ctx_link; ctx_link=ctx_link->next) {\ Type instance= ctx_link->ptr.data; -#define CTX_DATA_END \ - } \ - BLI_freelistN(&ctx_data_list); \ +#define CTX_DATA_END \ + } \ + BLI_freelistN(&ctx_data_list); \ } int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase*)); diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 9282f0ef29a..f0704741ebb 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -65,6 +65,7 @@ void make_local_curve( struct Curve *cu); struct ListBase *curve_editnurbs(struct Curve *cu); short curve_type( struct Curve *cu); void test_curve_type( struct Object *ob); +void update_curve_dimension( struct Curve *cu ); void tex_space_curve( struct Curve *cu); int count_curveverts( struct ListBase *nurb); int count_curveverts_without_handles( struct ListBase *nurb); diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index 84a6517fd52..3e643fe961c 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -45,6 +45,7 @@ struct bDeformGroup *defgroup_duplicate(struct bDeformGroup *ingroup); struct bDeformGroup *defgroup_find_name(struct Object *ob, const char *name); int defgroup_find_index(struct Object *ob, struct bDeformGroup *dg); int *defgroup_flip_map(struct Object *ob, int *flip_map_len, int use_default); +int *defgroup_flip_map_single(struct Object *ob, int *flip_map_len, int use_default, int defgroup); int defgroup_flip_index(struct Object *ob, int index, int use_default); int defgroup_name_index(struct Object *ob, const char *name); void defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob); @@ -57,7 +58,7 @@ float defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index void defvert_copy(struct MDeformVert *dvert_r, const struct MDeformVert *dvert); void defvert_sync(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, int use_verify); -void defvert_sync_mapped(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, const int *flip_map, const int flip_map_len, int use_verify); +void defvert_sync_mapped(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, const int *flip_map, const int flip_map_len, const int use_verify); void defvert_remap (struct MDeformVert *dvert, int *map); void defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len); void defvert_normalize(struct MDeformVert *dvert); diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index 59b7712a5a4..e0b8e40d731 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -120,6 +120,12 @@ void DAG_ids_flush_update(struct Main *bmain, int time); void DAG_id_tag_update(struct ID *id, short flag); /* flush all tagged updates */ void DAG_ids_flush_tagged(struct Main *bmain); + /* check and clear ID recalc flags */ +void DAG_ids_check_recalc(struct Main *bmain); +void DAG_ids_clear_recalc(struct Main *bmain); + /* test if any of this id type is tagged for update */ +void DAG_id_type_tag(struct Main *bmain, short idtype); +int DAG_id_type_tagged(struct Main *bmain, short idtype); /* (re)-create dependency graph for armature pose */ void DAG_pose_sort(struct Object *ob); @@ -127,6 +133,9 @@ void DAG_pose_sort(struct Object *ob); /* callback for editors module to do updates */ void DAG_editors_update_cb(void (*func)(struct Main *bmain, struct ID *id)); + /* debugging */ +void DAG_print_dependencies(struct Main *bmain, struct Scene *scene, struct Object *ob); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index bc9134b40b8..5ccdd7c04af 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -58,7 +58,7 @@ typedef struct Global { /* flag: if != 0 G.main->name contains valid relative base path */ int relbase_valid; - /* strings of recent opend files */ + /* strings of recent opened files */ struct ListBase recent_files; short afbreek, moving, file_loaded; diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index e2033915caa..9130cac6cd6 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -49,6 +49,7 @@ void *alloc_libblock(struct ListBase *lb, short type, const char *name); void *copy_libblock(void *rt); void copy_libblock_data(struct ID *id, const struct ID *id_from, const short do_action); +void BKE_id_lib_local_paths(struct Main *bmain, struct ID *id); void id_lib_extern(struct ID *id); void BKE_library_filepath_set(struct Library *lib, const char *filepath); void id_us_plus(struct ID *id); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index a819a464d3f..7509205e968 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -130,7 +130,7 @@ typedef struct bNodeType { char name[32]; float width, minwidth, maxwidth; float height, minheight, maxheight; - short nclass, flag; + short nclass, flag, compatibility; /* templates for static sockets */ bNodeSocketTemplate *inputs, *outputs; @@ -230,8 +230,13 @@ typedef struct bNodeType { #define NODE_CLASS_PARTICLES 25 #define NODE_CLASS_TRANSFORM 30 #define NODE_CLASS_COMBINE 31 +#define NODE_CLASS_SHADER 40 #define NODE_CLASS_LAYOUT 100 +/* nodetype->compatibility */ +#define NODE_OLD_SHADING 1 +#define NODE_NEW_SHADING 2 + /* enum values for input/output */ #define SOCK_IN 1 #define SOCK_OUT 2 @@ -388,6 +393,7 @@ void node_type_exec_new(struct bNodeType *ntype, void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **)); void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out)); void node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node, void *nodedata, struct GPUNodeStack *in, struct GPUNodeStack *out)); +void node_type_compatibility(struct bNodeType *ntype, short compatibility); /* ************** COMMON NODES *************** */ diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 393568c6b60..c5a24c1e5e9 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -139,9 +139,12 @@ struct KeyBlock *object_insert_shape_key(struct Scene *scene, struct Object *ob, int object_is_modified(struct Scene *scene, struct Object *ob); void object_camera_mode(struct RenderData *rd, struct Object *camera); +void object_camera_intrinsics(struct Object *camera, struct Camera **cam_r, short *is_ortho, float *shiftx, float *shifty, + float *clipsta, float *clipend, float *lens, float *sensor_x, float *sensor_y, short *sensor_fit); void object_camera_matrix( struct RenderData *rd, struct Object *camera, int winx, int winy, short field_second, - float winmat[][4], struct rctf *viewplane, float *clipsta, float *clipend, float *lens, float *ycor, + float winmat[][4], struct rctf *viewplane, float *clipsta, float *clipend, float *lens, + float *sensor_x, float *sensor_y, short *sensor_fit, float *ycor, float *viewdx, float *viewdy); void camera_view_frame_ex(struct Scene *scene, struct Camera *camera, float drawsize, const short do_clip, const float scale[3], diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 5c214b2892a..4806a288cee 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -88,6 +88,8 @@ int scene_check_setscene(struct Main *bmain, struct Scene *sce); float BKE_curframe(struct Scene *scene); void scene_update_tagged(struct Main *bmain, struct Scene *sce); +void scene_clear_tagged(struct Main *bmain, struct Scene *sce); + void scene_update_for_newframe(struct Main *bmain, struct Scene *sce, unsigned int lay); void scene_add_render_layer(struct Scene *sce); @@ -98,6 +100,8 @@ int get_render_child_particle_number(struct RenderData *r, int num); int get_render_shadow_samples(struct RenderData *r, int samples); float get_render_aosss_error(struct RenderData *r, float error); +int scene_use_new_shading_nodes(struct Scene *scene); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 5b6d7e3cd96..77a351d534e 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -34,22 +34,23 @@ */ struct ARegion; -struct bContext; -struct bContextDataResult; -struct bScreen; -struct ListBase; -struct Panel; struct Header; +struct ListBase; struct Menu; +struct Panel; +struct Scene; struct ScrArea; struct SpaceType; -struct Scene; +struct View3D; +struct bContext; +struct bContextDataResult; +struct bScreen; +struct uiLayout; +struct uiMenuItem; +struct wmKeyConfig; struct wmNotifier; struct wmWindow; struct wmWindowManager; -struct wmKeyConfig; -struct uiLayout; -struct uiMenuItem; #include "RNA_types.h" @@ -239,6 +240,7 @@ void BKE_area_region_free(struct SpaceType *st, struct ARegion *ar); void BKE_screen_area_free(struct ScrArea *sa); struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type); +struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min); void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene); void BKE_screen_view3d_scene_sync(struct bScreen *sc); diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index e64de965db5..917b62c27cf 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -67,21 +67,21 @@ void seq_next(SeqIterator *iter); void seq_end(SeqIterator *iter); void seq_array(struct Editing *ed, struct Sequence ***seqarray, int *tot, int use_pointer); -#define SEQP_BEGIN(ed, _seq) \ -{ \ - SeqIterator iter;\ - for(seq_begin(ed, &iter, 1); iter.valid; seq_next(&iter)) { \ +#define SEQP_BEGIN(ed, _seq) \ +{ \ + SeqIterator iter; \ + for(seq_begin(ed, &iter, 1); iter.valid; seq_next(&iter)) { \ _seq= iter.seq; -#define SEQ_BEGIN(ed, _seq) \ - { \ - SeqIterator iter;\ - for(seq_begin(ed, &iter, 0); iter.valid; seq_next(&iter)) { \ +#define SEQ_BEGIN(ed, _seq) \ + { \ + SeqIterator iter; \ + for(seq_begin(ed, &iter, 0); iter.valid; seq_next(&iter)) { \ _seq= iter.seq; -#define SEQ_END \ - } \ - seq_end(&iter); \ +#define SEQ_END \ + } \ + seq_end(&iter); \ } typedef struct SeqRenderData { diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 2a1794fe2fc..944f7c6a0b6 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -146,13 +146,10 @@ void make_local_action(bAction *act) id_clear_lib_data(bmain, &act->id); } else if (mlac.is_local && mlac.is_lib) { - char *bpath_user_data[2]= {bmain->name, act->id.lib->filepath}; - mlac.actn= copy_action(act); mlac.actn->id.us= 0; - /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &mlac.actn->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &mlac.actn->id); BKE_animdata_main_cb(bmain, make_localact_apply_cb, &mlac); } diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 2ef13318af4..f939c168f51 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -753,6 +753,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, extern int enable_cu_speed; /* object.c */ Object copyob = {{NULL}}; int cfrao = scene->r.cfra; + int dupend = ob->dupend; /* simple prevention of too deep nested groups */ if (level > MAX_DUPLI_RECUR) return; @@ -773,7 +774,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, /* duplicate over the required range */ if (ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0; - for (scene->r.cfra= ob->dupsta; scene->r.cfra<=ob->dupend; scene->r.cfra++) { + for (scene->r.cfra= ob->dupsta; scene->r.cfra<=dupend; scene->r.cfra++) { short ok= 1; /* - dupoff = how often a frames within the range shouldn't be made into duplis diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 13abf18e20c..6d94b42a7ac 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -43,12 +43,15 @@ #include "BLI_utildefines.h" #include "DNA_anim_types.h" +#include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_scene_types.h" #include "DNA_texture_types.h" +#include "DNA_world_types.h" #include "BKE_animsys.h" #include "BKE_action.h" +#include "BKE_depsgraph.h" #include "BKE_fcurve.h" #include "BKE_nla.h" #include "BKE_global.h" @@ -1179,6 +1182,15 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i RNA_property_update_cache_add(&new_ptr, prop); } #endif + + /* as long as we don't do property update, we still tag datablock + as having been updated. this flag does not cause any updates to + be run, it's for e.g. render engines to synchronize data */ + if(new_ptr.id.data) { + ID *id= new_ptr.id.data; + id->flag |= LIB_ID_RECALC; + DAG_id_type_tag(G.main, GS(id->name)); + } } /* successful */ @@ -2291,7 +2303,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, Scene *scene, float ctime) EVAL_ANIM_NODETREE_IDS(main->tex.first, Tex, ADT_RECALC_ANIM); /* lamps */ - EVAL_ANIM_IDS(main->lamp.first, ADT_RECALC_ANIM); + EVAL_ANIM_NODETREE_IDS(main->lamp.first, Lamp, ADT_RECALC_ANIM); /* materials */ EVAL_ANIM_NODETREE_IDS(main->mat.first, Material, ADT_RECALC_ANIM); @@ -2320,7 +2332,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, Scene *scene, float ctime) /* particles */ EVAL_ANIM_IDS(main->particle.first, ADT_RECALC_ANIM); - /* lamps */ + /* speakers */ EVAL_ANIM_IDS(main->speaker.first, ADT_RECALC_ANIM); /* objects */ @@ -2331,7 +2343,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, Scene *scene, float ctime) EVAL_ANIM_IDS(main->object.first, 0); /* worlds */ - EVAL_ANIM_IDS(main->world.first, ADT_RECALC_ANIM); + EVAL_ANIM_NODETREE_IDS(main->world.first, World, ADT_RECALC_ANIM); /* scenes */ EVAL_ANIM_NODETREE_IDS(main->scene.first, Scene, ADT_RECALC_ANIM); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 9fba18dd7cf..e9a19b50a81 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -157,12 +157,11 @@ void make_local_armature(bArmature *arm) id_clear_lib_data(bmain, &arm->id); } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, arm->id.lib->filepath}; bArmature *armn= copy_armature(arm); armn->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &armn->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &armn->id); for(ob= bmain->object.first; ob; ob= ob->id.next) { if(ob->data == arm) { diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 6e343e874f1..d68b0b361d1 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -172,7 +172,7 @@ static void clean_paths(Main *main) { Scene *scene; - bpath_traverse_main(main, clean_paths_visit_cb, 0, NULL); + bpath_traverse_main(main, clean_paths_visit_cb, BPATH_TRAVERSE_SKIP_MULTIFILE, NULL); for(scene= main->scene.first; scene; scene= scene->id.next) { BLI_clean(scene->r.pic); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 10f056e9b78..e78b89441c9 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -224,13 +224,12 @@ void make_local_brush(Brush *brush) } } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, brush->id.lib->filepath}; Brush *brushn= copy_brush(brush); brushn->id.us= 1; /* only keep fake user */ brushn->id.flag |= LIB_FAKEUSER; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &brushn->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &brush->id); for(scene= bmain->scene.first; scene; scene=scene->id.next) { if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) { diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index c244c26ad7f..8b5cf3bd196 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -447,7 +447,8 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat } else { /* when not in EditMode, use the 'final' derived mesh, depsgraph - * ensures we build with CD_MDEFORMVERT layer */ + * ensures we build with CD_MDEFORMVERT layer + */ dm = (DerivedMesh *)ob->derivedFinal; } @@ -703,7 +704,7 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC ct->type = CONSTRAINT_OBTYPE_BONE; \ ct->rotOrder= (pchan) ? (pchan->rotmode) : EULER_ORDER_DEFAULT; \ }\ - else if (ELEM(ct->tar->type, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) { \ + else if (OB_TYPE_SUPPORT_VGROUP(ct->tar->type) && (ct->subtarget[0])) { \ ct->type = CONSTRAINT_OBTYPE_VERT; \ ct->rotOrder = EULER_ORDER_DEFAULT; \ } \ @@ -1256,10 +1257,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr float quat[4]; if ((data->followflag & FOLLOWPATH_STATIC) == 0) { /* animated position along curve depending on time */ - if (cob->scene) - curvetime= bsystem_time(cob->scene, ct->tar, cu->ctime, 0.0) - data->offset; - else - curvetime= cu->ctime - data->offset; + curvetime= cu->ctime - data->offset; /* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated, * but this will only work if it actually is animated... diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 13b1da22449..adc08f5cd9f 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -273,13 +273,10 @@ void make_local_curve(Curve *cu) extern_local_curve(cu); } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, cu->id.lib->filepath}; Curve *cun= copy_curve(cu); cun->id.us= 0; - - /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &cun->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &cun->id); for(ob= bmain->object.first; ob; ob= ob->id.next) { if(ob->data==cu) { @@ -318,9 +315,34 @@ short curve_type(Curve *cu) return OB_CURVE; } +void update_curve_dimension(Curve *cu) +{ + ListBase *nurbs= BKE_curve_nurbs(cu); + Nurb *nu= nurbs->first; + + if(cu->flag&CU_3D) { + for( ; nu; nu= nu->next) { + nu->flag &= ~CU_2D; + } + } + else { + for( ; nu; nu= nu->next) { + nu->flag |= CU_2D; + test2DNurb(nu); + + /* since the handles are moved they need to be auto-located again */ + if(nu->type == CU_BEZIER) + calchandlesNurb(nu); + } + } +} + void test_curve_type(Object *ob) -{ - ob->type = curve_type(ob->data); +{ + ob->type= curve_type(ob->data); + + if(ob->type==OB_CURVE) + update_curve_dimension((Curve *)ob->data); } void tex_space_curve(Curve *cu) diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 83eda860510..0c3c78f6eef 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -257,17 +257,19 @@ int defgroup_find_index (Object *ob, bDeformGroup *dg) /* note, must be freed */ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default) { - bDeformGroup *dg; int totdg= *flip_map_len= BLI_countlist(&ob->defbase); if(totdg==0) { return NULL; } else { + bDeformGroup *dg; char name[sizeof(dg->name)]; int i, flip_num, *map= MEM_mallocN(totdg * sizeof(int), __func__); - memset(map, -1, totdg * sizeof(int)); + for (i=0; i < totdg; i++) { + map[i]= -1; + } for (dg=ob->defbase.first, i=0; dg; dg=dg->next, i++) { if(map[i] == -1) { /* may be calculated previously */ @@ -276,7 +278,7 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default) if(use_default) map[i]= i; - flip_side_name(name, dg->name, 0); + flip_side_name(name, dg->name, FALSE); if(strcmp(name, dg->name)) { flip_num= defgroup_name_index(ob, name); if(flip_num >= 0) { @@ -290,6 +292,40 @@ int *defgroup_flip_map(Object *ob, int *flip_map_len, int use_default) } } +/* note, must be freed */ +int *defgroup_flip_map_single(Object *ob, int *flip_map_len, int use_default, int defgroup) +{ + int totdg= *flip_map_len= BLI_countlist(&ob->defbase); + + if(totdg==0) { + return NULL; + } + else { + bDeformGroup *dg; + char name[sizeof(dg->name)]; + int i, flip_num, *map= MEM_mallocN(totdg * sizeof(int), __func__); + + for (i=0; i < totdg; i++) { + if (use_default) map[i]= i; + else map[i]= -1; + } + + dg= BLI_findlink(&ob->defbase, defgroup); + + flip_side_name(name, dg->name, FALSE); + if(strcmp(name, dg->name)) { + flip_num= defgroup_name_index(ob, name); + + if(flip_num >= 0) { + map[defgroup]= flip_num; + map[flip_num]= defgroup; + } + } + + return map; + } +} + int defgroup_flip_index(Object *ob, int index, int use_default) { bDeformGroup *dg= BLI_findlink(&ob->defbase, index); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index c9df8a135fe..51edee9ea71 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -591,9 +591,9 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if(part->ren_as == PART_DRAW_OB && part->dup_ob) { node2 = dag_get_node(dag, part->dup_ob); - dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Object Visualisation"); + dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Object Visualisation"); if(part->dup_ob->type == OB_MBALL) - dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA, "Particle Object Visualisation"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA, "Particle Object Visualisation"); } if(part->ren_as == PART_DRAW_GR && part->dup_group) { @@ -799,6 +799,7 @@ DagNode * dag_find_node (DagForest *forest,void * fob) } static int ugly_hack_sorry= 1; // prevent type check +static int dag_print_dependencies= 0; // debugging /* no checking of existence, use dag_find_node first or dag_get_node */ DagNode * dag_add_node (DagForest *forest, void * fob) @@ -926,7 +927,6 @@ static const char *dag_node_name(DagNode *node) return ((bPoseChannel*)(node->ob))->name; } -#if 0 static void dag_node_print_dependencies(DagNode *node) { DagAdjList *itA; @@ -937,7 +937,6 @@ static void dag_node_print_dependencies(DagNode *node) printf(" %s through %s\n", dag_node_name(itA->node), itA->name); printf("\n"); } -#endif static int dag_node_print_dependency_recurs(DagNode *node, DagNode *endnode) { @@ -998,6 +997,11 @@ static void dag_check_cycle(DagForest *dag) DagNode *node; DagAdjList *itA; + /* debugging print */ + if(dag_print_dependencies) + for(node = dag->DagNode.first; node; node= node->next) + dag_node_print_dependencies(node); + /* tag nodes unchecked */ for(node = dag->DagNode.first; node; node= node->next) node->color= DAG_WHITE; @@ -1761,9 +1765,22 @@ void DAG_scene_sort(Main *bmain, Scene *sce) sce->recalc |= SCE_PRV_CHANGED; /* test for 3d preview */ } +static void lib_id_recalc_tag(Main *bmain, ID *id) +{ + id->flag |= LIB_ID_RECALC; + bmain->id_tag_update[id->name[0]] = 1; +} + +static void lib_id_recalc_data_tag(Main *bmain, ID *id) +{ + id->flag |= LIB_ID_RECALC_DATA; + bmain->id_tag_update[id->name[0]] = 1; +} + /* node was checked to have lasttime != curtime and is if type ID_OB */ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) { + Main *bmain= G.main; DagAdjList *itA; Object *ob, *obc; int oldflag, changed=0; @@ -1789,20 +1806,24 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) if(itA->type & DAG_RL_OB_OB) { //printf("ob %s changes ob %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_OB; + lib_id_recalc_tag(bmain, &obc->id); } if(itA->type & DAG_RL_OB_DATA) { //printf("ob %s changes obdata %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &obc->id); } } if(ob->recalc & OB_RECALC_DATA) { if(itA->type & DAG_RL_DATA_OB) { //printf("obdata %s changes ob %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_OB; + lib_id_recalc_tag(bmain, &obc->id); } if(itA->type & DAG_RL_DATA_DATA) { //printf("obdata %s changes obdata %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &obc->id); } } if(oldflag!=obc->recalc) changed= 1; @@ -1833,6 +1854,7 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) if(itA->type & (DAG_RL_OB_DATA|DAG_RL_DATA_DATA)) { // printf("parent %s changes ob %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &obc->id); } } } @@ -1872,6 +1894,7 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) /* node was checked to have lasttime != curtime , and is of type ID_OB */ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int reset) { + Main *bmain= G.main; DagAdjList *itA; Object *ob; @@ -1883,8 +1906,10 @@ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int ob= (Object*)(itA->node->ob); if(reset || (ob->recalc & OB_RECALC_ALL)) { - if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) + if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) { ob->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &ob->id); + } flush_pointcache_reset(scene, itA->node, curtime, 1); } @@ -2001,8 +2026,10 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho ob= (Object*)(itA->node->ob); if(ob->recalc & OB_RECALC_ALL) { - if(BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) + if(BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) { ob->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &ob->id); + } flush_pointcache_reset(sce, itA->node, lasttime, 1); } @@ -2204,6 +2231,12 @@ static void dag_object_time_update_flags(Object *ob) } } } + + if(ob->recalc & OB_RECALC_OB) + lib_id_recalc_tag(G.main, &ob->id); + if(ob->recalc & OB_RECALC_DATA) + lib_id_recalc_data_tag(G.main, &ob->id); + } /* flag all objects that need recalc, for changes in time for example */ /* do_time: make this optional because undo resets objects to their animated locations without this */ @@ -2362,6 +2395,9 @@ void DAG_on_visible_update(Main *bmain, const short do_time) DAG_scene_update_flags(bmain, scene, lay, do_time); scene->lay_updated |= lay; } + + /* hack to get objects updating on layer changes */ + DAG_id_type_tag(bmain, ID_OB); } static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUSED(ob), ID **idpoin) @@ -2408,6 +2444,7 @@ static void dag_id_flush_update(Scene *sce, ID *id) for(obt=bmain->object.first; obt; obt= obt->id.next) { if(!(ob && obt == ob) && obt->data == id) { obt->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &obt->id); BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); } } @@ -2421,8 +2458,10 @@ static void dag_id_flush_update(Scene *sce, ID *id) data.is_dependent= 0; modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data); - if (data.is_dependent) + if (data.is_dependent) { obt->recalc |= OB_RECALC_DATA; + lib_id_recalc_data_tag(bmain, &obt->id); + } /* particle settings can use the texture as well */ if(obt->particlesystem.first) { @@ -2435,7 +2474,8 @@ static void dag_id_flush_update(Scene *sce, ID *id) mtex = *mtexp; if(mtex && mtex->tex == (Tex*)id) { obt->recalc |= OB_RECALC_DATA; - + lib_id_recalc_data_tag(bmain, &obt->id); + if(mtex->mapto & PAMAP_INIT) psys->recalc |= PSYS_RECALC_RESET; if(mtex->mapto & PAMAP_CHILD) @@ -2455,6 +2495,8 @@ static void dag_id_flush_update(Scene *sce, ID *id) Key *key= ob_get_key(obt); if(!(ob && obt == ob) && ((ID *)key == id)) { obt->flag |= (OB_RECALC_OB|OB_RECALC_DATA); + lib_id_recalc_tag(bmain, &obt->id); + lib_id_recalc_data_tag(bmain, &obt->id); BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); } } @@ -2479,7 +2521,7 @@ void DAG_ids_flush_tagged(Main *bmain) ListBase *lbarray[MAX_LIBARRAY]; Scene *sce; unsigned int lay; - int a, have_tag = 0; + int a, do_flush = 0; dag_current_scene_layers(bmain, &sce, &lay); @@ -2497,23 +2539,64 @@ void DAG_ids_flush_tagged(Main *bmain) looping over all ID's in case there are no tags */ if(id && bmain->id_tag_update[id->name[0]]) { for(; id; id=id->next) { - if(id->flag & LIB_ID_RECALC) { + if(id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) { dag_id_flush_update(sce, id); - id->flag &= ~LIB_ID_RECALC; + do_flush = 1; } } + } + } + + /* flush changes to other objects */ + if(do_flush) + DAG_scene_flush_update(bmain, sce, lay, 0); +} + +void DAG_ids_check_recalc(Main *bmain) +{ + ListBase *lbarray[MAX_LIBARRAY]; + int a; - have_tag = 1; + /* loop over all ID types */ + a = set_listbasepointers(bmain, lbarray); + + while(a--) { + ListBase *lb = lbarray[a]; + ID *id = lb->first; + + /* we tag based on first ID type character to avoid + looping over all ID's in case there are no tags */ + if(id && bmain->id_tag_update[id->name[0]]) { + /* do editors update */ + dag_editors_update(bmain, NULL); + return; } } +} - if(have_tag) { - /* clear tags */ - memset(bmain->id_tag_update, 0, sizeof(bmain->id_tag_update)); - /* flush changes to other objects */ - DAG_scene_flush_update(bmain, sce, lay, 0); +void DAG_ids_clear_recalc(Main *bmain) +{ + ListBase *lbarray[MAX_LIBARRAY]; + int a; + + /* loop over all ID types */ + a = set_listbasepointers(bmain, lbarray); + + while(a--) { + ListBase *lb = lbarray[a]; + ID *id = lb->first; + + /* we tag based on first ID type character to avoid + looping over all ID's in case there are no tags */ + if(id && bmain->id_tag_update[id->name[0]]) { + for(; id; id=id->next) + if(id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) + id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA); + } } + + memset(bmain->id_tag_update, 0, sizeof(bmain->id_tag_update)); } void DAG_id_tag_update(ID *id, short flag) @@ -2523,8 +2606,14 @@ void DAG_id_tag_update(ID *id, short flag) if(id==NULL) return; /* tag ID for update */ - id->flag |= LIB_ID_RECALC; - bmain->id_tag_update[id->name[0]] = 1; + if(flag) { + if(flag & OB_RECALC_OB) + lib_id_recalc_tag(bmain, id); + if(flag & (OB_RECALC_DATA|PSYS_RECALC)) + lib_id_recalc_data_tag(bmain, id); + } + else + lib_id_recalc_tag(bmain, id); /* flag is for objects and particle systems */ if(flag) { @@ -2556,6 +2645,16 @@ void DAG_id_tag_update(ID *id, short flag) } } +void DAG_id_type_tag(struct Main *bmain, short idtype) +{ + bmain->id_tag_update[((char*)&idtype)[0]] = 1; +} + +int DAG_id_type_tagged(Main *bmain, short idtype) +{ + return bmain->id_tag_update[((char*)&idtype)[0]]; +} + #if 0 // UNUSED /* recursively descends tree, each node only checked once */ /* node is checked to be of type object */ @@ -2739,5 +2838,22 @@ void DAG_pose_sort(Object *ob) ugly_hack_sorry= 1; } +/* ************************ DAG DEBUGGING ********************* */ +void DAG_print_dependencies(Main *bmain, Scene *scene, Object *ob) +{ + /* utility for debugging dependencies */ + dag_print_dependencies= 1; + + if(ob && (ob->mode & OB_MODE_POSE)) { + printf("\nDEPENDENCY RELATIONS for %s\n\n", ob->id.name+2); + DAG_pose_sort(ob); + } + else { + printf("\nDEPENDENCY RELATIONS for %s\n\n", scene->id.name+2); + DAG_scene_sort(bmain, scene); + } + + dag_print_dependencies= 0; +} diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 9aeacb9d7fa..08440849a4e 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -385,13 +385,12 @@ void make_local_image(struct Image *ima) extern_local_image(ima); } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, ima->id.lib->filepath}; Image *iman= copy_image(ima); iman->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &iman->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &iman->id); tex= bmain->tex.first; while(tex) { diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 85e00bcea06..034f4a96879 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -703,14 +703,7 @@ static const char *world_adrcodes_to_paths (int adrcode, int *array_index) return "mist.start"; case WO_MISTHI: return "mist.height"; - - /* Star Color is unused -- recommend removal */ - /* case WO_STAR_R: - *array_index= 0; return "stars.color"; - case WO_STAR_G: - *array_index= 1; return "stars.color"; - case WO_STAR_B: - *array_index= 2; return "stars.color"; */ + case WO_STAR_R: case WO_STAR_G: case WO_STAR_B: diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 0a467142f74..6d095117136 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1381,7 +1381,7 @@ float *do_ob_key(Scene *scene, Object *ob) ob->shapenr= 1; } - if(ELEM(ob->type, OB_MESH, OB_LATTICE)) { + if (OB_TYPE_SUPPORT_VGROUP(ob->type)) { float *weights= get_weights_array(ob, kb->vgroup); cp_key(0, tot, tot, out, key, actkb, kb, weights, 0); diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 9a528b54143..47878242604 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -271,12 +271,11 @@ void make_local_lattice(Lattice *lt) id_clear_lib_data(bmain, <->id); } else if(is_local && is_lib) { - char *bath_user_data[2]= {bmain->name, lt->id.lib->filepath}; Lattice *ltn= copy_lattice(lt); ltn->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, <n->id, bpath_relocate_visitor, 0, bath_user_data); + BKE_id_lib_local_paths(bmain, <n->id); for(ob= bmain->object.first; ob; ob= ob->id.next) { if(ob->data==lt) { diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 9d8acc44e88..35b50730a31 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -127,6 +127,21 @@ /* ************* general ************************ */ + +/* this has to be called from each make_local_* func, we could call + * from id_make_local() but then the make local functions would not be self + * contained. + * also note that the id _must_ have a library - campbell */ +void BKE_id_lib_local_paths(Main *bmain, ID *id) +{ + char *bpath_user_data[2]= {bmain->name, (id)->lib->filepath}; + + bpath_traverse_id(bmain, id, + bpath_relocate_visitor, + BPATH_TRAVERSE_SKIP_MULTIFILE, + bpath_user_data); +} + void id_lib_extern(ID *id) { if(id) { @@ -1252,8 +1267,8 @@ int new_id(ListBase *lb, ID *id, const char *tname) don't have other library users. */ void id_clear_lib_data(Main *bmain, ID *id) { - char *bpath_user_data[2]= {bmain->name, id->lib->filepath}; - bpath_traverse_id(bmain, id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, id); + id->lib= NULL; id->flag= LIB_LOCAL; new_id(which_libbase(bmain, GS(id->name)), id, NULL); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 2ad3da9f3a0..7be3514e0f2 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -364,13 +364,12 @@ void make_local_material(Material *ma) } /* Both user and local, so copy. */ else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, ma->id.lib->filepath}; Material *man= copy_material(ma); man->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &man->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &man->id); /* do objects */ ob= bmain->object.first; diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 98646bd2faa..327306b32ee 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -174,12 +174,11 @@ void make_local_mball(MetaBall *mb) extern_local_mball(mb); } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, mb->id.lib->filepath}; MetaBall *mbn= copy_mball(mb); mbn->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &mbn->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &mbn->id); for(ob= G.main->object.first; ob; ob= ob->id.next) { if(ob->data == mb) { diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 6f66e189dcf..4a8bc34cdf7 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -298,13 +298,12 @@ void make_local_mesh(Mesh *me) expand_local_mesh(me); } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, me->id.lib->filepath}; Mesh *men= copy_mesh(me); men->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &men->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &men->id); for(ob= bmain->object.first; ob; ob= ob->id.next) { if(me == ob->data) { diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 824e59a82c5..8f609291351 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -43,10 +43,11 @@ #include <string.h> #include <limits.h> +#include "DNA_action_types.h" #include "DNA_anim_types.h" #include "DNA_node_types.h" +#include "DNA_node_types.h" #include "DNA_scene_types.h" -#include "DNA_action_types.h" #include "BLI_string.h" #include "BLI_math.h" @@ -1320,7 +1321,7 @@ void nodeSetActive(bNodeTree *ntree, bNode *node) node->flag |= NODE_ACTIVE_ID; } -/* use flags are not persistant yet, groups might need different tagging, so we do it each time +/* use flags are not persistent yet, groups might need different tagging, so we do it each time when we need to get this info */ void ntreeSocketUseFlags(bNodeTree *ntree) { @@ -1751,6 +1752,10 @@ void node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMate ntype->gpuextfunc = gpuextfunc; } +void node_type_compatibility(struct bNodeType *ntype, short compatibility) +{ + ntype->compatibility = compatibility; +} static bNodeType *is_nodetype_registered(ListBase *typelist, int type) { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 0d0552cf3b3..b09d1ea98aa 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -86,6 +86,7 @@ #include "BKE_mesh.h" #include "BKE_mball.h" #include "BKE_modifier.h" +#include "BKE_node.h" #include "BKE_object.h" #include "BKE_paint.h" #include "BKE_particle.h" @@ -302,8 +303,6 @@ void free_object(Object *ob) ob->matbits= NULL; if(ob->bb) MEM_freeN(ob->bb); ob->bb= NULL; - if(ob->path) free_path(ob->path); - ob->path= NULL; if(ob->adt) BKE_free_animdata((ID *)ob); if(ob->poselib) ob->poselib->id.us--; if(ob->gpd) ((ID *)ob->gpd)->us--; @@ -723,6 +722,8 @@ void *add_camera(const char *name) cam= alloc_libblock(&G.main->camera, ID_CA, name); cam->lens= 35.0f; + cam->sensor_x= 32.0f; + cam->sensor_y= 18.0f; cam->clipsta= 0.1f; cam->clipend= 100.0f; cam->drawsize= 0.5f; @@ -772,13 +773,12 @@ void make_local_camera(Camera *cam) id_clear_lib_data(bmain, &cam->id); } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, cam->id.lib->filepath}; Camera *camn= copy_camera(cam); camn->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &camn->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &camn->id); for(ob= bmain->object.first; ob; ob= ob->id.next) { if(ob->data == cam) { @@ -878,6 +878,9 @@ Lamp *copy_lamp(Lamp *la) } lan->curfalloff = curvemapping_copy(la->curfalloff); + + if(la->nodetree) + lan->nodetree= ntreeCopyTree(la->nodetree); if(la->preview) lan->preview = BKE_previewimg_copy(la->preview); @@ -904,6 +907,9 @@ Lamp *localize_lamp(Lamp *la) lan->curfalloff = curvemapping_copy(la->curfalloff); + if(la->nodetree) + lan->nodetree= ntreeLocalize(la->nodetree); + lan->preview= NULL; return lan; @@ -939,13 +945,11 @@ void make_local_lamp(Lamp *la) id_clear_lib_data(bmain, &la->id); } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, la->id.lib->filepath}; Lamp *lan= copy_lamp(la); lan->id.us= 0; - /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &lan->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &lan->id); ob= bmain->object.first; while(ob) { @@ -981,6 +985,12 @@ void free_lamp(Lamp *la) BKE_free_animdata((ID *)la); curvemapping_free(la->curfalloff); + + /* is no lib link block, but lamp extension */ + if(la->nodetree) { + ntreeFreeTree(la->nodetree); + MEM_freeN(la->nodetree); + } BKE_previewimg_free(&la->preview); BKE_icon_delete(&la->id); @@ -1095,7 +1105,6 @@ Object *add_only_object(int type, const char *name) ob->obstacleRad = 1.; /* NT fluid sim defaults */ - ob->fluidsimFlag = 0; ob->fluidsimSettings = NULL; ob->pc_ids.first = ob->pc_ids.last = NULL; @@ -1365,7 +1374,6 @@ Object *copy_object(Object *ob) } if(ob->bb) obn->bb= MEM_dupallocN(ob->bb); - obn->path= NULL; obn->flag &= ~OB_FROMGROUP; obn->modifiers.first = obn->modifiers.last= NULL; @@ -1486,13 +1494,12 @@ void make_local_object(Object *ob) extern_local_object(ob); } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, ob->id.lib->filepath}; Object *obn= copy_object(ob); obn->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &obn->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &obn->id); sce= bmain->scene.first; while(sce) { @@ -2945,27 +2952,23 @@ void object_camera_mode(RenderData *rd, Object *camera) } } -/* 'lens' may be set for envmap only */ -void object_camera_matrix( - RenderData *rd, Object *camera, int winx, int winy, short field_second, - float winmat[][4], rctf *viewplane, float *clipsta, float *clipend, float *lens, float *ycor, - float *viewdx, float *viewdy -) { - Camera *cam=NULL; - float pixsize; - float shiftx=0.0, shifty=0.0, winside, viewfac; - short is_ortho= FALSE; +void object_camera_intrinsics(Object *camera, Camera **cam_r, short *is_ortho, float *shiftx, float *shifty, + float *clipsta, float *clipend, float *lens, float *sensor_x, float *sensor_y, short *sensor_fit) +{ + Camera *cam= NULL; - /* question mark */ - (*ycor)= rd->yasp / rd->xasp; - if(rd->mode & R_FIELDS) - (*ycor) *= 2.0f; + (*shiftx)= 0.0f; + (*shifty)= 0.0f; + + (*sensor_x)= DEFAULT_SENSOR_WIDTH; + (*sensor_y)= DEFAULT_SENSOR_HEIGHT; + (*sensor_fit)= CAMERA_SENSOR_FIT_AUTO; if(camera->type==OB_CAMERA) { cam= camera->data; if(cam->type == CAM_ORTHO) { - is_ortho= TRUE; + *is_ortho= TRUE; } /* solve this too... all time depending stuff is in convertblender.c? @@ -2978,11 +2981,14 @@ void object_camera_matrix( execute_ipo(&cam->id, cam->ipo); } #endif // XXX old animation system - shiftx=cam->shiftx; - shifty=cam->shifty; + (*shiftx)=cam->shiftx; + (*shifty)=cam->shifty; (*lens)= cam->lens; + (*sensor_x)= cam->sensor_x; + (*sensor_y)= cam->sensor_y; (*clipsta)= cam->clipsta; (*clipend)= cam->clipend; + (*sensor_fit)= cam->sensor_fit; } else if(camera->type==OB_LAMP) { Lamp *la= camera->data; @@ -2996,7 +3002,7 @@ void object_camera_matrix( (*clipend)= la->clipend; } else { /* envmap exception... */; - if((*lens)==0.0f) + if((*lens)==0.0f) /* is this needed anymore? */ (*lens)= 16.0f; if((*clipsta)==0.0f || (*clipend)==0.0f) { @@ -3005,25 +3011,69 @@ void object_camera_matrix( } } + (*cam_r)= cam; +} + +/* 'lens' may be set for envmap only */ +void object_camera_matrix( + RenderData *rd, Object *camera, int winx, int winy, short field_second, + float winmat[][4], rctf *viewplane, float *clipsta, float *clipend, float *lens, + float *sensor_x, float *sensor_y, short *sensor_fit, float *ycor, + float *viewdx, float *viewdy) +{ + Camera *cam=NULL; + float pixsize; + float shiftx=0.0, shifty=0.0, winside, viewfac; + short is_ortho= FALSE; + + /* question mark */ + (*ycor)= rd->yasp / rd->xasp; + if(rd->mode & R_FIELDS) + (*ycor) *= 2.0f; + + object_camera_intrinsics(camera, &cam, &is_ortho, &shiftx, &shifty, clipsta, clipend, lens, sensor_x, sensor_y, sensor_fit); + /* ortho only with camera available */ if(cam && is_ortho) { - if(rd->xasp*winx >= rd->yasp*winy) { + if((*sensor_fit)==CAMERA_SENSOR_FIT_AUTO) { + if(rd->xasp*winx >= rd->yasp*winy) viewfac= winx; + else viewfac= (*ycor) * winy; + } + else if((*sensor_fit)==CAMERA_SENSOR_FIT_HOR) { viewfac= winx; } - else { + else { /* if((*sensor_fit)==CAMERA_SENSOR_FIT_VERT) { */ viewfac= (*ycor) * winy; } + /* ortho_scale == 1.0 means exact 1 to 1 mapping */ pixsize= cam->ortho_scale/viewfac; } else { - if(rd->xasp*winx >= rd->yasp*winy) viewfac= ((*lens) * winx)/32.0f; - else viewfac= (*ycor) * ((*lens) * winy)/32.0f; + if((*sensor_fit)==CAMERA_SENSOR_FIT_AUTO) { + if(rd->xasp*winx >= rd->yasp*winy) viewfac= ((*lens) * winx) / (*sensor_x); + else viewfac= (*ycor) * ((*lens) * winy) / (*sensor_x); + } + else if((*sensor_fit)==CAMERA_SENSOR_FIT_HOR) { + viewfac= ((*lens) * winx) / (*sensor_x); + } + else { /* if((*sensor_fit)==CAMERA_SENSOR_FIT_VERT) { */ + viewfac= ((*lens) * winy) / (*sensor_y); + } + pixsize= (*clipsta) / viewfac; } /* viewplane fully centered, zbuffer fills in jittered between -.5 and +.5 */ winside= MAX2(winx, winy); + + if(cam) { + if(cam->sensor_fit==CAMERA_SENSOR_FIT_HOR) + winside= winx; + else if(cam->sensor_fit==CAMERA_SENSOR_FIT_VERT) + winside= winy; + } + viewplane->xmin= -0.5f*(float)winx + shiftx*winside; viewplane->ymin= -0.5f*(*ycor)*(float)winy + shifty*winside; viewplane->xmax= 0.5f*(float)winx + shiftx*winside; @@ -3067,7 +3117,17 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh float aspx= (float) scene->r.xsch*scene->r.xasp; float aspy= (float) scene->r.ysch*scene->r.yasp; - if(aspx < aspy) { + if(camera->sensor_fit==CAMERA_SENSOR_FIT_AUTO) { + if(aspx < aspy) { + r_asp[0]= aspx / aspy; + r_asp[1]= 1.0; + } + else { + r_asp[0]= 1.0; + r_asp[1]= aspy / aspx; + } + } + else if(camera->sensor_fit==CAMERA_SENSOR_FIT_AUTO) { r_asp[0]= aspx / aspy; r_asp[1]= 1.0; } @@ -3093,16 +3153,18 @@ void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const sh else { /* that way it's always visible - clipsta+0.1 */ float fac; + float half_sensor= 0.5f*((camera->sensor_fit==CAMERA_SENSOR_FIT_VERT) ? (camera->sensor_y) : (camera->sensor_x)); + *r_drawsize= drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f); if(do_clip) { /* fixed depth, variable size (avoids exceeding clipping range) */ depth = -(camera->clipsta + 0.1f); - fac = depth / (camera->lens/-16.0f * scale[2]); + fac = depth / (camera->lens/(-half_sensor) * scale[2]); } else { /* fixed size, variable depth (stays a reasonable size in the 3D view) */ - depth= *r_drawsize * camera->lens/-16.0f * scale[2]; + depth= *r_drawsize * camera->lens/(-half_sensor) * scale[2]; fac= *r_drawsize; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 2d372b33dfb..3901fde2bf1 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3641,13 +3641,12 @@ void make_local_particlesettings(ParticleSettings *part) expand_local_particlesettings(part); } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, part->id.lib->filepath}; ParticleSettings *partn= psys_copy_settings(part); partn->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &partn->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &partn->id); /* do objects */ for(ob= bmain->object.first; ob; ob= ob->id.next) { diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 6b3786663df..a9de75dc7d0 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -72,6 +72,8 @@ #include "BKE_sound.h" +#include "RE_engine.h" + //XXX #include "BIF_previewrender.h" //XXX #include "BIF_editseq.h" @@ -988,16 +990,22 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen /* this is called in main loop, doing tagged updates before redraw */ void scene_update_tagged(Main *bmain, Scene *scene) { + /* keep this first */ + BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE); + + /* flush recalc flags to dependencies */ DAG_ids_flush_tagged(bmain); scene->physics_settings.quick_cache_step= 0; /* update all objects: drivers, matrices, displists, etc. flags set - by depgraph or manual, no layer check here, gets correct flushed */ + by depgraph or manual, no layer check here, gets correct flushed + in the future this should handle updates for all datablocks, not + only objects and scenes. - brecht */ scene_update_tagged_recursive(bmain, scene, scene); - /* recalc scene animation data here (for sequencer) */ + /* extra call here to recalc scene animation (for sequencer) */ { AnimData *adt= BKE_animdata_from_id(&scene->id); float ctime = BKE_curframe(scene); @@ -1006,11 +1014,20 @@ void scene_update_tagged(Main *bmain, Scene *scene) BKE_animsys_evaluate_animdata(scene, &scene->id, adt, ctime, 0); } + /* quick point cache updates */ 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 - only objects and scenes. - brecht */ + /* notify editors about recalc */ + DAG_ids_check_recalc(bmain); + + /* keep this last */ + BLI_exec_cb(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_POST); +} + +void scene_clear_tagged(Main *bmain, Scene *UNUSED(scene)) +{ + DAG_ids_clear_recalc(bmain); } /* applies changes right away, does all sets too */ @@ -1020,7 +1037,8 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) Scene *sce_iter; /* keep this first */ - BLI_exec_cb(bmain, (ID *)sce, BLI_CB_EVT_FRAME_CHANGE_PRE); + BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_PRE); + BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_PRE); sound_set_cfra(sce->r.cfra); @@ -1032,6 +1050,10 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) DAG_scene_sort(bmain, sce_iter); } + /* flush recalc flags to dependencies, if we were only changing a frame + this would not be necessary, but if a user or a script has modified + some datablock before scene_update_tagged was called, we need the flush */ + DAG_ids_flush_tagged(bmain); /* Following 2 functions are recursive * so dont call within 'scene_update_tagged_recursive' */ @@ -1050,7 +1072,10 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) scene_update_tagged_recursive(bmain, sce, sce); /* keep this last */ - BLI_exec_cb(bmain, (ID *)sce, BLI_CB_EVT_FRAME_CHANGE_POST); + BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_SCENE_UPDATE_POST); + BLI_exec_cb(bmain, &sce->id, BLI_CB_EVT_FRAME_CHANGE_POST); + + DAG_ids_clear_recalc(bmain); } /* return default layer, also used to patch old files */ @@ -1127,3 +1152,10 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base) return NULL; } + +int scene_use_new_shading_nodes(Scene *scene) +{ + RenderEngineType *type= RE_engines_find(scene->r.engine); + return (type->flag & RE_USE_SHADING_NODES); +} + diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 02e6fe945f3..3d28e45f6b7 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -351,6 +351,29 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type) return NULL; } +/* note, using this function is generally a last resort, you really want to be + * using the context when you can - campbell + * -1 for any type */ +struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min) +{ + ScrArea *sa, *big= NULL; + int size, maxsize= 0; + + for(sa= sc->areabase.first; sa; sa= sa->next) { + if ((spacetype == -1) || sa->spacetype == spacetype) { + if (min <= sa->winx && min <= sa->winy) { + size= sa->winx*sa->winy; + if (size > maxsize) { + maxsize= size; + big= sa; + } + } + } + } + + return big; +} + void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene) { int bit; diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index ac2a840c95a..7174126a00c 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -77,6 +77,8 @@ #include "BKE_smoke.h" +#ifdef WITH_SMOKE + #ifdef _WIN32 #include <time.h> #include <stdio.h> @@ -131,12 +133,13 @@ struct SmokeModifierData; #define TRI_UVOFFSET (1./4.) -#ifdef WITH_SMOKE /* forward declerations */ static void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *tris, int numfaces, int numtris, int **tridivs, float cell_len); static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int correct); static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs); + #else /* WITH_SMOKE */ + /* Stubs to use when smoke is disabled */ struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res), int UNUSED(amplify), int UNUSED(noisetype)) { return NULL; } struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(p0)) { return NULL; } @@ -146,9 +149,11 @@ void smoke_initWaveletBlenderRNA(struct WTURBULENCE *UNUSED(wt), float *UNUSED(s void smoke_initBlenderRNA(struct FLUID_3D *UNUSED(fluid), float *UNUSED(alpha), float *UNUSED(beta), float *UNUSED(dt_factor), float *UNUSED(vorticity), int *UNUSED(border_colli)) {} long long smoke_get_mem_req(int UNUSED(xres), int UNUSED(yres), int UNUSED(zres), int UNUSED(amplify)) { return 0; } void smokeModifier_do(SmokeModifierData *UNUSED(smd), Scene *UNUSED(scene), Object *UNUSED(ob), DerivedMesh *UNUSED(dm)) {} + #endif /* WITH_SMOKE */ #ifdef WITH_SMOKE + static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, DerivedMesh *dm) { if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain && !smd->domain->fluid) diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c index d5788d7a748..018c7a197ff 100644 --- a/source/blender/blenkernel/intern/speaker.c +++ b/source/blender/blenkernel/intern/speaker.c @@ -106,12 +106,11 @@ void make_local_speaker(Speaker *spk) id_clear_lib_data(bmain, &spk->id); } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, spk->id.lib->filepath}; Speaker *spkn= copy_speaker(spk); spkn->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &spkn->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &spkn->id); ob= bmain->object.first; while(ob) { diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 15ee98624f5..f02a8031bce 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1598,6 +1598,9 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, if(!mcol) mcol = dm->getFaceDataArray(dm, CD_MCOL); + if(!mcol) + mcol = dm->getFaceDataArray(dm, CD_TEXTURE_MCOL); + totface = ccgSubSurf_getNumFaces(ss); for(i = 0; i < totface; i++) { CCGFace *f = ccgdm->faceMap[i].face; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index e3713b1e177..d3bd7d7b766 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -897,13 +897,12 @@ void make_local_texture(Tex *tex) extern_local_texture(tex); } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, tex->id.lib->filepath}; Tex *texn= copy_texture(tex); texn->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &texn->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &texn->id); ma= bmain->mat.first; while(ma) { diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 4d7a7c9a262..c7d2763774d 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -42,12 +42,14 @@ #include "BLI_utildefines.h" #include "BLI_bpath.h" -#include "BKE_world.h" -#include "BKE_library.h" #include "BKE_animsys.h" #include "BKE_global.h" -#include "BKE_main.h" #include "BKE_icons.h" +#include "BKE_library.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_node.h" +#include "BKE_world.h" void free_world(World *wrld) { @@ -63,6 +65,12 @@ void free_world(World *wrld) BKE_free_animdata((ID *)wrld); + /* is no lib link block, but world extension */ + if(wrld->nodetree) { + ntreeFreeTree(wrld->nodetree); + MEM_freeN(wrld->nodetree); + } + BKE_icon_delete((struct ID*)wrld); wrld->id.icon_id = 0; } @@ -119,6 +127,9 @@ World *copy_world(World *wrld) id_us_plus((ID *)wrldn->mtex[a]->tex); } } + + if(wrld->nodetree) + wrldn->nodetree= ntreeCopyTree(wrld->nodetree); if(wrld->preview) wrldn->preview = BKE_previewimg_copy(wrld->preview); @@ -143,6 +154,9 @@ World *localize_world(World *wrld) } } + if(wrld->nodetree) + wrldn->nodetree= ntreeLocalize(wrld->nodetree); + wrldn->preview= NULL; return wrldn; @@ -176,12 +190,11 @@ void make_local_world(World *wrld) id_clear_lib_data(bmain, &wrld->id); } else if(is_local && is_lib) { - char *bpath_user_data[2]= {bmain->name, wrld->id.lib->filepath}; World *wrldn= copy_world(wrld); wrldn->id.us= 0; /* Remap paths of new ID using old library as base. */ - bpath_traverse_id(bmain, &wrldn->id, bpath_relocate_visitor, 0, bpath_user_data); + BKE_id_lib_local_paths(bmain, &wrldn->id); for(sce= bmain->scene.first; sce; sce= sce->id.next) { if(sce->world == wrld) { |