[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12347] branches/cloth/blender/source/ blender: WIP commit, (just in case my HD breaks down).

Daniel Genrich daniel.genrich at gmx.net
Tue Oct 23 00:50:32 CEST 2007


Revision: 12347
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12347
Author:   genscher
Date:     2007-10-23 00:50:32 +0200 (Tue, 23 Oct 2007)

Log Message:
-----------
WIP commit, (just in case my HD breaks down). Don't expect anything to work. Code crashes and sim doesn't work ;)

Modified Paths:
--------------
    branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
    branches/cloth/blender/source/blender/blenkernel/BKE_collisions.h
    branches/cloth/blender/source/blender/blenkernel/BKE_modifier.h
    branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
    branches/cloth/blender/source/blender/blenkernel/intern/collision.c
    branches/cloth/blender/source/blender/blenkernel/intern/implicit.c
    branches/cloth/blender/source/blender/blenkernel/intern/kdop.c
    branches/cloth/blender/source/blender/blenkernel/intern/modifier.c
    branches/cloth/blender/source/blender/blenloader/intern/readfile.c
    branches/cloth/blender/source/blender/makesdna/DNA_cloth_types.h
    branches/cloth/blender/source/blender/makesdna/DNA_modifier_types.h
    branches/cloth/blender/source/blender/makesdna/DNA_object_force.h
    branches/cloth/blender/source/blender/src/editobject.c

Modified: branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h	2007-10-22 20:54:19 UTC (rev 12346)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_cloth.h	2007-10-22 22:50:32 UTC (rev 12347)
@@ -122,7 +122,7 @@
 void implicit_set_positions ( ClothModifierData *clmd );
 
 // from cloth.c, needed for modifier.c
-void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm, float ( *vertexCos ) [3], int numverts );
+DerivedMesh *clothModifier_do(ClothModifierData *clmd, Object *ob, DerivedMesh *dm);
 
 ////////////////////////////////////////////////
 
@@ -132,9 +132,7 @@
 ////////////////////////////////////////////////
 void cloth_free_modifier ( ClothModifierData *clmd );
 void cloth_init ( ClothModifierData *clmd );
-void cloth_deform_verts ( struct Object *ob, float framenr, float ( *vertexCos ) [3], int numVerts, void *derivedData, ClothModifierData *clmd );
 void cloth_update_normals ( ClothVertex *verts, int nVerts, MFace *face, int totface );
-
 ////////////////////////////////////////////////
 
 

Modified: branches/cloth/blender/source/blender/blenkernel/BKE_collisions.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_collisions.h	2007-10-22 20:54:19 UTC (rev 12346)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_collisions.h	2007-10-22 22:50:32 UTC (rev 12347)
@@ -44,21 +44,21 @@
 #include "BKE_DerivedMesh.h"
 
 // used in kdop.c and collision.c
-typedef struct Tree
+typedef struct CollisionTree
 {
-	struct Tree *nodes[4]; // 4 children --> quad-tree
-	struct Tree *parent;
-	struct Tree *nextLeaf;
-	struct Tree *prevLeaf;
+	struct CollisionTree *nodes[4]; // 4 children --> quad-tree
+	struct CollisionTree *parent;
+	struct CollisionTree *nextLeaf;
+	struct CollisionTree *prevLeaf;
 	float	bv[26]; // Bounding volume of all nodes / we have 7 axes on a 14-DOP
-	unsigned int tri_index; // this saves the index of the face
+	int point_index[4]; // supports up to 4 points in a leaf
 	int	count_nodes; // how many nodes are used
 	int	traversed;  // how many nodes already traversed until this level?
 	int	isleaf;
 }
-Tree;
+CollisionTree;
 
