[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16565] trunk/blender/source: BGE patch: bullet buttons UI change after discussion with Erwin: use a drop down instead of a series of buttons.

Benoit Bolsee benoit.bolsee at online.be
Wed Sep 17 00:52:42 CEST 2008


Revision: 16565
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16565
Author:   ben2610
Date:     2008-09-17 00:52:42 +0200 (Wed, 17 Sep 2008)

Log Message:
-----------
BGE patch: bullet buttons UI change after discussion with Erwin: use a drop down instead of a series of buttons. Introduction of soft body option.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/object.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/makesdna/DNA_object_types.h
    trunk/blender/source/blender/python/api2_2x/Object.c
    trunk/blender/source/blender/src/buttons_logic.c
    trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c	2008-09-16 21:23:56 UTC (rev 16564)
+++ trunk/blender/source/blender/blenkernel/intern/object.c	2008-09-16 22:52:42 UTC (rev 16565)
@@ -960,7 +960,7 @@
 	ob->anisotropicFriction[0] = 1.0f;
 	ob->anisotropicFriction[1] = 1.0f;
 	ob->anisotropicFriction[2] = 1.0f;
-	ob->gameflag= OB_PROP|OB_PHYSICS;
+	ob->gameflag= OB_PROP|OB_COLLISION;
 	ob->margin = 0.0;
 
 	/* NT fluid sim defaults */

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2008-09-16 21:23:56 UTC (rev 16564)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2008-09-16 22:52:42 UTC (rev 16565)
@@ -7794,7 +7794,7 @@
 	if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 2)){
 		Object *ob;
 		for(ob = main->object.first; ob; ob= ob->id.next) {
-			ob->gameflag |= OB_PHYSICS;
+			ob->gameflag |= OB_COLLISION;
 			ob->margin = 0.06;
 		}
 	}

Modified: trunk/blender/source/blender/makesdna/DNA_object_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_object_types.h	2008-09-16 21:23:56 UTC (rev 16564)
+++ trunk/blender/source/blender/makesdna/DNA_object_types.h	2008-09-16 22:52:42 UTC (rev 16565)
@@ -212,7 +212,8 @@
 
 	short shapenr, shapeflag;	/* current shape key for menu or pinned, flag for pinning */
 	float smoothresh;			/* smoothresh is phong interpolation ray_shadow correction in render */
-	short recalco, pad4;		/* recalco for temp storage of ob->recalc, bad design warning */
+	short recalco;				/* recalco for temp storage of ob->recalc, bad design warning */
+	short body_type;			/* for now used to temporarily holds the type of collision object */
 	
 	struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */
 
@@ -429,13 +430,21 @@
 #define OB_PROP			16384
 #define OB_MAINACTOR	32768
 
-#define OB_PHYSICS		65536
+#define OB_COLLISION	65536
+#define OB_SOFT_BODY	0x20000
 
 /* ob->gameflag2 */
 #define OB_NEVER_DO_ACTIVITY_CULLING	1
 
 #define OB_LIFE			(OB_PROP|OB_DYNAMIC|OB_ACTOR|OB_MAINACTOR|OB_CHILD)
 
+/* ob->body_type */
+#define OB_BODY_TYPE_NO_COLLISION	0
+#define OB_BODY_TYPE_STATIC			1
+#define OB_BODY_TYPE_DYNAMIC		2
+#define OB_BODY_TYPE_RIGID			3
+#define OB_BODY_TYPE_SOFT			4
+
 /* ob->scavisflag */
 #define OB_VIS_SENS		1
 #define OB_VIS_CONT		2

Modified: trunk/blender/source/blender/python/api2_2x/Object.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Object.c	2008-09-16 21:23:56 UTC (rev 16564)
+++ trunk/blender/source/blender/python/api2_2x/Object.c	2008-09-16 22:52:42 UTC (rev 16565)
@@ -3519,8 +3519,8 @@
 
 /* this is too low level, possible to add helper methods */
 
-#define GAMEFLAG_MASK ( OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \
-		OB_ROT_FH | OB_ANISOTROPIC_FRICTION | OB_GHOST | OB_RIGID_BODY | \
+#define GAMEFLAG_MASK ( OB_COLLISION | OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \
+		OB_ROT_FH | OB_ANISOTROPIC_FRICTION | OB_GHOST | OB_RIGID_BODY | OB_SOFT_BODY | \
 		OB_BOUNDS | OB_COLLISION_RESPONSE | OB_SECTOR | OB_PROP | \
 		OB_MAINACTOR )
 
