Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606@gmail.com>2020-02-28 16:40:40 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-02-28 19:03:20 +0300
commit4a373afa5fb8f9eab92314fac1b140b7803f30fe (patch)
treeb546d18088f5c61441e770eae4e8c6e12a4d3ed9 /source/blender/editors/sculpt_paint/sculpt_intern.h
parent793135e190c7450d30451617e9b8ae2d5ecec94a (diff)
Sculpt: Cloth brush
This brush has a simple physics solver that helps when sculpting cloth. - The mass and the damping properties of the simulation are properties of the brush. - It has two additional radius control to limit the influence and falloff of the simulation. - Masked vertices are pinned in the simulation, and it applies the sculpt gravity directly in the solver. - The Cloth Brush has 7 deformation modes with 2 falloff types (radial and plane). The brush can create the constraints only on the required PBVH nodes, so the simulation is isolated on high poly meshes. As long as the brush size is not too big it should be possible to keep it real time. Known issues: - The way constraints are created is extremely basic and it creates repeated constraints. Maybe there is another way to create fewer constraints while keeping the simulation quality decent. This part can also be multithreaded. (As it is it works ok, but it could be better) Reviewed By: jbakker Differential Revision: https://developer.blender.org/D6715
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_intern.h')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 8302e119ddb..c67096c2dff 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -85,13 +85,92 @@ struct SculptPoseIKChain *sculpt_pose_ik_chain_init(struct Sculpt *sd,
void sculpt_pose_ik_chain_free(struct SculptPoseIKChain *ik_chain);
/* Sculpt PBVH abstraction API */
+int sculpt_vertex_count_get(struct SculptSession *ss);
const float *sculpt_vertex_co_get(struct SculptSession *ss, int index);
+float sculpt_vertex_mask_get(struct SculptSession *ss, int index);
+
+#define SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY 256
+typedef struct SculptVertexNeighborIter {
+ /* Storage */
+ int *neighbors;
+ int size;
+ int capacity;
+ int neighbors_fixed[SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY];
+
+ /* Internal iterator. */
+ int num_duplicates;
+ int i;
+
+ /* Public */
+ int index;
+ bool is_duplicate;
+} SculptVertexNeighborIter;
+
+void sculpt_vertex_neighbors_get(struct SculptSession *ss,
+ const int index,
+ const bool include_duplicates,
+ SculptVertexNeighborIter *iter);
+
+/* Iterator over neighboring vertices. */
+#define sculpt_vertex_neighbors_iter_begin(ss, v_index, neighbor_iterator) \
+ sculpt_vertex_neighbors_get(ss, v_index, false, &neighbor_iterator); \
+ for (neighbor_iterator.i = 0; neighbor_iterator.i < neighbor_iterator.size; \
+ neighbor_iterator.i++) { \
+ neighbor_iterator.index = ni.neighbors[ni.i];
+
+/* Iterate over neighboring and duplicate vertices (for PBVH_GRIDS). Duplicates come
+ * first since they are nearest for floodfill. */
+#define sculpt_vertex_duplicates_and_neighbors_iter_begin(ss, v_index, neighbor_iterator) \
+ sculpt_vertex_neighbors_get(ss, v_index, true, &neighbor_iterator); \
+ for (neighbor_iterator.i = neighbor_iterator.size - 1; neighbor_iterator.i >= 0; \
+ neighbor_iterator.i--) { \
+ neighbor_iterator.index = ni.neighbors[ni.i]; \
+ neighbor_iterator.is_duplicate = (ni.i >= \
+ neighbor_iterator.size - neighbor_iterator.num_duplicates);
+
+#define sculpt_vertex_neighbors_iter_end(neighbor_iterator) \
+ } \
+ if (neighbor_iterator.neighbors != neighbor_iterator.neighbors_fixed) { \
+ MEM_freeN(neighbor_iterator.neighbors); \
+ } \
+ ((void)0)
/* 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,
+ struct PBVHNode **nodes,
+ int totnode,
+ float r_area_no[3],
+ float r_area_co[3]);
+
+/* Brushes. */
+
+/* Cloth Brush. */
+void SCULPT_do_cloth_brush(struct Sculpt *sd,
+ struct Object *ob,
+ struct PBVHNode **nodes,
+ int totnode);
+void SCULPT_cloth_simulation_free(struct SculptClothSimulation *cloth_sim);
+
+void SCULPT_cloth_simulation_limits_draw(const uint gpuattr,
+ const struct Brush *brush,
+ const float obmat[4][4],
+ const float location[3],
+ const float normal[3],
+ const float rds,
+ const float line_width,
+ const float outline_col[3],
+ const float alpha);
+void SCULPT_cloth_plane_falloff_preview_draw(const uint gpuattr,
+ struct SculptSession *ss,
+ const float outline_col[3],
+ float outline_alpha);
+
/* Undo */
typedef enum {
@@ -242,6 +321,8 @@ typedef struct SculptThreadedTaskData {
float transform_mats[8][4][4];
+ float cloth_time_step;
+
float dirty_mask_min;
float dirty_mask_max;
bool dirty_mask_dirty_only;
@@ -416,6 +497,13 @@ typedef struct StrokeCache {
float clay_pressure_stabilizer[CLAY_STABILIZER_LEN];
int clay_pressure_stabilizer_index;
+ /* Cloth brush */
+ struct SculptClothSimulation *cloth_sim;
+ float initial_location[3];
+ float true_initial_location[3];
+ float initial_normal[3];
+ float true_initial_normal[3];
+
float vertex_rotation; /* amount to rotate the vertices when using rotate brush */
struct Dial *dial;