[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16808] trunk/blender/source: Update the Bullet/game buttons_bullet, to better reflect usage.

Erwin Coumans blender at erwincoumans.com
Mon Sep 29 06:14:57 CEST 2008


Revision: 16808
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16808
Author:   erwin
Date:     2008-09-29 06:14:47 +0200 (Mon, 29 Sep 2008)

Log Message:
-----------
Update the Bullet/game buttons_bullet, to better reflect usage. 
1) Anisotropic friction works for static and dynamic objects
2) For soft bodies, assume triangle mesh if no bounds a chosen
3) Form factor == inertia scaling factor, it was actually hooked up in Bullet
4) Only show 'radius' if sphere is chosen, or no bounds+dynamics (== sphere bounds)

Modified Paths:
--------------
    trunk/blender/source/blender/src/buttons_logic.c
    trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp

Modified: trunk/blender/source/blender/src/buttons_logic.c
===================================================================
--- trunk/blender/source/blender/src/buttons_logic.c	2008-09-29 04:00:42 UTC (rev 16807)
+++ trunk/blender/source/blender/src/buttons_logic.c	2008-09-29 04:14:47 UTC (rev 16808)
@@ -2932,6 +2932,10 @@
 					&ob->gameflag, 0, 0,0, 0,
 					"Specify a collision shape bounds type");
 			if (ob->gameflag & OB_BOUNDS) {
+				/* assume triangle mesh, if no bounds chosen for soft body */
+				
+				
+
 				uiDefButS(block, MENU, REDRAWVIEW3D, "Collision Type%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull%x5|Concave TriangleMesh %x4",
 					85, 105, 160, 19, &ob->boundtype, 0, 0, 0, 0, "Selects the collision type");
 				uiDefButBitI(block, TOG, OB_CHILD, B_REDR, "Compound", 250,105,100,19, 
@@ -2940,6 +2944,7 @@
 			}
 			uiBlockEndAlign(block);
 		}
+		uiBlockEndAlign(block);
 	}
 }
 
@@ -2967,9 +2972,12 @@
 	case OB_BODY_TYPE_SOFT:
 		ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_SOFT_BODY|OB_ACTOR;
 		ob->gameflag &= ~(OB_RIGID_BODY);
-		ob->gameflag |= OB_BOUNDS;
-		if (ob->boundtype<OB_BOUND_POLYH)
+		
+		/* assume triangle mesh, if no bounds chosen for soft body */
+		if ((ob->gameflag & OB_BOUNDS) && (ob->boundtype<OB_BOUND_POLYH))
+		{
 			ob->boundtype=OB_BOUND_POLYH;
+		}
 		/* create a BulletSoftBody structure if not already existing */
 		if (!ob->bsoft)
 			ob->bsoft = bsbNew();
@@ -3054,43 +3062,20 @@
 					"Objects that are detected by the Near and Radar sensor");
 
 		if (ob->gameflag & OB_DYNAMIC) {
-			uiDefButBitI(block, TOG, OB_COLLISION_RESPONSE, 0, "No sleeping", 
-						xco+=120, yco, 118, 19, &ob->gameflag, 0, 0, 0, 0, 
-						"Disable auto (de)activation");
-		}
-
-		yco -= 25;
-		xco = 0;
-		if (ob->gameflag & OB_DYNAMIC) {
 			if (ob->margin < 0.001f)
 				ob->margin = 0.06f;
 			uiDefButF(block, NUM, 0, "Margin", 
-					xco, yco, 118, 19, &ob->margin, 0.001, 1.0, 1, 0, 
+					xco+120, yco, 118, 19, &ob->margin, 0.001, 1.0, 1, 0, 
 					"Collision margin");
 		} else {
 			uiDefButF(block, NUM, 0, "Margin", 
-					xco, yco, 118, 19, &ob->margin, 0.0, 1.0, 1, 0, 
+					xco+120, yco, 118, 19, &ob->margin, 0.0, 1.0, 1, 0, 
 					"Collision margin");
 		}
-		uiDefButBitI(block, TOG, OB_ANISOTROPIC_FRICTION, B_REDR, "Anisotropic", 
-						xco+120, yco, 120, 19,
-						&ob->gameflag, 0.0, 1.0, 10, 0,
-						"Enable anisotropic friction");			
-
-		yco-=25;
-
-		if (ob->gameflag & OB_ANISOTROPIC_FRICTION) {
-			uiDefButF(block, NUM, 0, "X:", 
-				xco, yco, 80, 19,&ob->anisotropicFriction[0], 0.0, 1.0, 10, 0,
-					"Relative friction coefficient in the x-direction.");
-			uiDefButF(block, NUM, 0, "Y:", 
-				xco+80, yco, 80, 19,&ob->anisotropicFriction[1], 0.0, 1.0, 10, 0,
-					"Relative friction coefficient in the y-direction.");
-			uiDefButF(block, NUM, 0, "Z:", 
-				xco+160, yco, 80, 19,&ob->anisotropicFriction[2], 0.0, 1.0, 10, 0,
-					"Relative friction coefficient in the z-direction.");
-		}
-
+		yco -= 25;
+		xco = 0;
+		
+	
 	}
 			
 	uiBlockSetDirection(block, UI_TOP);
