[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19948] trunk/blender/source: BGE: Add soft body welding parameter to the Advanced Settings panel.

Benoit Bolsee benoit.bolsee at online.be
Mon Apr 27 18:44:02 CEST 2009


Revision: 19948
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19948
Author:   ben2610
Date:     2009-04-27 18:44:02 +0200 (Mon, 27 Apr 2009)

Log Message:
-----------
BGE: Add soft body welding parameter to the Advanced Settings panel. The values are very small so I chose to use logarithmic scale. Should be fine, it's an advanced setting after all.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/bullet.c
    trunk/blender/source/blender/makesdna/DNA_object_force.h
    trunk/blender/source/blender/src/buttons_logic.c
    trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    trunk/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
    trunk/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
    trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp

Modified: trunk/blender/source/blender/blenkernel/intern/bullet.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/bullet.c	2009-04-27 16:40:26 UTC (rev 19947)
+++ trunk/blender/source/blender/blenkernel/intern/bullet.c	2009-04-27 16:44:02 UTC (rev 19948)
@@ -82,6 +82,7 @@
 	bsb->collisionflags = 0;
 	//bsb->collisionflags = OB_BSB_COL_CL_RS + OB_BSB_COL_CL_SS;
 	bsb->numclusteriterations = 64;
+	bsb->welding = -4.f;
 
 	return bsb;
 }

Modified: trunk/blender/source/blender/makesdna/DNA_object_force.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_object_force.h	2009-04-27 16:40:26 UTC (rev 19947)
+++ trunk/blender/source/blender/makesdna/DNA_object_force.h	2009-04-27 16:44:02 UTC (rev 19948)
@@ -119,7 +119,7 @@
 	float	kAHR;			/* Anchors hardness [0,1] */
 	int		collisionflags;	/* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
 	int		numclusteriterations;	/* number of iterations to refine collision clusters*/
-
+	float	welding;		/* welding limit to remove duplicate/nearby vertices, 0.0000001..0.01 */
 } BulletSoftBody;
 
 /* BulletSoftBody.flag */

