38# include "eltopo-capi.h"
65 const bool moving_bvh)
93 const int3 *vert_tris,
100 for (
int i = 0; i < tri_num; i++) {
103 copy_v3_v3(co[0], positions[vert_tris[i][0]]);
104 copy_v3_v3(co[1], positions[vert_tris[i][1]]);
105 copy_v3_v3(co[2], positions[vert_tris[i][2]]);
117 const float (*positions)[3],
118 const float (*positions_moving)[3],
119 const int3 *vert_tris,
124 if ((bvhtree ==
nullptr) || (positions ==
nullptr)) {
128 if (positions_moving ==
nullptr) {
132 for (
int i = 0; i < tri_num; i++) {
136 copy_v3_v3(co[0], positions[vert_tris[i][0]]);
137 copy_v3_v3(co[1], positions[vert_tris[i][1]]);
138 copy_v3_v3(co[2], positions[vert_tris[i][2]]);
142 float co_moving[3][3];
144 copy_v3_v3(co_moving[0], positions_moving[vert_tris[i][0]]);
145 copy_v3_v3(co_moving[1], positions_moving[vert_tris[i][1]]);
146 copy_v3_v3(co_moving[2], positions_moving[vert_tris[i][2]]);
167 return (++i < 3) ? i : 0;
185 float tmp_co1[3], tmp_co2[3];
186 float isect_a[3], isect_b[3];
187 float tmp, tmp_vec[3];
188 float normal[3], cent[3];
189 bool backside =
false;
200 int tri_a_edge_isect_count;
202 a,
b, isect_a, isect_b, &tri_a_edge_isect_count);
209 if (!is_intersecting) {
210 for (
int i = 0; i < 3; i++) {
212 if (
dot_v3v3(tmp_vec, normal) < 0.0f) {
218 else if (tri_a_edge_isect_count != 1) {
223 else if (use_normal) {
227 if (tri_a_edge_isect_count == 1) {
243 float maxdist = 0.0f;
247 for (
int i = 0; i < 3; i++) {
260 for (
int i = 0; i < 3; i++) {
274 for (
int i = 0; i < 3; i++) {
280 for (
int j = 0; j < 3; j++) {
289 if ((tmp > maxdist) && (
dot_v3v3(tmp_vec, normal) < 0.0f)) {
304 if (
dot_v3v3(normal, r_vec) >= 0.0f) {
317 for (
int i = 0; i < 3; i++) {
328 for (
int i = 0; i < 3; i++) {
340 if (!is_intersecting) {
341 for (
int i = 0; i < 3; i++) {
342 for (
int j = 0; j < 3; j++) {
355 if (!is_intersecting) {
364 if (culling && use_normal) {
367 else if (use_normal) {
368 if (
dot_v3v3(normal, r_vec) >= 0.0f) {
375 else if (culling && (
dot_v3v3(r_vec, normal) < 0.0f)) {
396 float tmp_co1[3], tmp_co2[3];
399 float tmp, tmp_vec[3];
400 float normal[3], cent[3];
401 bool backside =
false;
426 for (
int i = 0; i < 2; i++) {
428 if (
dot_v3v3(tmp_vec, normal) < 0.0f) {
447 float maxdist = 0.0f;
451 for (
int i = 0; i < 2; i++) {
463 for (
int i = 0; i < 3; i++) {
477 if ((tmp > maxdist) && (
dot_v3v3(tmp_vec, normal) < 0.0f)) {
491 if (
dot_v3v3(normal, r_vec) >= 0.0f) {
504 for (
int i = 0; i < 2; i++) {
517 for (
int j = 0; j < 3; j++) {
538 if (culling && use_normal) {
541 else if (use_normal) {
542 if (
dot_v3v3(normal, r_vec) >= 0.0f) {
549 else if (culling && (
dot_v3v3(r_vec, normal) < 0.0f)) {
566#define INPR(v1, v2) ((v1)[0] * (v2)[0] + (v1)[1] * (v2)[1] + (v1)[2] * (v2)[2])
568 double tempV1[3], tempV2[3], tempV4[3];
569 double a,
b, c, d,
e, f;
575 a =
INPR(tempV1, tempV1);
576 b =
INPR(tempV1, tempV2);
577 c =
INPR(tempV2, tempV2);
578 e =
INPR(tempV1, tempV4);
579 f =
INPR(tempV2, tempV4);
584 *w1 = *w2 = *w3 = 1.0 / 3.0;
588 w1[0] =
float((
e * c -
b * f) / d);
589 w1[0] = std::max<float>(w1[0], 0);
591 w2[0] =
float((f -
b *
double(w1[0])) / c);
592 w2[0] = std::max<float>(w2[0], 0);
594 w3[0] = 1.0f - w1[0] - w2[0];
600# pragma GCC diagnostic push
601# pragma GCC diagnostic ignored "-Wdouble-promotion"
619 const float impulse[3],
624 if ((clamp_sq > 0.0f) && (impulse_len_sq > clamp_sq)) {
628 if (
fabsf(vert->impulse[0]) <
fabsf(impulse[0])) {
629 vert->impulse[0] = impulse[0];
632 if (
fabsf(vert->impulse[1]) <
fabsf(impulse[1])) {
633 vert->impulse[1] = impulse[1];
636 if (
fabsf(vert->impulse[2]) <
fabsf(impulse[2])) {
637 vert->impulse[2] = impulse[2];
640 vert->impulse_count++;
647 uint collision_count,
655 const float min_distance = (clmd->
coll_parms->
epsilon + epsilon2) * (8.0f / 9.0f);
657 const bool is_hair = (clmd->
hairdata !=
nullptr);
658 for (
int i = 0; i < collision_count; i++, collpair++) {
659 float i1[3], i2[3], i3[3];
660 float v1[3],
v2[3], relativeVelocity[3];
671 float w1 = collpair->
aw1, w2 = collpair->
aw2, w3 = collpair->
aw3;
672 float u1 = collpair->
bw1, u2 = collpair->
bw2, u3 = collpair->
bw3;
699 const float magrelVel =
dot_v3v3(relativeVelocity, collpair->
normal);
700 const float d = min_distance - collpair->
distance;
703 if (magrelVel > 0.0f) {
705 float magtangent = 0, repulse = 0;
706 double impulse = 0.0;
724 impulse = magtangent / 1.5;
726 VECADDMUL(i1, vrel_t_pre,
double(w1) * impulse);
727 VECADDMUL(i2, vrel_t_pre,
double(w2) * impulse);
730 VECADDMUL(i3, vrel_t_pre,
double(w3) * impulse);
735 impulse = magrelVel / 1.5f;
743 if ((magrelVel < 0.1f * d * time_multiplier) && (d >
ALMOST_ZERO)) {
744 repulse = std::min(d / time_multiplier, 0.1f * d * time_multiplier - magrelVel);
748 repulse =
min_ff(repulse, 5.0f * impulse);
751 repulse =
max_ff(impulse, repulse);
753 impulse = repulse / 1.5f;
766 float repulse = d / time_multiplier;
767 float impulse = repulse / 4.5f;
793 uint collision_count,
802 for (
int i = 0; i < collision_count; i++, collpair++) {
803 float ia[3][3] = {{0.0f}};
804 float ib[3][3] = {{0.0f}};
805 float v1[3],
v2[3], relativeVelocity[3];
813 float w1 = collpair->
aw1, w2 = collpair->
aw2, w3 = collpair->
aw3;
814 float u1 = collpair->
bw1, u2 = collpair->
bw2, u3 = collpair->
bw3;
837 const float magrelVel =
dot_v3v3(relativeVelocity, collpair->
normal);
838 const float d = min_distance - collpair->
distance;
844 if (magrelVel > 0.0f) {
846 float magtangent = 0, repulse = 0;
847 double impulse = 0.0;
865 impulse = magtangent / 1.5;
867 VECADDMUL(ia[0], vrel_t_pre,
double(w1) * impulse);
868 VECADDMUL(ia[1], vrel_t_pre,
double(w2) * impulse);
869 VECADDMUL(ia[2], vrel_t_pre,
double(w3) * impulse);
871 VECADDMUL(ib[0], vrel_t_pre,
double(u1) * -impulse);
872 VECADDMUL(ib[1], vrel_t_pre,
double(u2) * -impulse);
873 VECADDMUL(ib[2], vrel_t_pre,
double(u3) * -impulse);
877 impulse = magrelVel / 3.0f;
887 if ((magrelVel < 0.1f * d * time_multiplier) && (d >
ALMOST_ZERO)) {
888 repulse = std::min(d / time_multiplier, 0.1f * d * time_multiplier - magrelVel);
891 repulse =
min_ff(repulse, 5.0 * impulse);
894 repulse =
max_ff(impulse, repulse);
895 impulse = repulse / 1.5f;
910 float repulse = d * 1.0f / time_multiplier;
911 float impulse = repulse / 9.0f;
939# pragma GCC diagnostic pop
944 const int3 vert_tri_a)
949 const int flags_a = verts[vert_tri_a[0]].
flags & verts[vert_tri_a[1]].
flags &
950 verts[vert_tri_a[2]].
flags;
972 float pa[3], pb[3], vect[3];
979 verts1[vert_tri_a[1]].tx,
980 verts1[vert_tri_a[2]].tx,
991 collpair[
index].
ap1 = vert_tri_a[0];
992 collpair[
index].
ap2 = vert_tri_a[1];
993 collpair[
index].
ap3 = vert_tri_a[2];
995 collpair[
index].
bp1 = vert_tri_b[0];
996 collpair[
index].
bp2 = vert_tri_b[1];
997 collpair[
index].
bp3 = vert_tri_b[2];
1008 data->collided =
true;
1012 verts1[vert_tri_a[0]].tx,
1013 verts1[vert_tri_a[1]].tx,
1014 verts1[vert_tri_a[2]].tx,
1015 &collpair[
index].aw1,
1016 &collpair[
index].aw2,
1017 &collpair[
index].aw3);
1034 const int3 vert_tri_a,
1035 const int3 vert_tri_b)
1040 const int flags_a = verts[vert_tri_a[0]].
flags & verts[vert_tri_a[1]].
flags &
1041 verts[vert_tri_a[2]].
flags;
1042 const int flags_b = verts[vert_tri_b[0]].
flags & verts[vert_tri_b[1]].
flags &
1043 verts[vert_tri_b[2]].
flags;
1057 for (
uint i = 0; i < 3; i++) {
1058 for (
uint j = 0; j < 3; j++) {
1059 if (vert_tri_a[i] == vert_tri_b[j]) {
1063 if (sewing_active) {
1064 if (
cloth->sew_edge_graph.contains({vert_tri_a[i], vert_tri_b[j]})) {
1085 float pa[3], pb[3], vect[3];
1090 if (indexA > indexB) {
1091 std::swap(indexA, indexB);
1101 verts1[vert_tri_a[1]].tx,
1102 verts1[vert_tri_a[2]].tx,
1103 verts1[vert_tri_b[0]].tx,
1104 verts1[vert_tri_b[1]].tx,
1105 verts1[vert_tri_b[2]].tx,
1113 collpair[
index].
ap1 = vert_tri_a[0];
1114 collpair[
index].
ap2 = vert_tri_a[1];
1115 collpair[
index].
ap3 = vert_tri_a[2];
1117 collpair[
index].
bp1 = vert_tri_b[0];
1118 collpair[
index].
bp2 = vert_tri_b[1];
1119 collpair[
index].
bp3 = vert_tri_b[2];
1130 data->collided =
true;
1134 verts1[vert_tri_a[0]].tx,
1135 verts1[vert_tri_a[1]].tx,
1136 verts1[vert_tri_a[2]].tx,
1137 &collpair[
index].aw1,
1138 &collpair[
index].aw2,
1139 &collpair[
index].aw3);
1142 verts1[vert_tri_b[0]].tx,
1143 verts1[vert_tri_b[1]].tx,
1144 verts1[vert_tri_b[2]].tx,
1145 &collpair[
index].bw1,
1146 &collpair[
index].bw2,
1147 &collpair[
index].bw3);
1167 float pa[3], pb[3], vect[3];
1171 const int2 &edge_coll =
reinterpret_cast<const int2 *
>(
1177 verts1[edge_coll[1]].tx,
1188 collpair[
index].
ap1 = edge_coll[0];
1189 collpair[
index].
ap2 = edge_coll[1];
1204 data->collided =
true;
1208 pa, verts1[edge_coll[0]].tx, verts1[edge_coll[1]].tx);
1266 for (; base; base = base->
next) {
1267 if (base->
flag & base_flag) {
1278 relations->free_no_destruct();
1279 MEM_delete(relations);
1290 depsgraph, collection, modifier_type);
1297 int maxnum = relations->count();
1316 MEM_delete(objects);
1327 MEM_delete(objects);
1337 ListBaseT<ColliderCache> *cache =
nullptr;
1354 if (cache ==
nullptr) {
1374 MEM_delete(*colliders);
1375 *colliders =
nullptr;
1387 const bool is_hair = (clmd->
hairdata !=
nullptr);
1392 data.collmd = collmd;
1393 data.overlap = overlap;
1394 data.collisions = *collisions;
1395 data.culling = culling;
1396 data.use_normal = use_normal;
1397 data.collided =
false;
1405 return data.collided;
1415 data.overlap = overlap;
1416 data.collisions = collisions;
1417 data.collided =
false;
1424 return data.collided;
1430 uint *collision_counts,
1431 const uint numcollobj,
1435 int i = 0, j = 0, mvert_num = 0;
1441 verts =
cloth->verts;
1445 for (j = 0; j < 2; j++) {
1448 for (i = 0; i < numcollobj; i++) {
1449 Object *collob = collobjs[i];
1455 clmd, collmd, collob, collisions[i], collision_counts[i], dt);
1461 for (i = 0; i < mvert_num; i++) {
1463 if (verts[i].impulse_count) {
1464 add_v3_v3(verts[i].tv, verts[i].impulse);
1465 add_v3_v3(verts[i].dcvel, verts[i].impulse);
1482 int collision_count,
1486 int i = 0, j = 0, mvert_num = 0;
1492 verts =
cloth->verts;
1494 for (j = 0; j < 2; j++) {
1501 for (i = 0; i < mvert_num; i++) {
1502 if (verts[i].impulse_count) {
1504 add_v3_v3(verts[i].tv, verts[i].impulse);
1505 add_v3_v3(verts[i].dcvel, verts[i].impulse);
1534 if (index_a != index_b) {
1552 uint i = 0, mvert_num = 0;
1555 int ret = 0, ret2 = 0;
1556 Object **collobjs =
nullptr;
1557 uint numcollobj = 0;
1558 uint *coll_counts_obj =
nullptr;
1560 uint coll_count_self = 0;
1562 bool bvh_updated =
false;
1568 verts =
cloth->verts;
1569 mvert_num =
cloth->mvert_num;
1576 const bool is_hair = (clmd->
hairdata !=
nullptr);
1579 is_hair ?
nullptr : ob,
1588 for (i = 0; i < numcollobj; i++) {
1589 Object *collob = collobjs[i];
1602 &coll_counts_obj[i],
1610 if (
cloth->bvhselftree !=
cloth->bvhtree || !bvh_updated) {
1624 bool collided =
false;
1628 for (i = 0; i < numcollobj; i++) {
1629 Object *collob = collobjs[i];
1637 if (coll_counts_obj[i] && overlap_obj[i]) {
1652 clmd, collobjs, collisions, coll_counts_obj, numcollobj, dt);
1656 for (i = 0; i < numcollobj; i++) {
1657 MEM_SAFE_DELETE(collisions[i]);
1660 MEM_delete(collisions);
1667 verts =
cloth->verts;
1668 mvert_num =
cloth->mvert_num;
1670 if (
cloth->bvhselftree) {
1671 if (coll_count_self && overlap_self) {
1682 MEM_SAFE_DELETE(collisions);
1687 for (i = 0; i < mvert_num; i++) {
1694 add_v3_v3v3(verts[i].tx, verts[i].txold, verts[i].tv);
1702 for (i = 0; i < numcollobj; i++) {
1703 MEM_SAFE_DELETE(overlap_obj[i]);
1706 MEM_delete(overlap_obj);
1709 MEM_SAFE_DELETE(coll_counts_obj);
1711 MEM_SAFE_DELETE(overlap_self);
1715 return std::min(
ret, 1);
#define VECADDMUL(v1, v2, aS)
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_END
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(_collection, _object)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
float distance(float, float) RET
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
MINLINE float min_ff(float a, float b)
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)
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
bool point_in_slice_seg(float p[3], float l1[3], float l2[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
float line_point_factor_v3(const float p[3], const float l1[3], const float l2[3])
void isect_seg_seg_v3(const float a0[3], const float a1[3], const float b0[3], const float b1[3], float r_a[3], float r_b[3])
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
BVHTreeOverlap * BLI_bvhtree_overlap(const BVHTree *tree1, const BVHTree *tree2, unsigned int *r_overlap_num, BVHTree_OverlapCallback callback, void *userdata)
static float compute_collision_point_edge_tri(const float a1[3], const float a2[3], const float b1[3], const float b2[3], const float b3[3], bool culling, bool use_normal, float r_a[3], float r_b[3], float r_vec[3])
void BKE_collider_cache_free(ListBaseT< ColliderCache > **colliders)
float BLI_bvhtree_get_epsilon(const BVHTree *tree)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
static void hair_collision(void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
void mid_v3_v3v3v3(float v[3], const float v1[3], const float v2[3], const float v3[3])
@ PFIELD_CLOTH_USE_CULLING
@ PFIELD_CLOTH_USE_NORMAL
bool isect_tri_tri_v3_ex(const float tri_a[3][3], const float tri_b[3][3], float r_i1[3], float r_i2[3], int *r_tri_a_edge_isect_count)
static bool cloth_bvh_selfcollision_is_active(const ClothModifierData *clmd, const Cloth *cloth, const int3 vert_tri_a, const int3 vert_tri_b)
void collision_move_object(struct CollisionModifierData *collmd, float step, float prevstep, bool moving_bvh)
@ eModifierType_Collision
void BLI_bvhtree_balance(BVHTree *tree)
static void collision_compute_barycentric(const float pv[3], const float p1[3], const float p2[3], const float p3[3], float *w1, float *w2, float *w3)
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
static bool cloth_bvh_obj_overlap_cb(void *userdata, int index_a, int, int)
void BKE_collision_relations_free(ListBaseT< CollisionRelation > *relations)
bool BLI_bvhtree_update_node(BVHTree *tree, int index, const float co[3], const float co_moving[3], int numpoints)
bool isect_line_segment_tri_v3(const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
void collision_get_collider_velocity(float vel_old[3], float vel_new[3], struct CollisionModifierData *collmd, struct CollPair *collpair)
MINLINE void mul_v3_fl(float r[3], float f)
static int cloth_bvh_objcollisions_resolve(ClothModifierData *clmd, Object **collobjs, CollPair **collisions, uint *collision_counts, const uint numcollobj, const float dt)
BLI_INLINE int next_ind(int i)
void BLI_bvhtree_update_tree(BVHTree *tree)
static bool cloth_bvh_selfcollisions_nearcheck(ClothModifierData *clmd, CollPair *collisions, int numresult, BVHTreeOverlap *overlap)
ViewLayer * DEG_get_input_view_layer(const Depsgraph *graph)
VecBase< int32_t, 2 > int2
struct BVHTree * bvhtree_build_from_mvert(const float(*positions)[3], const int3 *vert_tris, int tri_num, float epsilon)
VecBase< int32_t, 3 > int3
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
ListBaseT< ColliderCache > * BKE_collider_cache_create(struct Depsgraph *depsgraph, struct Object *self, struct Collection *collection)
Main * DEG_get_bmain(const Depsgraph *graph)
BMesh const char void * data
static bool cloth_bvh_objcollisions_nearcheck(ClothModifierData *clmd, CollisionModifierData *collmd, CollPair **collisions, int numresult, BVHTreeOverlap *overlap, bool culling, bool use_normal)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
BVHTree * BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
Base * BKE_collection_or_layer_objects(const Main &bmain, const Scene *scene, ViewLayer *view_layer, Collection *collection)
MINLINE void negate_v3(float r[3])
static void cloth_selfcollision(void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
ATTR_WARN_UNUSED_RESULT const size_t num
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
static int cloth_bvh_selfcollisions_resolve(ClothModifierData *clmd, CollPair *collisions, int collision_count, const float dt)
BVHTreeOverlap * BLI_bvhtree_overlap_self(const BVHTree *tree, unsigned int *r_overlap_num, BVHTree_OverlapCallback callback, void *userdata)
bool isect_ray_tri_v3(const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
MINLINE void zero_v3(float r[3])
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
bool isect_line_plane_v3(float r_isect_co[3], const float l1[3], const float l2[3], const float plane_co[3], const float plane_no[3]) ATTR_WARN_UNUSED_RESULT
int cloth_bvh_collision(Depsgraph *depsgraph, Object *ob, ClothModifierData *clmd, float step, float dt)
void bvhtree_update_from_cloth(ClothModifierData *clmd, bool moving, bool self)
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3(float n[3])
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
MINLINE void add_v3_v3(float r[3], const float a[3])
@ CLOTH_SIMSETTINGS_FLAG_COLLOBJ
@ CLOTH_SIMSETTINGS_FLAG_SEW
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
BLI_INLINE void max_v3_v3v3(float r[3], const float a[3], const float b[3])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
MINLINE void sub_v3db_v3fl_v3fl(double r[3], const float a[3], const float b[3])
struct Object ** BKE_collision_objects_create(struct Depsgraph *depsgraph, struct Object *self, struct Collection *collection, unsigned int *numcollobj, unsigned int modifier_type)
ListBaseT< CollisionRelation > * DEG_get_collision_relations(const Depsgraph *depsgraph, Collection *collection, unsigned int modifier_type)
void bvhtree_update_from_mvert(struct BVHTree *bvhtree, const float(*positions)[3], const float(*positions_moving)[3], const int3 *vert_tris, int tri_num, bool moving)
MINLINE float max_ff(float a, float b)
float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3])
DO_INLINE void collision_interpolateOnTriangle(float to[3], const float v1[3], const float v2[3], const float v3[3], const double w1, const double w2, const double w3)
void closest_on_tri_to_point_v3(float r[3], const float p[3], const float v1[3], const float v2[3], const float v3[3])
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
Scene * DEG_get_input_scene(const Depsgraph *graph)
ListBaseT< CollisionRelation > * BKE_collision_relations_create(struct Depsgraph *depsgraph, struct Collection *collection, unsigned int modifier_type)
@ CLOTH_VERT_FLAG_NOSELFCOLL
@ CLOTH_VERT_FLAG_NOOBJCOLL
void BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints)
MINLINE float square_f(float a)
static void cloth_collision(void *__restrict userdata, const int index, const TaskParallelTLS *__restrict)
static int cloth_collision_response_static(ClothModifierData *clmd, CollisionModifierData *collmd, Object *collob, CollPair *collpair, uint collision_count, const float dt)
static void add_collision_object(ListBaseT< CollisionRelation > *relations, Object *ob, int level, const ModifierType modifier_type)
static float compute_collision_point_tri_tri(const float a1[3], const float a2[3], const float a3[3], const float b1[3], const float b2[3], const float b3[3], bool culling, bool use_normal, float r_a[3], float r_b[3], float r_vec[3])
@ CLOTH_COLLSETTINGS_FLAG_ENABLED
@ CLOTH_COLLSETTINGS_FLAG_SELF
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void BKE_collision_objects_free(struct Object **objects)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static bool cloth_bvh_self_overlap_cb(void *userdata, int index_a, int index_b, int)
static void cloth_collision_impulse_vert(const float clamp_sq, const float impulse[3], ClothVertex *vert)
static int cloth_selfcollision_response_static(ClothModifierData *clmd, CollPair *collpair, uint collision_count, const float dt)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static bool cloth_bvh_collision_is_active(const ClothModifierData *, const Cloth *cloth, const int3 vert_tri_a)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
CLOTH_COLLISIONSETTINGS_FLAGS flags
struct Collection * group
struct Cloth * clothObject
struct ClothHairData * hairdata
struct ClothSimSettings * sim_parms
struct ClothCollSettings * coll_parms
CLOTH_SIMSETTINGS_FLAGS flags
unsigned int impulse_count
CollisionModifierData * collmd
struct CollisionModifierData * collmd
struct Collection * instance_collection