@@ -5497,6 +5497,7 @@
 
 	if( M ) {
 		BPy_constant *d = ( BPy_constant * ) M;
+		PyConstant_Insert( d, "COLLISION", PyInt_FromLong( OB_COLLISION ) );
 		PyConstant_Insert( d, "DYNAMIC", PyInt_FromLong( OB_DYNAMIC ) );
 		PyConstant_Insert( d, "CHILD", PyInt_FromLong( OB_CHILD ) );
 		PyConstant_Insert( d, "ACTOR", PyInt_FromLong( OB_ACTOR ) );
@@ -5506,6 +5507,7 @@
 				PyInt_FromLong( OB_ANISOTROPIC_FRICTION ) );
 		PyConstant_Insert( d, "GHOST", PyInt_FromLong( OB_GHOST ) );
 		PyConstant_Insert( d, "RIGIDBODY", PyInt_FromLong( OB_RIGID_BODY ) );
+		PyConstant_Insert( d, "SOFTBODY", PyInt_FromLong( OB_SOFT_BODY ) );
 		PyConstant_Insert( d, "BOUNDS", PyInt_FromLong( OB_BOUNDS ) );
 		PyConstant_Insert( d, "COLLISION_RESPONSE",
 				PyInt_FromLong( OB_COLLISION_RESPONSE ) );

