diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_intern.h')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_intern.h | 220 |
1 files changed, 196 insertions, 24 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index fe56283dbcb..e2fd54596e7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -24,6 +24,7 @@ #ifndef __SCULPT_INTERN_H__ #define __SCULPT_INTERN_H__ +#include "DNA_brush_types.h" #include "DNA_key_types.h" #include "DNA_listBase.h" #include "DNA_vec_types.h" @@ -57,6 +58,10 @@ typedef enum SculptUpdateType { SCULPT_UPDATE_VISIBILITY = 1 << 2, } SculptUpdateType; +void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags); +void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags); +void SCULPT_flush_stroke_deform(struct Sculpt *sd, Object *ob, bool is_proxy_used); + /* Stroke */ typedef struct SculptCursorGeometryInfo { @@ -72,11 +77,20 @@ bool SCULPT_cursor_geometry_info_update(bContext *C, bool use_sampled_normal); void SCULPT_geometry_preview_lines_update(bContext *C, struct SculptSession *ss, float radius); +void SCULPT_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush); +float SCULPT_raycast_init(struct ViewContext *vc, + const float mouse[2], + float ray_start[3], + float ray_end[3], + float ray_normal[3], + bool original); + /* Sculpt PBVH abstraction API */ void SCULPT_vertex_random_access_init(struct SculptSession *ss); int SCULPT_vertex_count_get(struct SculptSession *ss); const float *SCULPT_vertex_co_get(struct SculptSession *ss, int index); +void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3]); float SCULPT_vertex_mask_get(struct SculptSession *ss, int index); #define SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY 256 @@ -127,6 +141,35 @@ void SCULPT_vertex_neighbors_get(struct SculptSession *ss, int SCULPT_active_vertex_get(SculptSession *ss); const float *SCULPT_active_vertex_co_get(SculptSession *ss); +void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]); + +bool SCULPT_vertex_is_boundary(SculptSession *ss, const int index); + +/* Sculpt Visibility API */ + +void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible); +bool SCULPT_vertex_visible_get(SculptSession *ss, int index); + +void SCULPT_visibility_sync_all_face_sets_to_vertices(struct SculptSession *ss); +void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss); + +/* Face Sets API */ + +int SCULPT_active_face_set_get(SculptSession *ss); +int SCULPT_vertex_face_set_get(SculptSession *ss, int index); +void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_set); + +bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set); +bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index); + +int SCULPT_face_set_next_available_get(SculptSession *ss); + +void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool visible); +bool SCULPT_vertex_all_face_sets_visible_get(SculptSession *ss, int index); +bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, int index); + +void SCULPT_face_sets_visibility_invert(SculptSession *ss); +void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible); /* Sculpt Original Data */ typedef struct { @@ -146,16 +189,6 @@ typedef struct { void SCULPT_orig_vert_data_init(SculptOrigVertData *data, Object *ob, PBVHNode *node); void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, PBVHVertexIter *iter); -/* Face Sets */ -int SCULPT_vertex_face_set_get(SculptSession *ss, int index); -bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set); -bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index); - -/* Dynamic topology */ -void sculpt_pbvh_clear(Object *ob); -void sculpt_dyntopo_node_layers_add(struct SculptSession *ss); -void sculpt_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode); - /* Utils. */ void SCULPT_calc_brush_plane(struct Sculpt *sd, struct Object *ob, @@ -177,11 +210,16 @@ int SCULPT_plane_point_side(const float co[3], const float plane[4]); int SCULPT_plane_trim(const struct StrokeCache *cache, const struct Brush *brush, const float val[3]); +void SCULPT_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3]); float SCULPT_brush_plane_offset_get(Sculpt *sd, SculptSession *ss); ePaintSymmetryAreas SCULPT_get_vertex_symm_area(const float co[3]); bool SCULPT_check_vertex_pivot_symmetry(const float vco[3], const float pco[3], const char symm); +bool SCULPT_is_vertex_inside_brush_radius_symm(const float vertex[3], + const float br_co[3], + float radius, + char symm); bool SCULPT_is_symmetry_iteration_valid(char i, char symm); void SCULPT_flip_v3_by_symm_area(float v[3], const ePaintSymmetryFlags symm, @@ -210,7 +248,7 @@ void SCULPT_floodfill_add_initial_with_symmetry(struct Sculpt *sd, SculptFloodFill *flood, int index, float radius); -void sculpt_floodfill_add_initial(SculptFloodFill *flood, int index); +void SCULPT_floodfill_add_initial(SculptFloodFill *flood, int index); void SCULPT_floodfill_execute( struct SculptSession *ss, SculptFloodFill *flood, @@ -218,9 +256,61 @@ void SCULPT_floodfill_execute( void *userdata); void SCULPT_floodfill_free(SculptFloodFill *flood); +/* Dynamic topology */ + +enum eDynTopoWarnFlag { + DYNTOPO_WARN_VDATA = (1 << 0), + DYNTOPO_WARN_EDATA = (1 << 1), + DYNTOPO_WARN_LDATA = (1 << 2), + DYNTOPO_WARN_MODIFIER = (1 << 3), +}; + +void SCULPT_dynamic_topology_enable_ex(struct Main *bmain, + struct Depsgraph *depsgraph, + Scene *scene, + Object *ob); +void SCULPT_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode); +void sculpt_dynamic_topology_disable_with_undo(struct Main *bmain, + struct Depsgraph *depsgraph, + Scene *scene, + Object *ob); + +bool SCULPT_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *brush); + +void SCULPT_dynamic_topology_triangulate(struct BMesh *bm); +void SCULPT_dyntopo_node_layers_add(struct SculptSession *ss); + +enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene *scene, Object *ob); + +void SCULPT_pbvh_clear(Object *ob); + /* Automasking. */ float SCULPT_automasking_factor_get(SculptSession *ss, int vert); +void SCULPT_automasking_init(Sculpt *sd, Object *ob); +void SCULPT_automasking_end(Object *ob); + +bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd, + const Brush *br, + const eAutomasking_flag mode); +bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br); + +typedef enum eBoundaryAutomaskMode { + AUTOMASK_INIT_BOUNDARY_EDGES = 1, + AUTOMASK_INIT_BOUNDARY_FACE_SETS = 2, +} eBoundaryAutomaskMode; +float *SCULPT_boundary_automasking_init(Object *ob, + eBoundaryAutomaskMode mode, + int propagation_steps, + float *automask_factor); + +/* Filters. */ +void SCULPT_filter_cache_init(Object *ob, Sculpt *sd); +void SCULPT_filter_cache_free(SculptSession *ss); + +void SCULPT_mask_filter_smooth_apply( + Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, const int smooth_iterations); + /* Brushes. */ /* Cloth Brush. */ @@ -274,6 +364,43 @@ void SCULPT_multiplane_scrape_preview_draw(const uint gpuattr, SculptSession *ss, const float outline_col[3], const float outline_alpha); +/* Draw Face Sets Brush. */ +void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode); + +/* Smooth Brush. */ + +void SCULPT_neighbor_average(SculptSession *ss, float avg[3], uint vert); +void SCULPT_bmesh_neighbor_average(float avg[3], struct BMVert *v); + +void SCULPT_bmesh_four_neighbor_average(float avg[3], float direction[3], struct BMVert *v); + +void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], int index); +float SCULPT_neighbor_mask_average(SculptSession *ss, int index); + +void SCULPT_smooth(Sculpt *sd, + Object *ob, + PBVHNode **nodes, + const int totnode, + float bstrength, + const bool smooth_mask); +void SCULPT_do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode); + +/* Surface Smooth Brush. */ + +void SCULPT_surface_smooth_laplacian_step(SculptSession *ss, + float *disp, + const float co[3], + float (*laplacian_disp)[3], + const int v_index, + const float origco[3], + const float alpha); +void SCULPT_surface_smooth_displace_step(SculptSession *ss, + float *co, + float (*laplacian_disp)[3], + const int v_index, + const float beta, + const float fade); +void SCULPT_do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode); /* Slide/Relax */ void SCULPT_relax_vertex(struct SculptSession *ss, @@ -282,10 +409,6 @@ void SCULPT_relax_vertex(struct SculptSession *ss, bool filter_boundary_face_sets, float *r_final_pos); -/* Sculpt Visibility API */ -void SCULPT_visibility_sync_all_face_sets_to_vertices(struct SculptSession *ss); -void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss); - /* Undo */ typedef enum { @@ -299,6 +422,23 @@ typedef enum { SCULPT_UNDO_FACE_SETS, } SculptUndoType; +/* Storage of geometry for the undo node. + * Is used as a storage for either original or modified geometry. */ +typedef struct SculptUndoNodeGeometry { + /* Is used for sanity check, helping with ensuring that two and only two + * geometry pushes happened in the undo stack. */ + bool is_initialized; + + CustomData vdata; + CustomData edata; + CustomData ldata; + CustomData pdata; + int totvert; + int totedge; + int totloop; + int totpoly; +} SculptUndoNodeGeometry; + typedef struct SculptUndoNode { struct SculptUndoNode *next, *prev; @@ -332,15 +472,17 @@ typedef struct SculptUndoNode { /* shape keys */ char shapeName[sizeof(((KeyBlock *)0))->name]; - /* geometry modification operations and bmesh enter data */ - CustomData geom_vdata; - CustomData geom_edata; - CustomData geom_ldata; - CustomData geom_pdata; - int geom_totvert; - int geom_totedge; - int geom_totloop; - int geom_totpoly; + /* Geometry modification operations. + * + * Original geometry is stored before some modification is run and is used to restore state of + * the object when undoing the operation + * + * Modified geometry is stored after the modification and is used to redo the modification. */ + SculptUndoNodeGeometry geometry_original; + SculptUndoNodeGeometry geometry_modified; + + /* Geometry at the bmesh enter moment. */ + SculptUndoNodeGeometry geometry_bmesh_enter; /* pivot */ float pivot_pos[3]; @@ -707,6 +849,7 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType SculptUndoNode *SCULPT_undo_get_node(PBVHNode *node); void SCULPT_undo_push_begin(const char *name); void SCULPT_undo_push_end(void); +void SCULPT_undo_push_end_ex(const bool use_nested_undo); void SCULPT_vertcos_to_key(Object *ob, KeyBlock *kb, const float (*vertCos)[3]); @@ -717,4 +860,33 @@ bool SCULPT_get_redraw_rect(struct ARegion *region, Object *ob, rcti *rect); +/* Operators. */ + +/* Face Sets. */ +void SCULPT_OT_face_sets_randomize_colors(struct wmOperatorType *ot); +void SCULPT_OT_face_sets_change_visibility(struct wmOperatorType *ot); +void SCULPT_OT_face_sets_init(struct wmOperatorType *ot); +void SCULPT_OT_face_sets_create(struct wmOperatorType *ot); + +/* Transform. */ +void SCULPT_OT_set_pivot_position(struct wmOperatorType *ot); + +/* Mesh Filter. */ +void SCULPT_OT_mesh_filter(struct wmOperatorType *ot); + +/* Mask filter and Dirty Mask. */ +void SCULPT_OT_mask_filter(struct wmOperatorType *ot); +void SCULPT_OT_dirty_mask(struct wmOperatorType *ot); + +/* Mask and Face Sets Expand. */ +void SCULPT_OT_mask_expand(struct wmOperatorType *ot); + +/* Detail size. */ +void SCULPT_OT_detail_flood_fill(struct wmOperatorType *ot); +void SCULPT_OT_sample_detail_size(struct wmOperatorType *ot); +void SCULPT_OT_set_detail_size(struct wmOperatorType *ot); + +/* Dyntopo. */ +void SCULPT_OT_dynamic_topology_toggle(struct wmOperatorType *ot); + #endif |