[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13712] trunk/blender/source/blender/ blenkernel/intern/softbody.c: cleaning up softbody.c code

Jens Ole Wund (bjornmose) bjornmose at gmx.net
Sat Feb 16 01:07:05 CET 2008


Revision: 13712
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13712
Author:   bjornmose
Date:     2008-02-16 01:07:05 +0100 (Sat, 16 Feb 2008)

Log Message:
-----------
cleaning up softbody.c code
- removed some 'hopes' on ODE solving
- no linking to open numeric library (ONL) should be required for now

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/softbody.c

Modified: trunk/blender/source/blender/blenkernel/intern/softbody.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/softbody.c	2008-02-15 23:12:03 UTC (rev 13711)
+++ trunk/blender/source/blender/blenkernel/intern/softbody.c	2008-02-16 00:07:05 UTC (rev 13712)
@@ -87,7 +87,7 @@
 #include  "BIF_editdeform.h"
 #include  "BIF_graphics.h"
 #include  "PIL_time.h"
-#include  "ONL_opennl.h"
+// #include  "ONL_opennl.h" remove linking to ONL for now
 
 /* callbacks for errors and interrupts and some goo */
 static int (*SB_localInterruptCallBack)(void) = NULL;
@@ -816,50 +816,6 @@
 }
 
 
-char set_octant_flags(float *ce, float *pos, float ball)
-{ 
-	float x,y,z;
-	char res = 0;
-	int a;
-	
-	for (a=0;a<7;a++){
-		switch(a){
-		case 0: x=pos[0];      y=pos[1];      z=pos[2]; break;
-		case 1: x=pos[0]+ball; y=pos[1];      z=pos[2]; break;
-		case 2: x=pos[0]-ball; y=pos[1];      z=pos[2]; break;
-		case 3: x=pos[0];      y=pos[1]+ball; z=pos[2]; break;
-		case 4: x=pos[0];      y=pos[1]-ball; z=pos[2]; break;
-		case 5: x=pos[0];      y=pos[1];      z=pos[2]+ball; break;
-		case 6: x=pos[0];      y=pos[1];      z=pos[2]-ball; break;
-		}
-
-		x=pos[0]; y=pos[1]; z=pos[2];
-		
-		if (x > ce[0]){
-			if (y > ce[1]){
-				if (z > ce[2])  res|= 1;
-				else res|= 2;
-			}
-			else{
-				if (z > ce[2])  res|= 4;
-				else res|= 8;
-			}
-		}
-		
-		else{
-			if (y > ce[1]){
-				if (z > ce[2])  res|= 16;
-				else res|= 32;
-			}
-			else{
-				if (z > ce[2])  res|= 64;
-				else res|= 128;
-			}
-		}
-	}
-	return res;
-}
-
 /* creates new softbody if didn't exist yet, makes new points and springs arrays */
 static void renew_softbody(Object *ob, int totpoint, int totspring)  
 {
@@ -1000,6 +956,7 @@
 }
 
 /* +++ dependancy information functions*/
