77 indices.
resize(grid_verts_num);
92 for (
const BMVert *vert : verts) {
109 indices.
reserve(grid_verts_num);
111 const int start = grids[i] * key.
grid_area;
113 [&](
const int offset) { indices.
append(start + offset); });
123 for (
const BMVert *vert : verts) {
143 r_offset_data[i] = r_data.
size();
153 r_offset_data.
last() = r_data.
size();
169 r_offset_data[i] = r_data.
size();
175 r_offset_data.
last() = r_data.
size();
199 switch (
brush.cloth_simulation_area_type) {
202 (1.0 +
brush.cloth_sim_limit));
247 const float limit = radius + (radius *
brush.cloth_sim_limit);
248 const float falloff = radius + (radius *
brush.cloth_sim_limit *
brush.cloth_sim_falloff);
259 float p = 1.0f - ((
distance - falloff) / (limit - falloff));
260 return 3.0f * p * p - 2.0f * p * p * p;
276#define CLOTH_LENGTH_CONSTRAINTS_BLOCK 100000
277#define CLOTH_SIMULATION_ITERATIONS 5
279#define CLOTH_SOLVER_DISPLACEMENT_FACTOR 0.6f
280#define CLOTH_MAX_CONSTRAINTS_PER_VERTEX 1024
281#define CLOTH_SIMULATION_TIME_STEP 0.01f
282#define CLOTH_DEFORMATION_SNAKEHOOK_STRENGTH 0.35f
283#define CLOTH_DEFORMATION_TARGET_STRENGTH 0.01f
284#define CLOTH_DEFORMATION_GRAB_STRENGTH 0.1f
287 const int node_index,
297 length_constraint.
node = node_index;
311 const int node_index,
313 const float strength)
320 length_constraint.
node = node_index;
327 length_constraint.
length = 0.0f;
328 length_constraint.
strength = strength;
334 const int node_index,
336 const float strength)
343 length_constraint.
node = node_index;
350 length_constraint.
length = 0.0f;
351 length_constraint.
strength = strength;
357 const int node_index,
359 const float strength)
366 length_constraint.
node = node_index;
373 length_constraint.
length = 0.0f;
374 length_constraint.
strength = strength;
381 const float3 &cloth_sim_initial_location,
382 const float cloth_sim_radius,
384 const int node_index,
392 const bool is_brush_has_stroke_cache = ss.
cache !=
nullptr &&
brush !=
nullptr;
393 const bool pin_simulation_boundary = is_brush_has_stroke_cache &&
395 brush->cloth_simulation_area_type !=
402 const bool use_falloff_plane =
brush->cloth_force_falloff_type ==
404 float radius_squared = 0.0f;
405 if (cloth_is_deform_brush) {
410 const float cloth_sim_radius_squared =
brush->cloth_simulation_area_type ==
412 cloth_sim_radius * cloth_sim_radius :
416 const int vert = verts[i];
418 cloth_sim_initial_location);
424 const Span<int> neighbors = vert_neighbors[i];
430 for (
const int neighbor : neighbors) {
431 if (created_length_constraints.
add({vert, neighbor})) {
435 for (
const int a : neighbors) {
436 for (
const int b : neighbors) {
438 if (created_length_constraints.
add({a, b})) {
450 if (use_falloff_plane) {
480 if (pin_simulation_boundary) {
484 if (sim_falloff < 1.0f) {
497 const float3 &initial_location,
514 switch (
pbvh.type()) {
518 node_mask, memory, [&](
const int i) {
535 persistent_position = *attributes.
lookup<
float3>(
".sculpt_persistent_co",
538 if (persistent_position.
is_empty()) {
539 init_positions = cloth_sim.
init_pos;
542 init_positions = persistent_position;
544 uninitialized_nodes.foreach_index([&](
const int i) {
563 created_length_constraints);
570 node_mask, memory, [&](
const int i) {
580 const std::optional<PersistentMultiresData> persistent_multires_data =
583 persistent_position = persistent_multires_data->positions;
585 if (persistent_position.
is_empty()) {
586 init_positions = cloth_sim.
init_pos;
589 init_positions = persistent_position;
592 uninitialized_nodes.foreach_index([&](
const int i) {
594 key, grid_hidden,
nodes[i].grids(), vert_indices);
596 subdiv_ccg, verts, neighbor_offsets, neighbor_data);
606 created_length_constraints);
613 node_mask, memory, [&](
const int i) {
620 uninitialized_nodes.foreach_index([&](
const int i) {
624 bm, verts, neighbor_offsets, neighbor_data);
634 created_length_constraints);
648 cloth_sim.
acceleration[verts[i]] += forces[i] * mass_inv;
659 length_constraint_tweak[verts[i]] += factors[i] * 0.01f;
678 for (
float &factor : factors) {
679 factor = std::clamp(factor,
min,
max);
686 const bool use_falloff_plane,
687 const float3 &grab_delta_symmetry)
692 grab_delta_symmetry * factors[i];
694 if (use_falloff_plane) {
706 const float3 &grab_delta_symmetry)
710 const int vert = verts[i];
711 cloth_sim.
deformation_pos[vert] = cloth_sim.
pos[vert] + grab_delta_symmetry * factors[i];
728 const float3 &plane_normal,
748 const float3 x_disp = x_object_space *
math::dot(disp_center, x_object_space);
749 const float3 z_disp = z_object_space *
math::dot(disp_center, z_object_space);
750 forces[i] = x_disp + z_disp;
775 const float3 &sim_location,
777 const std::optional<FalloffPlane> &falloff_plane,
834 switch (
brush.cloth_deform_type) {
846 cloth_sim, verts, factors, falloff_plane.has_value(), cache.
grab_delta_symm);
883 const float3 &sim_location,
885 const std::optional<FalloffPlane> &falloff_plane,
945 switch (
brush.cloth_deform_type) {
957 cloth_sim, verts, factors, falloff_plane.has_value(), cache.
grab_delta_symm);
994 const float3 &sim_location,
996 const std::optional<FalloffPlane> &falloff_plane,
1036 if (falloff_plane) {
1054 switch (
brush.cloth_deform_type) {
1066 cloth_sim, verts, factors, falloff_plane.has_value(), cache.
grab_delta_symm);
1072 if (falloff_plane) {
1099 const Depsgraph &depsgraph)
1103 deg_iter_settings.
depsgraph = &
const_cast<Depsgraph &
>(depsgraph);
1107 if (
STREQ(
object.
id.name, ob->id.name)) {
1144 float (*positions)[3] = col_data->
x;
1145 float *tri[3], no[3], co[3];
1147 tri[0] = positions[vert_tri[0]];
1148 tri[1] = positions[vert_tri[1]];
1149 tri[2] = positions[vert_tri[2]];
1157 if (tri_hit && dist < hit->dist) {
1172 const float4x4 &object_to_world =
object.object_to_world();
1173 const float4x4 &world_to_object =
object.world_to_object();
1184 pos_world_space - prev_pos_world_space, hit.
dist);
1192 prev_pos_world_space,
1200 if (hit.
index == -1) {
1208 float3 pos_on_friction_plane;
1210 constexpr float friction_factor = 0.35f;
1211 const float3 movement_disp = (pos_on_friction_plane -
float3(hit.
co)) * friction_factor;
1214 float3(hit.
co) + movement_disp + collision_disp);
1220 const float3 &sim_location,
1232 pos_diff[i] = cloth_sim.
pos[verts[i]] - cloth_sim.
prev_pos[verts[i]];
1235 for (
const int vert : verts) {
1240 const int vert = verts[i];
1253 const int vert = verts[i];
1254 cloth_sim.
pos[vert] += pos_diff[i];
1257 for (
const int vert : verts) {
1261 for (
const int vert : verts) {
1271 const float3 &sim_location,
1287 switch (
pbvh.type()) {
1289 const Mesh &
mesh = *id_cast<const Mesh *>(
object.
data);
1299 attribute_data.
hide_vert, attribute_data.
mask, verts, factors);
1324 depsgraph,
object, automasking,
nodes[i], grids, factors);
1327 subdiv_ccg, init_positions, grids, tls.
positions);
1389 float3 correction_vector;
1391 const float constraint_distance = constraint.
length +
1395 if (current_distance > 0.0f) {
1397 (1.0f - (constraint_distance / current_distance));
1403 const float3 correction_vector_half = correction_vector * 0.5f;
1405 const float factor_v1 = factors[v1];
1406 const float factor_v2 = factors[
v2];
1408 float deformation_strength = 1.0f;
1416 const float softbody_plasticity =
brush ?
brush->cloth_constraint_softbody_strength : 0.0f;
1417 cloth_sim.
pos[v1] += correction_vector_half *
1418 (1.0f * factor_v1 * constraint.
strength * softbody_plasticity);
1419 cloth_sim.
softbody_pos[v1] += correction_vector_half * -1.0f * factor_v1 *
1420 constraint.
strength * (1.0f - softbody_plasticity);
1423 cloth_sim.
pos[v1] += correction_vector_half * 1.0f * factor_v1 * constraint.
strength *
1424 deformation_strength;
1426 cloth_sim.
pos[
v2] += correction_vector_half * -1.0f * factor_v2 * constraint.
strength *
1427 deformation_strength;
1452 switch (
pbvh.type()) {
1456 node_mask, memory, [&](
const int i) {
1463 active_nodes.foreach_index(
1471 attribute_data.
hide_vert, attribute_data.
mask, verts, factors);
1480 translations[i] = cloth_sim.
pos[verts[i]] - position_data.eval[verts[i]];
1484 position_data.deform(translations, verts);
1496 node_mask, memory, [&](
const int i) {
1504 active_nodes.foreach_index(
1515 depsgraph,
object, automasking,
nodes[i], grids, factors);
1520 for (
const int grid : grids) {
1535 node_mask, memory, [&](
const int i) {
1540 active_nodes.foreach_index(
1553 object,
brush, sim_location, vert_indices, factors, tls, cloth_sim);
1555 for (
BMVert *vert : verts) {
1567 pbvh.tag_positions_changed(node_mask);
1568 pbvh.flush_bounds_to_parents();
1617 cache.
cloth_sim->deformation_strength.fill(0.0f);
1628 std::optional<FalloffPlane> falloff_plane;
1630 falloff_plane.emplace();
1638 switch (
pbvh.type()) {
1713 switch (
pbvh.type()) {
1738 switch (
pbvh.type()) {
1759 switch (
pbvh.type()) {
1776 const float cloth_mass,
1777 const float cloth_damping,
1778 const float cloth_softbody_strength,
1779 const bool use_collisions,
1780 const bool needs_deform_coords)
1784 std::unique_ptr<SimulationData> cloth_sim = std::make_unique<SimulationData>();
1790 cloth_sim->length_constraint_tweak =
Array<float>(totverts, 0.0f);
1792 cloth_sim->init_pos.reinitialize(totverts);
1795 cloth_sim->last_iteration_pos = cloth_sim->init_pos;
1796 cloth_sim->prev_pos = cloth_sim->init_pos;
1798 cloth_sim->init_no.reinitialize(totverts);
1801 if (needs_deform_coords) {
1802 cloth_sim->deformation_pos = cloth_sim->init_pos;
1803 cloth_sim->deformation_strength =
Array<float>(totverts, 1.0f);
1806 if (cloth_softbody_strength > 0.0f) {
1807 cloth_sim->softbody_pos = cloth_sim->init_pos;
1810 cloth_sim->mass = cloth_mass;
1811 cloth_sim->damping = cloth_damping;
1812 cloth_sim->softbody_strength = cloth_softbody_strength;
1814 if (use_collisions) {
1837 switch (
pbvh.type()) {
1872 const float limit = radius + (radius *
brush->cloth_sim_limit);
1890 brush->cloth_damping,
1891 brush->cloth_constraint_softbody_strength,
1934 const float location[3],
1935 const float normal[3],
1937 const float line_width,
1938 const float outline_col[3],
1941 float cursor_trans[4][4], cursor_rot[4][4];
1942 const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f};
1945 translate_m4(cursor_trans, location[0], location[1], location[2]);
1955 gpuattr, 0, 0, rds + (rds *
brush.cloth_sim_limit *
brush.cloth_sim_falloff), 320);
1964 const float outline_col[3],
1965 float outline_alpha)
1988 immVertex3f(gpuattr, dist - arrow_x, arrow_y, 0.0f);
1989 immVertex3f(gpuattr, dist - arrow_x, -arrow_y, 0.0f);
1992 immVertex3f(gpuattr, -dist + arrow_x, arrow_y, 0.0f);
1993 immVertex3f(gpuattr, -dist + arrow_x, -arrow_y, 0.0f);
2016 "Pulls the cloth to the cursor's start position"},
2021 "Scales the mesh as a soft body using the origin of the object as scale"},
2022 {0,
nullptr, 0,
nullptr,
nullptr},
2030 "Use the local axis to limit the force and set the gravity direction"},
2035 "Use the global axis to limit the force and set the gravity direction"},
2040 "Use the view axis to limit the force and set the gravity direction"},
2041 {0,
nullptr, 0,
nullptr,
nullptr},
2054 {0,
nullptr, 0,
nullptr,
nullptr},
2072 force[1] = -factors[i];
2075 force[2] = -factors[i];
2077 forces[i] = to_object_space * force;
2099 filter_cache.
cloth_sim->deformation_pos[verts[i]] =
2100 filter_cache.
cloth_sim->init_pos[verts[i]] + translations[i];
2106 const float filter_strength,
2129 const int vert = verts[i];
2143 forces.
fill(gravity);
2147 switch (filter_type) {
2178 const float filter_strength,
2215 forces.
fill(gravity);
2219 switch (filter_type) {
2249 const float filter_strength,
2271 for (
const BMVert *vert : verts) {
2286 forces.
fill(gravity);
2290 switch (filter_type) {
2341 const float len =
event->prev_press_xy[0] -
event->xy[0];
2370 switch (
pbvh.type()) {
2374 const Mesh &
mesh = *id_cast<const Mesh *>(
object.
data);
2398 const Mesh &base_mesh = *id_cast<const Mesh *>(
object.
data);
2402 SubdivCCG &subdiv_ccg = *
object.runtime->sculpt_session->subdiv_ccg;
2427 *depsgraph, filter_type, filter_strength, gravity,
nodes[i],
object, tls);
2434 pbvh.tag_positions_changed(node_mask);
2435 pbvh.flush_bounds_to_parents();
2508 if (use_face_sets) {
2528 ot->
name =
"Filter Cloth";
2529 ot->
idname =
"SCULPT_OT_cloth_filter";
2530 ot->
description =
"Applies a cloth simulation deformation to the entire mesh";
2545 "Operation that is going to be applied to the mesh");
2552 "Apply the force in the selected axis");
2558 "Orientation of the axis to limit the filter force");
2565 "Mass of each simulation particle",
2574 "How much the applied forces are propagated through the cloth",
2581 "Apply the filter only to the face set under the cursor");
2586 "Collide with other collider objects in the scene");
A BVH for high poly meshes.
#define BVH_RAYCAST_DEFAULT
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define DEG_OBJECT_ITER_BEGIN(settings_, instance_)
#define DEG_OBJECT_ITER_END
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define PRF_scope(category)
#define BLI_assert_unreachable()
#define BM_elem_index_get(ele)
#define BM_elem_flag_test(ele, hflag)
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
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)
MutableSpan< T > as_mutable_span()
void reserve(const int64_t min_capacity)
Span< T > as_span() const
GAttributeReader lookup(const StringRef name) const
constexpr bool is_empty() const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
float distance(float, float) RET
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
ccl_device_inline dual1 len_squared(const ccl_private dual< T > &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)
bool is_enabled(const Paint &paint, const Object &object, const Brush *br)
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)
Cache & filter_cache_ensure(const Depsgraph &depsgraph, const Paint &paint, Object &ob)
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)
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 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)
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 plane_falloff_preview_draw(const uint gpuattr, Brush &brush, SculptSession &ss, const float outline_col[3], float outline_alpha)
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, bke::pbvh::MESH_LEAF_LIMIT > &indices)
void push_end(Object &ob)
void push_begin(const Scene &scene, Object &ob, const wmOperator *op)
bool shape_key_check(const Object &ob, ReportList *reports)
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)
int vertex_count_get(const Object &object)
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)
bool stroke_is_first_brush_step_of_symmetry_pass(const StrokeCache &cache)
void scale_translations(MutableSpan< float3 > translations, Span< float > factors)
bool sculpt_mode_poll(bContext *C)
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)
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 flush_update_step(bContext *C, const UpdateType update_type)
void gather_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
void flush_update_done(bContext *C, Object &ob, const UpdateType update_type)
std::optional< CursorGeometryInfo > cursor_geometry_info_update(bContext *C, const float2 &mval, const bool use_sampled_normal)
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 calc_brush_texture_factors(PaintMode paint_mode, const SculptSession &ss, const Brush &brush, Span< float3 > vert_positions, Span< int > vert, MutableSpan< float > factors)
void scatter_data_grids(const SubdivCCG &subdiv_ccg, Span< T > node_data, Span< int > grids, MutableSpan< T > dst)
constexpr ParallelGrainSize grain_size(int grain_size)
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)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void closest_to_plane_v3(float r_close[3], const float plane[4], const float pt[3])
void BM_mesh_vert_normals_get(BMesh *bm, MutableSpan< float3 > normals)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void imm_draw_circle_dashed_3d(uint pos, float x, float y, float radius, int nsegments)
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])
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])
bool BKE_base_is_visible(const View3D *v3d, const Base *base)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
void collision_move_object(struct CollisionModifierData *collmd, float step, float prevstep, bool moving_bvh)
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)
@ eModifierType_Collision
void immBegin(GPUPrimType, uint vertex_len)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3])
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
@ BRUSH_CLOTH_USE_COLLISION
@ BRUSH_CLOTH_PIN_SIMULATION_BOUNDARY
ATTR_WARN_UNUSED_RESULT const BMVert * v
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
MatBase< float, 4, 4 > float4x4
Base * CTX_data_active_base(const bContext *C)
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
@ BRUSH_CLOTH_DEFORM_PUSH
@ BRUSH_CLOTH_DEFORM_EXPAND
@ BRUSH_CLOTH_DEFORM_INFLATE
@ BRUSH_CLOTH_DEFORM_SNAKE_HOOK
@ BRUSH_CLOTH_DEFORM_DRAG
@ BRUSH_CLOTH_DEFORM_GRAB
@ BRUSH_CLOTH_DEFORM_PINCH_POINT
@ BRUSH_CLOTH_DEFORM_PINCH_PERPENDICULAR
void BM_mesh_vert_coords_get(const BMesh *bm, MutableSpan< float3 > positions)
void GPU_matrix_mul(const float m[4][4])
void GPU_line_width(float width)
CCGKey BKE_subdiv_ccg_key_top_level(const SubdivCCG &subdiv_ccg)
void normalize_m4(float R[4][4]) ATTR_NONNULL()
@ SCULPT_BRUSH_TYPE_CLOTH
VecBase< float, 4 > float4
void BKE_subdiv_ccg_neighbor_coords_get(const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord, bool include_duplicates, SubdivCCGNeighbors &r_neighbors)
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
BMesh const char void * data
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, StringRef name)
@ DEG_ITER_OBJECT_FLAG_VISIBLE
@ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY
@ DEG_ITER_OBJECT_FLAG_DUPLI
float BKE_brush_curve_strength(eBrushCurvePreset preset, const CurveMapping *cumap, float distance, float brush_radius)
void unit_m4(float m[4][4])
void isect_ray_tri_watertight_v3_precalc(struct IsectRayPrecalc *isect_precalc, const float ray_direction[3])
ToolSettings * CTX_data_tool_settings(const bContext *C)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
MatBase< float, 3, 3 > float3x3
BLI_INLINE BMVert * BM_vert_at_index(BMesh *bm, const int index)
@ BRUSH_AUTOMASKING_CAVITY_ALL
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
float dist_to_plane_v3(const float p[3], const float plane[4])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
@ BRUSH_DEFORM_TARGET_CLOTH_SIM
void BKE_sculptsession_update_for_edit(Depsgraph *depsgraph, Object *ob_orig, bool is_paint_tool)
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)
Scene * CTX_data_scene(const bContext *C)
void immVertex3f(uint attr_id, float x, float y, float z)
VecBase< float, 3 > float3
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void imm_draw_circle_wire_3d(uint pos, float x, float y, float radius, int nsegments)
void immUniformColor3fvAlpha(const float rgb[3], float a)
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)
Object * CTX_data_active_object(const bContext *C)
const Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_unique_verts(bke::pbvh::BMeshNode *node)
@ BRUSH_CLOTH_SIMULATION_AREA_GLOBAL
@ BRUSH_CLOTH_SIMULATION_AREA_LOCAL
@ BRUSH_CLOTH_SIMULATION_AREA_DYNAMIC
float RNA_float_get(PointerRNA *ptr, const char *name)
View3D * CTX_wm_view3d(const bContext *C)
void quat_to_mat4(float m[4][4], const float q[4])
@ BRUSH_CLOTH_FORCE_FALLOFF_PLANE
#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
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct CollisionModifierData * collmd
const c_style_mat & ptr() const
static MatBase identity()
bke::ObjectRuntime * runtime
ed::sculpt_paint::StrokeCache * cache
float3 active_vert_position(const Depsgraph &depsgraph, const Object &object) const
std::optional< PersistentMultiresData > persistent_multires_data()
ed::sculpt_paint::filter::Cache * filter_cache
struct Object * gravity_object
static SubdivCCGCoord from_index(const CCGKey &key, int index)
int to_index(const CCGKey &key) const
SubdivCCGNeighborCoords coords
Array< float3 > positions
SculptSession * sculpt_session
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
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
void resize(int new_size)