Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_ops.c
| Context not available. | |||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| static int vertex_color_bright_contrast_exec(bContext *C, wmOperator *op) | |||||
| { | |||||
| Object *obact = CTX_data_active_object(C); | |||||
| float brightness = RNA_float_get(op->ptr, "brightness"); | |||||
| float contrast = RNA_float_get(op->ptr, "contrast"); | |||||
| BrightContrastData user_data = { | |||||
| .brightness = brightness, .contrast = contrast | |||||
| }; | |||||
| void (*bc_fun)(const float col[3], void *user_data, float r_col[3]) = &vpaint_brightness_contrast; | |||||
| if (ED_vpaint_color_transform(obact, bc_fun, &user_data)) { | |||||
| ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| else { | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| } | |||||
| static void PAINT_OT_vertex_color_brightcontrast(wmOperatorType *ot) | |||||
| { | |||||
| /* identifiers */ | |||||
| ot->name = "Vertex Paint Bright/Contrast"; | |||||
| ot->idname = "PAINT_OT_vertex_color_brightcontrast"; | |||||
| ot->description = "Modify brightness/contrast of the active vertex color layer"; | |||||
| /* api callbacks */ | |||||
| ot->exec = vertex_color_bright_contrast_exec; | |||||
| ot->poll = vertex_paint_mode_poll; | |||||
| /* flags */ | |||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | |||||
| /* params */ | |||||
| RNA_def_float(ot->srna, "brightness", 0.0f, -100.0f, 100.0f, "Brightness", "Brightness factor", -100.0f, 100.0f); | |||||
| RNA_def_float(ot->srna, "contrast", 0.0f, -100.0f, 100.0f, "Contrast", "Contrast factor", -100.0f, 100.0f); | |||||
| } | |||||
| static int vertex_color_hue_sat_exec(bContext *C, wmOperator *op) | |||||
| { | |||||
| Object *obact = CTX_data_active_object(C); | |||||
| float hue = RNA_float_get(op->ptr, "hue"); | |||||
| float sat = RNA_float_get(op->ptr, "sat"); | |||||
| float val = RNA_float_get(op->ptr, "val"); | |||||
| HueSatData user_data = { | |||||
| .hue = hue, .sat = sat, .val = val | |||||
| }; | |||||
| void (*hsv_fun)(const float col[3], void *user_data, float r_col[3]) = &vpaint_hue_sat; | |||||
| if (ED_vpaint_color_transform(obact, hsv_fun, &user_data)) { | |||||
| ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| else { | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| } | |||||
| static void PAINT_OT_vertex_color_huesat(wmOperatorType *ot) | |||||
| { | |||||
| /* identifiers */ | |||||
| ot->name = "Vertex Paint Hue Saturation Value"; | |||||
| ot->idname = "PAINT_OT_vertex_color_huesat"; | |||||
| ot->description = "Scale hue/saturation/value of the active vertex color layer"; | |||||
| /* api callbacks */ | |||||
| ot->exec = vertex_color_hue_sat_exec; | |||||
| ot->poll = vertex_paint_mode_poll; | |||||
| /* flags */ | |||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | |||||
| /* params */ | |||||
| RNA_def_float(ot->srna, "hue", 0.5f, 0.0f, 1.0f, "Hue", "Hue factor", 0.0f, 1.0f); | |||||
| RNA_def_float(ot->srna, "sat", 1.0f, 0.0f, 2.0f, "Saturation", "Saturation factor", 0.0f, 2.0f); | |||||
| RNA_def_float(ot->srna, "val", 1.0f, 0.0f, 2.0f, "Value", "Value factor", 0.0f, 2.0f); | |||||
| } | |||||
| static int vertex_color_invert_exec(bContext *C, wmOperator *UNUSED(op)) | |||||
| { | |||||
| Object *obact = CTX_data_active_object(C); | |||||
| void (*invert_fun)(const float col[3], void *user_data, float r_col[3]) = vpaint_invert; | |||||
| if (ED_vpaint_color_transform(obact, invert_fun, NULL)) { | |||||
| ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| else { | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| } | |||||
| static void PAINT_OT_vertex_color_invert(wmOperatorType *ot) | |||||
| { | |||||
| /* identifiers */ | |||||
| ot->name = "Vertex Paint Invert"; | |||||
| ot->idname = "PAINT_OT_vertex_color_invert"; | |||||
| ot->description = "Invert RGB values of the active vertex color layer"; | |||||
| /* api callbacks */ | |||||
| ot->exec = vertex_color_invert_exec; | |||||
| ot->poll = vertex_paint_mode_poll; | |||||
| /* flags */ | |||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | |||||
| } | |||||
| static int vertex_color_levels_exec(bContext *C, wmOperator *op) | |||||
| { | |||||
| Object *obact = CTX_data_active_object(C); | |||||
| float gain = RNA_float_get(op->ptr, "gain"); | |||||
| float offset = RNA_float_get(op->ptr, "offset"); | |||||
| LevelsData user_data = { | |||||
| .gain = gain, .offset = offset | |||||
| }; | |||||
| void (*levels_fun)(const float col[3], void *user_data, float r_col[3]) = &vpaint_levels; | |||||
| if (ED_vpaint_color_transform(obact, levels_fun, &user_data)) { | |||||
| ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views | |||||
| return OPERATOR_FINISHED; | |||||
| } | |||||
| else { | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| } | |||||
| static void PAINT_OT_vertex_color_levels(wmOperatorType *ot) | |||||
| { | |||||
| /* identifiers */ | |||||
| ot->name = "Vertex Paint Levels"; | |||||
| ot->idname = "PAINT_OT_vertex_color_levels"; | |||||
| ot->description = "Add some offset and multiply with some gain the RGB values of the active vertex color layer"; | |||||
| /* api callbacks */ | |||||
| ot->exec = vertex_color_levels_exec; | |||||
| ot->poll = vertex_paint_mode_poll; | |||||
| /* flags */ | |||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | |||||
| /* params */ | |||||
| RNA_def_float(ot->srna, "offset", 0.0f, -1.0f, 1.0f, "Offset", "Value to add to colors", -1.0f, 1.0f); | |||||
| RNA_def_float(ot->srna, "gain", 1.0f, 0.0f, FLT_MAX, "Gain", "Value to multiply colors by", 0.0f, 10.0f); | |||||
| } | |||||
| static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op)) | static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Paint *paint = BKE_paint_get_active_from_context(C); | Paint *paint = BKE_paint_get_active_from_context(C); | ||||
| Context not available. | |||||
| WM_operatortype_append(PAINT_OT_vertex_paint); | WM_operatortype_append(PAINT_OT_vertex_paint); | ||||
| WM_operatortype_append(PAINT_OT_vertex_color_set); | WM_operatortype_append(PAINT_OT_vertex_color_set); | ||||
| WM_operatortype_append(PAINT_OT_vertex_color_smooth); | WM_operatortype_append(PAINT_OT_vertex_color_smooth); | ||||
| WM_operatortype_append(PAINT_OT_vertex_color_brightcontrast); | |||||
| WM_operatortype_append(PAINT_OT_vertex_color_huesat); | |||||
| WM_operatortype_append(PAINT_OT_vertex_color_invert); | |||||
| WM_operatortype_append(PAINT_OT_vertex_color_levels); | |||||
| /* face-select */ | /* face-select */ | ||||
| WM_operatortype_append(PAINT_OT_face_select_linked); | WM_operatortype_append(PAINT_OT_face_select_linked); | ||||
| Context not available. | |||||