Modified: trunk/blender/source/blender/src/buttons_logic.c
===================================================================
--- trunk/blender/source/blender/src/buttons_logic.c	2008-09-16 21:23:56 UTC (rev 16564)
+++ trunk/blender/source/blender/src/buttons_logic.c	2008-09-16 22:52:42 UTC (rev 16565)
@@ -2849,10 +2849,10 @@
 
 void buttons_ketsji(uiBlock *block, Object *ob)
 {
-	uiDefButBitI(block, TOG, OB_PHYSICS, B_REDR, "Physics",
+	uiDefButBitI(block, TOG, OB_COLLISION, B_REDR, "Physics",
 			  10,205,70,19, &ob->gameflag, 0, 0, 0, 0,
 			  "Objects that have a physics representation");
-	if (ob->gameflag & OB_PHYSICS) {
+	if (ob->gameflag & OB_COLLISION) {
 		uiBlockBeginAlign(block);
 		uiDefButBitI(block, TOG, OB_ACTOR, B_REDR, "Actor",
 				80,205,55,19, &ob->gameflag, 0, 0, 0, 0,
@@ -2933,46 +2933,90 @@
 	}
 }
 
+static void check_actor(void *arg1_but, void *arg2_object)
+{
+	int *gameflag = arg2_object;
+	/* force enabled ACTOR for body >= dynamic */
+	if (*gameflag & OB_DYNAMIC)
+		*gameflag |= OB_ACTOR;
+}
+
+static void check_body_type(void *arg1_but, void *arg2_object)
+{
+	Object *ob = arg2_object;
+
+	switch (ob->body_type) {
+	case OB_BODY_TYPE_NO_COLLISION:
+		ob->gameflag &= ~OB_COLLISION;
+		break;
+	case OB_BODY_TYPE_STATIC:
+		ob->gameflag |= OB_COLLISION;
+		ob->gameflag &= ~(OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY);
+		break;
+	case OB_BODY_TYPE_DYNAMIC:
+		ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_ACTOR;
+		ob->gameflag &= ~(OB_RIGID_BODY|OB_SOFT_BODY);
+		break;
+	case OB_BODY_TYPE_RIGID:
+		ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_RIGID_BODY|OB_ACTOR;
+		ob->gameflag &= ~(OB_SOFT_BODY);
+		break;
+	default:
+	case OB_BODY_TYPE_SOFT:
+		ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_SOFT_BODY|OB_ACTOR;
+		ob->gameflag &= ~(OB_RIGID_BODY);
+		break;
+	}
+}
+
 void buttons_bullet(uiBlock *block, Object *ob)
 {
-	uiDefButBitI(block, TOG, OB_PHYSICS, B_REDR, "Physics",
-			  10,205,70,19, &ob->gameflag, 0, 0, 0, 0,
-			  "Objects that have a physics representation");
-	if (ob->gameflag & OB_PHYSICS) {
-		uiBlockBeginAlign(block);
-		uiDefButBitI(block, TOG, OB_ACTOR, B_REDR, "Actor",
-				80,205,55,19, &ob->gameflag, 0, 0, 0, 0,
+	uiBut *but;
+
+	/* determine the body_type setting based on flags */
+	if (!(ob->gameflag & OB_COLLISION))
+		ob->body_type = OB_BODY_TYPE_NO_COLLISION;
+	else if (!(ob->gameflag & OB_DYNAMIC) || !(ob->gameflag & OB_DYNAMIC))
+		ob->body_type = OB_BODY_TYPE_STATIC;
+	else if (!(ob->gameflag & (OB_RIGID_BODY|OB_SOFT_BODY)))
+		ob->body_type = OB_BODY_TYPE_DYNAMIC;
+	else if (ob->gameflag & OB_RIGID_BODY)
+		ob->body_type = OB_BODY_TYPE_RIGID;
+	else
+		ob->body_type = OB_BODY_TYPE_SOFT;
+
+	uiBlockBeginAlign(block);
+	but = uiDefButS(block, MENU, REDRAWVIEW3D, 
+			"Object type%t|No collision%x0|Static%x1|Dynamic%x2|Rigid body%x3|Soft body%x4", 
+			10, 205, 150, 19, &ob->body_type, 0, 0, 0, 0, "Selects the type of physical representation of the object");
+	uiButSetFunc(but, check_body_type, but, ob);
+
+	if (ob->gameflag & OB_COLLISION) {
+		but = uiDefButBitI(block, TOG, OB_ACTOR, B_REDR, "Actor",
+				160,205,55,19, &ob->gameflag, 0, 0, 0, 0,
 				"Objects that are detected by the Near and Radar sensor");
-		if(ob->gameflag & OB_ACTOR) {	
-			uiDefButBitI(block, TOG, OB_GHOST, B_REDR, "Ghost", 135,205,55,19, 
+		uiButSetFunc(but, check_actor, but, &ob->gameflag);
+		
+		uiDefButBitI(block, TOG, OB_GHOST, B_REDR, "Ghost", 215,205,55,19, 
+				&ob->gameflag, 0, 0, 0, 0, 
+				"Objects that don't restitute collisions (like a ghost)");
+		if(ob->gameflag & OB_DYNAMIC) {
+			uiDefButBitI(block, TOG, OB_COLLISION_RESPONSE, B_REDR, "No sleeping", 270,205,80,19, 
 					&ob->gameflag, 0, 0, 0, 0, 
-					"Objects that don't restitute collisions (like a ghost)");
-			uiDefButBitI(block, TOG, OB_DYNAMIC, B_REDR, "Dynamic", 190,205,75,19, 
-					&ob->gameflag, 0, 0, 0, 0, 
-					"Motion defined by laws of physics");
-		
-			if(ob->gameflag & OB_DYNAMIC) {
-				uiDefButBitI(block, TOG, OB_RIGID_BODY, B_REDR, "Rigid Body", 265,205,85,19, 
-						&ob->gameflag, 0, 0, 0, 0, 
-						"Enable rolling physics");
+					"Disable auto (de)activation");
+			uiDefButF(block, NUM, B_DIFF, "Mass:", 10, 185, 170, 19, 
+					&ob->mass, 0.01, 10000.0, 10, 2, 
+					"The mass of the Object");
+			uiDefButF(block, NUM, REDRAWVIEW3D, "Radius:", 180, 185, 170, 19, 
+					&ob->inertia, 0.01, 10.0, 10, 2, 
+					"Bounding sphere radius, not used for other bounding shapes");
 
-				uiDefButF(block, NUM, B_DIFF, "Mass:", 10, 185, 130, 19, 
-						&ob->mass, 0.01, 10000.0, 10, 2, 
-						"The mass of the Object");
-				uiDefButF(block, NUM, REDRAWVIEW3D, "Radius:", 140, 185, 130, 19, 
-						&ob->inertia, 0.01, 10.0, 10, 2, 
-						"Bounding sphere radius, not used for other bounding shapes");
-				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");
-			}
+			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");
 		}
 		uiBlockEndAlign(block);
 
@@ -2999,8 +3043,8 @@
 					&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-16 21:23:56 UTC (rev 16564)
+++ trunk/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp	2008-09-16 22:52:42 UTC (rev 16565)
@@ -1280,7 +1280,7 @@
 	//bool bRigidBody = (userigidbody == 0);
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list