-typedef struct Tree TreeNode;
+typedef struct CollisionTree TreeNode;
 
 typedef struct BVH
 {
@@ -79,7 +79,7 @@
 /* used for collisions in kdop.c and also collision.c*/
 typedef struct CollisionPair
 {
-	unsigned int indexA, indexB;
+	int point_indexA[4], point_indexB[4];
 }
 CollisionPair;
 
@@ -89,18 +89,21 @@
 /////////////////////////////////////////////////
 
 // builds bounding volume hierarchy
-BVH *bvh_build (DerivedMesh *dm, MVert *x, MVert *xold, unsigned int numverts, float epsilon);
+BVH *bvh_build (MFace *mfaces, unsigned int numfaces, MVert *x, MVert *xnew, unsigned int numverts, float epsilon);
 // frees the same
 void bvh_free ( BVH *bvh );
 
 // checks two bounding volume hierarchies for potential collisions and returns some list with those
-int bvh_traverse(Tree *tree1, Tree *tree2, LinkNode *collision_list);
+int bvh_traverse(CollisionTree *tree1, CollisionTree *tree2, LinkNode *collision_list);
 
 // update bounding volumes, needs updated positions in bvh->x
-void bvh_update(DerivedMesh *dm, BVH * bvh, int moving);
+void bvh_update(BVH * bvh, int moving);
 
-LinkNode *BLI_linklist_append_fast ( LinkNode **listp, void *ptr );
+LinkNode *BLI_linklist_append_fast (LinkNode **listp, void *ptr);
 
+// move Collision modifier object inter-frame with step = [0,1]
+// defined in collisions.c
+void collision_move_object(CollisionModifierData *collmd, float step);
 
 /////////////////////////////////////////////////
 

Modified: branches/cloth/blender/source/blender/blenkernel/BKE_modifier.h
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/BKE_modifier.h	2007-10-22 20:54:19 UTC (rev 12346)
+++ branches/cloth/blender/source/blender/blenkernel/BKE_modifier.h	2007-10-22 22:50:32 UTC (rev 12347)
@@ -277,7 +277,7 @@
                                      int *lastPossibleCageIndex_r);
 
 int           modifiers_isSoftbodyEnabled(struct Object *ob);
-struct ModifierData  *modifiers_isClothEnabled(struct Object *ob);
+struct ClothModifierData *modifiers_isClothEnabled(Object *ob);
 struct Object *modifiers_isDeformedByArmature(struct Object *ob);
 struct Object *modifiers_isDeformedByLattice(struct Object *ob);
 int           modifiers_usesArmature(struct Object *ob, struct bArmature *arm);

Modified: branches/cloth/blender/source/blender/blenkernel/intern/cloth.c
===================================================================
--- branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2007-10-22 20:54:19 UTC (rev 12346)
+++ branches/cloth/blender/source/blender/blenkernel/intern/cloth.c	2007-10-22 22:50:32 UTC (rev 12347)
@@ -120,10 +120,9 @@
 /* ********** cloth engine ******* */
 /* Prototypes for internal functions.
 */
-static void cloth_to_object ( Object *ob, ClothModifierData *clmd, float ( *vertexCos ) [3], unsigned int numverts );
+static void cloth_to_object ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm );
 static void cloth_from_mesh ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm );
-static int cloth_from_object ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float ( *vertexCos ) [3], unsigned int numverts );
-static int collobj_from_object ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float ( *vertexCos ) [3], unsigned int numverts );
+static int cloth_from_object ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm );
 int cloth_build_springs ( Cloth *cloth, DerivedMesh *dm );
 static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm, short vgroup );
 
@@ -603,69 +602,63 @@
 * cloth_deform_verts - simulates one step, framenr is in frames.
 *
 **/
