79 indices.resize(grid_verts_num);
91 indices.resize(
verts.size());
109 indices.reserve(grid_verts_num);
111 const int start = grids[i] * key.
grid_area;
113 [&](
const int offset) { indices.append(start + offset); });
121 indices.reserve(
verts.size());
137 for (
const int i :
verts.index_range()) {
142 neighbor_indices[i].clear();
144 neighbor_indices[i].append(coord.to_index(key));
156 for (
const int i :
verts.index_range()) {
158 neighbor_indices[i].clear();
167 if (!ss.
cache || !brush) {
236 if (distance > limit) {
240 if (distance < falloff) {
245 float p = 1.0f - ((distance - falloff) / (limit - falloff));
246 return 3.0f * p * p - 2.0f * p * p * p;
257 for (
const int i : positions.index_range()) {
262#define CLOTH_LENGTH_CONSTRAINTS_BLOCK 100000
263#define CLOTH_SIMULATION_ITERATIONS 5
265#define CLOTH_SOLVER_DISPLACEMENT_FACTOR 0.6f
266#define CLOTH_MAX_CONSTRAINTS_PER_VERTEX 1024
267#define CLOTH_SIMULATION_TIME_STEP 0.01f
268#define CLOTH_DEFORMATION_SNAKEHOOK_STRENGTH 0.35f
269#define CLOTH_DEFORMATION_TARGET_STRENGTH 0.01f
270#define CLOTH_DEFORMATION_GRAB_STRENGTH 0.1f
273 const int node_index,
281 length_constraint.elem_index_b =
v2;
283 length_constraint.node = node_index;
285 length_constraint.elem_position_a = cloth_sim.
pos[v1];
286 length_constraint.elem_position_b = cloth_sim.
pos[
v2];
290 length_constraint.length =
math::distance(init_positions[v1], init_positions[
v2]);
291 length_constraint.strength = 1.0f;
297 const int node_index,
299 const float strength)
304 length_constraint.elem_index_b =
v;
306 length_constraint.node = node_index;
308 length_constraint.elem_position_a = cloth_sim.
pos[
v];
309 length_constraint.elem_position_b = cloth_sim.
softbody_pos[
v];
313 length_constraint.length = 0.0f;
314 length_constraint.strength = strength;
320 const int node_index,
322 const float strength)
327 length_constraint.elem_index_b =
v;
329 length_constraint.node = node_index;
331 length_constraint.elem_position_a = cloth_sim.
pos[
v];
332 length_constraint.elem_position_b = cloth_sim.
init_pos[
v];
336 length_constraint.length = 0.0f;
337 length_constraint.strength = strength;
343 const int node_index,
345 const float strength)
350 length_constraint.elem_index_b =
v;
352 length_constraint.node = node_index;
356 length_constraint.elem_position_a = cloth_sim.
pos[
v];
359 length_constraint.length = 0.0f;
360 length_constraint.strength = strength;
367 const float3 &cloth_sim_initial_location,
368 const float cloth_sim_radius,
370 const int node_index,
378 const bool is_brush_has_stroke_cache = ss.
cache !=
nullptr && brush !=
nullptr;
379 const bool pin_simulation_boundary = is_brush_has_stroke_cache &&
390 float radius_squared = 0.0f;
391 if (cloth_is_deform_brush) {
398 cloth_sim_radius * cloth_sim_radius :
401 for (
const int i :
verts.index_range()) {
402 const int vert =
verts[i];
404 cloth_sim_initial_location);
410 const Span<int> neighbors = vert_neighbors[i];
416 for (
const int neighbor : neighbors) {
417 if (created_length_constraints.
add({vert, neighbor})) {
421 for (
const int a : neighbors) {
422 for (
const int b : neighbors) {
424 if (created_length_constraints.
add({a, b})) {
436 if (use_falloff_plane) {
466 if (pin_simulation_boundary) {
470 if (sim_falloff < 1.0f) {
483 const float3 &initial_location,
499 switch (pbvh.
type()) {
503 node_mask,
GrainSize(1024), memory, [&](
const int i) {
507 const Mesh &mesh = *
static_cast<const Mesh *
>(
object.data);
509 const Span<int> corner_verts = mesh.corner_verts();
520 persistent_position = *attributes.lookup<
float3>(
".sculpt_persistent_co",
523 if (persistent_position.
is_empty()) {
524 init_positions = cloth_sim.
init_pos;
527 init_positions = persistent_position;
529 uninitialized_nodes.foreach_index([&](
const int i) {
533 faces, corner_verts, vert_to_face_map, hide_poly,
verts, vert_neighbors);
543 created_length_constraints);
550 node_mask,
GrainSize(1024), memory, [&](
const int i) {
557 uninitialized_nodes.foreach_index([&](
const int i) {
559 key, grid_hidden, nodes[i].grids(), vert_indices);
571 created_length_constraints);
578 node_mask,
GrainSize(1024), memory, [&](
const int i) {
585 uninitialized_nodes.foreach_index([&](
const int i) {
599 created_length_constraints);
611 for (
const int i :
verts.index_range()) {
621 for (
const int i :
verts.index_range()) {
622 length_constraint_tweak[
verts[i]] += factors[i] * 0.01f;
630 for (
const int i : positions.index_range()) {
639 for (
float &factor : factors) {
640 factor = std::clamp(factor,
min, max);
647 const bool use_falloff_plane,
648 const float3 &grab_delta_symmetry)
650 for (
const int i :
verts.index_range()) {
652 grab_delta_symmetry * factors[i];
654 if (use_falloff_plane) {
666 const float3 &grab_delta_symmetry)
668 for (
const int i :
verts.index_range()) {
669 const int vert =
verts[i];
670 cloth_sim.
deformation_pos[vert] = cloth_sim.
pos[vert] + grab_delta_symmetry * factors[i];
686 const float3 &plane_normal,
689 for (
const int i : positions.index_range()) {
702 for (
const int i : positions.index_range()) {
704 const float3 x_disp = x_object_space *
math::dot(disp_center, x_object_space);
705 const float3 z_disp = z_object_space *
math::dot(disp_center, z_object_space);
706 forces[i] = x_disp + z_disp;
731 const float3 &sim_location,
733 const std::optional<FalloffPlane> &falloff_plane,
840 const float3 &sim_location,
842 const std::optional<FalloffPlane> &falloff_plane,
950 const float3 &sim_location,
952 const std::optional<FalloffPlane> &falloff_plane,
1027 if (falloff_plane) {
1062 if (
STREQ(
object.
id.name, ob->id.name)) {
1099 float(*positions)[3] = col_data->
x;
1100 float *tri[3], no[3], co[3];
1102 tri[0] = positions[vert_tri[0]];
1103 tri[1] = positions[vert_tri[1]];
1104 tri[2] = positions[vert_tri[2]];
1108 ray->origin, &
col->isect_precalc,
UNPACK3(tri), &dist,
nullptr);
1112 if (tri_hit && dist < hit->dist) {
1127 const float4x4 &object_to_world =
object.object_to_world();
1128 const float4x4 &world_to_object =
object.world_to_object();
1139 pos_world_space - prev_pos_world_space, hit.dist);
1143 col.col_data = collmd;
1147 prev_pos_world_space,
1155 if (hit.index == -1) {
1163 float3 pos_on_friction_plane;
1165 constexpr float friction_factor = 0.35f;
1166 const float3 movement_disp = (pos_on_friction_plane -
float3(hit.co)) * friction_factor;
1169 float3(hit.co) + movement_disp + collision_disp);
1175 const float3 &sim_location,
1185 for (
const int i :
verts.index_range()) {
1189 for (
const int vert :
verts) {
1193 for (
const int i :
verts.index_range()) {
1194 const int vert =
verts[i];
1206 for (
const int i :
verts.index_range()) {
1207 const int vert =
verts[i];
1208 cloth_sim.
pos[vert] += pos_diff[i];
1211 for (
const int vert :
verts) {
1215 for (
const int vert :
verts) {
1225 const float3 &sim_location,
1241 switch (pbvh.
type()) {
1243 const Mesh &mesh = *
static_cast<const Mesh *
>(
object.data);
1257 *brush, ss.
cache->
radius, sim_location, positions, factors);
1269 const Span<int> grids = nodes[i].grids();
1277 subdiv_ccg, init_positions, grids, tls.
positions);
1279 *brush, ss.
cache->
radius, sim_location, positions, factors);
1299 *brush, ss.
cache->
radius, sim_location, positions, factors);
1328 const int v1 = constraint.elem_index_a;
1329 const int v2 = constraint.elem_index_b;
1331 const float3 v1_to_v2 =
float3(constraint.elem_position_b) -
1332 float3(constraint.elem_position_a);
1334 float3 correction_vector;
1336 const float constraint_distance = constraint.length +
1340 if (current_distance > 0.0f) {
1342 (1.0f - (constraint_distance / current_distance));
1348 const float3 correction_vector_half = correction_vector * 0.5f;
1350 const float factor_v1 = factors[v1];
1351 const float factor_v2 = factors[
v2];
1353 float deformation_strength = 1.0f;
1362 cloth_sim.
pos[v1] += correction_vector_half *
1363 (1.0f * factor_v1 * constraint.strength * softbody_plasticity);
1364 cloth_sim.
softbody_pos[v1] += correction_vector_half * -1.0f * factor_v1 *
1365 constraint.strength * (1.0f - softbody_plasticity);
1368 cloth_sim.
pos[v1] += correction_vector_half * 1.0f * factor_v1 * constraint.strength *
1369 deformation_strength;
1371 cloth_sim.
pos[
v2] += correction_vector_half * -1.0f * factor_v2 * constraint.strength *
1372 deformation_strength;
1396 switch (pbvh.
type()) {
1400 node_mask,
GrainSize(1024), memory, [&](
const int i) {
1404 Mesh &mesh = *
static_cast<Mesh *
>(
object.data);
1407 active_nodes.foreach_index(
GrainSize(1), [&](
const int i) {
1422 for (
const int i :
verts.index_range()) {
1438 node_mask,
GrainSize(1024), memory, [&](
const int i) {
1446 active_nodes.foreach_index(
GrainSize(1), [&](
const int i) {
1448 const Span<int> grids = nodes[i].grids();
1460 for (
const int grid : grids) {
1462 positions.slice(grid_range).copy_from(cloth_positions.
slice(grid_range));
1474 node_mask,
GrainSize(1024), memory, [&](
const int i) {
1479 active_nodes.foreach_index(
GrainSize(1), [&](
const int i) {
1553 cache.
cloth_sim->deformation_strength.fill(0.0f);
1564 std::optional<FalloffPlane> falloff_plane;
1566 falloff_plane.emplace();
1574 switch (pbvh.
type()) {
1645 switch (pbvh.
type()) {
1670 switch (pbvh.
type()) {
1676 positions.copy_from(subdiv_ccg.
positions);
1691 switch (pbvh.
type()) {
1697 normals.copy_from(subdiv_ccg.
normals);
1708 const float cloth_mass,
1709 const float cloth_damping,
1710 const float cloth_softbody_strength,
1711 const bool use_collisions,
1712 const bool needs_deform_coords)
1715 std::unique_ptr<SimulationData> cloth_sim = std::make_unique<SimulationData>();
1721 cloth_sim->length_constraint_tweak =
Array<float>(totverts, 0.0f);
1723 cloth_sim->init_pos.reinitialize(totverts);
1726 cloth_sim->last_iteration_pos = cloth_sim->init_pos;
1727 cloth_sim->prev_pos = cloth_sim->init_pos;
1729 cloth_sim->init_no.reinitialize(totverts);
1732 if (needs_deform_coords) {
1733 cloth_sim->deformation_pos = cloth_sim->init_pos;
1734 cloth_sim->deformation_strength =
Array<float>(totverts, 1.0f);
1737 if (cloth_softbody_strength > 0.0f) {
1738 cloth_sim->softbody_pos = cloth_sim->init_pos;
1741 cloth_sim->mass = cloth_mass;
1742 cloth_sim->damping = cloth_damping;
1743 cloth_sim->softbody_strength = cloth_softbody_strength;
1745 if (use_collisions) {
1766 switch (pbvh.
type()) {
1867 const float location[3],
1868 const float normal[3],
1870 const float line_width,
1871 const float outline_col[3],
1874 float cursor_trans[4][4], cursor_rot[4][4];
1875 const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f};
1878 translate_m4(cursor_trans, location[0], location[1], location[2]);
1896 const float outline_col[3],
1897 float outline_alpha)
1920 immVertex3f(gpuattr, dist - arrow_x, arrow_y, 0.0f);
1921 immVertex3f(gpuattr, dist - arrow_x, -arrow_y, 0.0f);
1924 immVertex3f(gpuattr, -dist + arrow_x, arrow_y, 0.0f);
1925 immVertex3f(gpuattr, -dist + arrow_x, -arrow_y, 0.0f);
1948 "Pulls the cloth to the cursor's start position"},
1953 "Scales the mesh as a soft body using the origin of the object as scale"},
1954 {0,
nullptr, 0,
nullptr,
nullptr},
1962 "Use the local axis to limit the force and set the gravity direction"},
1967 "Use the global axis to limit the force and set the gravity direction"},
1972 "Use the view axis to limit the force and set the gravity direction"},
1973 {0,
nullptr, 0,
nullptr,
nullptr},
1986 {0,
nullptr, 0,
nullptr,
nullptr},
2004 force[1] = -factors[i];
2007 force[2] = -factors[i];
2009 forces[i] = to_object_space * force;
2030 for (
const int i :
verts.index_range()) {
2038 const float filter_strength,
2060 for (
const int i :
verts.index_range()) {
2061 const int vert =
verts[i];
2075 forces.
fill(gravity);
2079 switch (filter_type) {
2110 const float filter_strength,
2147 forces.
fill(gravity);
2151 switch (filter_type) {
2181 const float filter_strength,
2218 forces.
fill(gravity);
2222 switch (filter_type) {
2271 const float len =
event->prev_press_xy[0] -
event->xy[0];
2294 switch (pbvh.
type()) {
2298 const Mesh &mesh = *
static_cast<const Mesh *
>(
object.data);
2320 const Mesh &base_mesh = *
static_cast<const Mesh *
>(
object.data);
2322 const VArraySpan face_sets = *attributes.lookup<
int>(
".sculpt_face_set",
2324 SubdivCCG &subdiv_ccg = *
object.sculpt->subdiv_ccg;
2330 *
depsgraph, face_sets, filter_type, filter_strength, gravity, nodes[i],
object, tls);
2340 *
depsgraph, filter_type, filter_strength, gravity, nodes[i],
object, tls);
2417 if (use_face_sets) {
2437 ot->
name =
"Filter Cloth";
2438 ot->
idname =
"SCULPT_OT_cloth_filter";
2439 ot->
description =
"Applies a cloth simulation deformation to the entire mesh";
2454 "Operation that is going to be applied to the mesh");
2461 "Apply the force in the selected axis");
2467 "Orientation of the axis to limit the filter force");
2474 "Mass of each simulation particle",
2483 "How much the applied forces are propagated through the cloth",
2490 "Apply the filter only to the Face Set under the cursor");
2495 "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 unit_m4(float m[4][4])
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
void normalize_m4(float R[4][4]) ATTR_NONNULL()
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_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)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_vert_coords_get(BMesh *bm, MutableSpan< float3 > positions)
void BM_mesh_vert_normals_get(BMesh *bm, MutableSpan< float3 > normals)
void BM_mesh_elem_table_ensure(BMesh *bm, const char htype)
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
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
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
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 fill_indices(Span< IndexT > indices, const T &value) 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)
void resize(const int64_t new_size)
void tag_positions_changed(const IndexMask &node_mask)
Span< NodeT > nodes() const
static IndexMask from_predicate(const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
void foreach_index(Fn &&fn) const
local_group_size(16, 16) .push_constant(Type b
const Depsgraph * depsgraph
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
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)
void flush_bounds_to_parents(Tree &pbvh)
void calc_grids_factors(const Depsgraph &depsgraph, const Object &object, const Cache &cache, const bke::pbvh::GridsNode &node, Span< int > grids, MutableSpan< float > factors)
std::unique_ptr< Cache > cache_init(const Depsgraph &depsgraph, const Sculpt &sd, Object &ob)
const Cache * active_cache_get(const SculptSession &ss)
void calc_vert_factors(const Depsgraph &depsgraph, const Object &object, const Cache &cache, const bke::pbvh::MeshNode &node, Span< int > verts, MutableSpan< float > factors)
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 Span< Vector< int > > vert_neighbors, SimulationData &cloth_sim, Set< OrderedEdge > &created_length_constraints)
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 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)
static void calc_vert_neighbor_indices_grids(const SubdivCCG &subdiv_ccg, const Span< int > verts, const MutableSpan< Vector< int > > neighbor_indices)
void do_cloth_brush(const Depsgraph &depsgraph, const Sculpt &sd, Object &object, const IndexMask &node_mask)
static void calc_vert_neighbor_indices_bmesh(const BMesh &bm, const Span< int > verts, const MutableSpan< Vector< int > > neighbor_indices)
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 BLI_NOINLINE void apply_snake_hook_brush(SimulationData &cloth_sim, const Span< int > verts, const MutableSpan< float > factors, const float3 &grab_delta_symmetry)
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 int sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent *event)
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)
static void cloth_brush_apply_brush_foces(const Depsgraph &depsgraph, const Sculpt &sd, Object &ob, const IndexMask &node_mask)
static EnumPropertyItem prop_cloth_filter_orientation_items[]
static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static BLI_NOINLINE void fill_factor_from_hide_and_mask(const Mesh &mesh, const Span< int > face_indices, const MutableSpan< float > r_factors)
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 cache_init(bContext *C, Object &ob, const Sculpt &sd, undo::Type undo_type, const float mval_fl[2], float area_normal_radius, float start_strength)
void zero_disabled_axis_components(const filter::Cache &filter_cache, MutableSpan< float3 > vectors)
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)
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 apply_hardness_to_distances(float radius, float hardness, MutableSpan< float > distances)
void gather_bmesh_normals(const Set< BMVert *, 0 > &verts, MutableSpan< float3 > normals)
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 flush_update_done(const bContext *C, Object &ob, UpdateType update_type)
void calc_brush_distances(const SculptSession &ss, Span< float3 > vert_positions, Span< int > vert_indices, eBrushFalloffShape falloff_shape, MutableSpan< float > r_distances)
void scale_translations(MutableSpan< float3 > translations, Span< float > factors)
void flush_update_step(bContext *C, UpdateType update_type)
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)
void scatter_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
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, Vector< BMVert *, 64 > &r_neighbors)
void gather_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
void calc_vert_neighbors(OffsetIndices< int > faces, Span< int > corner_verts, GroupedSpan< int > vert_to_face, Span< bool > hide_poly, Span< int > verts, MutableSpan< Vector< int > > result)
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(const SculptSession &ss, const Brush &brush, Span< float3 > vert_positions, Span< int > vert_indices, MutableSpan< float > factors)
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)
VecBase< float, 3 > float3
CCL_NAMESPACE_BEGIN ccl_device float fade(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_cursor_geometry_info_update(bContext *C, SculptCursorGeometryInfo *out, const float mval[2], bool use_sampled_normal)
void SCULPT_vertex_random_access_ensure(Object &object)
bool SCULPT_mode_poll(bContext *C)
int SCULPT_vertex_count_get(const Object &object)
bool SCULPT_stroke_is_first_brush_step(const blender::ed::sculpt_paint::StrokeCache &cache)
#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 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
struct Object * gravity_object
static SubdivCCGCoord from_index(const CCGKey &key, int index)
blender::Vector< SubdivCCGCoord, 256 > coords
blender::Array< blender::float3 > normals
blender::Array< blender::float3 > positions
const c_style_mat & ptr() const
static MatBase identity()
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
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)