[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12328] branches/cloth/blender/source/ blender: Code comments add to collision interface

Daniel Genrich daniel.genrich at gmx.net
Sun Oct 21 19:20:31 CEST 2007


Revision: 12328
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12328
Author:   genscher
Date:     2007-10-21 19:20:31 +0200 (Sun, 21 Oct 2007)

Log Message:
-----------
Code comments add to collision interface

Modified Paths:
--------------
    branches/cloth/blender/source/blender/blenkernel/BKE_collisions.h
    branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
    branches/cloth/blender/source/blender/src/buttons_object.c

Modified: branches/cloth/blender/source/blender/blenkernel/BKE_collisions.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_collisions.h	2007-10-21 16:53:25 UTC (rev 12327)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_collisions.h	2007-10-21 17:20:31 UTC (rev 12328)
@@ -88,10 +88,15 @@
 // forward declarations
 /////////////////////////////////////////////////
 
+// builds bounding volume hierarchy
+BVH *bvh_build (DerivedMesh *dm, MVert *x, MVert *xold, unsigned int numverts, float epsilon);
+// frees the same
 void bvh_free ( BVH *bvh );
-BVH *bvh_build (DerivedMesh *dm, MVert *x, MVert *xold, unsigned int numverts, float epsilon);
 
+// checks two bounding volume hierarchies for potential collisions and returns some list with those
 int bvh_traverse(Tree *tree1, Tree *tree2, LinkNode *collision_list);
+
+// update bounding volumes, needs updated positions in bvh->x
 void bvh_update(DerivedMesh *dm, BVH * bvh, int moving);
 
 LinkNode *BLI_linklist_append_fast ( LinkNode **listp, void *ptr );

Modified: branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2007-10-21 16:53:25 UTC (rev 12327)
+++ branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2007-10-21 17:20:31 UTC (rev 12328)
@@ -621,8 +621,7 @@
 	Frame *frame = NULL;
 	LinkNode *search = NULL;
 	float deltaTime = current_time - clmd->sim_parms.sim_time;
-
-
+	
 	// only be active during a specific period:
 	// that's "first frame" and "last frame" on GUI
 	if ( ! ( clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ ) )
@@ -671,59 +670,7 @@
 	clmd->sim_parms.dt = 1.0f / clmd->sim_parms.stepsPerFrame;
 
 	clmd->sim_parms.sim_time = current_time;
-
-	// check if cloth object was some collision object before and needs freeing now
-	if ( ! ( clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ ) && ( clmd->clothObject != NULL ) && ( clmd->clothObject->old_solver_type == 255 ) )
-	{
-		// temporary set CSIMSETT_FLAG_COLLOBJ flag for proper freeing
-		clmd->sim_parms.flags |= CLOTH_SIMSETTINGS_FLAG_COLLOBJ;
-		cloth_free_modifier ( clmd );
-		clmd->sim_parms.flags &= ~CLOTH_SIMSETTINGS_FLAG_COLLOBJ;
-	}
-
-	// This is for collisions objects: check special case CSIMSETT_FLAG_COLLOBJ
-	if ( clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ )
-	{
-		// save next position + time
-		if ( ( clmd->clothObject == NULL ) || ( numverts != clmd->clothObject->numverts ) )
-		{
-			if ( !collobj_from_object ( ob, clmd, dm, vertexCos, framenr ) )
-			{
-				clmd->sim_parms.flags |= CLOTH_SIMSETTINGS_FLAG_COLLOBJ;
-				cloth_free_modifier ( clmd );
-				return;
-			}
-
-			if ( clmd->clothObject == NULL )
-				return;
-
-			cloth = clmd->clothObject;
-		}
-
-		// Save old position
-		clmd->sim_parms.sim_time_old = clmd->sim_parms.sim_time;
-		clmd->sim_parms.sim_time = current_time;
-
-		verts = cloth->verts;
-
-		for ( i = 0; i < clmd->clothObject->numverts; i++, verts++ )
-		{
-			// Save the previous position.
-			VECCOPY ( verts->xold, verts->x );
-			VECCOPY ( verts->txold, verts->x );
-
-			// Get the current position.
-			VECCOPY ( verts->x, vertexCos[i] );
-			Mat4MulVecfl ( ob->obmat, verts->x );
-
-			// Compute the vertices "velocity".
-			// (no dt correction here because of float error)
-			VECSUB ( verts->v, verts->x, verts->xold );
-		}
-
-		return;
-	}
-
+	
 	if ( deltaTime == 1.0f )
 	{
 		if ( ( clmd->clothObject == NULL ) || ( numverts != clmd->clothObject->numverts ) )
@@ -956,72 +903,6 @@
 }
 
 // only meshes supported at the moment