-void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm,
-                        float ( *vertexCos ) [3], int numverts )
+DerivedMesh *clothModifier_do(ClothModifierData *clmd,
+					 Object *ob, DerivedMesh *dm)
 {
 	unsigned int i;
-	unsigned int numedges = -1;
-	unsigned int numfaces = -1;
-	MVert *mvert = NULL;
-	MEdge *medge = NULL;
-	MFace *mface = NULL;
-	DerivedMesh *result = NULL, *result2 = NULL;
+	DerivedMesh *result = NULL;
 	Cloth *cloth = clmd->clothObject;
 	unsigned int framenr = ( float ) G.scene->r.cfra;
 	float current_time = bsystem_time ( ob, ( float ) G.scene->r.cfra, 0.0 );
-	ListBase	*effectors = NULL;
-	ClothVertex *newframe= NULL, *verts;
+	ListBase *effectors = NULL;
+	ClothVertex *verts = NULL;
 	Frame *frame = NULL;
 	LinkNode *search = NULL;
 	float deltaTime = current_time - clmd->sim_parms.sim_time;
+	MVert *mverts = NULL;
 	
+	result = CDDM_copy(dm);
+	
 	// 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 ) )
+	if ( clmd->clothObject )
 	{
-		if ( clmd->clothObject )
+		if ( clmd->sim_parms.cache )
 		{
-			if ( clmd->sim_parms.cache )
+			if ( current_time < clmd->sim_parms.firstframe )
 			{
-				if ( current_time < clmd->sim_parms.firstframe )
+				int frametime = cloth_cache_first_frame ( clmd );
+				if ( cloth_cache_search_frame ( clmd, frametime ) )
 				{
-					int frametime = cloth_cache_first_frame ( clmd );
-					if ( cloth_cache_search_frame ( clmd, frametime ) )
-					{
-						cloth_cache_get_frame ( clmd, frametime );
-						cloth_to_object ( ob, clmd, vertexCos, numverts );
-					}
-					return;
+					cloth_cache_get_frame ( clmd, frametime );
+					cloth_to_object ( ob, clmd, result );
 				}
-				else if ( current_time > clmd->sim_parms.lastframe )
+				return;
+			}
+			else if ( current_time > clmd->sim_parms.lastframe )
+			{
+				int frametime = cloth_cache_last_frame ( clmd );
+				if ( cloth_cache_search_frame ( clmd, frametime ) )
 				{
-					int frametime = cloth_cache_last_frame ( clmd );
-					if ( cloth_cache_search_frame ( clmd, frametime ) )
-					{
-						cloth_cache_get_frame ( clmd, frametime );
-						cloth_to_object ( ob, clmd, vertexCos, numverts );
-					}
-					return;
+					cloth_cache_get_frame ( clmd, frametime );
+					cloth_to_object ( ob, clmd, result );
 				}
-				else if ( ABS ( deltaTime ) >= 2.0f ) // no timewarps allowed
+				return;
+			}
+			else if ( ABS ( deltaTime ) >= 2.0f ) // no timewarps allowed
+			{
+				if ( cloth_cache_search_frame ( clmd, framenr ) )
 				{
-					if ( cloth_cache_search_frame ( clmd, framenr ) )
-					{
-						cloth_cache_get_frame ( clmd, framenr );
-						cloth_to_object ( ob, clmd, vertexCos, numverts );
-					}
-					clmd->sim_parms.sim_time = current_time;
-					return;
+					cloth_cache_get_frame ( clmd, framenr );
+					cloth_to_object ( ob, clmd, result );
 				}
+				clmd->sim_parms.sim_time = current_time;
+				return;
 			}
+		}
 
-		}
 	}
-
-
+	
 	// unused in the moment, calculated seperately in implicit.c
 	clmd->sim_parms.dt = 1.0f / clmd->sim_parms.stepsPerFrame;
 
@@ -673,9 +666,9 @@
 	
 	if ( deltaTime == 1.0f )
 	{
-		if ( ( clmd->clothObject == NULL ) || ( numverts != clmd->clothObject->numverts ) )
+		if ( ( clmd->clothObject == NULL ) || ( dm->getNumVerts(dm) != clmd->clothObject->numverts ) )
 		{
-			if ( !cloth_from_object ( ob, clmd, dm, vertexCos, numverts ) )
+			if ( !cloth_from_object ( ob, clmd, dm ) )
 				return;
 
 			if ( clmd->clothObject == NULL )
@@ -692,6 +685,7 @@
 			if ( !cloth_cache_search_frame ( clmd, framenr ) )
 			{
 				verts = cloth->verts;
+				mverts = dm->getVertArray(dm);
 
 				// Force any pinned verts to their constrained location.
 				for ( i = 0; i < clmd->clothObject->numverts; i++, verts++ )
@@ -699,9 +693,8 @@
 					// Save the previous position.
 					VECCOPY ( verts->xold, verts->xconst );
 					VECCOPY ( verts->txold, verts->x );
-
 					// Get the current position.
-					VECCOPY ( verts->xconst, vertexCos[i] );
+					VECCOPY ( verts->xconst, mverts[i].co );
 					Mat4MulVecfl ( ob->obmat, verts->xconst );
 				}
 
@@ -723,7 +716,7 @@
 			}
 
 			// Copy the result back to the object.
-			cloth_to_object ( ob, clmd, vertexCos, numverts );
+			cloth_to_object ( ob, clmd, result );
 
 			// bvh_free(clmd->clothObject->tree);
 			// clmd->clothObject->tree = bvh_build(clmd, clmd->coll_parms.epsilon);
@@ -737,11 +730,12 @@

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list