Blender  V2.93
sculpt_intern.h
Go to the documentation of this file.
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) 2006 by Nicholas Bishop
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 #include "DNA_brush_types.h"
27 #include "DNA_key_types.h"
28 #include "DNA_listBase.h"
29 #include "DNA_meshdata_types.h"
30 #include "DNA_vec_types.h"
31 
32 #include "BLI_bitmap.h"
33 #include "BLI_gsqueue.h"
34 #include "BLI_threads.h"
35 
36 #include "BKE_paint.h"
37 #include "BKE_pbvh.h"
38 
39 struct AutomaskingCache;
40 struct KeyBlock;
41 struct Object;
42 struct SculptUndoNode;
43 struct bContext;
44 
46 
47 bool SCULPT_mode_poll(struct bContext *C);
48 bool SCULPT_mode_poll_view3d(struct bContext *C);
49 /* checks for a brush, not just sculpt mode */
50 bool SCULPT_poll(struct bContext *C);
51 bool SCULPT_poll_view3d(struct bContext *C);
52 
54 
55 /* Updates */
56 
57 typedef enum SculptUpdateType {
63 
65 void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags);
66 void SCULPT_flush_stroke_deform(struct Sculpt *sd, Object *ob, bool is_proxy_used);
67 
68 /* Should be used after modifying the mask or Face Sets IDs. */
70 
71 /* Stroke */
72 
73 typedef struct SculptCursorGeometryInfo {
74  float location[3];
75  float normal[3];
76  float active_vertex_co[3];
78 
79 bool SCULPT_stroke_get_location(struct bContext *C, float out[3], const float mouse[2]);
82  const float mouse[2],
83  bool use_sampled_normal);
84 void SCULPT_geometry_preview_lines_update(bContext *C, struct SculptSession *ss, float radius);
85 
86 void SCULPT_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush);
87 float SCULPT_raycast_init(struct ViewContext *vc,
88  const float mouse[2],
89  float ray_start[3],
90  float ray_end[3],
91  float ray_normal[3],
92  bool original);
93 
94 /* Symmetry */
96 
97 /* Sculpt PBVH abstraction API */
99 
100 int SCULPT_vertex_count_get(struct SculptSession *ss);
101 const float *SCULPT_vertex_co_get(struct SculptSession *ss, int index);
102 void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3]);
103 float SCULPT_vertex_mask_get(struct SculptSession *ss, int index);
104 const float *SCULPT_vertex_color_get(SculptSession *ss, int index);
105 
106 const float *SCULPT_vertex_persistent_co_get(SculptSession *ss, int index);
107 void SCULPT_vertex_persistent_normal_get(SculptSession *ss, int index, float no[3]);
108 
109 /* Coordinates used for manipulating the base mesh when Grab Active Vertex is enabled. */
110 const float *SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, int index);
111 
112 /* Returns the info of the limit surface when Multires is available, otherwise it returns the
113  * current coordinate of the vertex. */
114 void SCULPT_vertex_limit_surface_get(SculptSession *ss, int index, float r_co[3]);
115 
116 /* Returns the pointer to the coordinates that should be edited from a brush tool iterator
117  * depending on the given deformation target. */
119  const int deform_target,
120  PBVHVertexIter *iter);
121 
122 #define SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY 256
123 typedef struct SculptVertexNeighborIter {
124  /* Storage */
125  int *neighbors;
126  int size;
127  int capacity;
129 
130  /* Internal iterator. */
132  int i;
133 
134  /* Public */
135  int index;
138 
140  const int index,
141  const bool include_duplicates,
143 
144 /* Iterator over neighboring vertices. */
145 #define SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN(ss, v_index, neighbor_iterator) \
146  SCULPT_vertex_neighbors_get(ss, v_index, false, &neighbor_iterator); \
147  for (neighbor_iterator.i = 0; neighbor_iterator.i < neighbor_iterator.size; \
148  neighbor_iterator.i++) { \
149  neighbor_iterator.index = neighbor_iterator.neighbors[neighbor_iterator.i];
150 
151 /* Iterate over neighboring and duplicate vertices (for PBVH_GRIDS). Duplicates come
152  * first since they are nearest for floodfill. */
153 #define SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN(ss, v_index, neighbor_iterator) \
154  SCULPT_vertex_neighbors_get(ss, v_index, true, &neighbor_iterator); \
155  for (neighbor_iterator.i = neighbor_iterator.size - 1; neighbor_iterator.i >= 0; \
156  neighbor_iterator.i--) { \
157  neighbor_iterator.index = neighbor_iterator.neighbors[neighbor_iterator.i]; \
158  neighbor_iterator.is_duplicate = (neighbor_iterator.i >= \
159  neighbor_iterator.size - neighbor_iterator.num_duplicates);
160 
161 #define SCULPT_VERTEX_NEIGHBORS_ITER_END(neighbor_iterator) \
162  } \
163  if (neighbor_iterator.neighbors != neighbor_iterator.neighbors_fixed) { \
164  MEM_freeN(neighbor_iterator.neighbors); \
165  } \
166  ((void)0)
167 
171 
172 /* Returns PBVH deformed vertices array if shape keys or deform modifiers are used, otherwise
173  * returns mesh original vertices array. */
175 
176 /* Fake Neighbors */
177 
178 #define FAKE_NEIGHBOR_NONE -1
179 
180 void SCULPT_fake_neighbors_ensure(struct Sculpt *sd, Object *ob, const float max_dist);
183 void SCULPT_fake_neighbors_free(struct Object *ob);
184 
185 /* Vertex Info. */
186 void SCULPT_boundary_info_ensure(Object *object);
187 /* Boundary Info needs to be initialized in order to use this function. */
188 bool SCULPT_vertex_is_boundary(const SculptSession *ss, const int index);
189 
191 
192 /* Sculpt Visibility API */
193 
194 void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible);
195 bool SCULPT_vertex_visible_get(SculptSession *ss, int index);
196 
199 
200 /* Face Sets API */
201 
203 int SCULPT_vertex_face_set_get(SculptSession *ss, int index);
204 void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_set);
205 
206 bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set);
208 
210 
211 void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool visible);
212 bool SCULPT_vertex_all_face_sets_visible_get(const SculptSession *ss, int index);
214 
216 void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible);
217 
221 
222 /* Sculpt Original Data */
223 typedef struct {
224  struct BMLog *bm_log;
225 
227  float (*coords)[3];
228  short (*normals)[3];
229  const float *vmasks;
230  float (*colors)[4];
231 
232  /* Original coordinate, normal, and mask. */
233  const float *co;
234  const short *no;
235  float mask;
236  const float *col;
238 
242  Object *ob,
243  struct SculptUndoNode *unode);
244 
245 /* Utils. */
246 void SCULPT_calc_brush_plane(struct Sculpt *sd,
247  struct Object *ob,
248  struct PBVHNode **nodes,
249  int totnode,
250  float r_area_no[3],
251  float r_area_co[3]);
252 
254  Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float r_area_no[3]);
255 
256 int SCULPT_nearest_vertex_get(struct Sculpt *sd,
257  struct Object *ob,
258  const float co[3],
259  float max_distance,
260  bool use_original);
261 
262 int SCULPT_plane_point_side(const float co[3], const float plane[4]);
263 int SCULPT_plane_trim(const struct StrokeCache *cache,
264  const struct Brush *brush,
265  const float val[3]);
266 void SCULPT_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3]);
267 
269 
271 bool SCULPT_check_vertex_pivot_symmetry(const float vco[3], const float pco[3], const char symm);
272 bool SCULPT_is_vertex_inside_brush_radius_symm(const float vertex[3],
273  const float br_co[3],
274  float radius,
275  char symm);
276 bool SCULPT_is_symmetry_iteration_valid(char i, char symm);
277 void SCULPT_flip_v3_by_symm_area(float v[3],
278  const ePaintSymmetryFlags symm,
279  const ePaintSymmetryAreas symmarea,
280  const float pivot[3]);
281 void SCULPT_flip_quat_by_symm_area(float quat[3],
282  const ePaintSymmetryFlags symm,
283  const ePaintSymmetryAreas symmarea,
284  const float pivot[3]);
285 
286 /* Flood Fill. */
287 typedef struct {
291 
292 void SCULPT_floodfill_init(struct SculptSession *ss, SculptFloodFill *flood);
293 void SCULPT_floodfill_add_active(struct Sculpt *sd,
294  struct Object *ob,
295  struct SculptSession *ss,
296  SculptFloodFill *flood,
297  float radius);
299  struct Object *ob,
300  struct SculptSession *ss,
301  SculptFloodFill *flood,
302  int index,
303  float radius);
304 void SCULPT_floodfill_add_initial(SculptFloodFill *flood, int index);
307  struct SculptSession *ss,
308  SculptFloodFill *flood,
309  bool (*func)(SculptSession *ss, int from_v, int to_v, bool is_duplicate, void *userdata),
310  void *userdata);
312 
313 /* Dynamic topology */
314 
316  DYNTOPO_WARN_VDATA = (1 << 0),
317  DYNTOPO_WARN_EDATA = (1 << 1),
318  DYNTOPO_WARN_LDATA = (1 << 2),
320 };
321 
322 void SCULPT_dynamic_topology_enable_ex(struct Main *bmain,
323  struct Depsgraph *depsgraph,
324  Scene *scene,
325  Object *ob);
328  struct Depsgraph *depsgraph,
329  Scene *scene,
330  Object *ob);
331 
332 bool SCULPT_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *brush);
333 
336 
338 
339 void SCULPT_pbvh_clear(Object *ob);
340 
341 /* Auto-masking. */
342 float SCULPT_automasking_factor_get(struct AutomaskingCache *automasking,
343  SculptSession *ss,
344  int vert);
345 
346 /* Returns the automasking cache depending on the active tool. Used for code that can run both for
347  * brushes and filter. */
349 
351 void SCULPT_automasking_cache_free(struct AutomaskingCache *automasking);
352 
354  const Brush *br,
355  const eAutomasking_flag mode);
356 bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br);
357 
358 typedef enum eBoundaryAutomaskMode {
364  int propagation_steps,
365  float *automask_factor);
366 
367 /* Geodesic distances. */
368 
369 /* Returns an array indexed by vertex index containing the geodesic distance to the closest vertex
370 in the initial vertex set. The caller is responsible for freeing the array.
371 Geodesic distances will only work when used with PBVH_FACES, for other types of PBVH it will
372 fallback to euclidean distances to one of the initial vertices in the set. */
373 float *SCULPT_geodesic_distances_create(struct Object *ob,
374  struct GSet *initial_vertices,
375  const float limit_radius);
377  struct Object *ob,
378  const int vertex,
379  const float limit_radius);
380 float *SCULPT_geodesic_from_vertex(Object *ob, const int vertex, const float limit_radius);
381 
382 /* Filters. */
383 void SCULPT_filter_cache_init(struct bContext *C, Object *ob, Sculpt *sd, const int undo_type);
385 
387  Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, const int smooth_iterations);
388 
389 /* Brushes. */
390 
391 /* Cloth Brush. */
392 void SCULPT_do_cloth_brush(struct Sculpt *sd,
393  struct Object *ob,
394  struct PBVHNode **nodes,
395  int totnode);
396 
398 
400  struct SculptSession *ss,
401  const float cloth_mass,
402  const float cloth_damping,
403  const float cloth_softbody_strength,
404  const bool use_collisions,
405  const bool needs_deform_coords);
407  struct SculptClothSimulation *cloth_sim);
408 
410  PBVHNode **nodes,
411  int totnode);
412 
414  struct SculptClothSimulation *cloth_sim);
415 
417  struct Object *ob,
418  struct SculptClothSimulation *cloth_sim,
419  struct PBVHNode **nodes,
420  int totnode);
421 
423  struct Object *ob,
424  struct PBVHNode **nodes,
425  int totnode,
426  struct SculptClothSimulation *cloth_sim,
427  float initial_location[3],
428  const float radius);
429 
431  const struct Brush *brush,
432  const float location[3],
433  const float normal[3],
434  const float rds,
435  const float line_width,
436  const float outline_col[3],
437  const float alpha);
439  struct SculptSession *ss,
440  const float outline_col[3],
441  float outline_alpha);
442 
444  Brush *brush,
445  int *r_totnode);
446 
448 {
449  return (brush->sculpt_tool == SCULPT_TOOL_CLOTH && ELEM(brush->cloth_deform_type,
452  /* All brushes that are not the cloth brush deform the simulation using softbody
453  * constraints instead of applying forces. */
454  (brush->sculpt_tool != SCULPT_TOOL_CLOTH &&
456 }
457 
459 {
460  if (brush->sculpt_tool == SCULPT_TOOL_ELASTIC_DEFORM) {
461  /* Elastic deformations in any brush need all nodes to avoid artifacts as the effect
462  * of the Kelvinlet is not constrained by the radius. */
463  return true;
464  }
465 
466  if (brush->sculpt_tool == SCULPT_TOOL_POSE) {
467  /* Pose needs all nodes because it applies all symmetry iterations at the same time
468  * and the IK chain can grow to any area of the model. */
469  /* TODO: This can be optimized by filtering the nodes after calculating the chain. */
470  return true;
471  }
472 
473  if (brush->sculpt_tool == SCULPT_TOOL_BOUNDARY) {
474  /* Boundary needs all nodes because it is not possible to know where the boundary
475  * deformation is going to be propagated before calculating it. */
476  /* TODO: after calculating the boundary info in the first iteration, it should be
477  * possible to get the nodes that have vertices included in any boundary deformation
478  * and cache them. */
479  return true;
480  }
481 
482  if (brush->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK &&
484  /* Snake hook in elastic deform type has same requirements as the elastic deform tool. */
485  return true;
486  }
487  return false;
488 }
489 
490 /* Pose Brush. */
491 void SCULPT_do_pose_brush(struct Sculpt *sd,
492  struct Object *ob,
493  struct PBVHNode **nodes,
494  int totnode);
495 void SCULPT_pose_calc_pose_data(struct Sculpt *sd,
496  struct Object *ob,
497  struct SculptSession *ss,
498  float initial_location[3],
499  float radius,
500  float pose_offset,
501  float *r_pose_origin,
502  float *r_pose_factor);
503 void SCULPT_pose_brush_init(struct Sculpt *sd,
504  struct Object *ob,
505  struct SculptSession *ss,
506  struct Brush *br);
508  struct Object *ob,
509  struct SculptSession *ss,
510  struct Brush *br,
511  const float initial_location[3],
512  const float radius);
513 void SCULPT_pose_ik_chain_free(struct SculptPoseIKChain *ik_chain);
514 
515 /* Boundary Brush. */
517  Brush *brush,
518  const int initial_vertex,
519  const float radius);
520 void SCULPT_boundary_data_free(struct SculptBoundary *boundary);
521 void SCULPT_do_boundary_brush(struct Sculpt *sd,
522  struct Object *ob,
523  struct PBVHNode **nodes,
524  int totnode);
525 
526 void SCULPT_boundary_edges_preview_draw(const uint gpuattr,
527  struct SculptSession *ss,
528  const float outline_col[3],
529  const float outline_alpha);
530 void SCULPT_boundary_pivot_line_preview_draw(const uint gpuattr, struct SculptSession *ss);
531 
532 /* Multi-plane Scrape Brush. */
533 void SCULPT_do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
535  Brush *brush,
536  SculptSession *ss,
537  const float outline_col[3],
538  const float outline_alpha);
539 /* Draw Face Sets Brush. */
540 void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
541 
542 /* Paint Brush. */
543 void SCULPT_do_paint_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
544 
545 /* Smear Brush. */
546 void SCULPT_do_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
547 
548 /* Smooth Brush. */
549 void SCULPT_bmesh_four_neighbor_average(float avg[3], float direction[3], struct BMVert *v);
550 
551 void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], int index);
552 float SCULPT_neighbor_mask_average(SculptSession *ss, int index);
553 void SCULPT_neighbor_color_average(SculptSession *ss, float result[4], int index);
554 
555 /* Mask the mesh boundaries smoothing only the mesh surface without using automasking. */
556 void SCULPT_neighbor_coords_average_interior(SculptSession *ss, float result[3], int index);
557 
558 void SCULPT_smooth(Sculpt *sd,
559  Object *ob,
560  PBVHNode **nodes,
561  const int totnode,
562  float bstrength,
563  const bool smooth_mask);
564 void SCULPT_do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
565 
566 /* Surface Smooth Brush. */
567 
569  float *disp,
570  const float co[3],
571  float (*laplacian_disp)[3],
572  const int v_index,
573  const float origco[3],
574  const float alpha);
576  float *co,
577  float (*laplacian_disp)[3],
578  const int v_index,
579  const float beta,
580  const float fade);
581 void SCULPT_do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode);
582 
583 /* Slide/Relax */
584 void SCULPT_relax_vertex(struct SculptSession *ss,
585  struct PBVHVertexIter *vd,
586  float factor,
587  bool filter_boundary_face_sets,
588  float *r_final_pos);
589 
590 /* Undo */
591 
592 typedef enum {
603 
604 /* Storage of geometry for the undo node.
605  * Is used as a storage for either original or modified geometry. */
606 typedef struct SculptUndoNodeGeometry {
607  /* Is used for sanity check, helping with ensuring that two and only two
608  * geometry pushes happened in the undo stack. */
610 
615  int totvert;
616  int totedge;
617  int totloop;
618  int totpoly;
620 
621 typedef struct SculptUndoNode {
623 
625 
626  char idname[MAX_ID_NAME]; /* name instead of pointer*/
627  void *node; /* only during push, not valid afterwards! */
628 
629  float (*co)[3];
630  float (*orig_co)[3];
631  short (*no)[3];
632  float (*col)[4];
633  float *mask;
634  int totvert;
635 
636  /* non-multires */
637  int maxvert; /* to verify if totvert it still the same */
638  int *index; /* to restore into right location */
640 
641  /* multires */
642  int maxgrid; /* same for grid */
643  int gridsize; /* same for grid */
644  int totgrid; /* to restore into right location */
645  int *grids; /* to restore into right location */
647 
648  /* bmesh */
650  bool applied;
651 
652  /* shape keys */
653  char shapeName[sizeof(((KeyBlock *)0))->name];
654 
655  /* Geometry modification operations.
656  *
657  * Original geometry is stored before some modification is run and is used to restore state of
658  * the object when undoing the operation
659  *
660  * Modified geometry is stored after the modification and is used to redo the modification. */
664 
665  /* Geometry at the bmesh enter moment. */
667 
668  /* pivot */
669  float pivot_pos[3];
670  float pivot_rot[4];
671 
672  /* Sculpt Face Sets */
673  int *face_sets;
674 
675  size_t undo_size;
677 
678 /* Factor of brush to have rake point following behind
679  * (could be configurable but this is reasonable default). */
680 #define SCULPT_RAKE_BRUSH_FACTOR 0.25f
681 
683  float follow_dist;
684  float follow_co[3];
685 };
686 
687 /* Single struct used by all BLI_task threaded callbacks, let's avoid adding 10's of those... */
688 typedef struct SculptThreadedTaskData {
689  struct bContext *C;
690  struct Sculpt *sd;
691  struct Object *ob;
692  const struct Brush *brush;
693  struct PBVHNode **nodes;
694  int totnode;
695 
696  struct VPaint *vp;
697  struct VPaintData *vpd;
698  struct WPaintData *wpd;
700  unsigned int *lcol;
701  struct Mesh *me;
702  /* For passing generic params. */
703  void *custom_data;
704 
705  /* Data specific to some callbacks. */
706 
707  /* Note: even if only one or two of those are used at a time,
708  * keeping them separated, names help figuring out
709  * what it is, and memory overhead is ridiculous anyway. */
711  float angle;
712  float strength;
715 
717  float *offset;
718  float *grab_delta;
719  float *cono;
720  float *area_no;
721  float *area_no_sp;
722  float *area_co;
723  float (*mat)[4];
724  float (*vertCos)[3];
725 
726  /* X and Z vectors aligned to the stroke direction for operations where perpendicular vectors to
727  * the stroke direction are needed. */
729 
733 
736 
737  /* 0=towards view, 1=flipped */
740  int *count_no;
741  int *count_co;
742 
744 
746 
747  float *prev_mask;
748 
749  float *pose_factor;
752 
755 
758 
759  /* Stabilized strength for the Clay Thumb brush. */
761 
767 
768  float transform_mats[8][4][4];
769 
770  /* Boundary brush */
772 
777 
781 
782  /* Mask By Color Tool */
783 
787 
788  /* Index of the vertex that is going to be used as a reference for the colors. */
791 
792  int face_set;
794 
797 
799 
801 
802 /*************** Brush testing declarations ****************/
803 typedef struct SculptBrushTest {
805  float radius;
806  float location[3];
807  float dist;
809 
811  float symm_rot_mat_inv[4][4];
812 
813  /* For circle (not sphere) projection. */
814  float plane_view[4];
815 
816  /* Some tool code uses a plane for its calculations. */
817  float plane_tool[4];
818 
819  /* View3d clipping - only set rv3d for clipping */
822 
823 typedef bool (*SculptBrushTestFn)(SculptBrushTest *test, const float co[3]);
824 
825 typedef struct {
826  struct Sculpt *sd;
827  struct SculptSession *ss;
829  const float *center;
830  bool original;
831  /* This ignores fully masked and fully hidden nodes. */
834 
835 typedef struct {
836  struct Sculpt *sd;
837  struct SculptSession *ss;
839  bool original;
843 
845 bool SCULPT_brush_test_sphere(SculptBrushTest *test, const float co[3]);
846 bool SCULPT_brush_test_sphere_sq(SculptBrushTest *test, const float co[3]);
847 bool SCULPT_brush_test_sphere_fast(const SculptBrushTest *test, const float co[3]);
849  const float co[3],
850  const float local[4][4],
851  const float roundness);
852 bool SCULPT_brush_test_circle_sq(SculptBrushTest *test, const float co[3]);
853 bool SCULPT_search_sphere_cb(PBVHNode *node, void *data_v);
854 bool SCULPT_search_circle_cb(PBVHNode *node, void *data_v);
855 
857  SculptBrushTest *test,
858  char falloff_shape);
860  char falloff_shape);
861 
863  const struct Brush *br,
864  const float point[3],
865  const float len,
866  const short vno[3],
867  const float fno[3],
868  const float mask,
869  const int vertex_index,
870  const int thread_id);
871 
872 /* Tilts a normal by the x and y tilt values using the view axis. */
873 void SCULPT_tilt_apply_to_normal(float r_normal[3],
874  struct StrokeCache *cache,
875  const float tilt_strength);
876 
877 /* Get effective surface normal with pen tilt and tilt strength applied to it. */
878 void SCULPT_tilt_effective_normal_get(const SculptSession *ss, const Brush *brush, float r_no[3]);
879 
880 /* just for vertex paint. */
881 bool SCULPT_pbvh_calc_area_normal(const struct Brush *brush,
882  Object *ob,
883  PBVHNode **nodes,
884  int totnode,
885  bool use_threading,
886  float r_area_no[3]);
887 
888 /* Cache stroke properties. Used because
889  * RNA property lookup isn't particularly fast.
890  *
891  * For descriptions of these settings, check the operator properties.
892  */
893 
894 #define SCULPT_CLAY_STABILIZER_LEN 10
895 
896 typedef struct AutomaskingSettings {
897  /* Flags from eAutomasking_flag. */
898  int flags;
901 
902 typedef struct AutomaskingCache {
904  /* Precomputed auto-mask factor indexed by vertex, owned by the auto-masking system and
905  * initialized in #SCULPT_automasking_cache_init when needed. */
906  float *factor;
908 
909 typedef struct StrokeCache {
910  /* Invariants */
912  float scale[3];
913  int flag;
914  float clip_tolerance[3];
915  float clip_mirror_mtx[4][4];
916  float initial_mouse[2];
917 
918  /* Variants */
919  float radius;
921  float true_location[3];
923  float location[3];
924  float last_location[3];
925 
926  /* Used for alternating between deformation in brushes that need to apply different ones to
927  * achieve certain effects. */
929 
930  /* Original pixel radius with the pressure curve applied for dyntopo detail size */
932 
934 
935  bool pen_flip;
936  bool invert;
937  float pressure;
938  float bstrength;
939  float normal_weight; /* from brush (with optional override) */
940  float x_tilt;
941  float y_tilt;
942 
943  /* Position of the mouse corresponding to the stroke location, modified by the paint_stroke
944  * operator according to the stroke type. */
945  float mouse[2];
946  /* Position of the mouse event in screen space, not modified by the stroke type. */
947  float mouse_event[2];
948 
950 
951  /* Multires Displacement Smear. */
954 
955  /* The rest is temporary storage that isn't saved as a property */
956 
957  bool first_time; /* Beginning of stroke may do some things special */
958 
959  /* from ED_view3d_ob_project_mat_get() */
960  float projection_mat[4][4];
961 
962  /* Clean this up! */
963  struct ViewContext *vc;
964  const struct Brush *brush;
965 
969 
970  /* screen-space rotation defined by mouse motion */
973  struct SculptRakeData rake_data;
974 
975  /* Face Sets */
977 
978  /* Symmetry index between 0 and 7 bit combo 0 is Brush only;
979  * 1 is X mirror; 2 is Y mirror; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
980  int symmetry;
981  int mirror_symmetry_pass; /* the symmetry pass we are currently on between 0 and 7*/
983  float view_normal[3];
984 
985  /* sculpt_normal gets calculated by calc_sculpt_normal(), then the
986  * sculpt_normal_symm gets updated quickly with the usual symmetry
987  * transforms */
988  float sculpt_normal[3];
990 
991  /* Used for area texture mode, local_mat gets calculated by
992  * calc_brush_local_mat() and used in tex_strength(). */
993  float brush_local_mat[4][4];
994 
995  float plane_offset[3]; /* used to shift the plane around when doing tiled strokes */
997 
998  float last_center[3];
1000  float symm_rot_mat[4][4];
1001  float symm_rot_mat_inv[4][4];
1002  bool original;
1004 
1005  /* Paint Brush. */
1006  struct {
1007  float hardness;
1008  float flow;
1009  float wet_mix;
1011  float density;
1013 
1014  /* Pose brush */
1016 
1017  /* Enhance Details. */
1019 
1020  /* Clay Thumb brush */
1021  /* Angle of the front tilting plane of the brush to simulate clay accumulation. */
1023  /* Stores pressure samples to get an stabilized strength and radius variation. */
1026 
1027  /* Cloth brush */
1031  float initial_normal[3];
1033 
1034  /* Boundary brush */
1036 
1037  /* Surface Smooth Brush */
1038  /* Stores the displacement produced by the laplacian step of HC smooth. */
1040 
1041  /* Layer brush */
1043 
1044  float vertex_rotation; /* amount to rotate the vertices when using rotate brush */
1045  struct Dial *dial;
1046 
1049  int saved_smooth_size; /* smooth tool copies the size of the current tool */
1051 
1053 
1057 
1058  /* Auto-masking. */
1060 
1061  float stroke_local_mat[4][4];
1063 
1066 
1067  rcti previous_r; /* previous redraw rectangle */
1068  rcti current_r; /* current redraw rectangle */
1069 
1071 
1072 /* Sculpt Filters */
1078 
1079 /* Defines how transform tools are going to apply its displacement. */
1081  /* Displaces the elements from their original coordinates. */
1083  /* Displaces the elements incrementally from their previous position. */
1086 
1087 void SCULPT_filter_to_orientation_space(float r_v[3], struct FilterCache *filter_cache);
1088 void SCULPT_filter_to_object_space(float r_v[3], struct FilterCache *filter_cache);
1089 void SCULPT_filter_zero_disabled_axis_components(float r_v[3], struct FilterCache *filter_cache);
1090 
1091 /* Sculpt Expand. */
1102 
1108 
1113 
1114 #define EXPAND_SYMM_AREAS 8
1115 
1116 typedef struct ExpandCache {
1117  /* Target data elements that the expand operation will affect. */
1119 
1120  /* Falloff data. */
1122 
1123  /* Indexed by vertex index, precalculated falloff value of that vertex (without any falloff
1124  * editing modification applied). */
1126  /* Max falloff value in *vert_falloff. */
1128 
1129  /* Indexed by base mesh poly index, precalculated falloff value of that face. These values are
1130  * calculated from the per vertex falloff (*vert_falloff) when needed. */
1133 
1134  /* Falloff value of the active element (vertex or base mesh face) that Expand will expand to. */
1136 
1137  /* When set to true, expand skips all falloff computations and considers all elements as enabled.
1138  */
1140 
1141  /* Initial mouse and cursor data from where the current falloff started. This data can be changed
1142  * during the execution of Expand by moving the origin. */
1144  float initial_mouse[2];
1147 
1148  /* Maximum number of vertices allowed in the SculptSession for previewing the falloff using
1149  * geodesic distances. */
1151 
1152  /* Original falloff type before starting the move operation. */
1154  /* Falloff type using when moving the origin for preview. */
1156 
1157  /* Face set ID that is going to be used when creating a new Face Set. */
1159 
1160  /* Face Set ID of the Face set selected for editing. */
1162 
1163  /* Mouse position since the last time the origin was moved. Used for reference when moving the
1164  * initial position of Expand. */
1166 
1167  /* Active components checks. */
1168  /* Indexed by symmetry pass index, contains the connected component ID found in
1169  * SculptSession->vertex_info.connected_component. Other connected components not found in this
1170  * array will be ignored by Expand. */
1172 
1173  /* Snapping. */
1174  /* GSet containing all Face Sets IDs that Expand will use to snap the new data. */
1176 
1177  /* Texture distortion data. */
1179  struct Scene *scene;
1180  struct MTex *mtex;
1181 
1182  /* Controls how much texture distortion will be applied to the current falloff */
1184 
1185  /* Cached PBVH nodes. This allows to skip gathering all nodes from the PBVH each time expand
1186  * needs to update the state of the elements. */
1188  int totnode;
1189 
1190  /* Expand state options. */
1191 
1192  /* Number of loops (times that the falloff is going to be repeated). */
1194 
1195  /* Invert the falloff result. */
1196  bool invert;
1197 
1198  /* When set to true, preserves the previous state of the data and adds the new one on top. */
1199  bool preserve;
1200 
1201  /* When set to true, the mask or colors will be applied as a gradient. */
1203 
1204  /* When set to true, Expand will use the Brush falloff curve data to shape the gradient. */
1206 
1207  /* When set to true, Expand will move the origin (initial active vertex and cursor position)
1208  * instead of updating the active vertex and active falloff. */
1209  bool move;
1210 
1211  /* When set to true, Expand will snap the new data to the Face Sets IDs found in
1212  * *original_face_sets. */
1213  bool snap;
1214 
1215  /* When set to true, Expand will use the current Face Set ID to modify an existing Face Set
1216  * instead of creating a new one. */
1218 
1219  /* When set to true, Expand will reposition the sculpt pivot to the boundary of the expand result
1220  * after finishing the operation. */
1222 
1223  /* Color target data type related data. */
1224  float fill_color[4];
1225  short blend_mode;
1226 
1227  /* Face Sets at the first step of the expand operation, before starting modifying the active
1228  * vertex and active falloff. These are not the original Face Sets of the sculpt before starting
1229  * the operator as they could have been modified by Expand when initializing the operator and
1230  * before starting changing the active vertex. These Face Sets are used for restoring and
1231  * checking the Face Sets state while the Expand operation modal runs. */
1233 
1234  /* Original data of the sculpt as it was before running the Expand operator. */
1239 
1240 typedef struct FilterCache {
1241  bool enabled_axis[3];
1244 
1245  /* Used for alternating between filter operations in filters that need to apply different ones to
1246  * achieve certain effects. */
1248 
1249  /* Stores the displacement produced by the laplacian step of HC smooth. */
1253 
1254  /* Sharpen mesh filter. */
1260 
1261  /* Filter orientation. */
1263  float obmat[4][4];
1264  float obmat_inv[4][4];
1265  float viewmat[4][4];
1266  float viewmat_inv[4][4];
1267 
1268  /* Displacement eraser. */
1270 
1271  /* unmasked nodes */
1273  int totnode;
1274 
1275  /* Cloth filter. */
1278 
1279  /* mask expand iteration caches */
1284  float *edge_factor;
1285  float *prev_mask;
1287 
1290 
1292 
1293  /* Transform. */
1295 
1296  /* Auto-masking. */
1299 
1301  const char symm,
1302  const char axis,
1303  const float angle);
1304 void SCULPT_cache_free(StrokeCache *cache);
1305 
1309 void SCULPT_undo_push_begin(struct Object *ob, const char *name);
1310 void SCULPT_undo_push_end(void);
1311 void SCULPT_undo_push_end_ex(const bool use_nested_undo);
1312 
1313 void SCULPT_vertcos_to_key(Object *ob, KeyBlock *kb, const float (*vertCos)[3]);
1314 
1315 void SCULPT_update_object_bounding_box(struct Object *ob);
1316 
1317 bool SCULPT_get_redraw_rect(struct ARegion *region,
1318  struct RegionView3D *rv3d,
1319  Object *ob,
1320  rcti *rect);
1321 
1322 /* Operators. */
1323 
1324 /* Expand. */
1325 void SCULPT_OT_expand(struct wmOperatorType *ot);
1326 void sculpt_expand_modal_keymap(struct wmKeyConfig *keyconf);
1327 
1328 /* Gestures. */
1331 
1334 
1336 
1337 /* Face Sets. */
1343 
1344 /* Transform. */
1346 
1347 /* Mesh Filter. */
1349 
1350 /* Cloth Filter. */
1352 
1353 /* Color Filter. */
1355 
1356 /* Mask filter and Dirty Mask. */
1358 void SCULPT_OT_dirty_mask(struct wmOperatorType *ot);
1359 
1360 /* Mask and Face Sets Expand. */
1362 
1363 /* Mask Init. */
1364 void SCULPT_OT_mask_init(struct wmOperatorType *ot);
1365 
1366 /* Detail size. */
1371 
1372 /* Dyntopo. */
typedef float(TangentPoint)[2]
#define PAINT_SYMM_AREAS
Definition: BKE_paint.h:126
ePaintSymmetryAreas
Definition: BKE_paint.h:120
A BVH for high poly meshes.
unsigned int BLI_bitmap
Definition: BLI_bitmap.h:32
#define BLI_INLINE
struct GSet GSet
Definition: BLI_ghash.h:189
unsigned int uint
Definition: BLI_sys_types.h:83
pthread_mutex_t ThreadMutex
Definition: BLI_threads.h:83
#define ELEM(...)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
#define MAX_ID_NAME
Definition: DNA_ID.h:269
eAutomasking_flag
@ BRUSH_DEFORM_TARGET_CLOTH_SIM
@ BRUSH_CLOTH_DEFORM_GRAB
@ BRUSH_CLOTH_DEFORM_SNAKE_HOOK
@ BRUSH_SNAKE_HOOK_DEFORM_ELASTIC
@ SCULPT_TOOL_CLOTH
@ SCULPT_TOOL_BOUNDARY
@ SCULPT_TOOL_POSE
@ SCULPT_TOOL_ELASTIC_DEFORM
@ SCULPT_TOOL_SNAKE_HOOK
These structs are the foundation for all linked lists in the library system.
ePaintSymmetryFlags
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
#define C
Definition: RandGen.cpp:39
ATTR_WARN_UNUSED_RESULT BMesh * bm
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
OperationNode * node
Scene scene
const Depsgraph * depsgraph
static CCL_NAMESPACE_BEGIN const double alpha
static float normals[][3]
IconTextureDrawCall normal
void SCULPT_OT_project_line_gesture(struct wmOperatorType *ot)
Definition: paint_mask.c:1784
void SCULPT_flush_stroke_deform(struct Sculpt *sd, Object *ob, bool is_proxy_used)
Definition: sculpt.c:6340
eSculptExpandFalloffType
@ SCULPT_EXPAND_FALLOFF_BOUNDARY_FACE_SET
@ SCULPT_EXPAND_FALLOFF_BOUNDARY_TOPOLOGY
@ SCULPT_EXPAND_FALLOFF_NORMALS
@ SCULPT_EXPAND_FALLOFF_SPHERICAL
@ SCULPT_EXPAND_FALLOFF_GEODESIC
@ SCULPT_EXPAND_FALLOFF_TOPOLOGY
@ SCULPT_EXPAND_FALLOFF_TOPOLOGY_DIAGONALS
@ SCULPT_EXPAND_FALLOFF_ACTIVE_FACE_SET
void SCULPT_OT_face_sets_init(struct wmOperatorType *ot)
bool SCULPT_brush_test_sphere(SculptBrushTest *test, const float co[3])
Definition: sculpt.c:1667
void SCULPT_undo_push_begin(struct Object *ob, const char *name)
Definition: sculpt_undo.c:1383
void SCULPT_cloth_brush_store_simulation_state(struct SculptSession *ss, struct SculptClothSimulation *cloth_sim)
void SCULPT_dynamic_topology_triangulate(struct BMesh *bm)
void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, PBVHVertexIter *iter)
Definition: sculpt.c:1310
bool SCULPT_get_redraw_rect(struct ARegion *region, struct RegionView3D *rv3d, Object *ob, rcti *rect)
Definition: sculpt.c:1573
void sculpt_dynamic_topology_disable_with_undo(struct Main *bmain, struct Depsgraph *depsgraph, Scene *scene, Object *ob)
void SCULPT_floodfill_add_and_skip_initial(SculptFloodFill *flood, int index)
Definition: sculpt.c:1099
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_visibility_sync_all_face_sets_to_vertices(struct Object *ob)
Definition: sculpt.c:563
struct SculptClothSimulation * SCULPT_cloth_brush_simulation_create(struct SculptSession *ss, const float cloth_mass, const float cloth_damping, const float cloth_softbody_strength, const bool use_collisions, const bool needs_deform_coords)
void SCULPT_filter_zero_disabled_axis_components(float r_v[3], struct FilterCache *filter_cache)
struct SculptVertexNeighborIter SculptVertexNeighborIter
void SCULPT_OT_dyntopo_detail_size_edit(struct wmOperatorType *ot)
void SCULPT_OT_trim_lasso_gesture(struct wmOperatorType *ot)
Definition: paint_mask.c:1742
void SCULPT_boundary_info_ensure(Object *object)
Definition: sculpt.c:9039
void SCULPT_vertcos_to_key(Object *ob, KeyBlock *kb, const float(*vertCos)[3])
Definition: sculpt.c:5763
void SCULPT_filter_to_orientation_space(float r_v[3], struct FilterCache *filter_cache)
void SCULPT_OT_mask_filter(struct wmOperatorType *ot)
PBVHNode ** SCULPT_cloth_brush_affected_nodes_gather(SculptSession *ss, Brush *brush, int *r_totnode)
Definition: sculpt_cloth.c:122
int SCULPT_active_vertex_get(SculptSession *ss)
Definition: sculpt.c:277
void SCULPT_do_smear_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
bool SCULPT_poll(struct bContext *C)
Definition: sculpt.c:6625
float * SCULPT_geodesic_distances_create(struct Object *ob, struct GSet *initial_vertices, const float limit_radius)
bool SCULPT_cursor_geometry_info_update(bContext *C, SculptCursorGeometryInfo *out, const float mouse[2], bool use_sampled_normal)
Definition: sculpt.c:7452
void SCULPT_filter_cache_init(struct bContext *C, Object *ob, Sculpt *sd, const int undo_type)
int SCULPT_plane_point_side(const float co[3], const float plane[4])
Definition: sculpt.c:4875
void SCULPT_OT_face_set_lasso_gesture(struct wmOperatorType *ot)
Definition: paint_mask.c:1706
void SCULPT_face_set_visibility_set(SculptSession *ss, int face_set, bool visible)
Definition: sculpt.c:382
float SCULPT_brush_strength_factor(struct SculptSession *ss, const struct Brush *br, const float point[3], const float len, const short vno[3], const float fno[3], const float mask, const int vertex_index, const int thread_id)
void SCULPT_floodfill_execute(struct SculptSession *ss, SculptFloodFill *flood, bool(*func)(SculptSession *ss, int from_v, int to_v, bool is_duplicate, void *userdata), void *userdata)
Definition: sculpt.c:1157
bool SCULPT_vertex_has_face_set(SculptSession *ss, int index, int face_set)
Definition: sculpt.c:539
void SCULPT_vertex_persistent_normal_get(SculptSession *ss, int index, float no[3])
Definition: sculpt.c:245
SculptUndoNode * SCULPT_undo_get_node(PBVHNode *node)
Definition: sculpt_undo.c:930
float * SCULPT_boundary_automasking_init(Object *ob, eBoundaryAutomaskMode mode, int propagation_steps, float *automask_factor)
bool SCULPT_mode_poll_view3d(struct bContext *C)
Definition: sculpt.c:6615
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)
Definition: sculpt.c:7412
void SCULPT_cloth_brush_ensure_nodes_constraints(struct Sculpt *sd, struct Object *ob, struct PBVHNode **nodes, int totnode, struct SculptClothSimulation *cloth_sim, float initial_location[3], const float radius)
void SCULPT_pose_brush_init(struct Sculpt *sd, struct Object *ob, struct SculptSession *ss, struct Brush *br)
Definition: sculpt_pose.c:980
bool SCULPT_vertex_has_unique_face_set(SculptSession *ss, int index)
Definition: sculpt.c:669
struct SculptUndoNodeGeometry SculptUndoNodeGeometry
void SCULPT_cache_calc_brushdata_symm(StrokeCache *cache, const char symm, const char axis, const float angle)
Definition: sculpt.c:6397
const float * SCULPT_brush_frontface_normal_from_falloff_shape(SculptSession *ss, char falloff_shape)
Definition: sculpt.c:1787
SculptBrushTestFn SCULPT_brush_test_init_with_falloff_shape(SculptSession *ss, SculptBrushTest *test, char falloff_shape)
Definition: sculpt.c:1770
void SCULPT_tilt_effective_normal_get(const SculptSession *ss, const Brush *brush, float r_no[3])
Definition: sculpt.c:2865
struct SculptUndoNode SculptUndoNode
void SCULPT_floodfill_init(struct SculptSession *ss, SculptFloodFill *flood)
Definition: sculpt.c:1085
bool SCULPT_vertex_any_face_set_visible_get(SculptSession *ss, int index)
Definition: sculpt.c:445
const float * SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, int index)
Definition: sculpt.c:207
void SCULPT_calc_brush_plane(struct Sculpt *sd, struct Object *ob, struct PBVHNode **nodes, int totnode, float r_area_no[3], float r_area_co[3])
Definition: sculpt.c:4228
const float * SCULPT_vertex_co_get(struct SculptSession *ss, int index)
Definition: sculpt.c:134
void SCULPT_multiplane_scrape_preview_draw(const uint gpuattr, Brush *brush, SculptSession *ss, const float outline_col[3], const float outline_alpha)
void SCULPT_vertex_face_set_set(SculptSession *ss, int index, int face_set)
Definition: sculpt.c:489
enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene *scene, Object *ob)
eSculptExpandRecursionType
@ SCULPT_EXPAND_RECURSION_GEODESICS
@ SCULPT_EXPAND_RECURSION_TOPOLOGY
bool SCULPT_brush_test_circle_sq(SculptBrushTest *test, const float co[3])
Definition: sculpt.c:1705
struct SculptThreadedTaskData SculptThreadedTaskData
BLI_INLINE bool SCULPT_is_cloth_deform_brush(const Brush *brush)
void SCULPT_floodfill_add_initial(SculptFloodFill *flood, int index)
Definition: sculpt.c:1094
void SCULPT_OT_mesh_filter(struct wmOperatorType *ot)
struct AutomaskingCache AutomaskingCache
void SCULPT_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode)
void SCULPT_boundary_edges_preview_draw(const uint gpuattr, struct SculptSession *ss, const float outline_col[3], const float outline_alpha)
bool SCULPT_is_symmetry_iteration_valid(char i, char symm)
Definition: sculpt.c:1042
void SCULPT_pbvh_clear(Object *ob)
void SCULPT_OT_set_pivot_position(struct wmOperatorType *ot)
void SCULPT_connected_components_ensure(Object *ob)
Definition: sculpt.c:9007
SculptFilterOrientation
@ SCULPT_FILTER_ORIENTATION_WORLD
@ SCULPT_FILTER_ORIENTATION_VIEW
@ SCULPT_FILTER_ORIENTATION_LOCAL
const float * SCULPT_active_vertex_co_get(SculptSession *ss)
Definition: sculpt.c:285
BLI_INLINE bool SCULPT_tool_needs_all_pbvh_nodes(const Brush *brush)
SculptTransformDisplacementMode
@ SCULPT_TRANSFORM_DISPLACEMENT_ORIGINAL
@ SCULPT_TRANSFORM_DISPLACEMENT_INCREMENTAL
bool SCULPT_stroke_get_location(struct bContext *C, float out[3], const float mouse[2])
Definition: sculpt.c:7584
void SCULPT_flush_update_done(const bContext *C, Object *ob, SculptUpdateType update_flags)
Definition: sculpt.c:7819
struct AutomaskingCache * SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, Object *ob)
void SCULPT_OT_dynamic_topology_toggle(struct wmOperatorType *ot)
bool SCULPT_brush_test_cube(SculptBrushTest *test, const float co[3], const float local[4][4], const float roundness)
Definition: sculpt.c:1723
bool SCULPT_search_sphere_cb(PBVHNode *node, void *data_v)
Definition: sculpt.c:2561
void SCULPT_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush)
Definition: sculpt.c:7327
void SCULPT_vertex_visible_set(SculptSession *ss, int index, bool visible)
Definition: sculpt.c:347
void SCULPT_filter_to_object_space(float r_v[3], struct FilterCache *filter_cache)
bool SCULPT_vertex_visible_get(SculptSession *ss, int index)
Definition: sculpt.c:362
void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible)
Definition: sculpt.c:418
float * SCULPT_brush_deform_target_vertex_co_get(SculptSession *ss, const int deform_target, PBVHVertexIter *iter)
Definition: sculpt.c:310
void sculpt_expand_modal_keymap(struct wmKeyConfig *keyconf)
void SCULPT_relax_vertex(struct SculptSession *ss, struct PBVHVertexIter *vd, float factor, bool filter_boundary_face_sets, float *r_final_pos)
Definition: sculpt.c:3506
void SCULPT_face_sets_visibility_invert(SculptSession *ss)
Definition: sculpt.c:404
int SCULPT_plane_trim(const struct StrokeCache *cache, const struct Brush *brush, const float val[3])
void SCULPT_do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags)
Definition: sculpt.c:7759
void SCULPT_orig_vert_data_unode_init(SculptOrigVertData *data, Object *ob, struct SculptUndoNode *unode)
Definition: sculpt.c:1277
void SCULPT_OT_expand(struct wmOperatorType *ot)
bool SCULPT_mode_poll(struct bContext *C)
Definition: sculpt.c:6601
void SCULPT_vertex_normal_get(SculptSession *ss, int index, float no[3])
Definition: sculpt.c:172
void SCULPT_neighbor_coords_average(SculptSession *ss, float result[3], int index)
bool SCULPT_stroke_is_first_brush_step(struct StrokeCache *cache)
Definition: sculpt.c:926
void SCULPT_visibility_sync_all_vertex_to_face_sets(struct SculptSession *ss)
Definition: sculpt.c:598
void SCULPT_vertex_limit_surface_get(SculptSession *ss, int index, float r_co[3])
Definition: sculpt.c:224
float SCULPT_neighbor_mask_average(SculptSession *ss, int index)
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_cloth_simulation_limits_draw(const uint gpuattr, const struct Brush *brush, const float location[3], const float normal[3], const float rds, const float line_width, const float outline_col[3], const float alpha)
bool SCULPT_stroke_is_dynamic_topology(const SculptSession *ss, const Brush *brush)
Definition: sculpt.c:1448
bool SCULPT_vertex_is_boundary(const SculptSession *ss, const int index)
Definition: sculpt.c:868
void SCULPT_flip_v3_by_symm_area(float v[3], const ePaintSymmetryFlags symm, const ePaintSymmetryAreas symmarea, const float pivot[3])
Definition: sculpt.c:4190
bool SCULPT_pbvh_calc_area_normal(const struct Brush *brush, Object *ob, PBVHNode **nodes, int totnode, bool use_threading, float r_area_no[3])
void SCULPT_smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, float bstrength, const bool smooth_mask)
void SCULPT_automasking_cache_free(struct AutomaskingCache *automasking)
void SCULPT_do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
bool SCULPT_poll_view3d(struct bContext *C)
Definition: sculpt.c:6620
bool(* SculptBrushTestFn)(SculptBrushTest *test, const float co[3])
float SCULPT_brush_plane_offset_get(Sculpt *sd, SculptSession *ss)
Definition: sculpt.c:4881
void SCULPT_floodfill_free(SculptFloodFill *flood)
Definition: sculpt.c:1188
void SCULPT_OT_set_detail_size(struct wmOperatorType *ot)
void SCULPT_undo_push_end_ex(const bool use_nested_undo)
Definition: sculpt_undo.c:1405
SculptUndoNode * SCULPT_undo_get_first_node(void)
Definition: sculpt_undo.c:941
#define SCULPT_CLAY_STABILIZER_LEN
void SCULPT_bmesh_four_neighbor_average(float avg[3], float direction[3], struct BMVert *v)
void SCULPT_fake_neighbors_enable(Object *ob)
Definition: sculpt.c:9099
void SCULPT_vertex_random_access_ensure(struct SculptSession *ss)
Definition: sculpt.c:112
void SCULPT_OT_face_sets_edit(struct wmOperatorType *ot)
void SCULPT_do_cloth_brush(struct Sculpt *sd, struct Object *ob, struct PBVHNode **nodes, int totnode)
SculptUpdateType
Definition: sculpt_intern.h:57
@ SCULPT_UPDATE_COLOR
Definition: sculpt_intern.h:61
@ SCULPT_UPDATE_MASK
Definition: sculpt_intern.h:59
@ SCULPT_UPDATE_VISIBILITY
Definition: sculpt_intern.h:60
@ SCULPT_UPDATE_COORDS
Definition: sculpt_intern.h:58
#define SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY
void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3])
Definition: sculpt.c:290
void SCULPT_update_object_bounding_box(struct Object *ob)
Definition: sculpt.c:7749
void SCULPT_do_pose_brush(struct Sculpt *sd, struct Object *ob, struct PBVHNode **nodes, int totnode)
Definition: sculpt_pose.c:1136
void SCULPT_mask_filter_smooth_apply(Sculpt *sd, Object *ob, PBVHNode **nodes, const int totnode, const int smooth_iterations)
void SCULPT_flip_quat_by_symm_area(float quat[3], const ePaintSymmetryFlags symm, const ePaintSymmetryAreas symmarea, const float pivot[3])
Definition: sculpt.c:4209
bool SCULPT_vertex_all_face_sets_visible_get(const SculptSession *ss, int index)
Definition: sculpt.c:465
void SCULPT_boundary_pivot_line_preview_draw(const uint gpuattr, struct SculptSession *ss)
const float * SCULPT_vertex_color_get(SculptSession *ss, int index)
Definition: sculpt.c:157
void SCULPT_dynamic_topology_enable_ex(struct Main *bmain, struct Depsgraph *depsgraph, Scene *scene, Object *ob)
void SCULPT_floodfill_add_initial_with_symmetry(struct Sculpt *sd, struct Object *ob, struct SculptSession *ss, SculptFloodFill *flood, int index, float radius)
Definition: sculpt.c:1105
void SCULPT_undo_push_end(void)
Definition: sculpt_undo.c:1400
void SCULPT_cloth_simulation_free(struct SculptClothSimulation *cloth_sim)
struct SculptBrushTest SculptBrushTest
bool SCULPT_is_automasking_mode_enabled(const Sculpt *sd, const Brush *br, const eAutomasking_flag mode)
eDynTopoWarnFlag
@ DYNTOPO_WARN_LDATA
@ DYNTOPO_WARN_MODIFIER
@ DYNTOPO_WARN_VDATA
@ DYNTOPO_WARN_EDATA
void SCULPT_do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
bool SCULPT_brush_test_sphere_sq(SculptBrushTest *test, const float co[3])
Definition: sculpt.c:1683
int SCULPT_vertex_face_set_get(SculptSession *ss, int index)
Definition: sculpt.c:514
void SCULPT_OT_face_set_box_gesture(struct wmOperatorType *ot)
Definition: paint_mask.c:1723
struct FilterCache FilterCache
struct AutomaskingCache * SCULPT_automasking_active_cache_get(SculptSession *ss)
SculptUndoNode * SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type)
Definition: sculpt_undo.c:1292
void SCULPT_fake_neighbors_disable(Object *ob)
Definition: sculpt.c:9106
struct AutomaskingSettings AutomaskingSettings
float * SCULPT_geodesic_from_vertex(Object *ob, const int vertex, const float limit_radius)
void SCULPT_OT_detail_flood_fill(struct wmOperatorType *ot)
struct SculptCursorGeometryInfo SculptCursorGeometryInfo
int SCULPT_face_set_next_available_get(SculptSession *ss)
Definition: sculpt.c:700
void SCULPT_neighbor_coords_average_interior(SculptSession *ss, float result[3], int index)
Definition: sculpt_smooth.c:65
void SCULPT_vertex_neighbors_get(struct SculptSession *ss, const int index, const bool include_duplicates, SculptVertexNeighborIter *iter)
Definition: sculpt.c:844
int SCULPT_nearest_vertex_get(struct Sculpt *sd, struct Object *ob, const float co[3], float max_distance, bool use_original)
Definition: sculpt.c:1000
struct SculptBoundary * SCULPT_boundary_data_init(Object *object, Brush *brush, const int initial_vertex, const float radius)
void SCULPT_cloth_brush_simulation_init(struct SculptSession *ss, struct SculptClothSimulation *cloth_sim)
void SCULPT_dyntopo_node_layers_add(struct SculptSession *ss)
void SCULPT_do_boundary_brush(struct Sculpt *sd, struct Object *ob, struct PBVHNode **nodes, int totnode)
char SCULPT_mesh_symmetry_xyz_get(Object *object)
Definition: sculpt.c:323
void SCULPT_neighbor_color_average(SculptSession *ss, float result[4], int index)
bool SCULPT_is_vertex_inside_brush_radius_symm(const float vertex[3], const float br_co[3], float radius, char symm)
Definition: sculpt.c:1048
void SCULPT_OT_face_sets_create(struct wmOperatorType *ot)
struct SculptPoseIKChain * SCULPT_pose_ik_chain_init(struct Sculpt *sd, struct Object *ob, struct SculptSession *ss, struct Brush *br, const float initial_location[3], const float radius)
Definition: sculpt_pose.c:945
void SCULPT_do_paint_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
void SCULPT_floodfill_add_active(struct Sculpt *sd, struct Object *ob, struct SculptSession *ss, SculptFloodFill *flood, float radius)
Definition: sculpt.c:1131
void SCULPT_filter_cache_free(SculptSession *ss)
bool SCULPT_stroke_is_first_brush_step_of_symmetry_pass(struct StrokeCache *cache)
Definition: sculpt.c:935
void SCULPT_geometry_preview_lines_update(bContext *C, struct SculptSession *ss, float radius)
Definition: sculpt.c:8605
bool SCULPT_search_circle_cb(PBVHNode *node, void *data_v)
Definition: sculpt.c:2608
void SCULPT_fake_neighbors_ensure(struct Sculpt *sd, Object *ob, const float max_dist)
Definition: sculpt.c:9070
eBoundaryAutomaskMode
@ AUTOMASK_INIT_BOUNDARY_EDGES
@ AUTOMASK_INIT_BOUNDARY_FACE_SETS
bool SCULPT_check_vertex_pivot_symmetry(const float vco[3], const float pco[3], const char symm)
Definition: sculpt.c:940
void SCULPT_cache_free(StrokeCache *cache)
Definition: sculpt.c:6708
void SCULPT_fake_neighbors_free(struct Object *ob)
Definition: sculpt.c:9113
float SCULPT_vertex_mask_get(struct SculptSession *ss, int index)
Definition: sculpt.c:254
void SCULPT_OT_face_sets_randomize_colors(struct wmOperatorType *ot)
void SCULPT_calc_area_normal(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float r_area_no[3])
Definition: sculpt.c:2197
struct StrokeCache StrokeCache
void SCULPT_OT_cloth_filter(struct wmOperatorType *ot)
bool SCULPT_vertex_colors_poll(struct bContext *C)
Definition: sculpt.c:6607
float SCULPT_automasking_factor_get(struct AutomaskingCache *automasking, SculptSession *ss, int vert)
void SCULPT_OT_sample_detail_size(struct wmOperatorType *ot)
const float * SCULPT_vertex_persistent_co_get(SculptSession *ss, int index)
Definition: sculpt.c:199
void SCULPT_OT_color_filter(struct wmOperatorType *ot)
float * SCULPT_geodesic_from_vertex_and_symm(struct Sculpt *sd, struct Object *ob, const int vertex, const float limit_radius)
void SCULPT_brush_test_init(struct SculptSession *ss, SculptBrushTest *test)
Definition: sculpt.c:1616
void SCULPT_OT_trim_box_gesture(struct wmOperatorType *ot)
Definition: paint_mask.c:1763
bool SCULPT_stroke_is_main_symmetry_pass(struct StrokeCache *cache)
Definition: sculpt.c:913
ePaintSymmetryAreas SCULPT_get_vertex_symm_area(const float co[3])
Definition: sculpt.c:4175
struct MVert * SCULPT_mesh_deformed_mverts_get(SculptSession *ss)
Definition: sculpt.c:295
void SCULPT_cloth_brush_do_simulation_step(struct Sculpt *sd, struct Object *ob, struct SculptClothSimulation *cloth_sim, struct PBVHNode **nodes, int totnode)
Definition: sculpt_cloth.c:927
bool SCULPT_is_automasking_enabled(const Sculpt *sd, const SculptSession *ss, const Brush *br)
#define EXPAND_SYMM_AREAS
void SCULPT_tilt_apply_to_normal(float r_normal[3], struct StrokeCache *cache, const float tilt_strength)
Definition: sculpt.c:2849
int SCULPT_active_face_set_get(SculptSession *ss)
Definition: sculpt.c:331
void SCULPT_boundary_data_free(struct SculptBoundary *boundary)
eSculptExpandTargetType
@ SCULPT_EXPAND_TARGET_COLORS
@ SCULPT_EXPAND_TARGET_FACE_SETS
@ SCULPT_EXPAND_TARGET_MASK
void SCULPT_cloth_plane_falloff_preview_draw(const uint gpuattr, struct SculptSession *ss, const float outline_col[3], float outline_alpha)
void SCULPT_OT_mask_init(struct wmOperatorType *ot)
void SCULPT_OT_dirty_mask(struct wmOperatorType *ot)
void SCULPT_do_draw_face_sets_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
int SCULPT_vertex_count_get(struct SculptSession *ss)
Definition: sculpt.c:120
struct ExpandCache ExpandCache
void SCULPT_clip(Sculpt *sd, SculptSession *ss, float co[3], const float val[3])
Definition: sculpt.c:2638
void SCULPT_OT_face_sets_change_visibility(struct wmOperatorType *ot)
void SCULPT_orig_vert_data_init(SculptOrigVertData *data, Object *ob, PBVHNode *node)
Definition: sculpt.c:1300
void SCULPT_pose_ik_chain_free(struct SculptPoseIKChain *ik_chain)
Definition: sculpt_pose.c:1233
SculptUndoType
@ SCULPT_UNDO_GEOMETRY
@ SCULPT_UNDO_FACE_SETS
@ SCULPT_UNDO_COORDS
@ SCULPT_UNDO_HIDDEN
@ SCULPT_UNDO_DYNTOPO_SYMMETRIZE
@ SCULPT_UNDO_COLOR
@ SCULPT_UNDO_DYNTOPO_END
@ SCULPT_UNDO_DYNTOPO_BEGIN
@ SCULPT_UNDO_MASK
void SCULPT_cloth_sim_activate_nodes(struct SculptClothSimulation *cloth_sim, PBVHNode **nodes, int totnode)
void SCULPT_tag_update_overlays(bContext *C)
Definition: sculpt.c:1066
bool SCULPT_brush_test_sphere_fast(const SculptBrushTest *test, const float co[3])
Definition: sculpt.c:1697
void SCULPT_OT_mask_expand(struct wmOperatorType *ot)
void SCULPT_pose_calc_pose_data(struct Sculpt *sd, struct Object *ob, struct SculptSession *ss, float initial_location[3], float radius, float pose_offset, float *r_pose_origin, float *r_pose_factor)
Definition: sculpt_pose.c:550
AutomaskingSettings settings
int cloth_deform_type
int snake_hook_deform_type
char sculpt_tool
int deform_target
eSculptExpandFalloffType falloff_type
float active_falloff
int * initial_face_sets
int * original_face_sets
float * vert_falloff
eSculptExpandFalloffType move_original_falloff_type
int max_geodesic_move_preview
float initial_mouse[2]
int initial_active_vertex
float texture_distortion_strength
int initial_active_face_set
bool reposition_pivot
eSculptExpandTargetType target
float max_vert_falloff
GSet * snap_enabled_face_sets
float * face_falloff
float * original_mask
bool falloff_gradient
float initial_mouse_move[2]
eSculptExpandFalloffType move_preview_falloff_type
bool modify_active_face_set
struct Scene * scene
float(* original_colors)[4]
struct MTex * mtex
int active_connected_components[EXPAND_SYMM_AREAS]
float max_face_falloff
float fill_color[4]
PBVHNode ** nodes
float original_mouse_move[2]
float surface_smooth_current_vertex
float(* detail_directions)[3]
float * edge_factor
float * prev_mask
int * mask_update_it
SculptTransformDisplacementMode transform_displacement_mode
AutomaskingCache * automasking
SculptFilterOrientation orientation
float * normal_factor
int * prev_face_set
float viewmat_inv[4][4]
float * sharpen_factor
float viewmat[4][4]
float cloth_sim_pinch_point[3]
int sharpen_curvature_smooth_iterations
float obmat[4][4]
int mask_update_last_it
float(* surface_smooth_laplacian_disp)[3]
bool enabled_axis[3]
float sharpen_smooth_ratio
PBVHNode ** nodes
float(* limit_surface_co)[3]
float mask_expand_initial_co[3]
float sharpen_intensify_detail_strength
SculptClothSimulation * cloth_sim
float surface_smooth_shape_preservation
float obmat_inv[4][4]
int mask_update_current_it
bool enabled_force_axis[3]
Definition: BKE_main.h:116
int initial_vertex
Definition: BKE_paint.h:398
struct RegionView3D * clip_rv3d
float plane_view[4]
float plane_tool[4]
float symm_rot_mat_inv[4][4]
BLI_bitmap * visited_vertices
const float * co
struct SculptUndoNode * unode
struct BMLog * bm_log
const float * vmasks
const float * col
const short * no
float follow_co[3]
struct Sculpt * sd
struct SculptSession * ss
struct DistRayAABB_Precalc * dist_ray_to_aabb_precalc
struct Sculpt * sd
struct SculptSession * ss
const struct Brush * brush
SculptClothSimulation * cloth_sim
struct Sculpt * sd
struct WPaintData * wpd
struct Object * ob
struct VPaintData * vpd
float nearest_vertex_search_co[3]
struct SculptProjectVector * spvc
struct PBVHNode ** nodes
float * cloth_sim_initial_location
struct VPaint * vp
struct WeightPaintInfo * wpi
float multiplane_scrape_planes[2][4]
float transform_mats[8][4][4]
struct bContext * C
float(* col)[4]
struct BMLogEntry * bm_entry
struct SculptUndoNode * prev
bool geometry_clear_pbvh
BLI_bitmap * vert_hidden
float(* co)[3]
BLI_bitmap ** grid_hidden
char idname[MAX_ID_NAME]
SculptUndoNodeGeometry geometry_modified
SculptUndoNodeGeometry geometry_bmesh_enter
char shapeName[sizeof(((KeyBlock *) 0)) ->name]
short(* no)[3]
float(* orig_co)[3]
SculptUndoNodeGeometry geometry_original
SculptUndoType type
struct SculptUndoNode * next
float pivot_rot[4]
float pivot_pos[3]
int neighbors_fixed[SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY]
float wet_mix_prev_color[4]
float orig_grab_location[3]
float old_grab_location[3]
float true_location[3]
float initial_radius
float initial_mouse[2]
const struct Brush * brush
float sculpt_normal[3]
float brush_local_mat[4][4]
float special_rotation
float mouse[2]
float symm_rot_mat_inv[4][4]
float scale[3]
float plane_offset[3]
float initial_location[3]
float clip_mirror_mtx[4][4]
float true_view_normal[3]
float radius_squared
float projection_mat[4][4]
float last_location[3]
float anchored_location[3]
float clip_tolerance[3]
float initial_normal[3]
char saved_active_brush_name[MAX_ID_NAME]
int mirror_symmetry_pass
float density_seed
struct SculptPoseIKChain * pose_ik_chain
float view_normal[3]
struct SculptBoundary * boundaries[PAINT_SYMM_AREAS]
float rake_rotation[4]
struct ViewContext * vc
float sculpt_normal_symm[3]
float(* limit_surface_co)[3]
struct SculptRakeData rake_data
float(* surface_smooth_laplacian_disp)[3]
float true_initial_location[3]
float last_center[3]
float multiplane_scrape_angle
float grab_delta_symmetry[3]
float location[3]
AutomaskingCache * automasking
float stroke_local_mat[4][4]
struct SculptClothSimulation * cloth_sim
int radial_symmetry_pass
float true_last_location[3]
float true_initial_normal[3]
struct StrokeCache::@489 paint_brush
struct Dial * dial
float(* prev_displacement)[3]
bool is_rake_rotation_valid
float gravity_direction[3]
float plane_trim_squared
float normal_weight
float vertex_rotation
float(* detail_directions)[3]
float true_gravity_direction[3]
float mouse_event[2]
float * layer_displacement_factor
char saved_mask_brush_tool
float clay_pressure_stabilizer[SCULPT_CLAY_STABILIZER_LEN]
float(* prev_colors)[4]
int clay_pressure_stabilizer_index
float wet_persistence
float clay_thumb_front_angle
bool supports_gravity
bool is_last_valid
float rake_rotation_symmetry[4]
float grab_delta[3]
float symm_rot_mat[4][4]
float dyntopo_pixel_radius
CCL_NAMESPACE_BEGIN ccl_device float fade(float t)
Definition: svm_noise.h:37
ccl_device_inline float beta(float x, float y)
Definition: util_math.h:666
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
uint len
wmOperatorType * ot
Definition: wm_files.c:3156