@@ -3114,6 +3099,8 @@
 	else
 		ob->body_type = OB_BODY_TYPE_SOFT;
 
+	uiBlockBeginAlign(block);
+
 	//only enable game soft body if Blender Soft Body exists
 	but = uiDefButS(block, MENU, REDRAWVIEW3D, 
 			"Object type%t|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4", 
@@ -3122,44 +3109,104 @@
 
 	if (ob->gameflag & OB_COLLISION) {
 
-		uiBlockSetCol(block, TH_BUT_SETTING1);
+			
+
+			uiDefButBitI(block, TOG, OB_GHOST, B_REDR, "Ghost", 
+				135,205,55,19, 
+					&ob->gameflag, 0, 0, 0, 0, 
+					"Objects that don't restitute collisions (like a ghost)");
+
+		//uiBlockSetCol(block, TH_BUT_SETTING1);
 		uiDefBlockBut(block, advanced_bullet_menu, ob, 
 					  "Advanced Settings", 
-					  200, 205, 150, 20, "Display collision advanced settings");
-		uiBlockSetCol(block, TH_BUT_SETTING2);
+					  200, 205, 150, 19, "Display collision advanced settings");
+		//uiBlockSetCol(block, TH_BUT_SETTING2);
 
-		uiBlockBeginAlign(block);
-		
-		
 
-		uiDefButBitI(block, TOG, OB_GHOST, 0, "Ghost", 10, 182, 60, 19, 
-				&ob->gameflag, 0, 0, 0, 0, 
-				"Objects that don't restitute collisions (like a ghost)");
-		if ((ob->gameflag & OB_DYNAMIC) || ((ob->gameflag & OB_BOUNDS) && (ob->boundtype == OB_BOUND_SPHERE))) {
-			uiDefButF(block, NUM, REDRAWVIEW3D, "Radius:", 70, 182, 140, 19, 
-					&ob->inertia, 0.01, 10.0, 10, 2, 
-					"Bounding sphere radius, not used for other bounding shapes");
-		}
 		if(ob->gameflag & OB_DYNAMIC) {
-			uiDefButF(block, NUM, B_DIFF, "Mass:", 210, 182, 140, 19, 
-					&ob->mass, 0.01, 10000.0, 10, 2, 
-					"The mass of the Object");
 
-			uiDefButF(block, NUMSLI, B_DIFF, "Damp ", 10, 162, 150, 19, 
-					&ob->damping, 0.0, 1.0, 10, 0, 
-					"General movement damping");
-			uiDefButF(block, NUMSLI, B_DIFF, "RotDamp ", 160, 162, 190, 19, 
-					&ob->rdamping, 0.0, 1.0, 10, 0, 
-					"General rotation damping");
-		}
+				uiDefButF(block, NUM, B_DIFF, "Mass:", 10, 185, 130, 19, 
+						&ob->mass, 0.01, 10000.0, 10, 2, 
+						"The mass of the Object");
+
+				if (!(ob->gameflag & OB_SOFT_BODY))
+				{
+
+					if (!(ob->gameflag & OB_BOUNDS) || (ob->boundtype==OB_BOUND_SPHERE))
+					{
+						uiDefButF(block, NUM, REDRAWVIEW3D, "Radius:", 140, 185, 130, 19, 
+								&ob->inertia, 0.01, 10.0, 10, 2, 
+								"Bounding sphere radius");
+					} else
+					{
+						uiBlockEndAlign(block);
+						uiBlockBeginAlign(block);
+					}
+					uiDefButBitI(block, TOG, OB_COLLISION_RESPONSE, B_REDR, "No sleeping", 270,185,80,19, 
+							&ob->gameflag, 0, 0, 0, 0, 
+							"Disable auto (de)activation");
+
+					uiDefButF(block, NUMSLI, B_DIFF, "Damp ", 10, 165, 150, 19, 
+							&ob->damping, 0.0, 1.0, 10, 0, 
+							"General movement damping");
+					uiDefButF(block, NUMSLI, B_DIFF, "RotDamp ", 160, 165, 190, 19, 
+							&ob->rdamping, 0.0, 1.0, 10, 0, 
+							"General rotation damping");
+
+					uiDefButBitI(block, TOG, OB_DO_FH, B_DIFF, "Do Fh", 10,145,50,19, 
+							&ob->gameflag, 0, 0, 0, 0, 
+							"Use Fh settings in Materials");
+					uiDefButBitI(block, TOG, OB_ROT_FH, B_DIFF, "Rot Fh", 60,145,50,19, 
+							&ob->gameflag, 0, 0, 0, 0, 
+							"Use face normal to rotate Object");
+					/* Form factor is hooked up in Bullet, to scale inertia tensor */
+
+					uiDefButF(block, NUM, B_DIFF, "Form:", 110, 145, 120, 19, 
+							&ob->formfactor, 0.01, 100.0, 10, 0, 
+							"Form factor scales the inertia tensor");
+				}
+
+				
+			}
+
 		uiBlockEndAlign(block);
 
