129 "layer persistent base");
131 for (
int i = 0; i < totvert; i++) {
143 ot->
name =
"Set Persistent Base";
144 ot->
idname =
"SCULPT_OT_set_persistent_base";
145 ot->
description =
"Reset the copy of the mesh that is being sculpted on";
175 ot->
description =
"Recalculate the sculpt BVH to improve performance";
225 "symmetrize input=%avef direction=%i dist=%f use_shapekey=%b",
268 ot->
idname =
"SCULPT_OT_symmetrize";
281 "Distance within which symmetrical vertices are merged",
319 for (
int i = 0; i < ss->
totfaces; i++) {
330 const bool force_dyntopo,
337 ob->
mode |= mode_flag;
344 reports,
RPT_WARNING,
"Object has non-uniform scale, sculpting may be unpredictable");
360 const char *message_unsupported =
NULL;
362 message_unsupported =
TIP_(
"non-triangle face");
364 else if (mmd !=
NULL) {
365 message_unsupported =
TIP_(
"multi-res modifier");
373 message_unsupported =
TIP_(
"vertex data");
376 message_unsupported =
TIP_(
"edge data");
379 message_unsupported =
TIP_(
"face data");
382 message_unsupported =
TIP_(
"constructive modifier");
389 if ((message_unsupported ==
NULL) || force_dyntopo) {
405 reports,
RPT_WARNING,
"Dynamic Topology found: %s, disabled", message_unsupported);
433 const int flush_recalc = ed_object_sculptmode_flush_recalc_flag(
scene, ob, mmd);
453 ob->
mode &= ~mode_flag;
485 const bool is_mode_set = (ob->
mode & mode_flag) != 0;
503 if (ob->
mode & mode_flag) {
531 ot->
idname =
"SCULPT_OT_sculptmode_toggle";
589 if (totpoints + (ni.
size * 2) < max_preview_vertices) {
632 if (mloopcol_layer_n == -1) {
638 if (MPropCol_layer_n == -1) {
647 const MPoly *c_poly = &polys[i];
648 for (
int j = 0; j < c_poly->
totloop; j++) {
653 loopcols[loop_index].
r = (char)(srgb_color[0] * 255);
654 loopcols[loop_index].
g = (char)(srgb_color[1] * 255);
655 loopcols[loop_index].
b = (char)(srgb_color[2] * 255);
656 loopcols[loop_index].
a = (char)(srgb_color[3] * 255);
684 ot->
name =
"Sculpt Vertex Color to Vertex Color";
685 ot->
description =
"Copy the Sculpt Vertex Color to a regular color layer";
686 ot->
idname =
"SCULPT_OT_vertex_to_loop_colors";
712 if (mloopcol_layer_n == -1) {
719 if (MPropCol_layer_n == -1) {
728 const MPoly *c_poly = &polys[i];
729 for (
int j = 0; j < c_poly->
totloop; j++) {
732 vertcols[c_loop->
v].
color[0] = (loopcols[loop_index].
r / 255.0f);
733 vertcols[c_loop->
v].
color[1] = (loopcols[loop_index].
g / 255.0f);
734 vertcols[c_loop->
v].
color[2] = (loopcols[loop_index].
b / 255.0f);
735 vertcols[c_loop->
v].
color[3] = (loopcols[loop_index].
a / 255.0f);
749 ot->
name =
"Vertex Color to Sculpt Vertex Color";
750 ot->
description =
"Copy the active loop color layer to the vertex color";
751 ot->
idname =
"SCULPT_OT_loop_to_vertex_colors";
768 float active_vertex_color[4];
796 ot->
name =
"Sample Color";
797 ot->
idname =
"SCULPT_OT_sample_color";
798 ot->
description =
"Sample the vertex color of the active vertex";
816 #define MASK_BY_COLOR_SLOPE 0.25f
819 const float *color_b,
844 const float new_mask,
846 const bool preserve_mask)
850 return min_ff(current_mask, new_mask);
852 return max_ff(current_mask, new_mask);
871 bool update_node =
false;
873 const bool invert =
data->mask_by_color_invert;
874 const bool preserve_mask =
data->mask_by_color_preserve_mask;
878 const float current_mask = *vd.
mask;
879 const float new_mask =
data->mask_by_color_floodfill[vd.
index];
881 if (current_mask == *vd.
mask) {
893 SculptSession *ss,
int from_v,
int to_v,
bool is_duplicate,
void *userdata)
896 float current_color[4];
901 current_color,
data->initial_color,
data->threshold,
data->invert);
902 data->new_mask[to_v] = new_vertex_mask;
905 data->new_mask[to_v] =
data->new_mask[from_v];
917 const bool preserve_mask)
925 for (
int i = 0; i < totvert; i++) {
954 .mask_by_color_floodfill = new_mask,
955 .mask_by_color_vertex = vertex,
957 .mask_by_color_invert =
invert,
958 .mask_by_color_preserve_mask = preserve_mask,
979 bool update_node =
false;
982 const bool invert =
data->mask_by_color_invert;
983 const bool preserve_mask =
data->mask_by_color_preserve_mask;
984 float active_color[4];
993 const float current_mask = *vd.
mask;
997 if (current_mask == *vd.
mask) {
1012 const bool preserve_mask)
1023 .mask_by_color_vertex = vertex,
1025 .mask_by_color_invert =
invert,
1026 .mask_by_color_preserve_mask = preserve_mask,
1092 ot->
name =
"Mask by Color";
1093 ot->
idname =
"SCULPT_OT_mask_by_color";
1094 ot->
description =
"Creates a mask based on the active color attribute";
1103 ot->
srna,
"contiguous",
false,
"Contiguous",
"Mask only contiguous color areas");
1108 "preserve_previous_mask",
1110 "Preserve Previous Mask",
1111 "Preserve the previous mask and add or subtract the new one generated by the colors");
1119 "How much changes in color affect the mask generation",
Generic geometry attributes built on CustomData.
void BKE_brush_color_set(struct Scene *scene, struct Brush *brush, const float color[3])
struct Scene * CTX_data_scene(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct ViewLayer * CTX_data_view_layer(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct Depsgraph * CTX_data_depsgraph_on_load(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
struct View3D * CTX_wm_view3d(const bContext *C)
struct wmMsgBus * CTX_wm_message_bus(const bContext *C)
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
int CustomData_get_active_layer(const struct CustomData *data, int type)
void * CustomData_get_layer_n(const struct CustomData *data, int type, int n)
void * CustomData_get_layer(const struct CustomData *data, int type)
struct Mesh * BKE_mesh_from_object(struct Object *ob)
void BKE_mesh_batch_cache_dirty_tag(struct Mesh *me, eMeshBatchDirtyMode mode)
void BKE_mesh_normals_tag_dirty(struct Mesh *mesh)
void BKE_mesh_mirror_apply_mirror_on_axis(struct Main *bmain, struct Mesh *mesh, int axis, float dist)
@ BKE_MESH_BATCH_DIRTY_ALL
void multires_flush_sculpt_updates(struct Object *object)
General operations, lookup, etc. for blender objects.
void BKE_object_free_derived_caches(struct Object *ob)
struct Paint * BKE_paint_get_active_from_paintmode(struct Scene *sce, ePaintMode mode)
void BKE_sculpt_toolsettings_data_ensure(struct Scene *scene)
struct MultiresModifierData * BKE_sculpt_multires_active(const struct Scene *scene, struct Object *ob)
void BKE_sculpt_update_object_for_edit(struct Depsgraph *depsgraph, struct Object *ob_orig, bool need_pmap, bool need_mask, bool is_paint_tool)
const char PAINT_CURSOR_SCULPT[3]
struct Brush * BKE_paint_brush(struct Paint *paint)
void BKE_paint_init(struct Main *bmain, struct Scene *sce, ePaintMode mode, const char col[3])
#define SCULPT_FACE_SET_NONE
void BKE_sculptsession_free(struct Object *ob)
void BKE_paint_toolslots_brush_validate(struct Main *bmain, struct Paint *paint)
void BKE_sculpt_color_layer_create_if_needed(struct Object *object)
void BKE_sculpt_ensure_orig_mesh_data(struct Scene *scene, struct Object *object)
A BVH for high poly meshes.
#define BKE_pbvh_vertex_iter_begin(pbvh, node, vi, mode)
PBVHType BKE_pbvh_type(const PBVH *pbvh)
#define BKE_pbvh_vertex_iter_end
void BKE_pbvh_ensure_node_loops(PBVH *pbvh)
void BKE_pbvh_parallel_range_settings(struct TaskParallelSettings *settings, bool use_threading, int totnode)
void BKE_pbvh_update_vertex_data(PBVH *pbvh, int flags)
void BKE_pbvh_node_mark_update_mask(PBVHNode *node)
void BKE_pbvh_search_gather(PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data, PBVHNode ***array, int *tot)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
void BKE_scene_graph_evaluated_ensure(struct Depsgraph *depsgraph, struct Main *bmain)
A (mainly) macro array library.
#define BLI_BITMAP_NEW(_num, _alloc_string)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
void BLI_gsqueue_free(GSQueue *queue)
GSQueue * BLI_gsqueue_new(size_t elem_size)
void BLI_gsqueue_push(GSQueue *queue, const void *item)
void BLI_gsqueue_pop(GSQueue *queue, void *r_item)
bool BLI_gsqueue_is_empty(const GSQueue *queue)
Single link-list utility macros. (header only api).
BLI_LINKSTACK_*** wrapper macros for using a LinkNode to store a stack of pointers,...
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4])
bool is_negative_m4(const float mat[4][4])
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v4_fl(float r[4], float f)
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
struct Depsgraph Depsgraph
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_COPY_ON_WRITE
#define ID_IS_LINKED(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
These structs are the foundation for all linked lists in the library system.
@ ME_SCULPT_DYNAMIC_TOPOLOGY
Object is a sort of wrapper for general info.
#define OBACT(_view_layer)
@ V3D_SHADING_VERTEX_COLOR
void ED_paint_cursor_start(struct Paint *p, bool(*poll)(struct bContext *C))
bool ED_object_mode_compat_set(struct bContext *C, struct Object *ob, eObjectMode mode, struct ReportList *reports)
bool ED_operator_object_active_editable_mesh(struct bContext *C)
void ED_sculpt_undo_geometry_begin(struct Object *ob, const char *name)
void ED_sculpt_undo_geometry_end(struct Object *ob)
BLI_INLINE void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3])
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
Platform independent time functions.
Provides wrapper around system-specific atomic primitives, and some extensions (faked-atomic operatio...
void BM_log_all_added(BMesh *bm, BMLog *log)
void BM_log_before_all_removed(BMesh *bm, BMLog *log)
void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
void BM_mesh_toolflags_set(BMesh *bm, bool use_toolflags)
bool BMO_op_callf(BMesh *bm, int flag, const char *fmt,...)
#define BMO_FLAG_DEFAULTS
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
const Depsgraph * depsgraph
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
ccl_gpu_kernel_postfix ccl_global float int int int int float threshold
void(* MEM_freeN)(void *vmemh)
void *(* MEM_calloc_arrayN)(size_t len, size_t size, const char *str)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
void paint_cursor_delete_textures(void)
void SCULPT_OT_trim_box_gesture(wmOperatorType *ot)
void SCULPT_OT_face_set_box_gesture(wmOperatorType *ot)
void SCULPT_OT_project_line_gesture(wmOperatorType *ot)
void SCULPT_OT_trim_lasso_gesture(wmOperatorType *ot)
void SCULPT_OT_face_set_lasso_gesture(wmOperatorType *ot)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
const float * SCULPT_vertex_co_get(SculptSession *ss, int index)
int SCULPT_vertex_count_get(SculptSession *ss)
void SCULPT_OT_brush_stroke(wmOperatorType *ot)
int SCULPT_active_vertex_get(SculptSession *ss)
bool SCULPT_cursor_geometry_info_update(bContext *C, SculptCursorGeometryInfo *out, const float mval[2], bool use_sampled_normal)
void SCULPT_floodfill_init(SculptSession *ss, SculptFloodFill *flood)
const float * SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, int index)
void SCULPT_floodfill_add_initial(SculptFloodFill *flood, int index)
const float * SCULPT_active_vertex_co_get(SculptSession *ss)
void SCULPT_vertex_random_access_ensure(SculptSession *ss)
void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags)
void SCULPT_vertex_color_get(const SculptSession *ss, int index, float r_color[4])
void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3])
bool SCULPT_mode_poll_view3d(bContext *C)
void SCULPT_floodfill_free(SculptFloodFill *flood)
bool SCULPT_mode_poll(bContext *C)
bool SCULPT_has_loop_colors(const Object *ob)
bool SCULPT_handles_colors_report(SculptSession *ss, ReportList *reports)
int SCULPT_face_set_next_available_get(SculptSession *ss)
void SCULPT_floodfill_execute(SculptSession *ss, SculptFloodFill *flood, bool(*func)(SculptSession *ss, int from_v, int to_v, bool is_duplicate, void *userdata), void *userdata)
bool SCULPT_has_colors(const SculptSession *ss)
void SCULPT_OT_cloth_filter(struct wmOperatorType *ot)
void SCULPT_OT_sample_detail_size(wmOperatorType *ot)
void SCULPT_OT_detail_flood_fill(wmOperatorType *ot)
void SCULPT_OT_set_detail_size(wmOperatorType *ot)
void SCULPT_OT_dyntopo_detail_size_edit(wmOperatorType *ot)
enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene *scene, Object *ob)
void SCULPT_pbvh_clear(Object *ob)
void SCULPT_OT_dynamic_topology_toggle(wmOperatorType *ot)
void sculpt_dynamic_topology_disable_with_undo(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
void SCULPT_dynamic_topology_enable_ex(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
void SCULPT_dynamic_topology_triangulate(BMesh *bm)
void SCULPT_OT_expand(wmOperatorType *ot)
void SCULPT_OT_face_sets_change_visibility(wmOperatorType *ot)
void SCULPT_OT_face_sets_init(wmOperatorType *ot)
void SCULPT_OT_face_sets_create(wmOperatorType *ot)
void SCULPT_OT_face_sets_edit(struct wmOperatorType *ot)
void SCULPT_OT_face_sets_randomize_colors(wmOperatorType *ot)
void SCULPT_OT_color_filter(struct wmOperatorType *ot)
void SCULPT_OT_mask_filter(struct wmOperatorType *ot)
void SCULPT_OT_dirty_mask(struct wmOperatorType *ot)
void SCULPT_OT_mesh_filter(struct wmOperatorType *ot)
void SCULPT_undo_push_begin(struct Object *ob, const char *name)
void SCULPT_undo_push_end(struct Object *ob)
#define SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN(ss, v_index, neighbor_iterator)
void SCULPT_OT_set_pivot_position(struct wmOperatorType *ot)
#define SCULPT_VERTEX_NEIGHBORS_ITER_END(neighbor_iterator)
SculptUndoNode * SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type)
void SCULPT_OT_mask_init(struct wmOperatorType *ot)
@ SCULPT_UNDO_DYNTOPO_SYMMETRIZE
@ SCULPT_UNDO_DYNTOPO_BEGIN
void SCULPT_OT_mask_expand(struct wmOperatorType *ot)
static bool sculpt_mask_by_color_contiguous_floodfill_cb(SculptSession *ss, int from_v, int to_v, bool is_duplicate, void *userdata)
static bool sculpt_no_multires_poll(bContext *C)
static bool sculpt_colors_poll(bContext *C)
static void SCULPT_OT_mask_by_color(wmOperatorType *ot)
static int sculpt_optimize_exec(bContext *C, wmOperator *UNUSED(op))
static void sculpt_mask_by_color_contiguous(Object *object, const int vertex, const float threshold, const bool invert, const bool preserve_mask)
static int sculpt_sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e))
static void SCULPT_OT_set_persistent_base(wmOperatorType *ot)
static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot)
static int sculpt_symmetrize_exec(bContext *C, wmOperator *op)
static void SCULPT_OT_loop_to_vertex_colors(wmOperatorType *ot)
static void SCULPT_OT_sample_color(wmOperatorType *ot)
void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float radius)
void ED_object_sculptmode_exit(bContext *C, Depsgraph *depsgraph)
static void sculpt_init_session(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
static void SCULPT_OT_optimize(wmOperatorType *ot)
static int sculpt_set_persistent_base_exec(bContext *C, wmOperator *UNUSED(op))
static void SCULPT_OT_vertex_to_loop_colors(wmOperatorType *ot)
void ED_object_sculptmode_exit_ex(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob)
static float sculpt_mask_by_color_delta_get(const float *color_a, const float *color_b, const float threshold, const bool invert)
static int vertex_to_loop_colors_exec(bContext *C, wmOperator *UNUSED(op))
static void sculpt_mask_by_color_full_mesh(Object *object, const int vertex, const float threshold, const bool invert, const bool preserve_mask)
static void do_mask_by_color_task_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
static void do_mask_by_color_contiguous_update_nodes_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
static int sculpt_mask_by_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
#define MASK_BY_COLOR_SLOPE
void ED_object_sculptmode_enter_ex(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, const bool force_dyntopo, ReportList *reports)
void ED_operatortypes_sculpt(void)
static int loop_to_vertex_colors_exec(bContext *C, wmOperator *UNUSED(op))
static void SCULPT_OT_symmetrize(wmOperatorType *ot)
void ED_object_sculptmode_enter(struct bContext *C, Depsgraph *depsgraph, ReportList *reports)
struct MaskByColorContiguousFloodFillData MaskByColorContiguousFloodFillData
static float sculpt_mask_by_color_final_mask_get(const float current_mask, const float new_mask, const bool invert, const bool preserve_mask)
struct SculptSession * sculpt
struct ToolSettings * toolsettings
int preview_vert_index_count
int * preview_vert_index_list
struct MeshElemMap * pmap
SculptPersistentBase * persistent_base
bool deform_modifiers_active
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
struct wmOperatorType * type
struct UndoStack * undo_stack
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))