1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 by Nicholas Bishop
17  * All rights reserved.
18  */
19 
20 #pragma once
21 
22 /** \file
23  * \ingroup bke
24  */
25 
26 #include "BLI_bitmap.h"
27 #include "BLI_utildefines.h"
28 #include "DNA_object_enums.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 struct BMFace;
35 struct BMesh;
36 struct Brush;
37 struct CurveMapping;
38 struct Depsgraph;
39 struct EdgeSet;
40 struct EnumPropertyItem;
41 struct GHash;
42 struct GridPaintMask;
43 struct ImagePool;
44 struct ListBase;
45 struct MLoop;
46 struct MLoopTri;
47 struct MVert;
48 struct Main;
49 struct Mesh;
50 struct MeshElemMap;
51 struct Object;
52 struct PBVH;
53 struct Paint;
54 struct PaintCurve;
55 struct Palette;
56 struct PaletteColor;
57 struct ReportList;
58 struct Scene;
59 struct StrokeCache;
60 struct SubdivCCG;
61 struct Tex;
62 struct ToolSettings;
63 struct UnifiedPaintSettings;
64 struct View3D;
65 struct ViewLayer;
66 struct bContext;
67 struct bToolRef;
68 struct tPaletteColorHSV;
69 
70 enum eOverlayFlags;
71 
72 extern const char PAINT_CURSOR_SCULPT[3];
73 extern const char PAINT_CURSOR_VERTEX_PAINT[3];
74 extern const char PAINT_CURSOR_WEIGHT_PAINT[3];
75 extern const char PAINT_CURSOR_TEXTURE_PAINT[3];
76 
77 typedef enum ePaintMode {
78   PAINT_MODE_SCULPT = 0,
79   /** Vertex color. */
80   PAINT_MODE_VERTEX = 1,
81   PAINT_MODE_WEIGHT = 2,
82   /** 3D view (projection painting). */
83   PAINT_MODE_TEXTURE_3D = 3,
84   /** Image space (2D painting). */
85   PAINT_MODE_TEXTURE_2D = 4,
86   PAINT_MODE_SCULPT_UV = 5,
87   PAINT_MODE_GPENCIL = 6,
88   /* Grease Pencil Vertex Paint */
89   PAINT_MODE_VERTEX_GPENCIL = 7,
90   PAINT_MODE_SCULPT_GPENCIL = 8,
91   PAINT_MODE_WEIGHT_GPENCIL = 9,
92 
93   /** Keep last. */
94   PAINT_MODE_INVALID = 10,
95 } ePaintMode;
96 
97 #define PAINT_MODE_HAS_BRUSH(mode) !ELEM(mode, PAINT_MODE_SCULPT_UV)
98 
99 /* overlay invalidation */
100 typedef enum ePaintOverlayControlFlags {
101   PAINT_OVERLAY_INVALID_TEXTURE_PRIMARY = 1,
102   PAINT_OVERLAY_INVALID_TEXTURE_SECONDARY = (1 << 2),
103   PAINT_OVERLAY_INVALID_CURVE = (1 << 3),
104   PAINT_OVERLAY_OVERRIDE_CURSOR = (1 << 4),
105   PAINT_OVERLAY_OVERRIDE_PRIMARY = (1 << 5),
106   PAINT_OVERLAY_OVERRIDE_SECONDARY = (1 << 6),
107 } ePaintOverlayControlFlags;
108 
109 #define PAINT_OVERRIDE_MASK \
110   (PAINT_OVERLAY_OVERRIDE_SECONDARY | PAINT_OVERLAY_OVERRIDE_PRIMARY | \
111    PAINT_OVERLAY_OVERRIDE_CURSOR)
112 
113 /* Defines 8 areas resulting of splitting the object space by the XYZ axis planes. This is used to
114  * flip or mirror transform values depending on where the vertex is and where the transform
115  * operation started to support XYZ symmetry on those operations in a predictable way. */
116 
117 #define PAINT_SYMM_AREA_DEFAULT 0
118 
119 typedef enum ePaintSymmetryAreas {
120   PAINT_SYMM_AREA_X = (1 << 0),
121   PAINT_SYMM_AREA_Y = (1 << 1),
122   PAINT_SYMM_AREA_Z = (1 << 2),
123 } ePaintSymmetryAreas;
124 
125 #define PAINT_SYMM_AREAS 8
126 
127 void BKE_paint_invalidate_overlay_tex(struct Scene *scene,
128                                       struct ViewLayer *view_layer,
129                                       const struct Tex *tex);
130 void BKE_paint_invalidate_cursor_overlay(struct Scene *scene,
131                                          struct ViewLayer *view_layer,
132                                          struct CurveMapping *curve);
133 void BKE_paint_invalidate_overlay_all(void);
134 ePaintOverlayControlFlags BKE_paint_get_overlay_flags(void);
135 void BKE_paint_reset_overlay_invalid(ePaintOverlayControlFlags flag);
136 void BKE_paint_set_overlay_override(enum eOverlayFlags flag);
137 
138 /* palettes */
139 struct Palette *BKE_palette_add(struct Main *bmain, const char *name);
140 struct PaletteColor *BKE_palette_color_add(struct Palette *palette);
141 bool BKE_palette_is_empty(const struct Palette *palette);
142 void BKE_palette_color_remove(struct Palette *palette, struct PaletteColor *color);
143 void BKE_palette_clear(struct Palette *palette);
144 
145 void BKE_palette_sort_hsv(struct tPaletteColorHSV *color_array, const int totcol);
146 void BKE_palette_sort_svh(struct tPaletteColorHSV *color_array, const int totcol);
147 void BKE_palette_sort_vhs(struct tPaletteColorHSV *color_array, const int totcol);
148 void BKE_palette_sort_luminance(struct tPaletteColorHSV *color_array, const int totcol);
149 bool BKE_palette_from_hash(struct Main *bmain,
150                            struct GHash *color_table,
151                            const char *name,
152                            const bool linear);
153 
154 /* paint curves */
155 struct PaintCurve *BKE_paint_curve_add(struct Main *bmain, const char *name);
156 
157 bool BKE_paint_ensure(struct ToolSettings *ts, struct Paint **r_paint);
158 void BKE_paint_init(struct Main *bmain, struct Scene *sce, ePaintMode mode, const char col[3]);
159 void BKE_paint_free(struct Paint *p);
160 void BKE_paint_copy(struct Paint *src, struct Paint *tar, const int flag);
161 
162 void BKE_paint_runtime_init(const struct ToolSettings *ts, struct Paint *paint);
163 
164 void BKE_paint_cavity_curve_preset(struct Paint *p, int preset);
165 
166 eObjectMode BKE_paint_object_mode_from_paintmode(ePaintMode mode);
167 bool BKE_paint_ensure_from_paintmode(struct Scene *sce, ePaintMode mode);
168 struct Paint *BKE_paint_get_active_from_paintmode(struct Scene *sce, ePaintMode mode);
169 const struct EnumPropertyItem *BKE_paint_get_tool_enum_from_paintmode(ePaintMode mode);
170 const char *BKE_paint_get_tool_prop_id_from_paintmode(ePaintMode mode);
171 uint BKE_paint_get_brush_tool_offset_from_paintmode(const ePaintMode mode);
172 struct Paint *BKE_paint_get_active(struct Scene *sce, struct ViewLayer *view_layer);
173 struct Paint *BKE_paint_get_active_from_context(const struct bContext *C);
174 ePaintMode BKE_paintmode_get_active_from_context(const struct bContext *C);
175 ePaintMode BKE_paintmode_get_from_tool(const struct bToolRef *tref);
176 struct Brush *BKE_paint_brush(struct Paint *paint);
177 void BKE_paint_brush_set(struct Paint *paint, struct Brush *br);
178 struct Palette *BKE_paint_palette(struct Paint *paint);
179 void BKE_paint_palette_set(struct Paint *p, struct Palette *palette);
180 void BKE_paint_curve_set(struct Brush *br, struct PaintCurve *pc);
181 void BKE_paint_curve_clamp_endpoint_add_index(struct PaintCurve *pc, const int add_index);
182 
183 /* testing face select mode
184  * Texture paint could be removed since selected faces are not used
185  * however hiding faces is useful */
186 bool BKE_paint_select_face_test(struct Object *ob);
187 bool BKE_paint_select_vert_test(struct Object *ob);
188 bool BKE_paint_select_elem_test(struct Object *ob);
189 
190 /* partial visibility */
191 bool paint_is_face_hidden(const struct MLoopTri *lt,
192                           const struct MVert *mvert,
193                           const struct MLoop *mloop);
194 bool paint_is_grid_face_hidden(const unsigned int *grid_hidden, int gridsize, int x, int y);
195 bool paint_is_bmesh_face_hidden(struct BMFace *f);
196 
197 /* paint masks */
198 float paint_grid_paint_mask(const struct GridPaintMask *gpm, uint level, uint x, uint y);
199 
200 void BKE_paint_face_set_overlay_color_get(const int face_set, const int seed, uchar r_color[4]);
201 
202 /* stroke related */
203 bool paint_calculate_rake_rotation(struct UnifiedPaintSettings *ups,
204                                    struct Brush *brush,
205                                    const float mouse_pos[2]);
206 void paint_update_brush_rake_rotation(struct UnifiedPaintSettings *ups,
207                                       struct Brush *brush,
208                                       float rotation);
209 
210 void BKE_paint_stroke_get_average(struct Scene *scene, struct Object *ob, float stroke[3]);
211 
212 /* Tool slot API. */
213 void BKE_paint_toolslots_init_from_main(struct Main *bmain);
214 void BKE_paint_toolslots_len_ensure(struct Paint *paint, int len);
215 void BKE_paint_toolslots_brush_update_ex(struct Paint *paint, struct Brush *brush);
216 void BKE_paint_toolslots_brush_update(struct Paint *paint);
217 void BKE_paint_toolslots_brush_validate(struct Main *bmain, struct Paint *paint);
218 struct Brush *BKE_paint_toolslots_brush_get(struct Paint *paint, int slot_index);
219 
220 #define SCULPT_FACE_SET_NONE 0
221 
222 /* Used for both vertex color and weight paint */
223 struct SculptVertexPaintGeomMap {
224   int *vert_map_mem;
225   struct MeshElemMap *vert_to_loop;
226   int *poly_map_mem;
227   struct MeshElemMap *vert_to_poly;
228 };
229 
230 /* Pose Brush IK Chain */
231 typedef struct SculptPoseIKChainSegment {
232   float orig[3];
233   float head[3];
234 
235   float initial_orig[3];
236   float initial_head[3];
237   float len;
238   float scale[3];
239   float rot[4];
240   float *weights;
241 
242   /* Store a 4x4 transform matrix for each of the possible combinations of enabled XYZ symmetry
243    * axis. */
244   float trans_mat[PAINT_SYMM_AREAS][4][4];
245   float pivot_mat[PAINT_SYMM_AREAS][4][4];
246   float pivot_mat_inv[PAINT_SYMM_AREAS][4][4];
247 } SculptPoseIKChainSegment;
248 
249 typedef struct SculptPoseIKChain {
250   SculptPoseIKChainSegment *segments;
251   int tot_segments;
252   float grab_delta_offset[3];
253 } SculptPoseIKChain;
254 
255 /* Cloth Brush */
256 
257 /* Cloth Simulation. */
258 typedef enum eSculptClothNodeSimState {
259   /* Constraints were not built for this node, so it can't be simulated. */
260   SCULPT_CLOTH_NODE_UNINITIALIZED,
261 
262   /* There are constraints for the geometry in this node, but it should not be simulated. */
263   SCULPT_CLOTH_NODE_INACTIVE,
264 
265   /* There are constraints for this node and they should be used by the solver. */
266   SCULPT_CLOTH_NODE_ACTIVE,
267 } eSculptClothNodeSimState;
268 
269 typedef enum eSculptClothConstraintType {
270   /* Constraint that creates the structure of the cloth. */
271   SCULPT_CLOTH_CONSTRAINT_STRUCTURAL = 0,
272   /* Constraint that references the position of a vertex and a position in deformation_pos which
273    * can be deformed by the tools. */
274   SCULPT_CLOTH_CONSTRAINT_DEFORMATION = 1,
275   /* Constraint that references the vertex position and a editable soft-body position for
276    * plasticity. */
277   SCULPT_CLOTH_CONSTRAINT_SOFTBODY = 2,
278   /* Constraint that references the vertex position and its initial position. */
279   SCULPT_CLOTH_CONSTRAINT_PIN = 3,
280 } eSculptClothConstraintType;
281 
282 typedef struct SculptClothLengthConstraint {
283   /* Elements that are affected by the constraint. */
284   /* Element a should always be a mesh vertex with the index stored in elem_index_a as it is always
285    * deformed. Element b could be another vertex of the same mesh or any other position (arbitrary
286    * point, position for a previous state). In that case, elem_index_a and elem_index_b should be
287    * the same to avoid affecting two different vertices when solving the constraints.
288    * *elem_position points to the position which is owned by the element. */
289   int elem_index_a;
290   float *elem_position_a;
291 
292   int elem_index_b;
293   float *elem_position_b;
294 
295   float length;
296   float strength;
297 
298   /* Index in #SculptClothSimulation.node_state of the node from where this constraint was created.
299    * This constraints will only be used by the solver if the state is active. */
300   int node;
301 
302   eSculptClothConstraintType type;
303 } SculptClothLengthConstraint;
304 
305 typedef struct SculptClothSimulation {
306   SculptClothLengthConstraint *length_constraints;
307   int tot_length_constraints;
308   struct EdgeSet *created_length_constraints;
309   int capacity_length_constraints;
310   float *length_constraint_tweak;
311 
312   /* Position anchors for deformation brushes. These positions are modified by the brush and the
313    * final positions of the simulated vertices are updated with constraints that use these points
314    * as targets. */
315   float (*deformation_pos)[3];
316   float *deformation_strength;
317 
318   float mass;
319   float damping;
320   float softbody_strength;
321 
322   float (*acceleration)[3];
323   float (*pos)[3];
324   float (*init_pos)[3];
325   float (*softbody_pos)[3];
326   float (*prev_pos)[3];
327   float (*last_iteration_pos)[3];
328 
329   struct ListBase *collider_list;
330 
331   int totnode;
332   /** #PBVHNode pointer as a key, index in #SculptClothSimulation.node_state as value. */
333   struct GHash *node_state_index;
334   eSculptClothNodeSimState *node_state;
335 } SculptClothSimulation;
336 
337 typedef struct SculptPersistentBase {
338   float co[3];
339   float no[3];
340   float disp;
341 } SculptPersistentBase;
342 
343 typedef struct SculptVertexInfo {
344   /* Indexed by vertex, stores and ID of its topologically connected component. */
345   int *connected_component;
346 
347   /* Indexed by base mesh vertex index, stores if that vertex is a boundary. */
348   BLI_bitmap *boundary;
349 } SculptVertexInfo;
350 
351 typedef struct SculptBoundaryEditInfo {
352   /* Vertex index from where the topology propagation reached this vertex. */
353   int original_vertex;
354 
355   /* How many steps were needed to reach this vertex from the boundary. */
356   int num_propagation_steps;
357 
358   /* Stregth that is used to deform this vertex. */
359   float strength_factor;
360 } SculptBoundaryEditInfo;
361 
362 /* Edge for drawing the boundary preview in the cursor. */
363 typedef struct SculptBoundaryPreviewEdge {
364   int v1;
365   int v2;
366 } SculptBoundaryPreviewEdge;
367 
368 typedef struct SculptBoundary {
369   /* Vertex indices of the active boundary. */
370   int *vertices;
371   int vertices_capacity;
372   int num_vertices;
373 
374   /* Distance from a vertex in the boundary to initial vertex indexed by vertex index, taking into
375    * account the length of all edges between them. Any vertex that is not in the boundary will have
376    * a distance of 0. */
377   float *distance;
378 
379   /* Data for drawing the preview. */
380   SculptBoundaryPreviewEdge *edges;
381   int edges_capacity;
382   int num_edges;
383 
384   /* True if the boundary loops into itself. */
385   bool forms_loop;
386 
387   /* Initial vertex in the boundary which is closest to the current sculpt active vertex. */
388   int initial_vertex;
389 
390   /* Vertex that at max_propagation_steps from the boundary and closest to the original active
391    * vertex that was used to initialize the boundary. This is used as a reference to check how much
392    * the deformation will go into the mesh and to calculate the strength of the brushes. */
393   int pivot_vertex;
394 
395   /* Stores the initial positions of the pivot and boundary initial vertex as they may be deformed
396    * during the brush action. This allows to use them as a reference positions and vectors for some
397    * brush effects. */
398   float initial_vertex_position[3];
399   float initial_pivot_position[3];
400 
401   /* Maximum number of topology steps that were calculated from the boundary. */
402   int max_propagation_steps;
403 
404   /* Indexed by vertex index, contains the topology information needed for boundary deformations.
405    */
406   struct SculptBoundaryEditInfo *edit_info;
407 
408   /* Bend Deform type. */
409   struct {
410     float (*pivot_rotation_axis)[3];
411     float (*pivot_positions)[3];
412   } bend;
413 
414   /* Slide Deform type. */
415   struct {
416     float (*directions)[3];
417   } slide;
418 
419   /* Twist Deform type. */
420   struct {
421     float rotation_axis[3];
422     float pivot_position[3];
423   } twist;
424 } SculptBoundary;
425 
426 typedef struct SculptFakeNeighbors {
427   bool use_fake_neighbors;
428 
429   /* Max distance used to calculate neighborhood information. */
430   float current_max_distance;
431 
432   /* Indexed by vertex, stores the vertex index of its fake neighbor if available. */
433   int *fake_neighbor_index;
434 
435 } SculptFakeNeighbors;
436 
437 /* Session data (mode-specific) */
438 
439 typedef struct SculptSession {
440   /* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */
441   struct { /* Special handling for multires meshes */
442     bool active;
443     struct MultiresModifierData *modifier;
444     int level;
445   } multires;
446 
447   /* Depsgraph for the Cloth Brush solver to get the colliders. */
448   struct Depsgraph *depsgraph;
449 
450   /* These are always assigned to base mesh data when using PBVH_FACES and PBVH_GRIDS. */
451   struct MVert *mvert;
452   struct MPoly *mpoly;
453   struct MLoop *mloop;
454 
455   /* These contain the vertex and poly counts of the final mesh. */
456   int totvert, totpoly;
457 
458   struct KeyBlock *shapekey_active;
459   struct MPropCol *vcol;
460   float *vmask;
461 
462   /* Mesh connectivity */
463   struct MeshElemMap *pmap;
464   int *pmap_mem;
465 
466   /* Mesh Face Sets */
467   /* Total number of polys of the base mesh. */
468   int totfaces;
469   /* Face sets store its visibility in the sign of the integer, using the absolute value as the
470    * Face Set ID. Positive IDs are visible, negative IDs are hidden. */
471   int *face_sets;
472 
473   /* BMesh for dynamic topology sculpting */
474   struct BMesh *bm;
475   int cd_vert_node_offset;
476   int cd_face_node_offset;
477   bool bm_smooth_shading;
478   /* Undo/redo log for dynamic topology sculpting */
479   struct BMLog *bm_log;
480 
481   /* Limit surface/grids. */
482   struct SubdivCCG *subdiv_ccg;
483 
484   /* PBVH acceleration structure */
485   struct PBVH *pbvh;
486   bool show_mask;
487   bool show_face_sets;
488 
489   /* Painting on deformed mesh */
490   bool deform_modifiers_active; /* Object is deformed with some modifiers. */
491   float (*orig_cos)[3];         /* Coords of un-deformed mesh. */
492   float (*deform_cos)[3];       /* Coords of deformed mesh but without stroke displacement. */
493   float (*deform_imats)[3][3];  /* Crazy-space deformation matrices. */
494 
495   /* Used to cache the render of the active texture */
496   unsigned int texcache_side, *texcache, texcache_actual;
497   struct ImagePool *tex_pool;
498 
499   struct StrokeCache *cache;
500   struct FilterCache *filter_cache;
501 
502   /* Cursor data and active vertex for tools */
503   int active_vertex_index;
504 
505   int active_face_index;
506   int active_grid_index;
507 
508   float cursor_radius;
509   float cursor_location[3];
510   float cursor_normal[3];
511   float cursor_sampled_normal[3];
512   float cursor_view_normal[3];
513 
514   /* For Sculpt trimming gesture tools, initial raycast data from the position of the mouse when
515    * the gesture starts (intersection with the surface and if they ray hit the surface or not). */
516   float gesture_initial_location[3];
517   bool gesture_initial_hit;
518 
519   /* TODO(jbakker): Replace rv3d adn v3d with ViewContext */
520   struct RegionView3D *rv3d;
521   struct View3D *v3d;
522   struct Scene *scene;
523 
524   /* Dynamic mesh preview */
525   int *preview_vert_index_list;
526   int preview_vert_index_count;
527 
528   /* Pose Brush Preview */
529   float pose_origin[3];
530   SculptPoseIKChain *pose_ik_chain_preview;
531 
532   /* Boundary Brush Preview */
533   SculptBoundary *boundary_preview;
534 
535   /* Mesh State Persistence */
536   /* This is freed with the PBVH, so it is always in sync with the mesh. */
537   SculptPersistentBase *persistent_base;
538 
539   SculptVertexInfo vertex_info;
540   SculptFakeNeighbors fake_neighbors;
541 
542   /* Transform operator */
543   float pivot_pos[3];
544   float pivot_rot[4];
545   float pivot_scale[3];
546 
547   float init_pivot_pos[3];
548   float init_pivot_rot[4];
549   float init_pivot_scale[3];
550 
551   union {
552     struct {
553       struct SculptVertexPaintGeomMap gmap;
554 
555       /* For non-airbrush painting to re-apply from the original (MLoop aligned). */
556       unsigned int *previous_color;
557     } vpaint;
558 
559     struct {
560       struct SculptVertexPaintGeomMap gmap;
561       /* Keep track of how much each vertex has been painted (non-airbrush only). */
562       float *alpha_weight;
563 
564       /* Needed to continuously re-apply over the same weights (BRUSH_ACCUMULATE disabled).
565        * Lazy initialize as needed (flag is set to 1 to tag it as uninitialized). */
566       struct MDeformVert *dvert_prev;
567     } wpaint;
568 
569     /* TODO: identify sculpt-only fields */
570     // struct { ... } sculpt;
571   } mode;
572   eObjectMode mode_type;
573 
574   /* This flag prevents PBVH from being freed when creating the vp_handle for texture paint. */
575   bool building_vp_handle;
576 
577   /**
578    * ID data is older than sculpt-mode data.
579    * Set #Main.is_memfile_undo_flush_needed when enabling.
580    */
581   char needs_flush_to_id;
582 
583 } SculptSession;
584 
585 void BKE_sculptsession_free(struct Object *ob);
586 void BKE_sculptsession_free_deformMats(struct SculptSession *ss);
587 void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss);
588 void BKE_sculptsession_bm_to_me(struct Object *ob, bool reorder);
589 void BKE_sculptsession_bm_to_me_for_render(struct Object *object);
590 
591 /* Create new color layer on object if it doesn't have one and if experimental feature set has
592  * sculpt vertex color enabled. Returns truth if new layer has been added, false otherwise. */
593 void BKE_sculpt_color_layer_create_if_needed(struct Object *object);
594 
595 void BKE_sculpt_update_object_for_edit(struct Depsgraph *depsgraph,
596                                        struct Object *ob_orig,
597                                        bool need_pmap,
598                                        bool need_mask,
599                                        bool need_colors);
600 void BKE_sculpt_update_object_before_eval(struct Object *ob_eval);
601 void BKE_sculpt_update_object_after_eval(struct Depsgraph *depsgraph, struct Object *ob_eval);
602 
603 struct MultiresModifierData *BKE_sculpt_multires_active(struct Scene *scene, struct Object *ob);
604 int BKE_sculpt_mask_layers_ensure(struct Object *ob, struct MultiresModifierData *mmd);
605 void BKE_sculpt_toolsettings_data_ensure(struct Scene *scene);
606 
607 struct PBVH *BKE_sculpt_object_pbvh_ensure(struct Depsgraph *depsgraph, struct Object *ob);
608 
609 void BKE_sculpt_bvh_update_from_ccg(struct PBVH *pbvh, struct SubdivCCG *subdiv_ccg);
610 
611 /* This ensure that all elements in the mesh (both vertices and grids) have their visibility
612  * updated according to the face sets. */
613 void BKE_sculpt_sync_face_set_visibility(struct Mesh *mesh, struct SubdivCCG *subdiv_ccg);
614 
615 /* Individual function to sync the Face Set visibility to mesh and grids. */
616 void BKE_sculpt_sync_face_sets_visibility_to_base_mesh(struct Mesh *mesh);
617 void BKE_sculpt_sync_face_sets_visibility_to_grids(struct Mesh *mesh,
618                                                    struct SubdivCCG *subdiv_ccg);
619 
620 /* Ensures that a Face Set data-layers exists. If it does not, it creates one respecting the
621  * visibility stored in the vertices of the mesh. If it does, it copies the visibility from the
622  * mesh to the Face Sets. */
623 void BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(struct Mesh *mesh);
624 
625 bool BKE_sculptsession_use_pbvh_draw(const struct Object *ob, const struct View3D *v3d);
626 
627 enum {
628   SCULPT_MASK_LAYER_CALC_VERT = (1 << 0),
629   SCULPT_MASK_LAYER_CALC_LOOP = (1 << 1),
630 };
631 
632 #ifdef __cplusplus
633 }
634 #endif
635