Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/render/render_shading.c
| Show First 20 Lines • Show All 766 Lines • ▼ Show 20 Lines | static int freestyle_active_module_poll(bContext *C) | ||||
| FreestyleModuleConfig *module = ptr.data; | FreestyleModuleConfig *module = ptr.data; | ||||
| return module != NULL; | return module != NULL; | ||||
| } | } | ||||
| static int freestyle_module_add_exec(bContext *C, wmOperator *UNUSED(op)) | static int freestyle_module_add_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| BKE_freestyle_module_add(&srl->freestyleConfig); | BKE_freestyle_module_add(&scene_layer->freestyleConfig); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SCENE_OT_freestyle_module_add(wmOperatorType *ot) | void SCENE_OT_freestyle_module_add(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Add Freestyle Module"; | ot->name = "Add Freestyle Module"; | ||||
| ot->idname = "SCENE_OT_freestyle_module_add"; | ot->idname = "SCENE_OT_freestyle_module_add"; | ||||
| ot->description = "Add a style module into the list of modules"; | ot->description = "Add a style module into the list of modules"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = freestyle_module_add_exec; | ot->exec = freestyle_module_add_exec; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ||||
| } | } | ||||
| static int freestyle_module_remove_exec(bContext *C, wmOperator *UNUSED(op)) | static int freestyle_module_remove_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); | PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); | ||||
| FreestyleModuleConfig *module = ptr.data; | FreestyleModuleConfig *module = ptr.data; | ||||
| BKE_freestyle_module_delete(&srl->freestyleConfig, module); | BKE_freestyle_module_delete(&scene_layer->freestyleConfig, module); | ||||
| DEG_id_tag_update(&scene->id, 0); | DEG_id_tag_update(&scene->id, 0); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SCENE_OT_freestyle_module_remove(wmOperatorType *ot) | void SCENE_OT_freestyle_module_remove(wmOperatorType *ot) | ||||
| Show All 9 Lines | void SCENE_OT_freestyle_module_remove(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ||||
| } | } | ||||
| static int freestyle_module_move_exec(bContext *C, wmOperator *op) | static int freestyle_module_move_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); | PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); | ||||
| FreestyleModuleConfig *module = ptr.data; | FreestyleModuleConfig *module = ptr.data; | ||||
| int dir = RNA_enum_get(op->ptr, "direction"); | int dir = RNA_enum_get(op->ptr, "direction"); | ||||
| if (BKE_freestyle_module_move(&srl->freestyleConfig, module, dir)) { | if (BKE_freestyle_module_move(&scene_layer->freestyleConfig, module, dir)) { | ||||
| DEG_id_tag_update(&scene->id, 0); | DEG_id_tag_update(&scene->id, 0); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | ||||
| } | } | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SCENE_OT_freestyle_module_move(wmOperatorType *ot) | void SCENE_OT_freestyle_module_move(wmOperatorType *ot) | ||||
| Show All 20 Lines | void SCENE_OT_freestyle_module_move(wmOperatorType *ot) | ||||
| RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", | RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", | ||||
| "Direction to move the chosen style module towards"); | "Direction to move the chosen style module towards"); | ||||
| } | } | ||||
| static int freestyle_lineset_add_exec(bContext *C, wmOperator *UNUSED(op)) | static int freestyle_lineset_add_exec(bContext *C, wmOperator *UNUSED(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); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| BKE_freestyle_lineset_add(bmain, &srl->freestyleConfig, NULL); | BKE_freestyle_lineset_add(bmain, &scene_layer->freestyleConfig, NULL); | ||||
| DEG_id_tag_update(&scene->id, 0); | DEG_id_tag_update(&scene->id, 0); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SCENE_OT_freestyle_lineset_add(wmOperatorType *ot) | void SCENE_OT_freestyle_lineset_add(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Add Line Set"; | ot->name = "Add Line Set"; | ||||
| ot->idname = "SCENE_OT_freestyle_lineset_add"; | ot->idname = "SCENE_OT_freestyle_lineset_add"; | ||||
| ot->description = "Add a line set into the list of line sets"; | ot->description = "Add a line set into the list of line sets"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = freestyle_lineset_add_exec; | ot->exec = freestyle_lineset_add_exec; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ||||
| } | } | ||||
| static int freestyle_active_lineset_poll(bContext *C) | static int freestyle_active_lineset_poll(bContext *C) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| if (!srl) { | if (!scene_layer) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return BKE_freestyle_lineset_get_active(&srl->freestyleConfig) != NULL; | return BKE_freestyle_lineset_get_active(&scene_layer->freestyleConfig) != NULL; | ||||
| } | } | ||||
| static int freestyle_lineset_copy_exec(bContext *C, wmOperator *UNUSED(op)) | static int freestyle_lineset_copy_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| FRS_copy_active_lineset(&srl->freestyleConfig); | FRS_copy_active_lineset(&scene_layer->freestyleConfig); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot) | void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Copy Line Set"; | ot->name = "Copy Line Set"; | ||||
| ot->idname = "SCENE_OT_freestyle_lineset_copy"; | ot->idname = "SCENE_OT_freestyle_lineset_copy"; | ||||
| ot->description = "Copy the active line set to a buffer"; | ot->description = "Copy the active line set to a buffer"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = freestyle_lineset_copy_exec; | ot->exec = freestyle_lineset_copy_exec; | ||||
| ot->poll = freestyle_active_lineset_poll; | ot->poll = freestyle_active_lineset_poll; | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ||||
| } | } | ||||
| static int freestyle_lineset_paste_exec(bContext *C, wmOperator *UNUSED(op)) | static int freestyle_lineset_paste_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| FRS_paste_active_lineset(&srl->freestyleConfig); | FRS_paste_active_lineset(&scene_layer->freestyleConfig); | ||||
| DEG_id_tag_update(&scene->id, 0); | DEG_id_tag_update(&scene->id, 0); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SCENE_OT_freestyle_lineset_paste(wmOperatorType *ot) | void SCENE_OT_freestyle_lineset_paste(wmOperatorType *ot) | ||||
| Show All 9 Lines | void SCENE_OT_freestyle_lineset_paste(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ||||
| } | } | ||||
| static int freestyle_lineset_remove_exec(bContext *C, wmOperator *UNUSED(op)) | static int freestyle_lineset_remove_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| FRS_delete_active_lineset(&srl->freestyleConfig); | FRS_delete_active_lineset(&scene_layer->freestyleConfig); | ||||
| DEG_id_tag_update(&scene->id, 0); | DEG_id_tag_update(&scene->id, 0); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SCENE_OT_freestyle_lineset_remove(wmOperatorType *ot) | void SCENE_OT_freestyle_lineset_remove(wmOperatorType *ot) | ||||
| Show All 9 Lines | void SCENE_OT_freestyle_lineset_remove(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ||||
| } | } | ||||
| static int freestyle_lineset_move_exec(bContext *C, wmOperator *op) | static int freestyle_lineset_move_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| int dir = RNA_enum_get(op->ptr, "direction"); | int dir = RNA_enum_get(op->ptr, "direction"); | ||||
| if (FRS_move_active_lineset(&srl->freestyleConfig, dir)) { | if (FRS_move_active_lineset(&scene_layer->freestyleConfig, dir)) { | ||||
| DEG_id_tag_update(&scene->id, 0); | DEG_id_tag_update(&scene->id, 0); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); | ||||
| } | } | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void SCENE_OT_freestyle_lineset_move(wmOperatorType *ot) | void SCENE_OT_freestyle_lineset_move(wmOperatorType *ot) | ||||
| Show All 20 Lines | void SCENE_OT_freestyle_lineset_move(wmOperatorType *ot) | ||||
| RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", | RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", | ||||
| "Direction to move the active line set towards"); | "Direction to move the active line set towards"); | ||||
| } | } | ||||
| static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op) | static int freestyle_linestyle_new_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); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig); | FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&scene_layer->freestyleConfig); | ||||
| if (!lineset) { | if (!lineset) { | ||||
| BKE_report(op->reports, RPT_ERROR, "No active lineset to add a new line style to"); | BKE_report(op->reports, RPT_ERROR, "No active lineset to add a new line style to"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (lineset->linestyle) { | if (lineset->linestyle) { | ||||
| id_us_min(&lineset->linestyle->id); | id_us_min(&lineset->linestyle->id); | ||||
| lineset->linestyle = BKE_linestyle_copy(bmain, lineset->linestyle); | lineset->linestyle = BKE_linestyle_copy(bmain, lineset->linestyle); | ||||
| Show All 20 Lines | void SCENE_OT_freestyle_linestyle_new(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ||||
| } | } | ||||
| static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op) | static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig); | FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&scene_layer->freestyleConfig); | ||||
| int type = RNA_enum_get(op->ptr, "type"); | int type = RNA_enum_get(op->ptr, "type"); | ||||
| if (!freestyle_linestyle_check_report(lineset, op->reports)) { | if (!freestyle_linestyle_check_report(lineset, op->reports)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (BKE_linestyle_color_modifier_add(lineset->linestyle, NULL, type) == NULL) { | if (BKE_linestyle_color_modifier_add(lineset->linestyle, NULL, type) == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Unknown line color modifier type"); | BKE_report(op->reports, RPT_ERROR, "Unknown line color modifier type"); | ||||
| Show All 22 Lines | void SCENE_OT_freestyle_color_modifier_add(wmOperatorType *ot) | ||||
| /* properties */ | /* properties */ | ||||
| ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_linestyle_color_modifier_type_items, 0, "Type", ""); | ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_linestyle_color_modifier_type_items, 0, "Type", ""); | ||||
| } | } | ||||
| static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op) | static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig); | FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&scene_layer->freestyleConfig); | ||||
| int type = RNA_enum_get(op->ptr, "type"); | int type = RNA_enum_get(op->ptr, "type"); | ||||
| if (!freestyle_linestyle_check_report(lineset, op->reports)) { | if (!freestyle_linestyle_check_report(lineset, op->reports)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (BKE_linestyle_alpha_modifier_add(lineset->linestyle, NULL, type) == NULL) { | if (BKE_linestyle_alpha_modifier_add(lineset->linestyle, NULL, type) == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Unknown alpha transparency modifier type"); | BKE_report(op->reports, RPT_ERROR, "Unknown alpha transparency modifier type"); | ||||
| Show All 22 Lines | void SCENE_OT_freestyle_alpha_modifier_add(wmOperatorType *ot) | ||||
| /* properties */ | /* properties */ | ||||
| ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_linestyle_alpha_modifier_type_items, 0, "Type", ""); | ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_linestyle_alpha_modifier_type_items, 0, "Type", ""); | ||||
| } | } | ||||
| static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op) | static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig); | FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&scene_layer->freestyleConfig); | ||||
| int type = RNA_enum_get(op->ptr, "type"); | int type = RNA_enum_get(op->ptr, "type"); | ||||
| if (!freestyle_linestyle_check_report(lineset, op->reports)) { | if (!freestyle_linestyle_check_report(lineset, op->reports)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (BKE_linestyle_thickness_modifier_add(lineset->linestyle, NULL, type) == NULL) { | if (BKE_linestyle_thickness_modifier_add(lineset->linestyle, NULL, type) == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Unknown line thickness modifier type"); | BKE_report(op->reports, RPT_ERROR, "Unknown line thickness modifier type"); | ||||
| Show All 22 Lines | void SCENE_OT_freestyle_thickness_modifier_add(wmOperatorType *ot) | ||||
| /* properties */ | /* properties */ | ||||
| ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_linestyle_thickness_modifier_type_items, 0, "Type", ""); | ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_linestyle_thickness_modifier_type_items, 0, "Type", ""); | ||||
| } | } | ||||
| static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op) | static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig); | FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&scene_layer->freestyleConfig); | ||||
| int type = RNA_enum_get(op->ptr, "type"); | int type = RNA_enum_get(op->ptr, "type"); | ||||
| if (!freestyle_linestyle_check_report(lineset, op->reports)) { | if (!freestyle_linestyle_check_report(lineset, op->reports)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| if (BKE_linestyle_geometry_modifier_add(lineset->linestyle, NULL, type) == NULL) { | if (BKE_linestyle_geometry_modifier_add(lineset->linestyle, NULL, type) == NULL) { | ||||
| BKE_report(op->reports, RPT_ERROR, "Unknown stroke geometry modifier type"); | BKE_report(op->reports, RPT_ERROR, "Unknown stroke geometry modifier type"); | ||||
| Show All 35 Lines | static int freestyle_get_modifier_type(PointerRNA *ptr) | ||||
| else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleGeometryModifier)) | else if (RNA_struct_is_a(ptr->type, &RNA_LineStyleGeometryModifier)) | ||||
| return LS_MODIFIER_TYPE_GEOMETRY; | return LS_MODIFIER_TYPE_GEOMETRY; | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| static int freestyle_modifier_remove_exec(bContext *C, wmOperator *op) | static int freestyle_modifier_remove_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig); | FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&scene_layer->freestyleConfig); | ||||
| PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); | PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); | ||||
| LineStyleModifier *modifier = ptr.data; | LineStyleModifier *modifier = ptr.data; | ||||
| if (!freestyle_linestyle_check_report(lineset, op->reports)) { | if (!freestyle_linestyle_check_report(lineset, op->reports)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| switch (freestyle_get_modifier_type(&ptr)) { | switch (freestyle_get_modifier_type(&ptr)) { | ||||
| Show All 32 Lines | void SCENE_OT_freestyle_modifier_remove(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ||||
| } | } | ||||
| static int freestyle_modifier_copy_exec(bContext *C, wmOperator *op) | static int freestyle_modifier_copy_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig); | FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&scene_layer->freestyleConfig); | ||||
| PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); | PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); | ||||
| LineStyleModifier *modifier = ptr.data; | LineStyleModifier *modifier = ptr.data; | ||||
| if (!freestyle_linestyle_check_report(lineset, op->reports)) { | if (!freestyle_linestyle_check_report(lineset, op->reports)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| switch (freestyle_get_modifier_type(&ptr)) { | switch (freestyle_get_modifier_type(&ptr)) { | ||||
| Show All 32 Lines | void SCENE_OT_freestyle_modifier_copy(wmOperatorType *ot) | ||||
| /* flags */ | /* flags */ | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; | ||||
| } | } | ||||
| static int freestyle_modifier_move_exec(bContext *C, wmOperator *op) | static int freestyle_modifier_move_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneRenderLayer *srl = BLI_findlink(&scene->r.layers, scene->r.actlay); | SceneLayer *scene_layer = BLI_findlink(&scene->render_layers, scene->active_layer); | ||||
| FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig); | FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&scene_layer->freestyleConfig); | ||||
| PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); | PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier); | ||||
| LineStyleModifier *modifier = ptr.data; | LineStyleModifier *modifier = ptr.data; | ||||
| int dir = RNA_enum_get(op->ptr, "direction"); | int dir = RNA_enum_get(op->ptr, "direction"); | ||||
| bool changed = false; | bool changed = false; | ||||
| if (!freestyle_linestyle_check_report(lineset, op->reports)) { | if (!freestyle_linestyle_check_report(lineset, op->reports)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 576 Lines • Show Last 20 Lines | |||||