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-08-18 14:27:58 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-08-18 14:28:37 +0300
commit4814836120e50cce4a23e037a9bbb6a1e53de890 (patch)
treeb2df8d63398e454e11a85dce9a68636e239879e9 /source/blender/editors/sculpt_paint/sculpt_cloth.c
parent976f0113e008b4ff2d96760b0e83d5466dda8c54 (diff)
Sculpt: Option to limit the forces axis in the Cloth Filter
This uses the same concept of the Mesh Filter but for applying the cloth filter forces, so now it can be limited to a specific axis. Reviewed By: sergey Differential Revision: https://developer.blender.org/D8567
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_cloth.c')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_cloth.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index bdc7d7520ea..080124d2445 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -1060,6 +1060,19 @@ static EnumPropertyItem prop_cloth_filter_type[] = {
{0, NULL, 0, NULL, NULL},
};
+typedef enum eClothFilterForceAxis {
+ CLOTH_FILTER_FORCE_X = 1 << 0,
+ CLOTH_FILTER_FORCE_Y = 1 << 1,
+ CLOTH_FILTER_FORCE_Z = 1 << 2,
+} eClothFilterForceAxis;
+
+static EnumPropertyItem prop_cloth_filter_force_axis_items[] = {
+ {CLOTH_FILTER_FORCE_X, "X", 0, "X", "Apply force in the X axis"},
+ {CLOTH_FILTER_FORCE_Y, "Y", 0, "Y", "Apply force in the Y axis"},
+ {CLOTH_FILTER_FORCE_Z, "Z", 0, "Z", "Apply force in the Z axis"},
+ {0, NULL, 0, NULL, NULL},
+};
+
static void cloth_filter_apply_forces_task_cb(void *__restrict userdata,
const int i,
const TaskParallelTLS *__restrict UNUSED(tls))
@@ -1114,6 +1127,12 @@ static void cloth_filter_apply_forces_task_cb(void *__restrict userdata,
break;
}
+ for (int axis = 0; axis < 3; axis++) {
+ if (!ss->filter_cache->enabled_force_axis[axis]) {
+ force[axis] = 0.0f;
+ }
+ }
+
add_v3_v3(force, sculpt_gravity);
cloth_brush_apply_force_to_vertex(ss, cloth_sim, force, vd.index);
@@ -1229,6 +1248,11 @@ static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent
ss->filter_cache->active_face_set = SCULPT_FACE_SET_NONE;
}
+ const int force_axis = RNA_enum_get(op->ptr, "force_axis");
+ ss->filter_cache->enabled_force_axis[0] = force_axis & CLOTH_FILTER_FORCE_X;
+ ss->filter_cache->enabled_force_axis[1] = force_axis & CLOTH_FILTER_FORCE_Y;
+ ss->filter_cache->enabled_force_axis[2] = force_axis & CLOTH_FILTER_FORCE_Z;
+
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
}
@@ -1256,6 +1280,12 @@ void SCULPT_OT_cloth_filter(struct wmOperatorType *ot)
"Operation that is going to be applied to the mesh");
RNA_def_float(
ot->srna, "strength", 1.0f, -10.0f, 10.0f, "Strength", "Filter Strength", -10.0f, 10.0f);
+ RNA_def_enum_flag(ot->srna,
+ "force_axis",
+ prop_cloth_filter_force_axis_items,
+ CLOTH_FILTER_FORCE_X | CLOTH_FILTER_FORCE_Y | CLOTH_FILTER_FORCE_Z,
+ "Force axis",
+ "Apply the force in the selected axis");
RNA_def_float(ot->srna,
"cloth_mass",
1.0f,