Blender V4.3
sculpt_cloth.cc File Reference
#include "sculpt_cloth.hh"
#include "MEM_guardedalloc.h"
#include "BLI_array_utils.hh"
#include "BLI_enumerable_thread_specific.hh"
#include "BLI_math_matrix.h"
#include "BLI_math_matrix.hh"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.hh"
#include "BLI_utildefines.h"
#include "BLI_vector.hh"
#include "BLT_translation.hh"
#include "DNA_brush_types.h"
#include "DNA_customdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_brush.hh"
#include "BKE_bvhutils.hh"
#include "BKE_ccg.hh"
#include "BKE_collision.h"
#include "BKE_context.hh"
#include "BKE_layer.hh"
#include "BKE_mesh.hh"
#include "BKE_modifier.hh"
#include "BKE_paint.hh"
#include "BKE_pbvh_api.hh"
#include "BKE_subdiv_ccg.hh"
#include "DEG_depsgraph_query.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "ED_sculpt.hh"
#include "brushes/types.hh"
#include "mesh_brush_common.hh"
#include "sculpt_automask.hh"
#include "sculpt_face_set.hh"
#include "sculpt_filter.hh"
#include "sculpt_hide.hh"
#include "sculpt_intern.hh"
#include "sculpt_undo.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "GPU_immediate.hh"
#include "GPU_immediate_util.hh"
#include "GPU_matrix.hh"
#include "GPU_state.hh"
#include "UI_interface.hh"
#include "bmesh.hh"
#include <cmath>
#include <cstdlib>
#include <cstring>

Go to the source code of this file.

Classes

struct  blender::ed::sculpt_paint::cloth::LocalData
 
struct  blender::ed::sculpt_paint::cloth::FalloffPlane
 
struct  blender::ed::sculpt_paint::cloth::ClothBrushCollision
 
struct  blender::ed::sculpt_paint::cloth::FilterLocalData
 

Namespaces

namespace  blender
 
namespace  blender::ed
 
namespace  blender::ed::sculpt_paint
 
namespace  blender::ed::sculpt_paint::cloth
 

Macros

#define CLOTH_LENGTH_CONSTRAINTS_BLOCK   100000
 
#define CLOTH_SIMULATION_ITERATIONS   5
 
#define CLOTH_SOLVER_DISPLACEMENT_FACTOR   0.6f
 
#define CLOTH_MAX_CONSTRAINTS_PER_VERTEX   1024
 
#define CLOTH_SIMULATION_TIME_STEP   0.01f
 
#define CLOTH_DEFORMATION_SNAKEHOOK_STRENGTH   0.35f
 
#define CLOTH_DEFORMATION_TARGET_STRENGTH   0.01f
 
#define CLOTH_DEFORMATION_GRAB_STRENGTH   0.1f
 

Enumerations

enum class  blender::ed::sculpt_paint::cloth::ClothFilterType {
  blender::ed::sculpt_paint::cloth::Gravity , blender::ed::sculpt_paint::cloth::Inflate , blender::ed::sculpt_paint::cloth::Expand , blender::ed::sculpt_paint::cloth::Pinch ,
  blender::ed::sculpt_paint::cloth::Scale
}
 
enum  blender::ed::sculpt_paint::cloth::eClothFilterForceAxis { blender::ed::sculpt_paint::cloth::CLOTH_FILTER_FORCE_X = 1 << 0 , blender::ed::sculpt_paint::cloth::CLOTH_FILTER_FORCE_Y = 1 << 1 , blender::ed::sculpt_paint::cloth::CLOTH_FILTER_FORCE_Z = 1 << 2 }
 

Functions

static MutableSpan< intblender::ed::sculpt_paint::cloth::calc_vert_indices_grids (const CCGKey &key, const Span< int > grids, Vector< int > &indices)
 
static MutableSpan< intblender::ed::sculpt_paint::cloth::calc_vert_indices_bmesh (const Set< BMVert *, 0 > &verts, Vector< int > &indices)
 
static MutableSpan< intblender::ed::sculpt_paint::cloth::calc_visible_vert_indices_grids (const CCGKey &key, const BitGroupVector<> &grid_hidden, const Span< int > grids, Vector< int > &indices)
 
static MutableSpan< intblender::ed::sculpt_paint::cloth::calc_visible_vert_indices_bmesh (const Set< BMVert *, 0 > &verts, Vector< int > &indices)
 
