diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-06-10 19:38:23 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-06-10 19:38:23 +0300 |
commit | 080cf9332bc9d71e0e14326bc8efdf06b738dea1 (patch) | |
tree | e8531a509dca4d8253aa19d89edc68152421f9e5 /source/blender/makesrna/intern/rna_object_api.c | |
parent | 6d495cc4ef071171ff0686b2be898a41e05b8051 (diff) | |
parent | 9676642cc94599b3419c9aaa5cf1aae2fbbd235f (diff) |
Merge branch 'gooseberry' into temp_motionpathstemp_motionpaths
Conflicts:
source/blender/blenkernel/intern/object.c
Diffstat (limited to 'source/blender/makesrna/intern/rna_object_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_object_api.c | 73 |
1 files changed, 66 insertions, 7 deletions
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index a312ec5d41a..c0aee13d37b 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -87,6 +87,8 @@ static EnumPropertyItem space_items[] = { #include "MEM_guardedalloc.h" +#include "DEG_depsgraph.h" + /* Convert a given matrix from a space to another (using the object and/or a bone as reference). */ static void rna_Scene_mat_convert_space(Object *ob, ReportList *reports, bPoseChannel *pchan, float *mat, float *mat_ret, int from, int to) @@ -131,7 +133,7 @@ static void rna_Object_calc_matrix_camera( static void rna_Object_camera_fit_coords( Object *ob, Scene *scene, int num_cos, float *cos, float co_ret[3], float *scale_ret) { - BKE_camera_view_frame_fit_to_coords(scene, (float (*)[3])cos, num_cos / 3, ob, co_ret, scale_ret); + BKE_camera_view_frame_fit_to_coords(scene, (const float (*)[3])cos, num_cos / 3, ob, co_ret, scale_ret); } /* copied from Mesh_getFromObject and adapted to RNA interface */ @@ -191,8 +193,8 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, int settings) { bool for_render = (settings == DAG_EVAL_RENDER); - EvaluationContext eval_ctx = {0}; - eval_ctx.mode = settings; + EvaluationContext eval_ctx; + DEG_evaluation_context_init(&eval_ctx, settings); if (!(ob->transflag & OB_DUPLI)) { BKE_report(reports, RPT_ERROR, "Object does not have duplis"); @@ -222,12 +224,24 @@ static void rna_Object_free_duplilist(Object *ob) } } +static PointerRNA rna_Object_find_dupli_cache(Object *ob, Object *dupob) +{ + DupliObjectData *data = NULL; + PointerRNA ptr; + + if (ob->dup_cache) + data = BKE_dupli_cache_find_data(ob->dup_cache, dupob); + + RNA_pointer_create((ID *)ob, &RNA_DupliObjectData, data, &ptr); + return ptr; +} + static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *reports, const char *name, int from_mix) { KeyBlock *kb = NULL; - if ((kb = BKE_object_insert_shape_key(ob, name, from_mix))) { + if ((kb = BKE_object_shapekey_insert(ob, name, from_mix))) { PointerRNA keyptr; RNA_pointer_create((ID *)ob->data, &RNA_ShapeKey, kb, &keyptr); @@ -241,6 +255,29 @@ static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList * } } +static void rna_Object_shape_key_remove( + Object *ob, Main *bmain, ReportList *reports, + PointerRNA *kb_ptr) +{ + KeyBlock *kb = kb_ptr->data; + Key *key = BKE_key_from_object(ob); + + if ((key == NULL) || BLI_findindex(&key->block, kb) == -1) { + BKE_reportf(reports, RPT_ERROR, "ShapeKey not found"); + return; + } + + if (!BKE_object_shapekey_remove(bmain, ob, kb)) { + BKE_reportf(reports, RPT_ERROR, "Could not remove ShapeKey"); + return; + } + + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); + + RNA_POINTER_INVALIDATE(kb_ptr); +} + static int rna_Object_is_visible(Object *ob, Scene *sce) { return !(ob->restrictflag & OB_RESTRICT_VIEW) && (ob->lay & sce->lay); @@ -441,6 +478,12 @@ static int rna_Object_update_from_editmode(Object *ob) } return false; } + +static void rna_Object_cache_release(Object *object, int free_smoke_sim) +{ + BKE_object_free_caches(object, free_smoke_sim != 0); +} + #else /* RNA_RUNTIME */ void RNA_api_object(StructRNA *srna) @@ -547,6 +590,14 @@ void RNA_api_object(StructRNA *srna) func = RNA_def_function(srna, "dupli_list_clear", "rna_Object_free_duplilist"); RNA_def_function_ui_description(func, "Free the list of dupli objects"); + func = RNA_def_function(srna, "find_dupli_cache", "rna_Object_find_dupli_cache"); + RNA_def_function_ui_description(func, "Find cached data for a dupli object"); + parm = RNA_def_pointer(func, "object", "Object", "", "Object data to look up"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "data", "DupliObjectData", "", "Cached object data"); + RNA_def_property_flag(parm, PROP_RNAPTR); + RNA_def_function_return(func, parm); + /* Armature */ func = RNA_def_function(srna, "find_armature", "modifiers_isDeformedByArmature"); RNA_def_function_ui_description(func, "Find armature influencing this object as a parent or via a modifier"); @@ -555,14 +606,21 @@ void RNA_api_object(StructRNA *srna) /* Shape key */ func = RNA_def_function(srna, "shape_key_add", "rna_Object_shape_key_add"); - RNA_def_function_ui_description(func, "Add shape key to an object"); + RNA_def_function_ui_description(func, "Add shape key to this object"); RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); - RNA_def_string(func, "name", "Key", 0, "", "Unique name for the new keylock"); /* optional */ + RNA_def_string(func, "name", "Key", 0, "", "Unique name for the new keyblock"); /* optional */ RNA_def_boolean(func, "from_mix", 1, "", "Create new shape from existing mix of shapes"); parm = RNA_def_pointer(func, "key", "ShapeKey", "", "New shape keyblock"); RNA_def_property_flag(parm, PROP_RNAPTR); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "shape_key_remove", "rna_Object_shape_key_remove"); + RNA_def_function_ui_description(func, "Remove a Shape Key from this object"); + RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "key", "ShapeKey", "", "Keyblock to be removed"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); + /* Ray Cast */ func = RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast"); RNA_def_function_ui_description(func, "Cast a ray onto in object space"); @@ -656,7 +714,8 @@ void RNA_api_object(StructRNA *srna) parm = RNA_def_boolean(func, "result", 0, "", "Success"); RNA_def_function_return(func, parm); - func = RNA_def_function(srna, "cache_release", "BKE_object_free_caches"); + func = RNA_def_function(srna, "cache_release", "rna_Object_cache_release"); + RNA_def_boolean(func, "free_smoke_sim", 0, "", "Free baked smoke simulation data"); RNA_def_function_ui_description(func, "Release memory used by caches associated with this object. Intended to be used by render engines only"); } |