[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16527] trunk/blender/source: BGE patch: new Physics button and margin parameter in Logic panel.

Benoit Bolsee benoit.bolsee at online.be
Sun Sep 14 21:34:06 CEST 2008


Revision: 16527
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16527
Author:   ben2610
Date:     2008-09-14 21:34:06 +0200 (Sun, 14 Sep 2008)

Log Message:
-----------
BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.

The Physics button controls the creation of a physics representation 
of the object when starting the game. If the button is not selected,
the object is a pure graphical object with no physics representation
and all the other physics buttons are hidden.
Selecting this button gives access to the usual physics buttons.
The physics button is enabled by default to match previous Blender
behavior.

The margin parameter allows to control the collision margin from
the UI. Previously, this parameter was only accessible through 
Python. By default, the collision margin is set to 0.0 on static 
objects and 0.06 on dynamic objects. 
To maintain compatibility with older games, the collision margin
is set to 0.06 on all objects when loading older blend file.

Note about the collision algorithms in Bullet 2.71
--------------------------------------------------
Bullet 2.71 handles the collision margin differently than Bullet 2.53
(the previous Bullet version in Blender). The collision margin is 
now kept "inside" the object for box, sphere and cylinder bound 
shapes. This means that two objects bound to any of these shape will
come in close contact when colliding. 
The static mesh, convex hull and cone shapes still have their
collision margin "outside" the object, which leaves a space of 1
or 2 times the collision margin between objects. 

The situation with Bullet 2.53 was more complicated, generally
leading to more space between objects, except for box-box collisions. 

This means that running a old game under Bullet 2.71 may cause
visual problems, especially if the objects are small. You can fix
these problems by changing some visual aspect of the objects: 
center, shape, size, position of children, etc.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_blender.h
    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/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/Physics/Bullet/CcdPhysicsController.cpp
    trunk/blender/source/gameengine/Physics/Bullet/CcdPhysicsController.h

Modified: trunk/blender/source/blender/blenkernel/BKE_blender.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_blender.h	2008-09-14 19:07:57 UTC (rev 16526)
+++ trunk/blender/source/blender/blenkernel/BKE_blender.h	2008-09-14 19:34:06 UTC (rev 16527)
@@ -41,7 +41,7 @@
 struct MemFile;
 
 #define BLENDER_VERSION			247
-#define BLENDER_SUBVERSION		1
+#define BLENDER_SUBVERSION		2
 
 #define BLENDER_MINVERSION		245
 #define BLENDER_MINSUBVERSION	15

Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c	2008-09-14 19:07:57 UTC (rev 16526)
+++ trunk/blender/source/blender/blenkernel/intern/object.c	2008-09-14 19:34:06 UTC (rev 16527)
@@ -960,7 +960,8 @@
 	ob->anisotropicFriction[0] = 1.0f;
 	ob->anisotropicFriction[1] = 1.0f;
 	ob->anisotropicFriction[2] = 1.0f;
-	ob->gameflag= OB_PROP;
+	ob->gameflag= OB_PROP|OB_PHYSICS;
+	ob->margin = 0.0;
 
 	/* NT fluid sim defaults */
 	ob->fluidsimFlag = 0;

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2008-09-14 19:07:57 UTC (rev 16526)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2008-09-14 19:34:06 UTC (rev 16527)
@@ -7769,7 +7769,7 @@
 			alphasort_version_246(fd, lib, me);
 	}
 	
-	if(main->versionfile <= 246 && main->subversionfile < 1){
+	if(main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)){
 		Object *ob;
 		for(ob = main->object.first; ob; ob= ob->id.next) {
 			if(ob->pd && (ob->pd->forcefield == PFIELD_WIND))
@@ -7777,6 +7777,14 @@
 		}
 	}
 
+	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->margin = 0.06;
+		}
+	}
+
 	/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
 	/* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
 

Modified: trunk/blender/source/blender/makesdna/DNA_object_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_object_types.h	2008-09-14 19:07:57 UTC (rev 16526)
+++ trunk/blender/source/blender/makesdna/DNA_object_types.h	2008-09-14 19:34:06 UTC (rev 16527)
@@ -156,7 +156,9 @@
 
 	float formfactor;
 	float rdamping, sizefac;
-	
+	float margin, pad3;
+
+
 	char dt, dtx;
 	char totcol;	/* copy of mesh or curve or meta */
 	char actcol;	/* currently selected material in the user interface */
@@ -427,6 +429,8 @@
 #define OB_PROP			16384
 #define OB_MAINACTOR	32768
 
+#define OB_PHYSICS		65536
+
 /* ob->gameflag2 */
 #define OB_NEVER_DO_ACTIVITY_CULLING	1
 

