Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_shader_fx.c
| Show All 28 Lines | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_shader_fx_types.h" | #include "DNA_shader_fx_types.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_string.h" | |||||
| #include "BLI_string_utf8.h" | #include "BLI_string_utf8.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | else { | ||||
| /* Move shaderfx up in list. */ | /* Move shaderfx up in list. */ | ||||
| for (; fx_index > index; fx_index--) { | for (; fx_index > index; fx_index--) { | ||||
| if (!ED_object_shaderfx_move_up(reports, ob, fx)) { | if (!ED_object_shaderfx_move_up(reports, ob, fx)) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | |||||
| WM_main_add_notifier(NC_OBJECT | ND_SHADERFX, ob); | |||||
| return true; | return true; | ||||
| } | } | ||||
| void ED_object_shaderfx_link(Object *dst, Object *src) | |||||
| { | |||||
| BLI_freelistN(&dst->shader_fx); | |||||
| BKE_shaderfx_copy(&dst->shader_fx, &src->shader_fx); | |||||
| DEG_id_tag_update(&dst->id, ID_RECALC_GEOMETRY); | |||||
| WM_main_add_notifier(NC_OBJECT | ND_SHADERFX, dst); | |||||
| } | |||||
| void ED_object_shaderfx_copy(Object *dst, ShaderFxData *fx) | |||||
| { | |||||
| ShaderFxData *nfx = BKE_shaderfx_new(fx->type); | |||||
| BLI_strncpy(nfx->name, fx->name, sizeof(nfx->name)); | |||||
| BKE_shaderfx_copydata(fx, nfx); | |||||
| BLI_addtail(&dst->shader_fx, nfx); | |||||
| DEG_id_tag_update(&dst->id, ID_RECALC_GEOMETRY); | |||||
| WM_main_add_notifier(NC_OBJECT | ND_SHADERFX, dst); | |||||
| } | |||||
| /************************ add effect operator *********************/ | /************************ add effect operator *********************/ | ||||
| static int shaderfx_add_exec(bContext *C, wmOperator *op) | static int shaderfx_add_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| int type = RNA_enum_get(op->ptr, "type"); | int type = RNA_enum_get(op->ptr, "type"); | ||||
| ▲ Show 20 Lines • Show All 333 Lines • ▼ Show 20 Lines | static int shaderfx_move_to_index_exec(bContext *C, wmOperator *op) | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| ShaderFxData *fx = edit_shaderfx_property_get(op, ob, 0); | ShaderFxData *fx = edit_shaderfx_property_get(op, ob, 0); | ||||
| int index = RNA_int_get(op->ptr, "index"); | int index = RNA_int_get(op->ptr, "index"); | ||||
| if (!fx || !ED_object_shaderfx_move_to_index(op->reports, ob, fx, index)) { | if (!fx || !ED_object_shaderfx_move_to_index(op->reports, ob, fx, index)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | |||||
| WM_event_add_notifier(C, NC_OBJECT | ND_SHADERFX, ob); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int shaderfx_move_to_index_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int shaderfx_move_to_index_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| int retval; | int retval; | ||||
| if (edit_shaderfx_invoke_properties(C, op, event, &retval)) { | if (edit_shaderfx_invoke_properties(C, op, event, &retval)) { | ||||
| return shaderfx_move_to_index_exec(C, op); | return shaderfx_move_to_index_exec(C, op); | ||||
| Show All 22 Lines | |||||