[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14187] trunk/blender/source/blender: Cloth structure names update: Sorry about this commit, it will kill all your cloth settings in old files but I had to do it before release because naming convention was really bad in cloth (e.g.

Joe Eagar joeedh at gmail.com
Mon Mar 24 02:37:52 CET 2008


You couldn't keep the old struct in and write a version patch?

Joe

Daniel Genrich wrote:
> Revision: 14187
>           http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14187
> Author:   genscher
> Date:     2008-03-20 19:28:40 +0100 (Thu, 20 Mar 2008)
>
> Log Message:
> -----------
> Cloth structure names update: Sorry about this commit, it will kill all your cloth settings in old files but I had to do it before release because naming convention was really bad in cloth (e.g. using SimulationSettings instead of ClothSimSettings in DNA). Same for some structure in CollisionModifier but with no sideeffects.
>
> Modified Paths:
> --------------
>     trunk/blender/source/blender/blenkernel/BKE_collision.h
>     trunk/blender/source/blender/blenkernel/intern/collision.c
>     trunk/blender/source/blender/blenkernel/intern/implicit.c
>     trunk/blender/source/blender/blenkernel/intern/modifier.c
>     trunk/blender/source/blender/blenloader/intern/readfile.c
>     trunk/blender/source/blender/blenloader/intern/writefile.c
>     trunk/blender/source/blender/makesdna/DNA_cloth_types.h
>     trunk/blender/source/blender/makesdna/DNA_modifier_types.h
>
> Modified: trunk/blender/source/blender/blenkernel/BKE_collision.h
> ===================================================================
> --- trunk/blender/source/blender/blenkernel/BKE_collision.h	2008-03-20 18:16:11 UTC (rev 14186)
> +++ trunk/blender/source/blender/blenkernel/BKE_collision.h	2008-03-20 18:28:40 UTC (rev 14187)
> @@ -172,7 +172,8 @@
>  // checks two bounding volume hierarchies for potential collisions and returns some list with those
>  
>  
> -// update bounding volumes, needs updated positions in bvh->x
> +// update bounding volumes, needs updated positions in  bvh->current_xold (static) 
> +// and also bvh->current_x if moving==1
>  void bvh_update_from_mvert(BVH * bvh, MVert *x, unsigned int numverts, MVert *xnew, int moving);
>  void bvh_update(BVH * bvh, int moving);
>  
>
> Modified: trunk/blender/source/blender/blenkernel/intern/collision.c
> ===================================================================
> --- trunk/blender/source/blender/blenkernel/intern/collision.c	2008-03-20 18:16:11 UTC (rev 14186)
> +++ trunk/blender/source/blender/blenkernel/intern/collision.c	2008-03-20 18:28:40 UTC (rev 14187)
> @@ -427,6 +427,7 @@
>  	float w1, w2, w3, u1, u2, u3;
>  	float v1[3], v2[3], relativeVelocity[3];
>  	float magrelVel;
> +	float epsilon2 = collmd->bvh->epsilon;
>  	
>  	cloth1 = clmd->clothObject;
>  
> @@ -510,7 +511,7 @@
>  			
>  			// Apply repulse impulse if distance too short
>  			// I_r = -min(dt*kd, m(0,1d/dt - v_n))
> -			d = clmd->coll_parms->epsilon*8.0/9.0 - collpair->distance;
> +			d = clmd->coll_parms->epsilon*8.0/9.0 + epsilon2*8.0/9.0 - collpair->distance;
>  			if((magrelVel < 0.1*d*clmd->sim_parms->stepsPerFrame) && (d > ALMOST_ZERO))
>  			{
>  				repulse = MIN2(d*1.0/clmd->sim_parms->stepsPerFrame, 0.1*d*clmd->sim_parms->stepsPerFrame - magrelVel);
> @@ -557,6 +558,7 @@
>  	ClothVertex *verts1=NULL;
>  	double distance = 0;
>  	float epsilon = clmd->coll_parms->epsilon;
> +	float epsilon2 = ((CollisionModifierData *)md2)->bvh->epsilon;
>  	unsigned int i = 0;
>  
>  	for(i = 0; i < 4; i++)
> @@ -641,9 +643,9 @@
>  					verts1[collpair->ap1].txold, verts1[collpair->ap2].txold, verts1[collpair->ap3].txold, collmd->current_x[collpair->bp1].co, collmd->current_x[collpair->bp2].co, collmd->current_x[collpair->bp3].co, collpair->pa,collpair->pb,collpair->vector);
>  #else
>  			// just be sure that we don't add anything
> -			distance = 2.0 * (epsilon + ALMOST_ZERO);
> +			distance = 2.0 * (epsilon + epsilon2 + ALMOST_ZERO);
>  #endif	
> -			if (distance <= (epsilon + ALMOST_ZERO))
> +			if (distance <= (epsilon + epsilon2 + ALMOST_ZERO))
>  			{
>  				// printf("dist: %f\n", (float)distance);
>  				
> @@ -968,10 +970,10 @@
>  	
>  	verts = cloth->verts;
>  	
> -	if (collmd->tree) 
> +	if (collmd->bvh) 
>  	{
>  		/* get pointer to bounding volume hierarchy */
> -		BVH *coll_bvh = collmd->tree;
> +		BVH *coll_bvh = collmd->bvh;
>  		
>  		/* move object to position (step) in time */
>  		collision_move_object(collmd, step + dt, step);
> @@ -991,7 +993,7 @@
>  	{
>  		result = 0;
>  				
> -		if (collmd->tree) 
> +		if (collmd->bvh) 
>  			result += cloth_collision_response_static(clmd, collmd);
>  				
>  				// apply impulses in parallel
>
> Modified: trunk/blender/source/blender/blenkernel/intern/implicit.c
> ===================================================================
> --- trunk/blender/source/blender/blenkernel/intern/implicit.c	2008-03-20 18:16:11 UTC (rev 14186)
> +++ trunk/blender/source/blender/blenkernel/intern/implicit.c	2008-03-20 18:28:40 UTC (rev 14187)
> @@ -37,13 +37,11 @@
>  #include "DNA_cloth_types.h"	
>  #include "DNA_scene_types.h"
>  
> -
>  #include "BKE_effect.h"
>  #include "BKE_global.h"
>  #include "BKE_cloth.h"
>  #include "BKE_utildefines.h"
>  
> -
>  #ifdef _WIN32
>  #include <windows.h>
>  static LARGE_INTEGER _itstart, _itend;
>
> Modified: trunk/blender/source/blender/blenkernel/intern/modifier.c
> ===================================================================
> --- trunk/blender/source/blender/blenkernel/intern/modifier.c	2008-03-20 18:16:11 UTC (rev 14186)
> +++ trunk/blender/source/blender/blenkernel/intern/modifier.c	2008-03-20 18:28:40 UTC (rev 14187)
> @@ -5037,8 +5037,8 @@
>  {
>  	ClothModifierData *clmd = (ClothModifierData*) md;
>  	
> -	clmd->sim_parms = MEM_callocN(sizeof(SimulationSettings), "cloth sim parms");
> -	clmd->coll_parms = MEM_callocN(sizeof(CollisionSettings), "cloth coll parms");
> +	clmd->sim_parms = MEM_callocN(sizeof(ClothSimSettings), "cloth sim parms");
> +	clmd->coll_parms = MEM_callocN(sizeof(ClothCollSettings), "cloth coll parms");
>  	
>  	/* check for alloc failing */
>  	if(!clmd->sim_parms || !clmd->coll_parms)
> @@ -5055,7 +5055,12 @@
>  	
>  	/* check for alloc failing */
>  	if(!clmd->sim_parms || !clmd->coll_parms)
> -		return derivedData;
> +	{
> +		clothModifier_initData(md);
> +		
> +		if(!clmd->sim_parms || !clmd->coll_parms)
> +			return derivedData;
> +	}
>  
>  	result = clothModifier_do(clmd, ob, derivedData, useRenderParams, isFinalCalc);
>  
> @@ -5090,7 +5095,7 @@
>  				}
>  			}
>  		}
> -	}	
> +	}
>  }
>  
>  CustomDataMask clothModifier_requiredDataMask(ModifierData *md)
> @@ -5156,7 +5161,7 @@
>  	collmd->current_v = NULL;
>  	collmd->time = -1;
>  	collmd->numverts = 0;
> -	collmd->tree = NULL;
> +	collmd->bvh = NULL;
>  }
>  
>  static void collisionModifier_freeData(ModifierData *md)
> @@ -5165,8 +5170,8 @@
>  	
>  	if (collmd) 
>  	{
> -		if(collmd->tree)
> -			bvh_free(collmd->tree);
> +		if(collmd->bvh)
> +			bvh_free(collmd->bvh);
>  		if(collmd->x)
>  			MEM_freeN(collmd->x);
>  		if(collmd->xnew)
> @@ -5188,7 +5193,7 @@
>  		collmd->current_v = NULL;
>  		collmd->time = -1;
>  		collmd->numverts = 0;
> -		collmd->tree = NULL;
> +		collmd->bvh = NULL;
>  		collmd->mfaces = NULL;
>  	}
>  }
> @@ -5258,7 +5263,7 @@
>  				
>  				// TODO: epsilon
>  				// create bounding box hierarchy
> -				collmd->tree = bvh_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, ob->pd->pdef_sbift);
> +				collmd->bvh = bvh_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, ob->pd->pdef_sboft);
>  				
>  				collmd->time = current_time;
>  			}
> @@ -5281,14 +5286,14 @@
>  				memcpy(collmd->current_x, collmd->x, numverts*sizeof(MVert));
>  				
>  				/* happens on file load (ONLY when i decomment changes in readfile.c */
> -				if(!collmd->tree)
> +				if(!collmd->bvh)
>  				{
> -					collmd->tree = bvh_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, numverts, ob->pd->pdef_sbift);
> +					collmd->bvh = bvh_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, numverts, ob->pd->pdef_sboft);
>  				}
>  				else
>  				{
>  					// recalc static bounding boxes
> -					bvh_update_from_mvert(collmd->tree, collmd->current_x, numverts, NULL, 0);
> +					bvh_update_from_mvert(collmd->bvh, collmd->current_x, numverts, NULL, 0);
>  				}
>  				
>  				collmd->time = current_time;
>
> Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
> ===================================================================
> --- trunk/blender/source/blender/blenloader/intern/readfile.c	2008-03-20 18:16:11 UTC (rev 14186)
> +++ trunk/blender/source/blender/blenloader/intern/readfile.c	2008-03-20 18:28:40 UTC (rev 14187)
> @@ -3051,12 +3051,15 @@
>  			clmd->sim_parms= newdataadr(fd, clmd->sim_parms);
>  			clmd->coll_parms= newdataadr(fd, clmd->coll_parms);
>  			
> -			clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_LOADED;
> -			clmd->sim_parms->flags &= ~CLOTH_SIMSETTINGS_FLAG_EDITMODE;
> +			if(clmd->sim_parms)
> +			{
> +				clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_LOADED;
> +				clmd->sim_parms->flags &= ~CLOTH_SIMSETTINGS_FLAG_EDITMODE;
> +				
> +				if(clmd->sim_parms->presets > 10)
> +					clmd->sim_parms->presets = 0;
> +			}
>  			
> -			if(clmd->sim_parms->presets > 10)
> -				clmd->sim_parms->presets = 0;
> -			
>  		}
>  		else if (md->type==eModifierType_Collision) {
>  			
> @@ -3080,7 +3083,7 @@
>  			collmd->current_v = NULL;
>  			collmd->time = -1;
>  			collmd->numverts = 0;
> -			collmd->tree = NULL;
> +			collmd->bvh = NULL;
>  			collmd->mfaces = NULL;
>  			
>  		}
>
> Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
> ===================================================================
> --- trunk/blender/source/blender/blenloader/intern/writefile.c	2008-03-20 18:16:11 UTC (rev 14186)
> +++ trunk/blender/source/blender/blenloader/intern/writefile.c	2008-03-20 18:28:40 UTC (rev 14187)
> @@ -859,8 +859,8 @@
>  		else if(md->type==eModifierType_Cloth) {
>  			ClothModifierData *clmd = (ClothModifierData*) md;
>  			
> -			writestruct(wd, DATA, "SimulationSettings", 1, clmd->sim_parms);
> -			writestruct(wd, DATA, "CollisionSettings", 1, clmd->coll_parms);
> +			writestruct(wd, DATA, "ClothSimSettings", 1, clmd->sim_parms);
> +			writestruct(wd, DATA, "ClothCollSettings", 1, clmd->coll_parms);
>  			
>  		} 
>  		else if (md->type==eModifierType_Collision) {
>
> Modified: trunk/blender/source/blender/makesdna/DNA_cloth_types.h
> ===================================================================
> --- trunk/blender/source/blender/makesdna/DNA_cloth_types.h	2008-03-20 18:16:11 UTC (rev 14186)
> +++ trunk/blender/source/blender/makesdna/DNA_cloth_types.h	2008-03-20 18:28:40 UTC (rev 14187)
> @@ -44,7 +44,8 @@
>  * as in stepsPerFrame comapred to the time step in the paper, I've used
>  * variables with different names to minimize confusion.
>  **/
> -typedef struct SimulationSettings
> +
> +typedef struct ClothSimSettings
>  {
>  	short	vgroup_mass;	/* optional vertexgroup name for assigning weight.*/
>  	short	vgroup_struct;  /* vertex group for scaling structural stiffness */
> @@ -87,10 +88,10 @@
>  	short pad;
>  	int pad2;
>  }
> -SimulationSettings;
> +ClothSimSettings;
>  
>  
> -typedef struct CollisionSettings
> +typedef struct ClothCollSettings
>  {
>  	float	epsilon;		/* min distance for collisions.		*/
>  	float	self_friction;		/* Fiction/damping with self contact.		 	*/
> @@ -101,7 +102,7 @@
>  	int	flags;			/* collision flags defined in BKE_cloth.h */
>  	float 	selfepsilon; 		/* for selfcollision */
>  }
> -CollisionSettings;
> +ClothCollSettings;
>  
>  
>  /**
>
> Modified: trunk/blender/source/blender/makesdna/DNA_modifier_types.h
> ===================================================================
> --- trunk/blender/source/blender/makesdna/DNA_modifier_types.h	2008-03-20 18:16:11 UTC (rev 14186)
> +++ trunk/blender/source/blender/makesdna/DNA_modifier_types.h	2008-03-20 18:28:40 UTC (rev 14187)
> @@ -369,8 +369,8 @@
>     ModifierData		modifier;
>  
>     struct Cloth *clothObject; /* The internal data structure for cloth. */
> -   struct SimulationSettings *sim_parms; /* definition is in DNA_cloth_types.h */
> -   struct CollisionSettings *coll_parms; /* definition is in DNA_cloth_types.h */
> +   struct ClothSimSettings *sim_parms; /* definition is in DNA_cloth_types.h */
>
> @@ Diff output truncated at 10240 characters. @@
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
>   



More information about the Bf-committers mailing list