Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 5,381 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| int totnode; | int totnode; | ||||
| PBVHNode **nodes; | PBVHNode **nodes; | ||||
| /* Check for unsupported features. */ | /* Check for unsupported features. */ | ||||
| PBVHType type = BKE_pbvh_type(ss->pbvh); | PBVHType type = BKE_pbvh_type(ss->pbvh); | ||||
| if (brush->sculpt_tool == SCULPT_TOOL_PAINT && type != PBVH_FACES) { | if (brush->sculpt_tool == SCULPT_TOOL_PAINT && type != PBVH_FACES) { | ||||
| if (!U.experimental.use_sculpt_vertex_colors) { | |||||
| return; | return; | ||||
| } | } | ||||
| } | |||||
| if (brush->sculpt_tool == SCULPT_TOOL_SMEAR && type != PBVH_FACES) { | if (brush->sculpt_tool == SCULPT_TOOL_SMEAR && type != PBVH_FACES) { | ||||
| if (!U.experimental.use_sculpt_vertex_colors) { | |||||
| return; | return; | ||||
| } | } | ||||
| } | |||||
| /* Build a list of all nodes that are potentially within the brush's area of influence */ | /* Build a list of all nodes that are potentially within the brush's area of influence */ | ||||
| /* These brushes need to update all nodes as they are not constrained by the brush radius */ | /* These brushes need to update all nodes as they are not constrained by the brush radius */ | ||||
| /* Elastic deform needs all nodes to avoid artifacts as the effect of the brush is not | /* Elastic deform needs all nodes to avoid artifacts as the effect of the brush is not | ||||
| * constrained by the radius. */ | * constrained by the radius. */ | ||||
| /* Pose needs all nodes because it applies all symmetry iterations at the same time and the IK | /* Pose needs all nodes because it applies all symmetry iterations at the same time and the IK | ||||
| * chain can grow to any area of the model. */ | * chain can grow to any area of the model. */ | ||||
| ▲ Show 20 Lines • Show All 637 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| bool SCULPT_mode_poll(bContext *C) | bool SCULPT_mode_poll(bContext *C) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| return ob && ob->mode & OB_MODE_SCULPT; | return ob && ob->mode & OB_MODE_SCULPT; | ||||
| } | } | ||||
| bool SCULPT_vertex_colors_poll(bContext *C) | |||||
| { | |||||
| if (!U.experimental.use_sculpt_vertex_colors) { | |||||
| return false; | |||||
| } | |||||
| return SCULPT_mode_poll(C); | |||||
| } | |||||
| bool SCULPT_mode_poll_view3d(bContext *C) | bool SCULPT_mode_poll_view3d(bContext *C) | ||||
| { | { | ||||
| return (SCULPT_mode_poll(C) && CTX_wm_region_view3d(C)); | return (SCULPT_mode_poll(C) && CTX_wm_region_view3d(C)); | ||||
| } | } | ||||
| bool SCULPT_poll_view3d(bContext *C) | bool SCULPT_poll_view3d(bContext *C) | ||||
| { | { | ||||
| return (SCULPT_poll(C) && CTX_wm_region_view3d(C)); | return (SCULPT_poll(C) && CTX_wm_region_view3d(C)); | ||||
| ▲ Show 20 Lines • Show All 2,034 Lines • ▼ Show 20 Lines | |||||
| static void SCULPT_OT_vertex_to_loop_colors(wmOperatorType *ot) | static void SCULPT_OT_vertex_to_loop_colors(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Sculpt Vertex Color to Vertex Color"; | ot->name = "Sculpt Vertex Color to Vertex Color"; | ||||
| ot->description = "Copy the Sculpt Vertex Color to a regular color layer"; | ot->description = "Copy the Sculpt Vertex Color to a regular color layer"; | ||||
| ot->idname = "SCULPT_OT_vertex_to_loop_colors"; | ot->idname = "SCULPT_OT_vertex_to_loop_colors"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->poll = SCULPT_mode_poll; | ot->poll = SCULPT_vertex_colors_poll; | ||||
| ot->exec = vertex_to_loop_colors_exec; | ot->exec = vertex_to_loop_colors_exec; | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| static int loop_to_vertex_colors_exec(bContext *C, wmOperator *UNUSED(op)) | static int loop_to_vertex_colors_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| static void SCULPT_OT_loop_to_vertex_colors(wmOperatorType *ot) | static void SCULPT_OT_loop_to_vertex_colors(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Vertex Color to Sculpt Vertex Color"; | ot->name = "Vertex Color to Sculpt Vertex Color"; | ||||
| ot->description = "Copy the active loop color layer to the vertex color"; | ot->description = "Copy the active loop color layer to the vertex color"; | ||||
| ot->idname = "SCULPT_OT_loop_to_vertex_colors"; | ot->idname = "SCULPT_OT_loop_to_vertex_colors"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->poll = SCULPT_mode_poll; | ot->poll = SCULPT_vertex_colors_poll; | ||||
| ot->exec = loop_to_vertex_colors_exec; | ot->exec = loop_to_vertex_colors_exec; | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| static int sculpt_sample_color_invoke(bContext *C, | static int sculpt_sample_color_invoke(bContext *C, | ||||
| wmOperator *UNUSED(op), | wmOperator *UNUSED(op), | ||||
| const wmEvent *UNUSED(e)) | const wmEvent *UNUSED(e)) | ||||
| Show All 24 Lines | |||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Sample color"; | ot->name = "Sample color"; | ||||
| ot->idname = "SCULPT_OT_sample_color"; | ot->idname = "SCULPT_OT_sample_color"; | ||||
| ot->description = "Sample the vertex color of the active vertex"; | ot->description = "Sample the vertex color of the active vertex"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->invoke = sculpt_sample_color_invoke; | ot->invoke = sculpt_sample_color_invoke; | ||||
| ot->poll = SCULPT_mode_poll; | ot->poll = SCULPT_vertex_colors_poll; | ||||
| ot->flag = OPTYPE_REGISTER; | ot->flag = OPTYPE_REGISTER; | ||||
| } | } | ||||
| /* Fake Neighbors. */ | /* Fake Neighbors. */ | ||||
| /* This allows the sculpt tools to work on meshes with multiple connected components as they had | /* This allows the sculpt tools to work on meshes with multiple connected components as they had | ||||
| * only one connected component. When initialized and enabled, the sculpt API will return extra | * only one connected component. When initialized and enabled, the sculpt API will return extra | ||||
| * connectivity neighbors that are not in the real mesh. These neighbors are calculated for each | * connectivity neighbors that are not in the real mesh. These neighbors are calculated for each | ||||
| ▲ Show 20 Lines • Show All 509 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ot->name = "Mask By Color"; | ot->name = "Mask By Color"; | ||||
| ot->idname = "SCULPT_OT_mask_by_color"; | ot->idname = "SCULPT_OT_mask_by_color"; | ||||
| ot->description = "Creates a mask based on the sculpt vertex colors"; | ot->description = "Creates a mask based on the sculpt vertex colors"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->invoke = sculpt_mask_by_color_invoke; | ot->invoke = sculpt_mask_by_color_invoke; | ||||
| ot->poll = SCULPT_mode_poll; | ot->poll = SCULPT_vertex_colors_poll; | ||||
| ot->flag = OPTYPE_REGISTER; | ot->flag = OPTYPE_REGISTER; | ||||
| ot->prop = RNA_def_boolean( | ot->prop = RNA_def_boolean( | ||||
| ot->srna, "contiguous", false, "Contiguous", "Mask only contiguos color areas"); | ot->srna, "contiguous", false, "Contiguous", "Mask only contiguos color areas"); | ||||
| ot->prop = RNA_def_boolean(ot->srna, "invert", false, "Invert", "Invert the generated mask"); | ot->prop = RNA_def_boolean(ot->srna, "invert", false, "Invert", "Invert the generated mask"); | ||||
| ot->prop = RNA_def_boolean( | ot->prop = RNA_def_boolean( | ||||
| Show All 31 Lines | void ED_operatortypes_sculpt(void) | ||||
| WM_operatortype_append(SCULPT_OT_mask_expand); | WM_operatortype_append(SCULPT_OT_mask_expand); | ||||
| WM_operatortype_append(SCULPT_OT_set_pivot_position); | WM_operatortype_append(SCULPT_OT_set_pivot_position); | ||||
| WM_operatortype_append(SCULPT_OT_face_sets_create); | WM_operatortype_append(SCULPT_OT_face_sets_create); | ||||
| WM_operatortype_append(SCULPT_OT_face_sets_change_visibility); | WM_operatortype_append(SCULPT_OT_face_sets_change_visibility); | ||||
| WM_operatortype_append(SCULPT_OT_face_sets_randomize_colors); | WM_operatortype_append(SCULPT_OT_face_sets_randomize_colors); | ||||
| WM_operatortype_append(SCULPT_OT_face_sets_init); | WM_operatortype_append(SCULPT_OT_face_sets_init); | ||||
| WM_operatortype_append(SCULPT_OT_cloth_filter); | WM_operatortype_append(SCULPT_OT_cloth_filter); | ||||
| WM_operatortype_append(SCULPT_OT_face_sets_edit); | WM_operatortype_append(SCULPT_OT_face_sets_edit); | ||||
| WM_operatortype_append(SCULPT_OT_sample_color); | WM_operatortype_append(SCULPT_OT_sample_color); | ||||
| WM_operatortype_append(SCULPT_OT_loop_to_vertex_colors); | WM_operatortype_append(SCULPT_OT_loop_to_vertex_colors); | ||||
| WM_operatortype_append(SCULPT_OT_vertex_to_loop_colors); | WM_operatortype_append(SCULPT_OT_vertex_to_loop_colors); | ||||
| WM_operatortype_append(SCULPT_OT_color_filter); | WM_operatortype_append(SCULPT_OT_color_filter); | ||||
| WM_operatortype_append(SCULPT_OT_mask_by_color); | WM_operatortype_append(SCULPT_OT_mask_by_color); | ||||
| } | } | ||||