[Bf-blender-cvs] [115aea5f2f] cloth-improvements: Optimization: Use static BVH for collision intersection

Luca Rood noreply at git.blender.org
Mon Jan 30 06:55:12 CET 2017


Commit: 115aea5f2f334ce656004ae73507089e0c7d03d4
Author: Luca Rood
Date:   Sun Jan 29 20:38:34 2017 -0200
Branches: cloth-improvements
https://developer.blender.org/rB115aea5f2f334ce656004ae73507089e0c7d03d4

Optimization: Use static BVH for collision intersection

No need to use moving BVH for intersection checking, as in the end
collisions are only evaluated at the next state anyway, so can use
static BVH to reduce the amount of intersections to check.

Moving BVH will only make sense if ccd is implemented.

===================================================================

M	source/blender/blenkernel/intern/cloth.c
M	source/blender/blenkernel/intern/collision.c

===================================================================

diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 8e377a69d7..b98700f7ea 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -220,12 +220,12 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, bool moving, bool self)
 			float co[3][3], co_moving[3][3];
 			bool ret;
 
-			copy_v3_v3(co[0], verts[vt->tri[0]].txold);
-			copy_v3_v3(co[1], verts[vt->tri[1]].txold);
-			copy_v3_v3(co[2], verts[vt->tri[2]].txold);
-
 			/* copy new locations into array */
 			if (moving) {
+				copy_v3_v3(co[0], verts[vt->tri[0]].txold);
+				copy_v3_v3(co[1], verts[vt->tri[1]].txold);
+				copy_v3_v3(co[2], verts[vt->tri[2]].txold);
+
 				/* update moving positions */
 				copy_v3_v3(co_moving[0], verts[vt->tri[0]].tx);
 				copy_v3_v3(co_moving[1], verts[vt->tri[1]].tx);
@@ -234,6 +234,10 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, bool moving, bool self)
 				ret = BLI_bvhtree_update_node(bvhtree, i, co[0], co_moving[0], 3);
 			}
 			else {
+				copy_v3_v3(co[0], verts[vt->tri[0]].tx);
+				copy_v3_v3(co[1], verts[vt->tri[1]].tx);
+				copy_v3_v3(co[2], verts[vt->tri[2]].tx);
+
 				ret = BLI_bvhtree_update_node(bvhtree, i, co[0], NULL, 3);
 			}
 			
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 2283083185..26bf0930c4 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -1064,7 +1064,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
 	////////////////////////////////////////////////////////////
 
 	if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) {
-		bvhtree_update_from_cloth(clmd, 1, false); // 0 means STATIC, 1 means MOVING (see later in this function)
+		bvhtree_update_from_cloth(clmd, false, false);
 		collobjs = get_collisionobjects(clmd->scene, ob, clmd->coll_parms->group, &numcollobj, eModifierType_Collision);
 		
 		if (!collobjs)
@@ -1084,7 +1084,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
 	}
 
 	if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF) {
-		bvhtree_update_from_cloth(clmd, 1, true); // 0 means STATIC, 1 means MOVING (see later in this function)
+		bvhtree_update_from_cloth(clmd, false, true);
 	}
 
 	do {




More information about the Bf-blender-cvs mailing list