-/* collision objects */
-static int collobj_from_object ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float ( *vertexCos ) [3], unsigned int numverts )
-{
-	unsigned int i;
-	MVert *mvert = NULL;
-	ClothVertex *verts = NULL;
-	float tnull[3] = {0,0,0};
-
-	/* If we have a clothObject, free it. */
-	if ( clmd->clothObject != NULL )
-		cloth_free_modifier ( clmd );
-
-	/* Allocate a new cloth object. */
-	clmd->clothObject = MEM_callocN ( sizeof ( Cloth ), "cloth" );
-	if ( clmd->clothObject )
-	{
-		clmd->clothObject->old_solver_type = 255;
-		// clmd->clothObject->old_collision_type = 255;
-	}
-	else if ( clmd->clothObject == NULL )
-	{
-		modifier_setError ( & ( clmd->modifier ), "Out of memory on allocating clmd->clothObject." );
-		return 0;
-	}
-
-	switch ( ob->type )
-	{
-		case OB_MESH:
-
-			// mesh input objects need DerivedMesh
-			if ( !dm )
-				return 0;
-
-			cloth_from_mesh ( ob, clmd, dm );
-
-			if ( clmd->clothObject != NULL )
-			{
-				if ( !dm ) return 0;
-				if ( !dm->getNumVerts ( dm ) || !dm->getNumFaces ( dm ) ) return 0;
-
-				mvert = dm->getVertArray ( dm );
-				verts = clmd->clothObject->verts;
-				numverts = clmd->clothObject->numverts = dm->getNumVerts ( dm );
-
-				for ( i = 0; i < numverts; i++, verts++ )
-				{
-					VECCOPY ( verts->x, mvert[i].co );
-					Mat4MulVecfl ( ob->obmat, verts->x );
-					verts->flags = 0;
-					VECCOPY ( verts->xold, verts->x );
-					VECCOPY ( verts->txold, verts->x );
-					VECCOPY ( verts->tx, verts->x );
-					VecMulf ( verts->v, 0.0f );
-					verts->impulse_count = 0;
-					VECCOPY ( verts->impulse, tnull );
-				}
-				// clmd->clothObject->tree =  bvh_build ( dm, clmd->coll_parms.epsilon );
-
-			}
-
-			return 1;
-		default: return 0; // TODO - we do not support changing meshes
-	}
-}
-
-// only meshes supported at the moment
 static int cloth_from_object ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float ( *vertexCos ) [3], unsigned int numverts )
 {
 	unsigned int i = 0;

Modified: branches/cloth/blender/source/blender/src/buttons_object.c
===================================================================
--- branches/cloth/blender/source/blender/src/buttons_object.c	2007-10-21 16:53:25 UTC (rev 12327)
+++ branches/cloth/blender/source/blender/src/buttons_object.c	2007-10-21 17:20:31 UTC (rev 12328)
@@ -3131,7 +3131,7 @@
 	
 	if(clmd)
 	{
-		but = uiDefButBitI(block, TOG, CLOTH_SIMSETTINGS_FLAG_COLLOBJ, B_EFFECT_DEP, "Collision Object",	170,200,130,20, &clmd->sim_parms.flags, 0, 0, 0, 0, "Sets object to become a cloth collision object");
+		// but = uiDefButBitI(block, TOG, CLOTH_SIMSETTINGS_FLAG_COLLOBJ, B_EFFECT_DEP, "Collision Object",	170,200,130,20, &clmd->sim_parms.flags, 0, 0, 0, 0, "Sets object to become a cloth collision object");
 
 		if (!(clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ))
 		{





More information about the Bf-blender-cvs mailing list