[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20269] trunk/blender/source: BGE soft body: give access to the soft body collision margin in the Advanced panel.

Benoit Bolsee benoit.bolsee at online.be
Mon May 18 23:32:03 CEST 2009


Revision: 20269
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20269
Author:   ben2610
Date:     2009-05-18 23:32:03 +0200 (Mon, 18 May 2009)

Log Message:
-----------
BGE soft body: give access to the soft body collision margin in the Advanced panel. By default the collision margin is set to 0.25, which causes the soft body to somewhat float above the ground. You can decrease this value to get more realistic collision. Note that the algorithm may become unstable with lower margin.

Modified Paths:
--------------
    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/Physics/Bullet/CcdPhysicsController.cpp

Modified: trunk/blender/source/blender/makesdna/DNA_object_force.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_object_force.h	2009-05-18 21:05:21 UTC (rev 20268)
+++ trunk/blender/source/blender/makesdna/DNA_object_force.h	2009-05-18 21:32:03 UTC (rev 20269)
@@ -120,6 +120,7 @@
 	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.0..0.01 */
+	float   margin;			/* margin specific to softbody */
 } BulletSoftBody;
 
 /* BulletSoftBody.flag */

Modified: trunk/blender/source/blender/src/buttons_logic.c
===================================================================
--- trunk/blender/source/blender/src/buttons_logic.c	2009-05-18 21:05:21 UTC (rev 20268)
+++ trunk/blender/source/blender/src/buttons_logic.c	2009-05-18 21:32:03 UTC (rev 20269)
@@ -3141,8 +3141,14 @@
 			uiBlockEndAlign(block);
 			yco -= 20;
 			xco = 0;
-			uiDefButF(block, NUMSLI, 0, "Welding ", 
-				xco, yco, 360, 19, &ob->bsoft->welding, 0.f, 0.01f, 10, 4, 
+			if (ob->bsoft->margin < 0.001f)
+				ob->bsoft->margin = 0.25f;
+			uiDefButF(block, NUM, 0, "Margin", 
+					xco, yco, 180, 19, &ob->bsoft->margin, 0.001, 1.0, 1, 0, 
+					"Collision margin for soft body. Small value makes the algorithm unstable");
+
+			uiDefButF(block, NUM, 0, "Welding ", 
+				xco+=180, yco, 180, 19, &ob->bsoft->welding, 0.f, 0.01f, 10, 4, 
 				"Welding threshold: distance between nearby vertices to be considered equal => set to 0.0 to disable welding test and speed up scene loading (ok if the mesh has no duplicates)");
 
 			/*

Modified: trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2009-05-18 21:05:21 UTC (rev 20268)
+++ trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2009-05-18 21:32:03 UTC (rev 20269)
@@ -1456,7 +1456,7 @@
 			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*/
 			objprop.m_soft_welding = blenderobject->bsoft->welding;		/* welding */
-		
+			objprop.m_margin = blenderobject->bsoft->margin;
 		} else
 		{
 			objprop.m_gamesoftFlag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT;
@@ -1496,6 +1496,7 @@
 			objprop.m_soft_collisionflags= OB_BSB_COL_SDF_RS + OB_BSB_COL_VF_SS;
 			objprop.m_soft_numclusteriterations= 16;
 			objprop.m_soft_welding = 0.f;
+			objprop.m_margin = 0.f;
 		}
 	}
 

Modified: trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
===================================================================
--- trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp	2009-05-18 21:05:21 UTC (rev 20268)
+++ trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp	2009-05-18 21:32:03 UTC (rev 20269)
@@ -296,7 +296,11 @@
 			}
 
 		}
-
+		if (m_cci.m_margin > 0.f)
+		{
+			psb->getCollisionShape()->setMargin(m_cci.m_margin);
+			psb->updateBounds();
+		}
 	
 		
 		m_object = psb;





More information about the Bf-blender-cvs mailing list