Blender V2.61 - r43446
|
#include "MEM_guardedalloc.h"
#include "BKE_cloth.h"
#include "DNA_cloth_types.h"
#include "DNA_group_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h"
#include "DNA_scene_types.h"
#include "DNA_meshdata_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_edgehash.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLI_memarena.h"
#include "BLI_rand.h"
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
#include "BKE_scene.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_modifier.h"
#include "BLI_kdopbvh.h"
#include "BKE_collision.h"
Go to the source code of this file.
Defines | |
#define | mySWAP(a, b) do { double tmp = b ; b = a ; a = tmp ; } while(0) |
Functions | |
void | collision_move_object (CollisionModifierData *collmd, float step, float prevstep) |
BVHTree * | bvhtree_build_from_mvert (MFace *mfaces, unsigned int numfaces, MVert *x, unsigned int UNUSED(numverts), float epsilon) |
void | bvhtree_update_from_mvert (BVHTree *bvhtree, MFace *faces, int numfaces, MVert *x, MVert *xnew, int UNUSED(numverts), int moving) |
static void | collision_compute_barycentric (float pv[3], float p1[3], float p2[3], float p3[3], float *w1, float *w2, float *w3) |
DO_INLINE void | collision_interpolateOnTriangle (float to[3], float v1[3], float v2[3], float v3[3], double w1, double w2, double w3) |
static int | cloth_collision_response_static (ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair, CollPair *collision_end) |
static CollPair * | cloth_collision (ModifierData *md1, ModifierData *md2, BVHTreeOverlap *overlap, CollPair *collpair, float dt) |
static void | add_collision_object (Object ***objs, unsigned int *numobj, unsigned int *maxobj, Object *ob, Object *self, int level) |
Object ** | get_collisionobjects (Scene *scene, Object *self, Group *group, unsigned int *numcollobj) |
static void | add_collider_cache_object (ListBase **objs, Object *ob, Object *self, int level) |
ListBase * | get_collider_cache (Scene *scene, Object *self, Group *group) |
void | free_collider_cache (ListBase **colliders) |
static void | cloth_bvh_objcollisions_nearcheck (ClothModifierData *clmd, CollisionModifierData *collmd, CollPair **collisions, CollPair **collisions_index, int numresult, BVHTreeOverlap *overlap, double dt) |
static int | cloth_bvh_objcollisions_resolve (ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collisions, CollPair *collisions_index) |
int | cloth_bvh_objcollision (Object *ob, ClothModifierData *clmd, float step, float dt) |
Definition in file collision.c.
#define mySWAP | ( | a, | |
b | |||
) | do { double tmp = b ; b = a ; a = tmp ; } while(0) |
gsl_poly_solve_cubic -
copied from SOLVE_CUBIC.C --> GSL
Definition at line 176 of file collision.c.
static void add_collider_cache_object | ( | ListBase ** | objs, |
Object * | ob, | ||
Object * | self, | ||
int | level | ||
) | [static] |
Definition at line 2198 of file collision.c.
References BLI_addtail(), CollisionModifierData::bvhtree, collision_move_object(), ColliderCache::collmd, PartDeflect::deflect, Object::dup_group, eModifierType_Collision, ListBase::first, Group::gobject, MEM_callocN(), modifiers_findByType(), GroupObject::next, NULL, GroupObject::ob, ColliderCache::ob, and Object::pd.
Referenced by get_collider_cache().
static void add_collision_object | ( | Object *** | objs, |
unsigned int * | numobj, | ||
unsigned int * | maxobj, | ||
Object * | ob, | ||
Object * | self, | ||
int | level | ||
) | [static] |
Definition at line 2133 of file collision.c.
References PartDeflect::deflect, Object::dup_group, eModifierType_Collision, ListBase::first, Group::gobject, MEM_reallocN(), modifiers_findByType(), GroupObject::next, NULL, GroupObject::ob, and Object::pd.
Referenced by get_collisionobjects().
BVHTree* bvhtree_build_from_mvert | ( | MFace * | mfaces, |
unsigned int | numfaces, | ||
MVert * | x, | ||
unsigned int | UNUSEDnumverts, | ||
float | epsilon | ||
) |
Definition at line 93 of file collision.c.
References BLI_bvhtree_balance(), BLI_bvhtree_insert(), BLI_bvhtree_new(), MVert::co, co, copy_v3_v3(), i, MFace::v1, MFace::v2, MFace::v3, and MFace::v4.
void bvhtree_update_from_mvert | ( | BVHTree * | bvhtree, |
MFace * | faces, | ||
int | numfaces, | ||
MVert * | x, | ||
MVert * | xnew, | ||
int | UNUSEDnumverts, | ||
int | moving | ||
) |
Definition at line 120 of file collision.c.
References BLI_bvhtree_update_node(), BLI_bvhtree_update_tree(), MVert::co, co, copy_v3_v3(), i, NULL, MFace::v1, MFace::v2, MFace::v3, and MFace::v4.
int cloth_bvh_objcollision | ( | Object * | ob, |
ClothModifierData * | clmd, | ||
float | step, | ||
float | dt | ||
) |
Definition at line 2361 of file collision.c.
References ABS, ClothVertex::avg_spring_len, BLI_bvhtree_overlap(), BLI_edgehash_haskey(), Cloth::bvhselftree, bvhselftree_update_from_cloth(), Cloth::bvhtree, CollisionModifierData::bvhtree, bvhtree_update_from_cloth(), cloth_bvh_objcollisions_nearcheck(), cloth_bvh_objcollisions_resolve(), CLOTH_COLLSETTINGS_FLAG_SELF, CLOTH_SIMSETTINGS_FLAG_COLLOBJ, CLOTH_SIMSETTINGS_FLAG_GOAL, CLOTH_VERT_FLAG_PINNED, ClothModifierData::clothObject, ClothModifierData::coll_parms, collision_move_object(), Cloth::edgehash, eModifierType_Collision, ClothCollSettings::flags, ClothVertex::flags, ClothSimSettings::flags, get_collisionobjects(), ClothCollSettings::group, i, BVHTreeOverlap::indexA, BVHTreeOverlap::indexB, length(), ClothCollSettings::loop_count, MAX2, MEM_callocN(), MEM_freeN(), MIN2, modifiers_findByType(), mul_v3_fl(), normalize_v3(), NULL, Cloth::numverts, ClothModifierData::scene, ClothCollSettings::self_loop_count, ClothCollSettings::selfepsilon, ClothModifierData::sim_parms, VECADD, VECSUB, and Cloth::verts.
Referenced by implicit_solver().
static void cloth_bvh_objcollisions_nearcheck | ( | ClothModifierData * | clmd, |
CollisionModifierData * | collmd, | ||
CollPair ** | collisions, | ||
CollPair ** | collisions_index, | ||
int | numresult, | ||
BVHTreeOverlap * | overlap, | ||
double | dt | ||
) | [static] |
Definition at line 2267 of file collision.c.
References BLI_ghash_free(), BLI_ghash_new(), BLI_memarena_free(), BLI_memarena_new(), cloth_collision(), ClothModifierData::clothObject, i, MEM_mallocN(), and NULL.
Referenced by cloth_bvh_objcollision().
static int cloth_bvh_objcollisions_resolve | ( | ClothModifierData * | clmd, |
CollisionModifierData * | collmd, | ||
CollPair * | collisions, | ||
CollPair * | collisions_index | ||
) | [static] |
Definition at line 2307 of file collision.c.
References CollisionModifierData::bvhtree, cloth_collision_response_static(), ClothModifierData::clothObject, copy_v3_v3(), i, ClothVertex::impulse_count, NULL, Cloth::numverts, VECADDMUL, and Cloth::verts.
Referenced by cloth_bvh_objcollision().
static CollPair* cloth_collision | ( | ModifierData * | md1, |
ModifierData * | md2, | ||
BVHTreeOverlap * | overlap, | ||
CollPair * | collpair, | ||
float | dt | ||
) | [static] |
Definition at line 1397 of file collision.c.
References add_v3_v3(), ALMOST_ZERO, CollPair::ap1, CollPair::ap2, CollPair::ap3, BLI_bvhtree_getepsilon(), CollPair::bp1, CollPair::bp2, CollPair::bp3, CollisionModifierData::bvhtree, ClothModifierData::clothObject, MVert::co, ClothModifierData::coll_parms, CollisionModifierData::current_x, CollisionModifierData::current_xnew, distance(), CollPair::distance, ClothCollSettings::distance_repel, ClothCollSettings::epsilon, CollPair::flag, i, BVHTreeOverlap::indexA, BVHTreeOverlap::indexB, isect_ray_plane_v3(), ClothVertex::mass, Cloth::mfaces, CollisionModifierData::mfaces, mul_v3_fl(), CollPair::normal, normal_tri_v3(), normalize_v3_v3(), NULL, CollPair::pa, CollPair::pb, plNearestPoints(), ClothCollSettings::repel_force, ClothVertex::tv, ClothVertex::tx, ClothVertex::txold, MFace::v1, MFace::v2, MFace::v3, MFace::v4, CollPair::vector, and Cloth::verts.
Referenced by cloth_bvh_objcollisions_nearcheck().
static int cloth_collision_response_static | ( | ClothModifierData * | clmd, |
CollisionModifierData * | collmd, | ||
CollPair * | collpair, | ||
CollPair * | collision_end | ||
) | [static] |
Definition at line 495 of file collision.c.
References ALMOST_ZERO, CollPair::ap1, CollPair::ap2, CollPair::ap3, BLI_bvhtree_getepsilon(), CollPair::bp1, CollPair::bp2, CollPair::bp3, CollisionModifierData::bvhtree, ClothModifierData::clothObject, MVert::co, ClothModifierData::coll_parms, collision_compute_barycentric(), COLLISION_IN_FUTURE, collision_interpolateOnTriangle(), copy_v3_v3(), CollisionModifierData::current_v, CollisionModifierData::current_x, CollPair::distance, ClothCollSettings::epsilon, KDL::epsilon2, CollPair::flag, ClothCollSettings::friction, if(), ClothVertex::impulse, ClothVertex::impulse_count, INPR, MAX2, MIN2, mul_v3_fl(), CollPair::normal, normalize_v3(), CollPair::pa, CollPair::pb, ClothModifierData::sim_parms, sqrtf, ClothSimSettings::stepsPerFrame, ClothSimSettings::timescale, ClothVertex::tv, ClothVertex::txold, VECADDMUL, VECSUB, and Cloth::verts.
Referenced by cloth_bvh_objcollisions_resolve().
static void collision_compute_barycentric | ( | float | pv[3], |
float | p1[3], | ||
float | p2[3], | ||
float | p3[3], | ||
float * | w1, | ||
float * | w2, | ||
float * | w3 | ||
) | [static] |
Definition at line 450 of file collision.c.
References ABS, ALMOST_ZERO, simple_enum_gen::d, credits_svn_gen::e, INPR, and VECSUB.
Referenced by cloth_collision_response_static().
DO_INLINE void collision_interpolateOnTriangle | ( | float | to[3], |
float | v1[3], | ||
float | v2[3], | ||
float | v3[3], | ||
double | w1, | ||
double | w2, | ||
double | w3 | ||
) |
Definition at line 486 of file collision.c.
References VECADDMUL.
Referenced by cloth_collision_response_static().
void collision_move_object | ( | CollisionModifierData * | collmd, |
float | step, | ||
float | prevstep | ||
) |
Definition at line 77 of file collision.c.
References CollisionModifierData::bvhtree, bvhtree_update_from_mvert(), MVert::co, CollisionModifierData::current_v, CollisionModifierData::current_x, CollisionModifierData::current_xnew, i, CollisionModifierData::mfaces, CollisionModifierData::numfaces, CollisionModifierData::numverts, VECADDS, VECSUB, CollisionModifierData::x, and CollisionModifierData::xnew.
Referenced by add_collider_cache_object(), and cloth_bvh_objcollision().
void free_collider_cache | ( | ListBase ** | colliders | ) |
Definition at line 2257 of file collision.c.
References BLI_freelistN(), MEM_freeN(), and NULL.
Referenced by dynamics_step(), eff_calc_visibility(), and hair_velocity_smoothing().
Definition at line 2232 of file collision.c.
References add_collider_cache_object(), ListBase::first, Group::gobject, Base::lay, GroupObject::next, NULL, GroupObject::ob, Base::object, and SETLOOPER.
Referenced by dynamics_step(), eff_calc_visibility(), and hair_velocity_smoothing().
Object** get_collisionobjects | ( | Scene * | scene, |
Object * | self, | ||
Group * | group, | ||
unsigned int * | numcollobj | ||
) | [read] |
Definition at line 2168 of file collision.c.
References add_collision_object(), ListBase::first, Group::gobject, Base::lay, MEM_callocN(), GroupObject::next, GroupObject::ob, Base::object, and SETLOOPER.
Referenced by cloth_bvh_objcollision().