diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-09-03 18:32:46 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-09-03 18:32:46 +0300 |
commit | 265ec400ab1945cd7bc78d50b7d8f184c01fdd10 (patch) | |
tree | f729674fe017bf8ef846dd284fc8a988c486b51e /source/blender/blenkernel/intern | |
parent | 4da2acae3ab1a40db8be7f7df36da29cfcbf280c (diff) |
ClosthCollision: fully avoid computing BVHTree when we have no collision objects to test against.
Followup to rBc6bbe6c5aac29, much more elegant solution to the problem. ;)
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/collision.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 65c84187307..1df749ee842 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -1339,6 +1339,14 @@ void cloth_find_point_contacts(Object *ob, ClothModifierData *clmd, float step, // static collisions //////////////////////////////////////////////////////////// + /* Check we do have collision objects to test against, before doing anything else. */ + collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision); + if (!collobjs) { + *r_collider_contacts = NULL; + *r_totcolliders = 0; + return; + } + // create temporary cloth points bvh cloth_bvh = BLI_bvhtree_new(mvert_num, max_ff(clmd->coll_parms->epsilon, clmd->coll_parms->distance_repel), 4, 6); /* fill tree */ @@ -1353,14 +1361,6 @@ void cloth_find_point_contacts(Object *ob, ClothModifierData *clmd, float step, /* balance tree */ BLI_bvhtree_balance(cloth_bvh); - collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision); - if (!collobjs) { - *r_collider_contacts = NULL; - *r_totcolliders = 0; - BLI_bvhtree_free(cloth_bvh); - return; - } - /* move object to position (step) in time */ for (i = 0; i < numcollobj; i++) { Object *collob= collobjs[i]; |