Modified: trunk/blender/source/blender/src/buttons_logic.c
===================================================================
--- trunk/blender/source/blender/src/buttons_logic.c	2008-09-14 19:07:57 UTC (rev 16526)
+++ trunk/blender/source/blender/src/buttons_logic.c	2008-09-14 19:34:06 UTC (rev 16527)
@@ -2836,134 +2836,158 @@
 
 void buttons_ketsji(uiBlock *block, Object *ob)
 {
-	uiDefButBitI(block, TOG, OB_ACTOR, B_REDR, "Actor",
-			  10,205,55,19, &ob->gameflag, 0, 0, 0, 0,
-			  "Objects that are evaluated by the engine ");
-	if(ob->gameflag & OB_ACTOR) {	
-		uiDefButBitI(block, TOG, OB_GHOST, B_REDR, "Ghost", 65,205,55,19, 
-				  &ob->gameflag, 0, 0, 0, 0, 
-				  "Objects that don't restitute collisions (like a ghost)");
-		uiDefButBitI(block, TOG, OB_DYNAMIC, B_REDR, "Dynamic", 120,205,70,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", 190,205,80,19, 
-					  &ob->gameflag, 0, 0, 0, 0, 
-					  "Enable rolling physics");
-			uiDefButBitI(block, TOG, OB_COLLISION_RESPONSE, B_REDR, "No sleeping", 270,205,80,19, 
-					  &ob->gameflag, 0, 0, 0, 0, 
-					  "Disable auto (de)activation");
+	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,
+				"Objects that are evaluated by the engine ");
+		if(ob->gameflag & OB_ACTOR) {	
+			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)");
+			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");
 
-			uiDefButBitI(block, TOG, OB_DO_FH, B_DIFF, "Do Fh", 10,185,50,19, 
-					  &ob->gameflag, 0, 0, 0, 0, 
-					  "Use Fh settings in Materials");
-			uiDefButBitI(block, TOG, OB_ROT_FH, B_DIFF, "Rot Fh", 60,185,50,19, 
-					  &ob->gameflag, 0, 0, 0, 0, 
-					  "Use face normal to rotate Object");
-			uiDefButF(block, NUM, B_DIFF, "Mass:", 110, 185, 80, 19, 
-					  &ob->mass, 0.01, 10000.0, 10, 0, 
-					  "The mass of the Object");
-			uiDefButF(block, NUM, REDRAWVIEW3D, "Radius:", 190, 185, 80, 19, 
-					  &ob->inertia, 0.01, 10.0, 10, 0, 
-					  "Bounding sphere radius");
-			uiDefButF(block, NUM, B_DIFF, "Form:", 270, 185, 80, 19, 
-					  &ob->formfactor, 0.01, 100.0, 10, 0, 
-					  "Form factor");
+				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");
+				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, NUM, B_DIFF, "Damp:", 10, 165, 100, 19, 
-					  &ob->damping, 0.0, 1.0, 10, 0, 
-					  "General movement damping");
-			uiDefButF(block, NUM, B_DIFF, "RotDamp:", 110, 165, 120, 19, 
-					  &ob->rdamping, 0.0, 1.0, 10, 0, 
-					  "General rotation damping");
-			uiDefButBitI(block, TOG, OB_ANISOTROPIC_FRICTION, B_REDR, "Anisotropic", 
-					  230, 165, 120, 19,
-					  &ob->gameflag, 0.0, 1.0, 10, 0,
-					  "Enable anisotropic friction");			
-		}
+				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");
 
-		if (ob->gameflag & OB_ANISOTROPIC_FRICTION) {
-			uiDefButF(block, NUM, B_DIFF, "x friction:", 10, 145, 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, 145, 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, 145, 113, 19,
-					  &ob->anisotropicFriction[2], 0.0, 1.0, 10, 0,
-					  "Relative friction coefficient in the z-direction.");
+				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");
+				uiDefButF(block, NUM, B_DIFF, "Form:", 110, 145, 120, 19, 
+						&ob->formfactor, 0.01, 100.0, 10, 0, 
+						"Form factor");
+
+				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.");
+			}
 		}
-	}
 
-	if (!(ob->gameflag & OB_GHOST)) {
-		uiBlockBeginAlign(block);
-		uiDefButBitI(block, TOG, OB_BOUNDS, B_REDR, "Bounds", 10, 125, 75, 19,
-				&ob->gameflag, 0, 0,0, 0,
-				"Specify a bounds object for physics");
-		if (ob->gameflag & OB_BOUNDS) {
-			uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull Polytope%x5|Static TriangleMesh %x4",
-				85, 125, 160, 19, &ob->boundtype, 0, 0, 0, 0, "Selects the collision type");
-			uiDefButBitI(block, TOG, OB_CHILD, B_REDR, "Compound", 250,125,100,19, 
-					  &ob->gameflag, 0, 0, 0, 0, 
-					  "Add Children");
+		if (!(ob->gameflag & OB_GHOST)) {
+			uiBlockBeginAlign(block);
+			uiDefButBitI(block, TOG, OB_BOUNDS, B_REDR, "Bounds", 10, 105, 75, 19,
+					&ob->gameflag, 0, 0,0, 0,
+					"Specify a bounds object for physics");
+			if (ob->gameflag & OB_BOUNDS) {
+				uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull%x5|Static 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, 
+						&ob->gameflag, 0, 0, 0, 0, 
+						"Add Children");
+			}
+			uiBlockEndAlign(block);
 		}
-		uiBlockEndAlign(block);
 	}
 }
 
 void buttons_bullet(uiBlock *block, Object *ob)
 {
-	uiBlockBeginAlign(block);
-	uiDefButBitI(block, TOG, OB_ACTOR, B_REDR, "Actor",
-			  10,205,55,19, &ob->gameflag, 0, 0, 0, 0,
-			  "Objects that are evaluated by the engine ");
-	if(ob->gameflag & OB_ACTOR) {	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list