+
 static int are_there_deflectors(unsigned int layer)
 {
 	Base *base;
@@ -1017,38 +974,9 @@
 {
 	return(are_there_deflectors(me->lay));
 }
-
-#if 0
-static int query_external_forces(Object *me)
-{
-/* silly but true: we need to create effector cache to see if anything is in it */
-	ListBase *ec = pdInitEffectors(me,NULL);
-	int result = 0;
-	if (ec){
-		result = 1;
-		pdEndEffectors(ec); /* sorry ec, yes i'm an idiot, but i needed to know if you were there */
-	}
-	return result;
-}
-
-/* 
-any of that external objects may have an IPO or something alike ..
-so unless we can ask them if they are moving we have to assume they do
-*/
-static int query_external_time(Object *me)
-{
-	if (query_external_colliders(me)) return 1;
-	if (query_external_forces(me)) return 1;
-	return 0;
-}
-static int query_internal_time(Object *me)
-{
-	if (me->softflag & OB_SB_GOAL) return 1;
-	return 0;
-}
-#endif
 /* --- dependancy information functions*/
 
+
 /* +++ the aabb "force" section*/
 int sb_detect_aabb_collisionCached(	float force[3], unsigned int par_layer,struct Object *vertexowner,float time)
 {
@@ -1981,254 +1909,7 @@
 	return deflected;	
 }
 
-/* not complete yet ..
-   try to find a pos resolving all inside collisions 
-*/
-#if 0 //mute it for now 
-int sb_detect_vertex_collisionCachedEx(float opco[3], float facenormal[3], float *damp,
-									 float force[3], unsigned int par_layer,struct Object *vertexowner,
-									 float time,float vel[3], float *intrusion)
-{
-	Object *ob;
-	GHash *hash;
-	GHashIterator *ihash;
-	float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3],d_nvect[3], dv1[3],ve[3],avel[3],
-    vv1[3], vv2[3], vv3[3], vv4[3],
-		facedist,n_mag,force_mag_norm,minx,miny,minz,maxx,maxy,maxz,
-		innerfacethickness,outerfacethickness,
-		closestinside,
-		ee = 5.0f, ff = 0.1f, fa;
-	int a, deflected=0, cavel=0;
-/* init */
-	*intrusion = 0.0f;
-	hash  = vertexowner->soft->scratch->colliderhash;
-	ihash =	BLI_ghashIterator_new(hash);
-/* go */
-    while (!BLI_ghashIterator_isDone(ihash) ) {
 
-		ccd_Mesh *ccdm = BLI_ghashIterator_getValue	(ihash);
-		ob             = BLI_ghashIterator_getKey	(ihash);
-			/* only with deflecting set */
-			if(ob->pd && ob->pd->deflect) {
-				MFace *mface= NULL;
-				MVert *mvert= NULL;
-				MVert *mprevvert= NULL;
-				ccdf_minmax *mima= NULL;
-
-				if(ccdm){
-					mface= ccdm->mface;
-					mvert= ccdm->mvert;
-					mprevvert= ccdm->mprevvert;
-					mima= ccdm->mima;
-					a = ccdm->totface;
-
-					minx =ccdm->bbmin[0]; 
-					miny =ccdm->bbmin[1]; 
-					minz =ccdm->bbmin[2];
-
-					maxx =ccdm->bbmax[0]; 
-					maxy =ccdm->bbmax[1]; 
-					maxz =ccdm->bbmax[2]; 
-
-					if ((opco[0] < minx) || 
-						(opco[1] < miny) ||
-						(opco[2] < minz) ||
-						(opco[0] > maxx) || 
-						(opco[1] > maxy) || 
-						(opco[2] > maxz) ) {
-							/* outside the padded boundbox --> collision object is too far away */ 
-												BLI_ghashIterator_step(ihash);
-							continue;				
-					}					
-				}
-				else{
-					/*aye that should be cached*/
-					printf("missing cache error \n");
-						BLI_ghashIterator_step(ihash);
-					continue;				
-				}
-
-				/* do object level stuff */
-				/* need to have user control for that since it depends on model scale */
-				innerfacethickness =-ob->pd->pdef_sbift;
-				outerfacethickness =ob->pd->pdef_sboft;
-				closestinside = innerfacethickness;
-				fa = (ff*outerfacethickness-outerfacethickness);
-				fa *= fa;
-				fa = 1.0f/fa;
-                avel[0]=avel[1]=avel[2]=0.0f;
-				/* use mesh*/
-				while (a--) {
-					if (
-						(opco[0] < mima->minx) || 
-						(opco[0] > mima->maxx) || 
-						(opco[1] < mima->miny) ||
-						(opco[1] > mima->maxy) || 
-						(opco[2] < mima->minz) ||
-						(opco[2] > mima->maxz) 
-						) {
-							mface++;
-							mima++;
-							continue;
-					}
-
-					if (mvert){
-
-						VECCOPY(nv1,mvert[mface->v1].co);						
-						VECCOPY(nv2,mvert[mface->v2].co);
-						VECCOPY(nv3,mvert[mface->v3].co);
-						if (mface->v4){
-							VECCOPY(nv4,mvert[mface->v4].co);
-						}
-
-						if (mprevvert){
-							/* grab the average speed of the collider vertices
-							before we spoil nvX 
-							humm could be done once a SB steps but then we' need to store that too
-							since the AABB reduced propabitlty to get here drasticallly
-							it might be a nice tradeof CPU <--> memory
-							*/
-							VECSUB(vv1,nv1,mprevvert[mface->v1].co);
-							VECSUB(vv2,nv2,mprevvert[mface->v2].co);
-							VECSUB(vv3,nv3,mprevvert[mface->v3].co);
-							if (mface->v4){
-								VECSUB(vv4,nv4,mprevvert[mface->v4].co);
-							}
-
-							VecMulf(nv1,time);
-							Vec3PlusStVec(nv1,(1.0f-time),mprevvert[mface->v1].co);
-
-							VecMulf(nv2,time);
-							Vec3PlusStVec(nv2,(1.0f-time),mprevvert[mface->v2].co);
-
-							VecMulf(nv3,time);
-							Vec3PlusStVec(nv3,(1.0f-time),mprevvert[mface->v3].co);
-
-							if (mface->v4){
-								VecMulf(nv4,time);
-								Vec3PlusStVec(nv4,(1.0f-time),mprevvert[mface->v4].co);
-							}
-						}	
-					}
-					
-					/* switch origin to be nv2*/
-					VECSUB(edge1, nv1, nv2);
-					VECSUB(edge2, nv3, nv2);
-					VECSUB(dv1,opco,nv2); /* abuse dv1 to have vertex in question at *origin* of triangle */
-
-					Crossf(d_nvect, edge2, edge1);
-					n_mag = Normalize(d_nvect);
-					facedist = Inpf(dv1,d_nvect);
-
-					if ((facedist > closestinside) && (facedist < outerfacethickness)){		
-//					if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){		
-						if (point_in_tri_prism(opco, nv1, nv2, nv3) ){
-							force_mag_norm =(float)exp(-ee*facedist);
-							if (facedist > outerfacethickness*ff)
-								force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness);
-							    *damp=ob->pd->pdef_sbdamp;
-
-								if (facedist > 0.0f){
-									*damp *= (1.0f - facedist/outerfacethickness);								
-									Vec3PlusStVec(force,force_mag_norm,d_nvect);
-									if (deflected < 2){
-										deflected = 1;
-										if ((mprevvert) && (*damp > 0.0f)){
-											choose_winner(ve,opco,nv1,nv2,nv3,vv1,vv2,vv3);
-											VECADD(avel,avel,ve);
-											cavel ++;
-										}
-									}
-									
-								}
-								else{
-									Vec3PlusStVec(force,force_mag_norm,d_nvect);
-									VECCOPY(facenormal,d_nvect);
-									if ((mprevvert) && (*damp > 0.0f)){
-										choose_winner(avel,opco,nv1,nv2,nv3,vv1,vv2,vv3);
-										cavel = 1;
-										deflected = 2;
-										closestinside = facedist;
-									}
-								}
-							*intrusion = facedist;
-						}
-					}		
-					if (mface->v4){ /* quad */
-						/* switch origin to be nv4 */
-						VECSUB(edge1, nv3, nv4);
-						VECSUB(edge2, nv1, nv4);
-						VECSUB(dv1,opco,nv4); /* abuse dv1 to have vertex in question at *origin* of triangle */
-
-						Crossf(d_nvect, edge2, edge1);
-						n_mag = Normalize(d_nvect);
-						facedist = Inpf(dv1,d_nvect);
-
-						if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){
-							if (point_in_tri_prism(opco, nv1, nv3, nv4) ){
-								force_mag_norm =(float)exp(-ee*facedist);
-								if (facedist > outerfacethickness*ff)
-									force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness);
-								Vec3PlusStVec(force,force_mag_norm,d_nvect);
-								*damp=ob->pd->pdef_sbdamp;
-
-								if (facedist > 0.0f){
-									*damp *= (1.0f - facedist/outerfacethickness);								
-									Vec3PlusStVec(force,force_mag_norm,d_nvect);
-									if (deflected < 2){
-										deflected = 1;
-										if ((mprevvert) && (*damp > 0.0f)){
-											choose_winner(ve,opco,nv1,nv3,nv4,vv1,vv3,vv4);
-											VECADD(avel,avel,ve);
-											cavel ++;
-										}
-									}
-									
-								}
-								else{
-									Vec3PlusStVec(force,force_mag_norm,d_nvect);
-									VECCOPY(facenormal,d_nvect);
-									if ((mprevvert) && (*damp > 0.0f)){
-										choose_winner(avel,opco,nv1,nv3,nv4,vv1,vv3,vv4);
-										cavel = 1;
-										deflected = 2;
-										closestinside = facedist;
-									}
-								}
-
-
-
-							    *intrusion = facedist;
-							}
-
-						}
-					}
-					mface++;
-					mima++;					
-				}/* while a */		
-			} /* if(ob->pd && ob->pd->deflect) */
-			BLI_ghashIterator_step(ihash);
-	} /* while () */
-	BLI_ghashIterator_free(ihash);
-	if (cavel) VecMulf(avel,1.0f/(float)cavel);
-	VECCOPY(vel,avel);
-
-    /* we  did stay "outside" but have some close to contact forces
-	   just to be complete fake a face normal
-	*/
-	if (deflected ==1){ 
-		VECCOPY(facenormal,force);
-		Normalize(facenormal);
-	} 
-	else{
-		facenormal[0] = facenormal[1] = facenormal[2] = 0.0f;
-	}
-	return deflected;	
-}

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list