106 indices.reserve(grid_verts_num);
110 [&](
const int offset) {
indices.append(start + offset); });
137 for (
const int i :
verts.index_range()) {
138 r_offset_data[
i] = r_data.
size();
148 r_offset_data.
last() = r_data.
size();
162 for (
const int i :
verts.index_range()) {
163 r_offset_data[
i] = r_data.
size();
169 r_offset_data.
last() = r_data.
size();
175 if (!ss.
cache || !brush) {
253 float p = 1.0f - ((
distance - falloff) / (limit - falloff));
254 return 3.0f * p * p - 2.0f * p * p * p;
270#define CLOTH_LENGTH_CONSTRAINTS_BLOCK 100000
271#define CLOTH_SIMULATION_ITERATIONS 5
273#define CLOTH_SOLVER_DISPLACEMENT_FACTOR 0.6f
274#define CLOTH_MAX_CONSTRAINTS_PER_VERTEX 1024
275#define CLOTH_SIMULATION_TIME_STEP 0.01f
276#define CLOTH_DEFORMATION_SNAKEHOOK_STRENGTH 0.35f
277#define CLOTH_DEFORMATION_TARGET_STRENGTH 0.01f
278#define CLOTH_DEFORMATION_GRAB_STRENGTH 0.1f
281 const int node_index,
291 length_constraint.
node = node_index;
305 const int node_index,
307 const float strength)
314 length_constraint.
node = node_index;
321 length_constraint.
length = 0.0f;
322 length_constraint.
strength = strength;
328 const int node_index,
330 const float strength)
337 length_constraint.
node = node_index;
344 length_constraint.
length = 0.0f;
345 length_constraint.
strength = strength;
351 const int node_index,
353 const float strength)
360 length_constraint.
node = node_index;
367 length_constraint.
length = 0.0f;
368 length_constraint.
strength = strength;
375 const float3 &cloth_sim_initial_location,
376 const float cloth_sim_radius,
378 const int node_index,
386 const bool is_brush_has_stroke_cache = ss.
cache !=
nullptr && brush !=
nullptr;
387 const bool pin_simulation_boundary = is_brush_has_stroke_cache &&
398 float radius_squared = 0.0f;
399 if (cloth_is_deform_brush) {
406 cloth_sim_radius * cloth_sim_radius :
409 for (
const int i :
verts.index_range()) {
410 const int vert =
verts[
i];
412 cloth_sim_initial_location);
418 const Span<int> neighbors = vert_neighbors[
i];
424 for (
const int neighbor : neighbors) {
425 if (created_length_constraints.
add({vert, neighbor})) {
429 for (
const int a : neighbors) {
430 for (
const int b : neighbors) {
432 if (created_length_constraints.
add({a, b})) {
444 if (use_falloff_plane) {
474 if (pin_simulation_boundary) {
478 if (sim_falloff < 1.0f) {
491 const float3 &initial_location,
508 switch (pbvh.
type()) {
512 node_mask,
GrainSize(1024), memory, [&](
const int i) {
516 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
529 persistent_position = *attributes.
lookup<
float3>(
".sculpt_persistent_co",
532 if (persistent_position.
is_empty()) {
533 init_positions = cloth_sim.
init_pos;
536 init_positions = persistent_position;
538 uninitialized_nodes.foreach_index([&](
const int i) {
556 created_length_constraints);
563 node_mask,
GrainSize(1024), memory, [&](
const int i) {
573 const std::optional<PersistentMultiresData> persistent_multires_data =
576 persistent_position = persistent_multires_data->positions;
578 if (persistent_position.
is_empty()) {
579 init_positions = cloth_sim.
init_pos;
582 init_positions = persistent_position;
584 uninitialized_nodes.foreach_index([&](
const int i) {
586 key, grid_hidden,
nodes[
i].grids(), vert_indices);
588 subdiv_ccg,
verts, neighbor_offsets, neighbor_data);
598 created_length_constraints);
605 node_mask,
GrainSize(1024), memory, [&](
const int i) {
611 uninitialized_nodes.foreach_index([&](
const int i) {
615 bm,
verts, neighbor_offsets, neighbor_data);
625 created_length_constraints);
637 for (
const int i :
verts.index_range()) {
647 for (
const int i :
verts.index_range()) {
648 length_constraint_tweak[
verts[
i]] += factors[
i] * 0.01f;
665 for (
float &factor : factors) {
666 factor = std::clamp(factor,
min,
max);
673 const bool use_falloff_plane,
674 const float3 &grab_delta_symmetry)
676 for (
const int i :
verts.index_range()) {
678 grab_delta_symmetry * factors[
i];
680 if (use_falloff_plane) {
692 const float3 &grab_delta_symmetry)
694 for (
const int i :
verts.index_range()) {
695 const int vert =
verts[
i];
712 const float3 &plane_normal,
730 const float3 x_disp = x_object_space *
math::dot(disp_center, x_object_space);
731 const float3 z_disp = z_object_space *
math::dot(disp_center, z_object_space);
732 forces[
i] = x_disp + z_disp;
757 const float3 &sim_location,
759 const std::optional<FalloffPlane> &falloff_plane,
867 const float3 &sim_location,
869 const std::optional<FalloffPlane> &falloff_plane,
978 const float3 &sim_location,
980 const std::optional<FalloffPlane> &falloff_plane,
1020 if (falloff_plane) {
1056 if (falloff_plane) {
1091 if (
STREQ(
object.
id.
name, ob->id.name)) {
1128 float (*positions)[3] = col_data->
x;
1129 float *tri[3], no[3], co[3];
1131 tri[0] = positions[vert_tri[0]];
1132 tri[1] = positions[vert_tri[1]];
1133 tri[2] = positions[vert_tri[2]];
1141 if (tri_hit && dist < hit->dist) {
1156 const float4x4 &object_to_world =
object.object_to_world();
1157 const float4x4 &world_to_object =
object.world_to_object();
1168 pos_world_space - prev_pos_world_space, hit.
dist);
1172 col.col_data = collmd;
1176 prev_pos_world_space,
1184 if (hit.
index == -1) {
1192 float3 pos_on_friction_plane;
1194 constexpr float friction_factor = 0.35f;
1195 const float3 movement_disp = (pos_on_friction_plane -
float3(hit.
co)) * friction_factor;
1198 float3(hit.
co) + movement_disp + collision_disp);
1204 const float3 &sim_location,
1214 for (
const int i :
verts.index_range()) {
1218 for (
const int vert :
verts) {
1222 for (
const int i :
verts.index_range()) {
1223 const int vert =
verts[
i];
1235 for (
const int i :
verts.index_range()) {
1236 const int vert =
verts[
i];
1237 cloth_sim.
pos[vert] += pos_diff[
i];
1240 for (
const int vert :
verts) {
1244 for (
const int vert :
verts) {
1254 const float3 &sim_location,
1270 switch (pbvh.
type()) {
1272 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
1286 *brush, ss.
cache->
radius, sim_location, positions, factors);
1306 subdiv_ccg, init_positions, grids, tls.
positions);
1308 *brush, ss.
cache->
radius, sim_location, positions, factors);
1328 *brush, ss.
cache->
radius, sim_location, positions, factors);
1363 float3 correction_vector;
1365 const float constraint_distance = constraint.
length +
1369 if (current_distance > 0.0f) {
1371 (1.0f - (constraint_distance / current_distance));
1377 const float3 correction_vector_half = correction_vector * 0.5f;
1379 const float factor_v1 = factors[v1];
1380 const float factor_v2 = factors[
v2];
1382 float deformation_strength = 1.0f;
1391 cloth_sim.
pos[v1] += correction_vector_half *
1392 (1.0f * factor_v1 * constraint.
strength * softbody_plasticity);
1393 cloth_sim.
softbody_pos[v1] += correction_vector_half * -1.0f * factor_v1 *
1394 constraint.
strength * (1.0f - softbody_plasticity);
1397 cloth_sim.
pos[v1] += correction_vector_half * 1.0f * factor_v1 * constraint.
strength *
1398 deformation_strength;
1400 cloth_sim.
pos[
v2] += correction_vector_half * -1.0f * factor_v2 * constraint.
strength *
1401 deformation_strength;
1425 switch (pbvh.
type()) {
1429 node_mask,
GrainSize(1024), memory, [&](
const int i) {
1436 active_nodes.foreach_index(
GrainSize(1), [&](
const int i) {
1451 for (
const int i :
verts.index_range()) {
1456 position_data.deform(translations,
verts);
1467 node_mask,
GrainSize(1024), memory, [&](
const int i) {
1475 active_nodes.foreach_index(
GrainSize(1), [&](
const int i) {
1489 for (
const int grid : grids) {
1503 node_mask,
GrainSize(1024), memory, [&](
const int i) {
1508 active_nodes.foreach_index(
GrainSize(1), [&](
const int i) {
1582 cache.
cloth_sim->deformation_strength.fill(0.0f);
1593 std::optional<FalloffPlane> falloff_plane;
1595 falloff_plane.emplace();
1603 switch (pbvh.
type()) {
1674 switch (pbvh.
type()) {
1699 switch (pbvh.
type()) {
1720 switch (pbvh.
type()) {
1737 const float cloth_mass,
1738 const float cloth_damping,
1739 const float cloth_softbody_strength,
1740 const bool use_collisions,
1741 const bool needs_deform_coords)
1744 std::unique_ptr<SimulationData> cloth_sim = std::make_unique<SimulationData>();
1750 cloth_sim->length_constraint_tweak =
Array<float>(totverts, 0.0f);
1752 cloth_sim->init_pos.reinitialize(totverts);
1755 cloth_sim->last_iteration_pos = cloth_sim->init_pos;
1756 cloth_sim->prev_pos = cloth_sim->init_pos;
1758 cloth_sim->init_no.reinitialize(totverts);
1761 if (needs_deform_coords) {
1762 cloth_sim->deformation_pos = cloth_sim->init_pos;
1763 cloth_sim->deformation_strength =
Array<float>(totverts, 1.0f);
1766 if (cloth_softbody_strength > 0.0f) {
1767 cloth_sim->softbody_pos = cloth_sim->init_pos;
1770 cloth_sim->mass = cloth_mass;
1771 cloth_sim->damping = cloth_damping;
1772 cloth_sim->softbody_strength = cloth_softbody_strength;
1774 if (use_collisions) {
1795 switch (pbvh.
type()) {
1891 const float location[3],
1892 const float normal[3],
1894 const float line_width,
1895 const float outline_col[3],
1898 float cursor_trans[4][4], cursor_rot[4][4];
1899 const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f};
1902 translate_m4(cursor_trans, location[0], location[1], location[2]);
1920 const float outline_col[3],
1921 float outline_alpha)
1944 immVertex3f(gpuattr, dist - arrow_x, arrow_y, 0.0f);
1945 immVertex3f(gpuattr, dist - arrow_x, -arrow_y, 0.0f);
1948 immVertex3f(gpuattr, -dist + arrow_x, arrow_y, 0.0f);
1949 immVertex3f(gpuattr, -dist + arrow_x, -arrow_y, 0.0f);
1972 "Pulls the cloth to the cursor's start position"},
1977 "Scales the mesh as a soft body using the origin of the object as scale"},
1978 {0,
nullptr, 0,
nullptr,
nullptr},
1986 "Use the local axis to limit the force and set the gravity direction"},
1991 "Use the global axis to limit the force and set the gravity direction"},
1996 "Use the view axis to limit the force and set the gravity direction"},
1997 {0,
nullptr, 0,
nullptr,
nullptr},
2010 {0,
nullptr, 0,
nullptr,
nullptr},
2028 force[1] = -factors[
i];
2031 force[2] = -factors[
i];
2033 forces[
i] = to_object_space * force;
2054 for (
const int i :
verts.index_range()) {
2062 const float filter_strength,
2084 for (
const int i :
verts.index_range()) {
2085 const int vert =
verts[
i];
2099 forces.
fill(gravity);
2103 switch (filter_type) {
2134 const float filter_strength,
2171 forces.
fill(gravity);
2175 switch (filter_type) {
2205 const float filter_strength,
2242 forces.
fill(gravity);
2246 switch (filter_type) {
2297 const float len =
event->prev_press_xy[0] -
event->xy[0];
2326 switch (pbvh.
type()) {
2330 const Mesh &
mesh = *
static_cast<const Mesh *
>(
object.data);
2352 const Mesh &base_mesh = *
static_cast<const Mesh *
>(
object.data);
2356 SubdivCCG &subdiv_ccg = *
object.sculpt->subdiv_ccg;
2362 *
depsgraph, face_sets, filter_type, filter_strength, gravity,
nodes[
i],
object, tls);
2372 *
depsgraph, filter_type, filter_strength, gravity,
nodes[
i],
object, tls);
2453 if (use_face_sets) {
2473 ot->name =
"Filter Cloth";
2474 ot->idname =
"SCULPT_OT_cloth_filter";
2475 ot->description =
"Applies a cloth simulation deformation to the entire mesh";
2490 "Operation that is going to be applied to the mesh");
2497 "Apply the force in the selected axis");
2503 "Orientation of the axis to limit the filter force");
2510 "Mass of each simulation particle",
2519 "How much the applied forces are propagated through the cloth",
2526 "Apply the filter only to the Face Set under the cursor");
2531 "Collide with other collider objects in the scene");
float BKE_brush_curve_strength(eBrushCurvePreset preset, const CurveMapping *cumap, float distance, float brush_radius)
void collision_move_object(struct CollisionModifierData *collmd, float step, float prevstep, bool moving_bvh)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Base * CTX_data_active_base(const bContext *C)
ToolSettings * CTX_data_tool_settings(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
bool BKE_base_is_visible(const View3D *v3d, const Base *base)
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
#define SCULPT_FACE_SET_NONE
const Brush * BKE_paint_brush_for_read(const Paint *paint)
void BKE_sculpt_update_object_for_edit(Depsgraph *depsgraph, Object *ob_orig, bool is_paint_tool)
A BVH for high poly meshes.
const blender::Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_unique_verts(blender::bke::pbvh::BMeshNode *node)
CCGKey BKE_subdiv_ccg_key_top_level(const SubdivCCG &subdiv_ccg)
void BKE_subdiv_ccg_neighbor_coords_get(const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord, bool include_duplicates, SubdivCCGNeighbors &r_neighbors)
#define BLI_assert_unreachable()
#define BVH_RAYCAST_DEFAULT
int BLI_bvhtree_ray_cast_ex(const BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata, int flag)
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
void isect_ray_tri_watertight_v3_precalc(struct IsectRayPrecalc *isect_precalc, const float ray_direction[3])
float dist_to_plane_v3(const float p[3], const float plane[4])
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
bool isect_ray_tri_watertight_v3(const float ray_origin[3], const struct IsectRayPrecalc *isect_precalc, const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
void closest_to_plane_v3(float r_close[3], const float plane[4], const float pt[3])
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
void normalize_m4(float R[4][4]) ATTR_NONNULL()
void unit_m4(float m[4][4])
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3])
void quat_to_mat4(float m[4][4], const float q[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define DEG_OBJECT_ITER_BEGIN(settings_, instance_)
#define DEG_OBJECT_ITER_END
@ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY
@ DEG_ITER_OBJECT_FLAG_VISIBLE
@ DEG_ITER_OBJECT_FLAG_DUPLI
@ BRUSH_AUTOMASKING_CAVITY_ALL
@ BRUSH_DEFORM_TARGET_CLOTH_SIM
@ SCULPT_BRUSH_TYPE_CLOTH
@ BRUSH_CLOTH_DEFORM_DRAG
@ BRUSH_CLOTH_DEFORM_EXPAND
@ BRUSH_CLOTH_DEFORM_GRAB
@ BRUSH_CLOTH_DEFORM_PINCH_POINT
@ BRUSH_CLOTH_DEFORM_PUSH
@ BRUSH_CLOTH_DEFORM_INFLATE
@ BRUSH_CLOTH_DEFORM_SNAKE_HOOK
@ BRUSH_CLOTH_DEFORM_PINCH_PERPENDICULAR
@ BRUSH_CLOTH_PIN_SIMULATION_BOUNDARY
@ BRUSH_CLOTH_USE_COLLISION
@ BRUSH_CLOTH_FORCE_FALLOFF_PLANE
@ BRUSH_CLOTH_SIMULATION_AREA_LOCAL
@ BRUSH_CLOTH_SIMULATION_AREA_DYNAMIC
@ BRUSH_CLOTH_SIMULATION_AREA_GLOBAL
@ eModifierType_Collision
Object is a sort of wrapper for general info.
#define GPU_matrix_mul(x)
void GPU_line_width(float width)
Read Guarded memory(de)allocation.
#define BM_elem_index_get(ele)
#define BM_elem_flag_test(ele, hflag)
void BM_mesh_vert_coords_get(BMesh *bm, MutableSpan< float3 > positions)
void BM_mesh_vert_normals_get(BMesh *bm, MutableSpan< float3 > normals)
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
BPy_StructRNA * depsgraph
MutableSpan< T > as_mutable_span()
constexpr void fill_indices(Span< IndexT > indices, const T &value) const
void resize(const int64_t new_size)
static IndexMask from_predicate(const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
constexpr int64_t size() const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr void fill(const T &value) const
constexpr Span< T > as_span() const
constexpr IndexRange index_range() const
constexpr void copy_from(Span< T > values) const
constexpr Span slice(int64_t start, int64_t size) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
void append(const T &value)
const T & last(const int64_t n=0) const
void resize(const int64_t new_size)
Span< T > as_span() const
GAttributeReader lookup(const StringRef attribute_id) const
void tag_positions_changed(const IndexMask &node_mask)
Span< NodeT > nodes() const
void flush_bounds_to_parents()
void foreach_index(Fn &&fn) const
static float normals[][3]
float distance(VecOp< float, D >, VecOp< float, D >) RET
ccl_device_inline float len_squared(const float2 a)
void fill_index_range(MutableSpan< T > span, const T start=0)
void foreach_0_index(const BitSpanT &data, Fn &&fn)
IndexRange grid_range(const int grid_area, const int grid)
pbvh::Tree * pbvh_get(Object &object)
IndexMask search_nodes(const Tree &pbvh, IndexMaskMemory &memory, FunctionRef< bool(const Node &)> filter_fn)
IndexMask all_leaf_nodes(const Tree &pbvh, IndexMaskMemory &memory)
void update_node_bounds_bmesh(BMeshNode &node)
void update_node_bounds_mesh(Span< float3 > positions, MeshNode &node)
Span< float3 > vert_normals_eval(const Depsgraph &depsgraph, const Object &object_orig)
void update_node_bounds_grids(int grid_area, Span< float3 > positions, GridsNode &node)
Span< float3 > vert_positions_eval(const Depsgraph &depsgraph, const Object &object_orig)
const Cache * active_cache_get(const SculptSession &ss)
Cache & filter_cache_ensure(const Depsgraph &depsgraph, const Sculpt &sd, Object &ob)
void calc_vert_factors(const Depsgraph &depsgraph, const Object &object, const Cache &automasking, const bke::pbvh::MeshNode &node, Span< int > verts, MutableSpan< float > factors)
void calc_grids_factors(const Depsgraph &depsgraph, const Object &object, const Cache &automasking, const bke::pbvh::GridsNode &node, Span< int > grids, MutableSpan< float > factors)
bool is_enabled(const Sculpt &sd, const Object &object, const Brush *br)
static BLI_NOINLINE void solve_verts_simulation(const Object &object, const Brush *brush, const float3 &sim_location, const Span< int > verts, const MutableSpan< float > factors, LocalData &tls, SimulationData &cloth_sim)
static void sculpt_cloth_ensure_constraints_in_simulation_area(const Sculpt &sd, Object &ob, const IndexMask &node_mask)
void plane_falloff_preview_draw(const uint gpuattr, SculptSession &ss, const float outline_col[3], float outline_alpha)
static void calc_forces_mesh(const Depsgraph &depsgraph, Object &ob, const Brush &brush, const float3 &offset, const float4x4 &imat, const float3 &sim_location, const float3 &gravity, const std::optional< FalloffPlane > &falloff_plane, const MeshAttributeData &attribute_data, const Span< float3 > positions_eval, const Span< float3 > vert_normals, const bke::pbvh::MeshNode &node, LocalData &tls)
static void calc_forces_grids(const Depsgraph &depsgraph, Object &ob, const Brush &brush, const float3 &offset, const float4x4 &imat, const float3 &sim_location, const float3 &gravity, const std::optional< FalloffPlane > &falloff_plane, const bke::pbvh::GridsNode &node, LocalData &tls)
static BLI_NOINLINE void apply_grab_brush(SimulationData &cloth_sim, const Span< int > verts, const MutableSpan< float > factors, const bool use_falloff_plane, const float3 &grab_delta_symmetry)
static BLI_NOINLINE void calc_perpendicular_pinch_forces(const Span< float3 > positions, const float4x4 &imat, const float3 &location, const MutableSpan< float3 > forces)
static void cloth_sim_initialize_default_node_state(Object &object, SimulationData &cloth_sim)
static BLI_NOINLINE void calc_distances_to_plane(const Span< float3 > positions, const float4 &plane, const MutableSpan< float > distances)
static float3 cloth_brush_simulation_location_get(const SculptSession &ss, const Brush *brush)
static BLI_NOINLINE void apply_scale_filter(filter::Cache &filter_cache, const Span< int > verts, const Span< float > factors, FilterLocalData &tls)
static void cloth_brush_add_deformation_constraint(SimulationData &cloth_sim, const int node_index, const int v, const float strength)
static MutableSpan< int > calc_visible_vert_indices_bmesh(const Set< BMVert *, 0 > &verts, Vector< int > &indices)
static void copy_positions_to_array(const Depsgraph &depsgraph, const Object &object, MutableSpan< float3 > positions)
static bool cloth_filter_is_deformation_filter(ClothFilterType filter_type)
bool is_cloth_deform_brush(const Brush &brush)
static void add_constraints_for_verts(const Object &object, const Brush *brush, const float3 &cloth_sim_initial_location, const float cloth_sim_radius, const Span< float3 > init_positions, const int node_index, const Span< int > verts, const GroupedSpan< int > vert_neighbors, SimulationData &cloth_sim, Set< OrderedEdge > &created_length_constraints)
static void cloth_brush_apply_brush_forces(const Depsgraph &depsgraph, const Sculpt &sd, Object &ob, const IndexMask &node_mask)
static void calc_constraint_factors(const Depsgraph &depsgraph, const Object &object, const Brush *brush, const float3 &sim_location, const Span< float3 > init_positions, const MutableSpan< float > cloth_factors)
static BLI_NOINLINE void calc_plane_pinch_forces(const Span< float3 > positions, const float4 &plane, const float3 &plane_normal, const MutableSpan< float3 > forces)
void SCULPT_OT_cloth_filter(wmOperatorType *ot)
static void apply_filter_forces_grids(const Depsgraph &depsgraph, const Span< int > face_sets, const ClothFilterType filter_type, const float filter_strength, const float3 &gravity, const bke::pbvh::GridsNode &node, Object &object, FilterLocalData &tls)
static GroupedSpan< int > calc_vert_neighbor_indices_bmesh(const BMesh &bm, const Span< int > verts, Vector< int > &r_offset_data, Vector< int > &r_data)
static void copy_normals_to_array(const Depsgraph &depsgraph, const Object &object, MutableSpan< float3 > normals)
static EnumPropertyItem prop_cloth_filter_type[]
void brush_store_simulation_state(const Depsgraph &depsgraph, const Object &object, SimulationData &cloth_sim)
static BLI_NOINLINE void calc_gravity_forces(const Span< float > factors, const filter::Cache &filter_cache, const MutableSpan< float3 > forces)
void ensure_nodes_constraints(const Sculpt &sd, Object &object, const IndexMask &node_mask, SimulationData &cloth_sim, const float3 &initial_location, const float radius)
void sim_activate_nodes(Object &object, SimulationData &cloth_sim, const IndexMask &node_mask)
static BLI_NOINLINE void calc_brush_simulation_falloff(const Brush &brush, const float radius, const float3 &location, const Span< float3 > positions, const MutableSpan< float > factors)
static void cloth_brush_collision_cb(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
static void calc_forces_bmesh(const Depsgraph &depsgraph, Object &ob, const Brush &brush, const float3 &offset, const float4x4 &imat, const float3 &sim_location, const float3 &gravity, const std::optional< FalloffPlane > &falloff_plane, bke::pbvh::BMeshNode &node, LocalData &tls)
static BLI_NOINLINE void expand_length_constraints(SimulationData &cloth_sim, const Span< int > verts, const Span< float > factors)
static float cloth_brush_simulation_falloff_get(const Brush &brush, const float radius, const float3 &location, const float3 &co)
static void cloth_brush_add_pin_constraint(SimulationData &cloth_sim, const int node_index, const int v, const float strength)
IndexMask brush_affected_nodes_gather(const Object &object, const Brush &brush, IndexMaskMemory &memory)
static void cloth_brush_satisfy_constraints(const Depsgraph &depsgraph, const Object &object, const Brush *brush, SimulationData &cloth_sim)
void do_simulation_step(const Depsgraph &depsgraph, const Sculpt &sd, Object &object, SimulationData &cloth_sim, const IndexMask &node_mask)
static void apply_filter_forces_bmesh(const Depsgraph &depsgraph, const ClothFilterType filter_type, const float filter_strength, const float3 &gravity, bke::pbvh::BMeshNode &node, Object &object, FilterLocalData &tls)
static MutableSpan< int > calc_vert_indices_grids(const CCGKey &key, const Span< int > grids, Vector< int > &indices)
static BLI_NOINLINE void clamp_factors(const MutableSpan< float > factors, const float min, const float max)
static void cloth_brush_add_length_constraint(SimulationData &cloth_sim, const int node_index, const int v1, const int v2, const Span< float3 > init_positions)
@ SCULPT_CLOTH_NODE_UNINITIALIZED
@ SCULPT_CLOTH_NODE_ACTIVE
@ SCULPT_CLOTH_NODE_INACTIVE
static BLI_NOINLINE void apply_forces(SimulationData &cloth_sim, const Span< float3 > forces, const Span< int > verts)
static EnumPropertyItem prop_cloth_filter_force_axis_items[]
static wmOperatorStatus sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent *event)
static BLI_NOINLINE void apply_snake_hook_brush(SimulationData &cloth_sim, const Span< int > verts, const MutableSpan< float > factors, const float3 &grab_delta_symmetry)
static wmOperatorStatus sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static MutableSpan< int > calc_vert_indices_bmesh(const Set< BMVert *, 0 > &verts, Vector< int > &indices)
static void cloth_brush_add_softbody_constraint(SimulationData &cloth_sim, const int node_index, const int v, const float strength)
static void apply_filter_forces_mesh(const Depsgraph &depsgraph, const ClothFilterType filter_type, const float filter_strength, const float3 &gravity, const Span< float3 > positions_eval, const Span< float3 > vert_normals, const GroupedSpan< int > vert_to_face_map, const MeshAttributeData &attribute_data, const bke::pbvh::MeshNode &node, Object &object, FilterLocalData &tls)
static void cloth_brush_solve_collision(const Object &object, SimulationData &cloth_sim, const int i)
void simulation_limits_draw(const uint gpuattr, const 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)
std::unique_ptr< SimulationData > brush_simulation_create(const Depsgraph &depsgraph, Object &ob, const float cloth_mass, const float cloth_damping, const float cloth_softbody_strength, const bool use_collisions, const bool needs_deform_coords)
static MutableSpan< int > calc_visible_vert_indices_grids(const CCGKey &key, const BitGroupVector<> &grid_hidden, const Span< int > grids, Vector< int > &indices)
@ SCULPT_CLOTH_CONSTRAINT_DEFORMATION
@ SCULPT_CLOTH_CONSTRAINT_STRUCTURAL
@ SCULPT_CLOTH_CONSTRAINT_SOFTBODY
@ SCULPT_CLOTH_CONSTRAINT_PIN
static BLI_NOINLINE void calc_pinch_forces(const Span< float3 > positions, const float3 &location, const MutableSpan< float3 > forces)
static Vector< ColliderCache > cloth_brush_collider_cache_create(Object &object, const Depsgraph &depsgraph)
void do_cloth_brush(const Depsgraph &depsgraph, const Sculpt &sd, Object &ob, const IndexMask &node_mask)
static GroupedSpan< int > calc_vert_neighbor_indices_grids(const SubdivCCG &subdiv_ccg, const Span< int > verts, Vector< int > &r_offset_data, Vector< int > &r_data)
static EnumPropertyItem prop_cloth_filter_orientation_items[]
bool vert_has_face_set(const GroupedSpan< int > vert_to_face_map, const Span< int > face_sets, const int vert, const int face_set)
int active_face_set_get(const Object &object)
void zero_disabled_axis_components(const filter::Cache &filter_cache, MutableSpan< float3 > vectors)
void cache_init(bContext *C, Object &ob, Sculpt &sd, undo::Type undo_type, const float mval_fl[2], float area_normal_radius, float start_strength)
float3x3 to_object_space(const filter::Cache &filter_cache)
void register_operator_props(wmOperatorType *ot)
Span< int > node_visible_verts(const bke::pbvh::MeshNode &node, const Span< bool > hide_vert, Vector< int > &indices)
void push_end(Object &ob)
void push_begin(const Scene &scene, Object &ob, const wmOperator *op)
void fill_factor_from_hide_and_mask(Span< bool > hide_vert, Span< float > mask, Span< int > verts, MutableSpan< float > r_factors)
MutableSpan< float3 > gather_grids_positions(const SubdivCCG &subdiv_ccg, const Span< int > grids, Vector< float3 > &positions)
bool node_in_sphere(const bke::pbvh::Node &node, const float3 &location, const float radius_sq, const bool original)
void scatter_data_bmesh(Span< T > node_data, const Set< BMVert *, 0 > &verts, MutableSpan< T > dst)
void gather_bmesh_positions(const Set< BMVert *, 0 > &verts, MutableSpan< float3 > positions)
void calc_brush_strength_factors(const StrokeCache &cache, const Brush &brush, Span< float > distances, MutableSpan< float > factors)
void gather_data_grids(const SubdivCCG &subdiv_ccg, Span< T > src, Span< int > grids, MutableSpan< T > node_data)
void vert_random_access_ensure(Object &object)
void apply_hardness_to_distances(float radius, float hardness, MutableSpan< float > distances)
GroupedSpan< int > calc_vert_neighbors(OffsetIndices< int > faces, Span< int > corner_verts, GroupedSpan< int > vert_to_face, Span< bool > hide_poly, Span< int > verts, Vector< int > &r_offset_data, Vector< int > &r_data)
void gather_bmesh_normals(const Set< BMVert *, 0 > &verts, MutableSpan< float3 > normals)
Vector< BMVert *, 64 > BMeshNeighborVerts
void filter_distances_with_radius(float radius, Span< float > distances, MutableSpan< float > factors)
void filter_region_clip_factors(const SculptSession &ss, Span< float3 > vert_positions, Span< int > verts, MutableSpan< float > factors)
void gather_data_bmesh(Span< T > src, const Set< BMVert *, 0 > &verts, MutableSpan< T > node_data)
void scale_translations(MutableSpan< float3 > translations, Span< float > factors)
bool report_if_shape_key_is_locked(const Object &ob, ReportList *reports)
void scale_factors(MutableSpan< float > factors, float strength)
void clip_and_lock_translations(const Sculpt &sd, const SculptSession &ss, Span< float3 > positions, Span< int > verts, MutableSpan< float3 > translations)
bool cursor_geometry_info_update(bContext *C, CursorGeometryInfo *out, const float2 &mval, const bool use_sampled_normal)
void flush_update_done(const bContext *C, Object &ob, const UpdateType update_type)
void scatter_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
void calc_brush_distances(const SculptSession &ss, Span< float3 > vert_positions, Span< int > vert, eBrushFalloffShape falloff_shape, MutableSpan< float > r_distances)
void calc_brush_plane(const Depsgraph &depsgraph, const Brush &brush, Object &ob, const IndexMask &node_mask, float3 &r_area_no, float3 &r_area_co)
Span< BMVert * > vert_neighbors_get_bmesh(BMVert &vert, BMeshNeighborVerts &r_neighbors)
void gather_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
void calc_brush_texture_factors(const SculptSession &ss, const Brush &brush, Span< float3 > vert_positions, Span< int > vert, MutableSpan< float > factors)
void flush_update_step(const bContext *C, const UpdateType update_type)
void calc_front_face(const float3 &view_normal, Span< float3 > normals, MutableSpan< float > factors)
void gather_grids_normals(const SubdivCCG &subdiv_ccg, Span< int > grids, MutableSpan< float3 > normals)
void translations_from_offset_and_factors(const float3 &offset, Span< float > factors, MutableSpan< float3 > r_translations)
void scatter_data_grids(const SubdivCCG &subdiv_ccg, Span< T > node_data, Span< int > grids, MutableSpan< T > dst)
T distance(const T &a, const T &b)
T length(const VecBase< T, Size > &a)
QuaternionBase< T > normalize_and_get_length(const QuaternionBase< T > &q, T &out_length)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3
CCL_NAMESPACE_BEGIN ccl_device float fade(const float t)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
bool SCULPT_stroke_is_first_brush_step_of_symmetry_pass(const blender::ed::sculpt_paint::StrokeCache &cache)
bool SCULPT_mode_poll(bContext *C)
int SCULPT_vertex_count_get(const Object &object)
#define CLOTH_SOLVER_DISPLACEMENT_FACTOR
#define CLOTH_LENGTH_CONSTRAINTS_BLOCK
#define CLOTH_DEFORMATION_SNAKEHOOK_STRENGTH
#define CLOTH_DEFORMATION_GRAB_STRENGTH
#define CLOTH_DEFORMATION_TARGET_STRENGTH
#define CLOTH_SIMULATION_ITERATIONS
#define CLOTH_SIMULATION_TIME_STEP
int cloth_simulation_area_type
float cloth_constraint_softbody_strength
int cloth_force_falloff_type
struct CollisionModifierData * collmd
struct SculptSession * sculpt
blender::ed::sculpt_paint::StrokeCache * cache
blender::ed::sculpt_paint::filter::Cache * filter_cache
blender::float3 active_vert_position(const Depsgraph &depsgraph, const Object &object) const
std::optional< PersistentMultiresData > persistent_multires_data()
struct Object * gravity_object
int to_index(const CCGKey &key) const
static SubdivCCGCoord from_index(const CCGKey &key, int index)
SubdivCCGNeighborCoords coords
blender::Array< blender::float3 > normals
blender::Array< blender::float3 > positions
const c_style_mat & ptr() const
static MatBase identity()
Span< int > grids() const
Span< int > verts() const
VArraySpan< int > face_sets
VArraySpan< bool > hide_vert
float3 gravity_direction_symm
float3 sculpt_normal_symm
float3 initial_location_symm
float4x4 stroke_local_mat
float3 last_location_symm
ePaintSymmetryFlags mirror_symmetry_pass
std::unique_ptr< cloth::SimulationData > cloth_sim
CollisionModifierData * col_data
IsectRayPrecalc isect_precalc
Vector< int > vert_indices
Vector< float3 > positions
Vector< float3 > positions
Vector< int > vert_indices
Vector< float3 > translations
Vector< float > distances
Vector< float > sim_factors
Vector< float3 > init_positions
Vector< LengthConstraint > length_constraints
Array< float3 > softbody_pos
Array< float3 > deformation_pos
Array< NodeSimState > node_state
Array< float3 > acceleration
Array< float > length_constraint_tweak
Map< const bke::pbvh::Node *, int > node_state_index
Array< float > deformation_strength
Vector< ColliderCache > collider_list
Array< float3 > last_iteration_pos
FilterOrientation orientation
std::unique_ptr< cloth::SimulationData > cloth_sim
float3 cloth_sim_pinch_point
std::unique_ptr< auto_mask::Cache > automasking
std::array< bool, 3 > enabled_axis
struct ReportList * reports
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)