+		/* In Bullet, anisotripic friction can be applied to static objects as well, just not soft bodies */
+
+		if (!(ob->gameflag & OB_SOFT_BODY))
+		{
+			uiDefButBitI(block, TOG, OB_ANISOTROPIC_FRICTION, B_REDR, "Anisotropic", 
+				230, 145, 120, 19,
+				&ob->gameflag, 0.0, 1.0, 10, 0,
+				"Enable anisotropic friction");			
+
+			if (ob->gameflag & OB_ANISOTROPIC_FRICTION) {
+				uiDefButF(block, NUM, B_DIFF, "x friction:", 10, 125, 114, 19,
+						&ob->anisotropicFriction[0], 0.0, 1.0, 10, 0,
+						"Relative friction coefficient in the x-direction.");
+				uiDefButF(block, NUM, B_DIFF, "y friction:", 124, 125, 113, 19,
+						&ob->anisotropicFriction[1], 0.0, 1.0, 10, 0,
+						"Relative friction coefficient in the y-direction.");
+				uiDefButF(block, NUM, B_DIFF, "z friction:", 237, 125, 113, 19,
+						&ob->anisotropicFriction[2], 0.0, 1.0, 10, 0,
+						"Relative friction coefficient in the z-direction.");
+			}
+
+
+		}
+		
 		uiBlockBeginAlign(block);
 		uiDefButBitI(block, TOG, OB_BOUNDS, B_REDR, "Bounds", 10, 105, 80, 19,
 				&ob->gameflag, 0, 0, 0, 0,
 				"Specify a collision bounds type");
 		if (ob->gameflag & OB_BOUNDS) {
 			//only allow convex hull/triangle mesh for soft bodies
+
+			if ((ob->body_type==OB_BODY_TYPE_SOFT) && (ob->gameflag & OB_BOUNDS) && (ob->boundtype<OB_BOUND_POLYH))
+			{
+				ob->boundtype=OB_BOUND_POLYH;
+			}
+
 			if (ob->body_type==OB_BODY_TYPE_SOFT)
 			{
 				uiDefButS(block, MENU, REDRAWVIEW3D, "Collision Bounds%t|Convex Hull%x5|Triangle Mesh%x4",
@@ -3169,12 +3216,19 @@
 				uiDefButS(block, MENU, REDRAWVIEW3D, "Collision Bounds%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull%x5|Triangle Mesh%x4",
 					90, 105, 150, 19, &ob->boundtype, 0, 0, 0, 0, "Selects the collision type");
 			}
-			uiDefButBitI(block, TOG, OB_CHILD, B_REDR, "Compound", 240,105,110,19, 
-					&ob->gameflag, 0, 0, 0, 0, 
-					"Add Children");
+			if (ob->body_type!=OB_BODY_TYPE_SOFT)
+			{
+				uiDefButBitI(block, TOG, OB_CHILD, B_REDR, "Compound", 240,105,110,19, 
+						&ob->gameflag, 0, 0, 0, 0, 
+						"Add Children");
+			}
 		}
+		uiBlockEndAlign(block);
 	}
+
 	uiBlockEndAlign(block);
+
+	
 }
 
 static void check_controller_state_mask(void *arg1_but, void *arg2_mask)

Modified: trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2008-09-29 04:00:42 UTC (rev 16807)
+++ trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2008-09-29 04:14:47 UTC (rev 16808)
@@ -1414,6 +1414,12 @@
 	objprop.m_dynamic_parent=NULL;
 	objprop.m_isdeformable = ((blenderobject->gameflag2 & 2)) != 0;
 	objprop.m_boundclass = objprop.m_dyna?KX_BOUNDSPHERE:KX_BOUNDMESH;
+	
+	if ((blenderobject->gameflag & OB_SOFT_BODY) && !(blenderobject->gameflag & OB_BOUNDS))
+	{
+		objprop.m_boundclass = KX_BOUNDMESH;
+	}
+
 	KX_BoxBounds bb;
 	my_get_local_bounds(blenderobject,objprop.m_boundobject.box.m_center,bb.m_extends);
 	if (blenderobject->gameflag & OB_BOUNDS)





More information about the Bf-blender-cvs mailing list