static void blender::ed::sculpt_paint::cloth::calc_vert_neighbor_indices_grids (const SubdivCCG &subdiv_ccg, const Span< int > verts, const MutableSpan< Vector< int > > neighbor_indices)
 
static void blender::ed::sculpt_paint::cloth::calc_vert_neighbor_indices_bmesh (const BMesh &bm, const Span< int > verts, const MutableSpan< Vector< int > > neighbor_indices)
 
static float3 blender::ed::sculpt_paint::cloth::cloth_brush_simulation_location_get (const SculptSession &ss, const Brush *brush)
 
IndexMask blender::ed::sculpt_paint::cloth::brush_affected_nodes_gather (const Object &object, const Brush &brush, IndexMaskMemory &memory)
 
bool blender::ed::sculpt_paint::cloth::is_cloth_deform_brush (const Brush &brush)
 
static float blender::ed::sculpt_paint::cloth::cloth_brush_simulation_falloff_get (const Brush &brush, const float radius, const float3 &location, const float3 &co)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::cloth::calc_brush_simulation_falloff (const Brush &brush, const float radius, const float3 &location, const Span< float3 > positions, const MutableSpan< float > factors)
 
static void blender::ed::sculpt_paint::cloth::cloth_brush_add_length_constraint (SimulationData &cloth_sim, const int node_index, const int v1, const int v2, const Span< float3 > init_positions)
 
static void blender::ed::sculpt_paint::cloth::cloth_brush_add_softbody_constraint (SimulationData &cloth_sim, const int node_index, const int v, const float strength)
 
static void blender::ed::sculpt_paint::cloth::cloth_brush_add_pin_constraint (SimulationData &cloth_sim, const int node_index, const int v, const float strength)
 
static void blender::ed::sculpt_paint::cloth::cloth_brush_add_deformation_constraint (SimulationData &cloth_sim, const int node_index, const int v, const float strength)
 
static void blender::ed::sculpt_paint::cloth::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)
 
void blender::ed::sculpt_paint::cloth::ensure_nodes_constraints (const Sculpt &sd, Object &object, const IndexMask &node_mask, SimulationData &cloth_sim, const float3 &initial_location, const float radius)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::cloth::apply_forces (SimulationData &cloth_sim, const Span< float3 > forces, const Span< int > verts)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::cloth::expand_length_constraints (SimulationData &cloth_sim, const Span< int > verts, const Span< float > factors)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::cloth::calc_distances_to_plane (const Span< float3 > positions, const float4 &plane, const MutableSpan< float > distances)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::cloth::clamp_factors (const MutableSpan< float > factors, const float min, const float max)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::cloth::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 blender::ed::sculpt_paint::cloth::apply_snake_hook_brush (SimulationData &cloth_sim, const Span< int > verts, const MutableSpan< float > factors, const float3 &grab_delta_symmetry)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::cloth::calc_pinch_forces (const Span< float3 > positions, const float3 &location, const MutableSpan< float3 > forces)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::cloth::calc_plane_pinch_forces (const Span< float3 > positions, const float4 &plane, const float3 &plane_normal, const MutableSpan< float3 > forces)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::cloth::calc_perpendicular_pinch_forces (const Span< float3 > positions, const float4x4 &imat, const float3 &location, const MutableSpan< float3 > forces)
 
static void blender::ed::sculpt_paint::cloth::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 blender::ed::sculpt_paint::cloth::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 void blender::ed::sculpt_paint::cloth::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 Vector< ColliderCacheblender::ed::sculpt_paint::cloth::cloth_brush_collider_cache_create (Object &object, const Depsgraph &depsgraph)
 
