Sculpt: add new bending constraint to cloth filter
This commit is contained in:
parent
3083e3fd26
commit
6c16801001
|
@ -1383,6 +1383,8 @@ class _defs_sculpt:
|
|||
layout.prop(props, "cloth_damping")
|
||||
layout.prop(props, "use_face_sets")
|
||||
layout.prop(props, "use_collisions")
|
||||
layout.prop(props, "use_bending")
|
||||
layout.prop(props, "bending_stiffness")
|
||||
|
||||
return dict(idname="builtin.cloth_filter",
|
||||
label="Cloth Filter",
|
||||
|
|
|
@ -3945,7 +3945,7 @@ static void pbvh_bmesh_collapse_edge(PBVH *pbvh,
|
|||
float(*uv)[2] = alloca(sizeof(float) * 4 * totuv);
|
||||
|
||||
do {
|
||||
BMLoop *ls2[2] = {l->head.data, l->next->head.data};
|
||||
const void *ls2[2] = {l->head.data, l->next->head.data};
|
||||
float ws2[2] = {0.5f, 0.5f};
|
||||
|
||||
if (!snap) {
|
||||
|
@ -4640,10 +4640,16 @@ static void pbvh_bmesh_collapse_edge1(PBVH *pbvh,
|
|||
else {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (BM_edge_is_wire(e_tri[j])) {
|
||||
v_conn ? validate_vert_faces(pbvh, pbvh->bm, v_conn, false, false) : NULL;
|
||||
if (v_conn) {
|
||||
validate_vert_faces(pbvh, pbvh->bm, v_conn, false, false);
|
||||
}
|
||||
|
||||
BM_log_edge_removed(pbvh->bm_log, e_tri[j]);
|
||||
BM_edge_kill(pbvh->bm, e_tri[j]);
|
||||
v_conn ? validate_vert_faces(pbvh, pbvh->bm, v_conn, false, false) : NULL;
|
||||
|
||||
if (v_conn) {
|
||||
validate_vert_faces(pbvh, pbvh->bm, v_conn, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5133,8 +5139,7 @@ cleanup_valence_3_4(EdgeQueueContext *ectx,
|
|||
int ni2 = BM_ELEM_CD_GET_INT(f, pbvh->cd_face_node_offset);
|
||||
|
||||
if (ni2 != DYNTOPO_NODE_NONE) {
|
||||
PBVHNode *node2 = pbvh->nodes + ni2;
|
||||
|
||||
// PBVHNode *node2 = pbvh->nodes + ni2;
|
||||
// BLI_table_gset_remove(node2->bm_unique_verts, v, NULL);
|
||||
|
||||
pbvh_bmesh_face_remove(pbvh, f, true, true, true);
|
||||
|
@ -5344,7 +5349,6 @@ static void on_vert_swap(BMVert *v1, BMVert *v2, void *userdata)
|
|||
{
|
||||
SwapData *sdata = (SwapData *)userdata;
|
||||
PBVH *pbvh = sdata->pbvh;
|
||||
BMesh *bm = pbvh->bm;
|
||||
|
||||
MSculptVert *mv1 = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v1);
|
||||
MSculptVert *mv2 = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v2);
|
||||
|
@ -5818,7 +5822,6 @@ typedef struct EdgeQueueContext {
|
|||
|
||||
/* clear PBVH_UpdateTopology flags */
|
||||
for (int i = 0; i < pbvh->totnode; i++) {
|
||||
BMVert *v;
|
||||
PBVHNode *node = pbvh->nodes + i;
|
||||
|
||||
if (!(node->flag & PBVH_Leaf)) {
|
||||
|
@ -6273,8 +6276,6 @@ static void pbvh_split_edges(EdgeQueueContext *eq_ctx,
|
|||
node->flag |= node_updateflag;
|
||||
|
||||
BLI_table_gset_add(node->bm_unique_verts, newv);
|
||||
BMIter iter;
|
||||
BMFace *f;
|
||||
|
||||
BM_ELEM_CD_SET_INT(newv, pbvh->cd_vert_node_offset, ni);
|
||||
// BM_ELEM_CD_SET_INT(newv, pbvh->cd_vert_node_offset, -1);
|
||||
|
@ -6314,7 +6315,7 @@ static void pbvh_split_edges(EdgeQueueContext *eq_ctx,
|
|||
|
||||
int flen = j;
|
||||
|
||||
if (mask >= ARRAY_SIZE(splitmap)) {
|
||||
if (mask >= (int)ARRAY_SIZE(splitmap)) {
|
||||
printf("splitmap error!\n");
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -288,7 +288,7 @@ int SCULPT_vertex_count_get(const SculptSession *ss)
|
|||
return 0;
|
||||
}
|
||||
|
||||
MSculptVert *SCULPT_vertex_get_mdyntopo(SculptSession *ss, SculptVertRef vertex)
|
||||
MSculptVert *SCULPT_vertex_get_mdyntopo(const SculptSession *ss, SculptVertRef vertex)
|
||||
{
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_BMESH: {
|
||||
|
@ -2067,7 +2067,7 @@ static bool neighbor_cache_begin(const SculptSession *ss)
|
|||
ncache->totvert = totvert;
|
||||
NeighborCache *old = ss->cache->ncache;
|
||||
|
||||
atomic_cas_ptr(&ss->cache->ncache, NULL, ncache);
|
||||
atomic_cas_ptr((void **)&ss->cache->ncache, NULL, ncache);
|
||||
|
||||
if (ss->cache->ncache != ncache) {
|
||||
// another thread got here first?
|
||||
|
@ -2138,7 +2138,7 @@ static NeighborCacheItem *neighbor_cache_get(const SculptSession *ss,
|
|||
// another thread got here first
|
||||
//}
|
||||
|
||||
atomic_cas_ptr(&cache[i], NULL, item);
|
||||
atomic_cas_ptr((void **)&cache[i], NULL, item);
|
||||
}
|
||||
|
||||
return cache[i];
|
||||
|
|
|
@ -754,7 +754,7 @@ static void cloth_brush_add_deformation_constraint(SculptClothSimulation *cloth_
|
|||
cloth_brush_reallocate_constraints(cloth_sim);
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static void do_cloth_brush_build_constraints_task_cb_ex(
|
||||
static void do_cloth_brush_build_constraints_task_cb_ex(
|
||||
void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
{
|
||||
SculptThreadedTaskData *data = userdata;
|
||||
|
@ -1617,6 +1617,8 @@ static void do_cloth_brush_solve_simulation_task_cb_ex(
|
|||
|
||||
static void cloth_free_tasks(SculptClothSimulation *cloth_sim)
|
||||
{
|
||||
// printf("Freeing tasks %d\n", BLI_task_parallel_thread_id(NULL));
|
||||
|
||||
for (int i = 0; i < cloth_sim->tot_constraint_tasks; i++) {
|
||||
for (int j = 0; j < TOT_CONSTRAINT_TYPES; j++) {
|
||||
MEM_SAFE_FREE(cloth_sim->constraint_tasks[i].constraints[j]);
|
||||
|
@ -1760,11 +1762,11 @@ static void cloth_sort_constraints_for_tasks(SculptSession *ss,
|
|||
MEM_SAFE_FREE(vthreads);
|
||||
}
|
||||
|
||||
ATTR_NO_OPT static void cloth_brush_satisfy_constraints_intern(SculptSession *ss,
|
||||
Brush *brush,
|
||||
SculptClothSimulation *cloth_sim,
|
||||
SculptClothTaskData *task,
|
||||
bool no_boundary)
|
||||
static void cloth_brush_satisfy_constraints_intern(SculptSession *ss,
|
||||
Brush *brush,
|
||||
SculptClothSimulation *cloth_sim,
|
||||
SculptClothTaskData *task,
|
||||
bool no_boundary)
|
||||
{
|
||||
|
||||
AutomaskingCache *automasking = SCULPT_automasking_active_cache_get(ss);
|
||||
|
@ -2771,6 +2773,7 @@ static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent
|
|||
const float cloth_damping = RNA_float_get(op->ptr, "cloth_damping");
|
||||
const bool use_collisions = RNA_boolean_get(op->ptr, "use_collisions");
|
||||
const int pinch_origin = RNA_enum_get(op->ptr, "pinch_origin");
|
||||
|
||||
ss->filter_cache->cloth_sim = SCULPT_cloth_brush_simulation_create(
|
||||
ss,
|
||||
cloth_mass,
|
||||
|
@ -2779,6 +2782,9 @@ static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent
|
|||
use_collisions,
|
||||
cloth_filter_is_deformation_filter(filter_type));
|
||||
|
||||
ss->filter_cache->cloth_sim->use_bending = RNA_boolean_get(op->ptr, "use_bending");
|
||||
ss->filter_cache->cloth_sim->bend_stiffness = RNA_float_get(op->ptr, "bending_stiffness");
|
||||
|
||||
switch (pinch_origin) {
|
||||
case CLOTH_FILTER_PINCH_ORIGIN_CURSOR:
|
||||
copy_v3_v3(ss->filter_cache->cloth_sim_pinch_point, SCULPT_active_vertex_co_get(ss));
|
||||
|
@ -2889,4 +2895,8 @@ void SCULPT_OT_cloth_filter(struct wmOperatorType *ot)
|
|||
false,
|
||||
"Use Collisions",
|
||||
"Collide with other collider objects in the scene");
|
||||
ot->prop = RNA_def_boolean(
|
||||
ot->srna, "use_bending", false, "Bending", "Enable bending constraints");
|
||||
ot->prop = RNA_def_float(
|
||||
ot->srna, "bending_stiffness", 0.5f, 0.0f, 1.0f, "Bending Stiffness", "", 0.0f, 1.0f);
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ float *SCULPT_vertex_origco_get(SculptSession *ss, SculptVertRef vertex);
|
|||
float *SCULPT_vertex_origno_get(SculptSession *ss, SculptVertRef vertex);
|
||||
|
||||
void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]);
|
||||
MSculptVert *SCULPT_vertex_get_mdyntopo(SculptSession *ss, SculptVertRef vertex);
|
||||
MSculptVert *SCULPT_vertex_get_mdyntopo(const SculptSession *ss, SculptVertRef vertex);
|
||||
|
||||
/* Returns PBVH deformed vertices array if shape keys or deform modifiers are used, otherwise
|
||||
* returns mesh original vertices array. */
|
||||
|
|
Loading…
Reference in New Issue