Modified: trunk/blender/source/blender/src/buttons_logic.c
===================================================================
--- trunk/blender/source/blender/src/buttons_logic.c	2009-04-27 16:40:26 UTC (rev 19947)
+++ trunk/blender/source/blender/src/buttons_logic.c	2009-04-27 16:44:02 UTC (rev 19948)
@@ -3073,19 +3073,19 @@
 {
 	uiBlock *block;
 	Object *ob = arg_ob;
-	short yco = 20, xco = 0;
+	short yco, xco = 0;
 
 	block= uiNewBlock(&curarea->uiblocks, "advanced_bullet_options", UI_EMBOSS, UI_HELV, curarea->win);
 	/* use this for a fake extra empy space around the buttons */
 	
 
 	if (ob->gameflag & OB_SOFT_BODY) {
-		uiDefBut(block, LABEL, 0, "", -10, -10, 380, 60, NULL, 0, 0, 0, 0, "");
+		uiDefBut(block, LABEL, 0, "", -10, -10, 380, 80, NULL, 0, 0, 0, 0, "");
 
 		if (ob->bsoft)
 		{
 			
-
+			yco = 40;
 			uiBlockBeginAlign(block);
 			uiDefButBitI(block, TOG, OB_BSB_COL_CL_RS, 0, "Cluster Collision RS", 
 				xco, yco, 180, 19, &ob->bsoft->collisionflags, 0, 0, 0, 0, 
@@ -3102,7 +3102,15 @@
 				xco+=180, yco, 180, 19, &ob->bsoft->piterations, 0, 10, 
 				0, 0, "Position solver iterations");
 			uiBlockEndAlign(block);
+			yco -= 20;
+			xco = 0;
+			if (ob->bsoft->welding == 0.f)
+				ob->bsoft->welding = -4.f;
 
+			uiDefButF(block, NUMSLI, 0, "Welding(10^) ", 
+				xco, yco, 360, 19, &ob->bsoft->welding, -7.f, -2.f, 10, 2, 
+				"Threshold to remove duplicate/nearby vertices. Displayed in logarithmic scale for readability: linear values from 0.0000001 to 0.01");
+
 			/*
 			//too complex tweaking, disable for now
 			uiDefButF(block, NUMSLI, REDRAWVIEW3D, "kVC",		
@@ -3131,7 +3139,7 @@
 
 		if (ob->gameflag & OB_DYNAMIC) {
 
-			yco = 100;
+			yco = 80;
 			uiDefBut(block, LABEL, 0, "", -10, -10, 380, 120, NULL, 0, 0, 0, 0, "");
 			uiBlockBeginAlign(block);
 			if (ob->margin < 0.001f)
@@ -3173,7 +3181,7 @@
 			
 			uiBlockEndAlign(block);
 			
-			uiDefBut(block, LABEL, 0, "Clamp Velocity (zero disables)",	  xco, yco, 180*2, 19, NULL, 0, 0, 0, 0, "");
+			uiDefBut(block, LABEL, 0, "Clamp Velocity (0=disabled)",	  xco, yco, 180*2, 19, NULL, 0, 0, 0, 0, "");
 			
 			uiBlockBeginAlign(block);
 			
@@ -3215,7 +3223,7 @@
 
 
 		} else {
-			
+			yco = 20;
 			uiDefBut(block, LABEL, 0, "", -10, -10, 380, 60, NULL, 0, 0, 0, 0, "");
 			uiDefButF(block, NUM, 0, "Margin", 
 					xco, yco, 180, 19, &ob->margin, 0.0, 1.0, 1, 0, 

Modified: trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2009-04-27 16:40:26 UTC (rev 19947)
+++ trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2009-04-27 16:44:02 UTC (rev 19948)
@@ -1418,6 +1418,10 @@
 			objprop.m_soft_kAHR= blenderobject->bsoft->kAHR;			/* Anchors hardness [0,1] */
 			objprop.m_soft_collisionflags= blenderobject->bsoft->collisionflags;	/* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
 			objprop.m_soft_numclusteriterations= blenderobject->bsoft->numclusteriterations;	/* number of iterations to refine collision clusters*/
+			if (blenderobject->bsoft->welding == 0.f)
+				objprop.m_soft_welding = 0.0001f;		/* welding */
+			else
+				objprop.m_soft_welding = pow(10.f,blenderobject->bsoft->welding);		/* welding */
 		
 		} else
 		{
@@ -1457,6 +1461,7 @@
 			objprop.m_soft_kAHR= 0.7f;
 			objprop.m_soft_collisionflags= OB_BSB_COL_SDF_RS + OB_BSB_COL_VF_SS;
 			objprop.m_soft_numclusteriterations= 16;
+			objprop.m_soft_welding = 0.0001f;
 		}
 	}
 

Modified: trunk/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h	2009-04-27 16:40:26 UTC (rev 19947)
+++ trunk/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h	2009-04-27 16:44:02 UTC (rev 19948)
@@ -124,6 +124,7 @@
 	float	m_soft_kAHR;			/* Anchors hardness [0,1] */
 	int		m_soft_collisionflags;	/* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
 	int		m_soft_numclusteriterations;	/* number of iterations to refine collision clusters*/
+	float   m_soft_welding;			/*   threshold to remove duplicate/nearby vertices */
 
 	/////////////////////////
 	

Modified: trunk/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp	2009-04-27 16:40:26 UTC (rev 19947)
+++ trunk/blender/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp	2009-04-27 16:44:02 UTC (rev 19948)
@@ -905,7 +905,9 @@
 
 				// Soft bodies require welding. Only avoid remove doubles for non-soft bodies!
 				if (objprop->m_softbody)
-					shapeInfo->setVertexWeldingThreshold1(0.0001f); //todo: expose this to the UI
+				{
+					shapeInfo->setVertexWeldingThreshold1(objprop->m_soft_welding); //todo: expose this to the UI
+				}
 
 				bm = shapeInfo->CreateBulletShape();
 				//no moving concave meshes, so don't bother calculating inertia

Modified: trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp	2009-04-27 16:40:26 UTC (rev 19947)
+++ trunk/blender/source/gameengine/Ketsji/KX_GameObject.cpp	2009-04-27 16:44:02 UTC (rev 19948)
@@ -462,11 +462,11 @@
 
 void KX_GameObject::UpdateTransform()
 {
-	if (m_pPhysicsController1)
-		// only update the transform of static object, dynamic object are handled differently
-		// note that for bullet, this does not even update the transform of static object
+	// HACK: saves function call for dynamic object, they are handled differently
+	if (m_pPhysicsController1 && !m_pPhysicsController1->IsDyna())
+		// Note that for Bullet, this does not even update the transform of static object
 		// but merely sets there collision flag to "kinematic" because the synchronization is 
-		// done differently during physics simulation
+		// done during physics simulation
 		m_pPhysicsController1->SetSumoTransform(true);
 	if (m_pGraphicController)
 		// update the culling tree





More information about the Bf-blender-cvs mailing list