static void blender::ed::sculpt_paint::cloth::cloth_brush_collision_cb (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
 
static void blender::ed::sculpt_paint::cloth::cloth_brush_solve_collision (const Object &object, SimulationData &cloth_sim, const int i)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::cloth::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 blender::ed::sculpt_paint::cloth::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 void blender::ed::sculpt_paint::cloth::cloth_brush_satisfy_constraints (const Depsgraph &depsgraph, const Object &object, const Brush *brush, SimulationData &cloth_sim)
 
void blender::ed::sculpt_paint::cloth::do_simulation_step (const Depsgraph &depsgraph, const Sculpt &sd, Object &object, SimulationData &cloth_sim, const IndexMask &node_mask)
 
static void blender::ed::sculpt_paint::cloth::cloth_brush_apply_brush_foces (const Depsgraph &depsgraph, const Sculpt &sd, Object &ob, const IndexMask &node_mask)
 
static void blender::ed::sculpt_paint::cloth::cloth_sim_initialize_default_node_state (Object &object, SimulationData &cloth_sim)
 
static void blender::ed::sculpt_paint::cloth::copy_positions_to_array (const Depsgraph &depsgraph, const Object &object, MutableSpan< float3 > positions)
 
static void blender::ed::sculpt_paint::cloth::copy_normals_to_array (const Depsgraph &depsgraph, const Object &object, MutableSpan< float3 > normals)
 
std::unique_ptr< SimulationDatablender::ed::sculpt_paint::cloth::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)
 
void blender::ed::sculpt_paint::cloth::brush_store_simulation_state (const Depsgraph &depsgraph, const Object &object, SimulationData &cloth_sim)
 
void blender::ed::sculpt_paint::cloth::sim_activate_nodes (Object &object, SimulationData &cloth_sim, const IndexMask &node_mask)
 
static void blender::ed::sculpt_paint::cloth::sculpt_cloth_ensure_constraints_in_simulation_area (const Sculpt &sd, Object &ob, const IndexMask &node_mask)
 
void blender::ed::sculpt_paint::cloth::do_cloth_brush (const Depsgraph &depsgraph, const Sculpt &sd, Object &object, const IndexMask &node_mask)
 
void blender::ed::sculpt_paint::cloth::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)
 
void blender::ed::sculpt_paint::cloth::plane_falloff_preview_draw (const uint gpuattr, SculptSession &ss, const float outline_col[3], float outline_alpha)
 
static bool blender::ed::sculpt_paint::cloth::cloth_filter_is_deformation_filter (ClothFilterType filter_type)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::cloth::calc_gravity_forces (const Span< float > factors, const filter::Cache &filter_cache, const MutableSpan< float3 > forces)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::cloth::apply_scale_filter (filter::Cache &filter_cache, const Span< int > verts, const Span< float > factors, FilterLocalData &tls)
 
static void blender::ed::sculpt_paint::cloth::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 blender::ed::sculpt_paint::cloth::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 blender::ed::sculpt_paint::cloth::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 int blender::ed::sculpt_paint::cloth::sculpt_cloth_filter_modal (bContext *C, wmOperator *op, const wmEvent *event)
 
static int blender::ed::sculpt_paint::cloth::sculpt_cloth_filter_invoke (bContext *C, wmOperator *op, const wmEvent *event)
 
void blender::ed::sculpt_paint::cloth::SCULPT_OT_cloth_filter (wmOperatorType *ot)
 

Variables

static EnumPropertyItem blender::ed::sculpt_paint::cloth::prop_cloth_filter_type []
 
static EnumPropertyItem blender::ed::sculpt_paint::cloth::prop_cloth_filter_orientation_items []
 
static EnumPropertyItem blender::ed::sculpt_paint::cloth::prop_cloth_filter_force_axis_items []
 

Macro Definition Documentation

◆ CLOTH_DEFORMATION_GRAB_STRENGTH

#define CLOTH_DEFORMATION_GRAB_STRENGTH   0.1f

◆ CLOTH_DEFORMATION_SNAKEHOOK_STRENGTH

#define CLOTH_DEFORMATION_SNAKEHOOK_STRENGTH   0.35f

◆ CLOTH_DEFORMATION_TARGET_STRENGTH

#define CLOTH_DEFORMATION_TARGET_STRENGTH   0.01f

◆ CLOTH_LENGTH_CONSTRAINTS_BLOCK

#define CLOTH_LENGTH_CONSTRAINTS_BLOCK   100000

◆ CLOTH_MAX_CONSTRAINTS_PER_VERTEX

#define CLOTH_MAX_CONSTRAINTS_PER_VERTEX   1024

Definition at line 266 of file sculpt_cloth.cc.

◆ CLOTH_SIMULATION_ITERATIONS

#define CLOTH_SIMULATION_ITERATIONS   5

◆ CLOTH_SIMULATION_TIME_STEP

#define CLOTH_SIMULATION_TIME_STEP   0.01f

◆ CLOTH_SOLVER_DISPLACEMENT_FACTOR

#define CLOTH_SOLVER_DISPLACEMENT_FACTOR   0.6f