diff options
author | Bastien Montagne <bastien@blender.org> | 2020-04-20 12:20:38 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-04-20 12:20:38 +0300 |
commit | 67593a41dd0ba504c8843808afb4e72b40a72314 (patch) | |
tree | 1ff4e3f6203a9c13c139ef7f3d237b4c1fbd02a7 /source/blender | |
parent | 0247ee5f5362632eb3e48ccb4c7d7fe33040360a (diff) | |
parent | 25e774422c00fe708475671f4a4a89a0c696d105 (diff) |
Merge branch 'blender-v2.83-release'
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/light.c | 95 | ||||
-rw-r--r-- | source/blender/editors/include/ED_transform.h | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 19 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_orientations.c | 3 |
4 files changed, 63 insertions, 56 deletions
diff --git a/source/blender/blenkernel/intern/light.c b/source/blender/blenkernel/intern/light.c index 3ecd1c81b27..3d0503b2e70 100644 --- a/source/blender/blenkernel/intern/light.c +++ b/source/blender/blenkernel/intern/light.c @@ -58,17 +58,6 @@ static void light_init_data(ID *id) BKE_curvemapping_initialize(la->curfalloff); } -Light *BKE_light_add(Main *bmain, const char *name) -{ - Light *la; - - la = BKE_libblock_alloc(bmain, ID_LA, name, 0); - - light_init_data(&la->id); - - return la; -} - /** * Only copy internal data of Light ID from source * to already allocated/initialized destination. @@ -100,6 +89,51 @@ static void light_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int } } +static void light_free_data(ID *id) +{ + Light *la = (Light *)id; + + BKE_curvemapping_free(la->curfalloff); + + /* is no lib link block, but light extension */ + if (la->nodetree) { + ntreeFreeNestedTree(la->nodetree); + MEM_freeN(la->nodetree); + la->nodetree = NULL; + } + + BKE_previewimg_free(&la->preview); + BKE_icon_id_delete(&la->id); + la->id.icon_id = 0; +} + +IDTypeInfo IDType_ID_LA = { + .id_code = ID_LA, + .id_filter = FILTER_ID_LA, + .main_listbase_index = INDEX_ID_LA, + .struct_size = sizeof(Light), + .name = "Light", + .name_plural = "lights", + .translation_context = BLT_I18NCONTEXT_ID_LIGHT, + .flags = 0, + + .init_data = light_init_data, + .copy_data = light_copy_data, + .free_data = light_free_data, + .make_local = NULL, +}; + +Light *BKE_light_add(Main *bmain, const char *name) +{ + Light *la; + + la = BKE_libblock_alloc(bmain, ID_LA, name, 0); + + light_init_data(&la->id); + + return la; +} + Light *BKE_light_copy(Main *bmain, const Light *la) { Light *la_copy; @@ -133,42 +167,3 @@ Light *BKE_light_localize(Light *la) return lan; } - -static void light_make_local(Main *bmain, ID *id, const int flags) -{ - BKE_lib_id_make_local_generic(bmain, id, flags); -} - -static void light_free_data(ID *id) -{ - Light *la = (Light *)id; - - BKE_curvemapping_free(la->curfalloff); - - /* is no lib link block, but light extension */ - if (la->nodetree) { - ntreeFreeNestedTree(la->nodetree); - MEM_freeN(la->nodetree); - la->nodetree = NULL; - } - - BKE_previewimg_free(&la->preview); - BKE_icon_id_delete(&la->id); - la->id.icon_id = 0; -} - -IDTypeInfo IDType_ID_LA = { - .id_code = ID_LA, - .id_filter = FILTER_ID_LA, - .main_listbase_index = INDEX_ID_LA, - .struct_size = sizeof(Light), - .name = "Light", - .name_plural = "lights", - .translation_context = BLT_I18NCONTEXT_ID_LIGHT, - .flags = 0, - - .init_data = light_init_data, - .copy_data = light_copy_data, - .free_data = light_free_data, - .make_local = light_make_local, -}; diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index eb1533dc639..27b7511c8a2 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -123,7 +123,7 @@ struct bContext; void BIF_clearTransformOrientation(struct bContext *C); void BIF_removeTransformOrientation(struct bContext *C, struct TransformOrientation *ts); void BIF_removeTransformOrientationIndex(struct bContext *C, int index); -void BIF_createTransformOrientation(struct bContext *C, +bool BIF_createTransformOrientation(struct bContext *C, struct ReportList *reports, const char *name, const bool use_view, diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index f8ac2a6ac09..d643244e6ca 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -223,6 +223,9 @@ static int delete_orientation_exec(bContext *C, wmOperator *UNUSED(op)) WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); + struct wmMsgBus *mbus = CTX_wm_message_bus(C); + WM_msg_publish_rna_prop(mbus, &scene->id, scene, Scene, transform_orientation_slots); + return OPERATOR_FINISHED; } @@ -233,12 +236,11 @@ static int delete_orientation_invoke(bContext *C, wmOperator *op, const wmEvent static bool delete_orientation_poll(bContext *C) { - Scene *scene = CTX_data_scene(C); - if (ED_operator_areaactive(C) == 0) { return 0; } + Scene *scene = CTX_data_scene(C); return ((scene->orientation_slots[SCE_ORIENT_DEFAULT].type >= V3D_ORIENT_CUSTOM) && (scene->orientation_slots[SCE_ORIENT_DEFAULT].index_custom != -1)); } @@ -264,6 +266,7 @@ static int create_orientation_exec(bContext *C, wmOperator *op) const bool overwrite = RNA_boolean_get(op->ptr, "overwrite"); const bool use_view = RNA_boolean_get(op->ptr, "use_view"); View3D *v3d = CTX_wm_view3d(C); + Scene *scene = CTX_data_scene(C); RNA_string_get(op->ptr, "name", name); @@ -274,10 +277,18 @@ static int create_orientation_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - BIF_createTransformOrientation(C, op->reports, name, use_view, use, overwrite); + if (!BIF_createTransformOrientation(C, op->reports, name, use_view, use, overwrite)) { + BKE_report(op->reports, RPT_ERROR, "Unable to create orientation"); + return OPERATOR_CANCELLED; + } + + if (use) { + struct wmMsgBus *mbus = CTX_wm_message_bus(C); + WM_msg_publish_rna_prop(mbus, &scene->id, scene, Scene, transform_orientation_slots); + WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); + } WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); - WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C)); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 423990b3713..76823adfd20 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -296,7 +296,7 @@ bool createSpaceNormalTangent(float mat[3][3], const float normal[3], const floa return true; } -void BIF_createTransformOrientation(bContext *C, +bool BIF_createTransformOrientation(bContext *C, ReportList *reports, const char *name, const bool use_view, @@ -333,6 +333,7 @@ void BIF_createTransformOrientation(bContext *C, if (activate && ts != NULL) { BIF_selectTransformOrientation(C, ts); } + return (ts != NULL); } TransformOrientation *addMatrixSpace(bContext *C, |