85 float bb_min[3], bb_max[3],
center[3], dim[3];
95 for (
int i = 0; i < totnodes; i++) {
114 for (
int i = 0; i < totnodes; i++) {
133 ot->
name =
"Detail Flood Fill";
134 ot->
idname =
"SCULPT_OT_detail_flood_fill";
135 ot->
description =
"Flood fill the mesh with the selected detail setting";
172 const float mval_fl[2] = {
UNPACK2(mval)};
179 float edge_length = 0.0f;
212 const float mval_fl[2] = {
UNPACK2(mval)};
213 float ray_start[3], ray_end[3], ray_normal[3];
237 if (region ==
NULL) {
261 const int mval[2] = {
311 switch (event->
type) {
340 ot->
name =
"Sample Detail Size";
341 ot->
idname =
"SCULPT_OT_sample_detail_size";
359 "Screen coordinates of sampling",
367 "Target sculpting workflow that is going to use the sampled size");
384 char *path =
BLI_sprintfN(
"tool_settings.sculpt.brush.%s", prop);
401 &props_ptr,
"data_path_primary",
"tool_settings.sculpt.constant_detail_resolution");
405 RNA_string_set(&props_ptr,
"data_path_primary",
"tool_settings.sculpt.detail_percent");
409 RNA_string_set(&props_ptr,
"data_path_primary",
"tool_settings.sculpt.detail_size");
427 ot->
name =
"Set Detail Size";
428 ot->
idname =
"SCULPT_OT_set_detail_size";
430 "Set the mesh detail (either relative or constant one, depending on current dyntopo mode)";
446 #define DETAIL_SIZE_DELTA_SPEED 0.08f
447 #define DETAIL_SIZE_DELTA_ACCURATE_SPEED 0.004f
472 const float start_co[3],
473 const float end_co[3],
477 float object_space_constant_detail = 1.0f /
485 object_space_constant_detail *= 0.7f;
488 const int tot_lines = (int)(total_len / object_space_constant_detail) + 1;
489 const float tot_lines_fl = total_len / object_space_constant_detail;
490 float spacing_disp[3];
496 mul_v3_fl(spacing_disp, total_len / tot_lines_fl);
499 for (
int i = 0; i < tot_lines; i++) {
502 line_length = total_len * ((
float)i / (
float)tot_lines_fl);
505 line_length = total_len * (1.0f - ((
float)i / (
float)tot_lines_fl));
584 int num_neighbors = 0;
593 if (num_neighbors > 0) {
594 const float avg_edge_len = len_accum / num_neighbors;
604 const float mval[2] = {
event->mval[0],
event->mval[1]};
606 float detail_size_delta;
613 detail_size_delta = mval[0] - cd->
init_mval[0];
699 "Dyntopo Detail Size Edit OP Custom Data");
717 float cursor_trans[4][4], cursor_rot[4][4];
718 const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f};
724 float cursor_normal[3];
738 const float y_axis[3] = {0.0f, cd->
radius, 0.0f};
739 for (
int i = 0; i < 3; i++) {
751 const char *status_str =
TIP_(
752 "Move the mouse to change the dyntopo detail size. LMB: confirm size, ESC/RMB: cancel");
761 ot->
name =
"Edit Dyntopo Detail Size";
762 ot->
description =
"Modify the detail size of dyntopo interactively";
763 ot->
idname =
"SCULPT_OT_dyntopo_detail_size_edit";
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
void CTX_wm_region_set(bContext *C, struct ARegion *region)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
struct bScreen * CTX_wm_screen(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
void CTX_wm_area_set(bContext *C, struct ScrArea *area)
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
void BKE_sculpt_update_object_for_edit(struct Depsgraph *depsgraph, struct Object *ob_orig, bool need_pmap, bool need_mask, bool is_paint_tool)
struct Brush * BKE_paint_brush(struct Paint *paint)
A BVH for high poly meshes.
PBVHType BKE_pbvh_type(const PBVH *pbvh)
float BKE_pbvh_node_get_tmin(PBVHNode *node)
bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh, PBVHTopologyUpdateMode mode, const float center[3], const float view_normal[3], float radius, bool use_frontface, bool use_projected)
void BKE_pbvh_raycast(PBVH *pbvh, BKE_pbvh_HitOccludedCallback cb, void *data, const float ray_start[3], const float ray_normal[3], bool original)
bool BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node, const float ray_start[3], struct IsectRayPrecalc *isect_precalc, float *depth, float *r_edge_length)
void BKE_pbvh_bounding_box(const PBVH *pbvh, float min[3], float max[3])
void BKE_pbvh_bmesh_detail_size_set(PBVH *pbvh, float detail_size)
void BKE_pbvh_node_mark_topology_update(PBVHNode *node)
void BKE_pbvh_search_gather(PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data, PBVHNode ***array, int *tot)
struct ScrArea struct ScrArea * BKE_screen_find_area_xy(struct bScreen *screen, int spacetype, const int xy[2]) ATTR_NONNULL(1
struct ARegion * BKE_area_find_region_xy(struct ScrArea *area, int regiontype, const int xy[2]) ATTR_NONNULL(3)
MINLINE float max_fff(float a, float b, float c)
MINLINE float clamp_f(float value, float min, float max)
void isect_ray_tri_watertight_v3_precalc(struct IsectRayPrecalc *isect_precalc, const float ray_direction[3])
void translate_m4(float mat[4][4], float tx, float ty, float tz)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
float mat4_to_scale(const float M[4][4])
void mul_m4_m4_post(float R[4][4], const float B[4][4])
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3])
void quat_to_mat4(float mat[4][4], const float q[4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE bool is_zero_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
void rotate_v2_v2fl(float r[2], const float p[2], float angle)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void zero_v3(float r[3])
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
struct Depsgraph Depsgraph
@ SCULPT_DYNTOPO_DETAIL_MANUAL
@ SCULPT_DYNTOPO_DETAIL_CONSTANT
@ SCULPT_DYNTOPO_DETAIL_BRUSH
void ED_region_tag_redraw(struct ARegion *region)
void ED_workspace_status_text(struct bContext *C, const char *str)
#define REGION_DRAW_POST_VIEW
void * ED_region_draw_cb_activate(struct ARegionType *art, void(*draw)(const struct bContext *, struct ARegion *, void *), void *customdata, int type)
bool ED_region_draw_cb_exit(struct ARegionType *art, void *handle)
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
NSNotificationCenter * center
void GPU_matrix_pop(void)
#define GPU_matrix_mul(x)
void GPU_matrix_push(void)
@ GPU_SHADER_3D_UNIFORM_COLOR
void GPU_blend(eGPUBlend blend)
void GPU_line_width(float width)
void GPU_line_smooth(bool enable)
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
const Depsgraph * depsgraph
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
static void area(int d1, int d2, int e1, int e2, float weights[2])
void RNA_int_set_array(PointerRNA *ptr, const char *name, const int *values)
void RNA_int_get_array(PointerRNA *ptr, const char *name, int *values)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, int len, const int *default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
const float * SCULPT_vertex_co_get(SculptSession *ss, int index)
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)
const float * SCULPT_active_vertex_co_get(SculptSession *ss)
void SCULPT_vertex_random_access_ensure(SculptSession *ss)
void SCULPT_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush)
float SCULPT_raycast_init(ViewContext *vc, const float mval[2], float ray_start[3], float ray_end[3], float ray_normal[3], bool original)
bool SCULPT_mode_poll(bContext *C)
static int sculpt_sample_detail_size_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e))
void SCULPT_OT_sample_detail_size(wmOperatorType *ot)
static void sculpt_raycast_detail_cb(PBVHNode *node, void *data_v, float *tmin)
static bool sculpt_and_constant_or_manual_detail_poll(bContext *C)
static void dyntopo_detail_size_edit_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar), void *arg)
static int dyntopo_detail_size_edit_modal(bContext *C, wmOperator *op, const wmEvent *event)
void SCULPT_OT_detail_flood_fill(wmOperatorType *ot)
static int sculpt_sample_detail_size_exec(bContext *C, wmOperator *op)
static void dyntopo_detail_size_parallel_lines_draw(uint pos3d, DyntopoDetailSizeEditCustomData *cd, const float start_co[3], const float end_co[3], bool flip, const float angle)
void SCULPT_OT_set_detail_size(wmOperatorType *ot)
static void dyntopo_detail_size_sample_from_surface(Object *ob, DyntopoDetailSizeEditCustomData *cd)
static int sculpt_sample_detail_size_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int sample_detail(bContext *C, const int event_xy[2], int mode)
static void dyntopo_detail_size_update_from_mouse_delta(DyntopoDetailSizeEditCustomData *cd, const wmEvent *event)
static bool sculpt_and_dynamic_topology_poll(bContext *C)
static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
#define DETAIL_SIZE_DELTA_ACCURATE_SPEED
static void dyntopo_detail_size_edit_cancel(bContext *C, wmOperator *op)
static void sculpt_detail_size_set_radial_control(bContext *C)
struct DyntopoDetailSizeEditCustomData DyntopoDetailSizeEditCustomData
static EnumPropertyItem prop_sculpt_sample_detail_mode_types[]
void SCULPT_OT_dyntopo_detail_size_edit(wmOperatorType *ot)
static void sample_detail_dyntopo(bContext *C, ViewContext *vc, const int mval[2])
eSculptSampleDetailModeTypes
static void sample_detail_voxel(bContext *C, ViewContext *vc, const int mval[2])
#define DETAIL_SIZE_DELTA_SPEED
static int sculpt_set_detail_size_exec(bContext *C, wmOperator *UNUSED(op))
static void set_brush_rc_props(PointerRNA *ptr, const char *prop)
static int dyntopo_detail_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void SCULPT_pbvh_clear(Object *ob)
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)
#define SCULPT_VERTEX_NEIGHBORS_ITER_END(neighbor_iterator)
SculptUndoNode * SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type)
struct ARegionType * type
float accurate_detail_size
struct SculptSession * sculpt
struct IsectRayPrecalc isect_precalc
float cursor_sampled_normal[3]
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
void(* cancel)(struct bContext *, struct wmOperator *)
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
void WM_cursor_modal_set(wmWindow *win, int val)
void WM_cursor_modal_restore(wmWindow *win)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_main_add_notifier(unsigned int type, void *reference)
int WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
void WM_operator_properties_free(PointerRNA *ptr)