BGE patch: new Physics button and margin parameter in Logic panel. Change subversion.
authorBenoit Bolsee <benoit.bolsee@online.be>
Sun, 14 Sep 2008 19:34:06 +0000 (19:34 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Sun, 14 Sep 2008 19:34:06 +0000 (19:34 +0000)
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.

source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/intern/object.c
source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_object_types.h
source/blender/src/buttons_logic.c
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
source/gameengine/Physics/Bullet/CcdPhysicsController.h

index e403fc33e068289008df363de47ddaa714b67a43..0591937ea4cfa50e0b792f381877b7b6dea36b30 100644 (file)
@@ -41,7 +41,7 @@ struct ListBase;
 struct MemFile;
 
 #define BLENDER_VERSION                        247
-#define BLENDER_SUBVERSION             1
+#define BLENDER_SUBVERSION             2
 
 #define BLENDER_MINVERSION             245
 #define BLENDER_MINSUBVERSION  15
index 3ed169ff77daf04df2446cbab7ec84363d85e64a..e63d6047cc63d55afa005b089227a7ce2d5aefe1 100644 (file)
@@ -960,7 +960,8 @@ Object *add_only_object(int type, char *name)
        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;
index da85a264a0cdce80ccb366a039692c4b9c4a9be5..fc863ff2f5e2d83aebf3df7486b06f733a269e79 100644 (file)
@@ -7769,7 +7769,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        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 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
+       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! */
 
index d258cf77ef562cff54d3eeb30d389a1ed8a2729c..3708db3fd38fa57bf13c598340f86f792f346b03 100644 (file)
@@ -156,7 +156,9 @@ typedef struct Object {
 
        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 @@ extern Object workob;
 #define OB_PROP                        16384
 #define OB_MAINACTOR   32768
 
+#define OB_PHYSICS             65536
+
 /* ob->gameflag2 */
 #define OB_NEVER_DO_ACTIVITY_CULLING   1
 
index a87104c82de866fd0afd794fbd06538a2bfa299a..c2f2389a50f1051156508219d39cb65c208ad6fa 100644 (file)
@@ -2836,134 +2836,158 @@ void buttons_enji(uiBlock *block, Object *ob)
 
 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_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, "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");                       
-               }
-
-               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_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");
+
+                               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, 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");
+                               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) {   
-               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");
-
-                       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");
-
-                       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_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 detected by the Near and Radar sensor");
+               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");
+
+                               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");
+                       }
                }
-       }
-       uiBlockEndAlign(block);
+               uiBlockEndAlign(block);
 
-       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",
-                 //almost ready to enable this one:                    uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull Polytope%x5|Static TriangleMesh %x4|Dynamic Mesh %x5|",
-                         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");
+               uiBlockBeginAlign(block);
+               if ((ob->gameflag & (OB_ACTOR|OB_DYNAMIC)) == (OB_ACTOR|OB_DYNAMIC)) {
+                       if (ob->margin < 0.001f)
+                               ob->margin = 0.06f;
+                       uiDefButF(block, NUM, B_DIFF, "Margin", 10, 105, 105, 19, 
+                                       &ob->margin, 0.001, 1.0, 1, 0, 
+                                       "Collision margin");
+               } else {
+                       uiDefButF(block, NUM, B_DIFF, "Margin", 10, 105, 105, 19, 
+                                       &ob->margin, 0.0, 1.0, 1, 0, 
+                                       "Collision margin");
+               }
+               uiDefButBitI(block, TOG, OB_BOUNDS, B_REDR, "Bounds", 115, 105, 55, 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 Mesh%x4",
+                       //almost ready to enable this one:                      uiDefButS(block, MENU, REDRAWVIEW3D, "Boundary Display%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull Polytope%x5|Static TriangleMesh %x4|Dynamic Mesh %x5|",
+                               170, 105, 105, 19, &ob->boundtype, 0, 0, 0, 0, "Selects the collision type");
+                       uiDefButBitI(block, TOG, OB_CHILD, B_REDR, "Compound", 275,105,75,19, 
+                                       &ob->gameflag, 0, 0, 0, 0, 
+                                       "Add Children");
+               }
+               uiBlockEndAlign(block);
        }
-       uiBlockEndAlign(block);
 }
 
 static void check_object_state(void *arg1_but, void *arg2_mask)
@@ -3132,7 +3156,7 @@ void logic_buts(void)
        
        uiBlockSetCol(block, TH_AUTO);
        uiBlockBeginAlign(block);
-       uiDefBut(block, BUT, B_ADD_PROP, "Add Property",                10, 90, 340, 24,
+       uiDefBut(block, BUT, B_ADD_PROP, "Add Property",                10, 70, 340, 24,
                         NULL, 0.0, 100.0, 100, 0,
                         "");
        
@@ -3141,26 +3165,26 @@ void logic_buts(void)
        a= 0;
        prop= ob->prop.first;
        while(prop) {
-               but= uiDefBut(block, BUT, 1, "Del",             10, (short)(70-20*a), 40, 20, NULL, 0.0, 0.0, 1, (float)a, "");
+               but= uiDefBut(block, BUT, 1, "Del",             10, (short)(50-20*a), 40, 20, NULL, 0.0, 0.0, 1, (float)a, "");
                uiButSetFunc(but, del_property, prop, NULL);
-               uiDefButS(block, MENU, B_CHANGE_PROP, pupstr,           50, (short)(70-20*a), 60, 20, &prop->type, 0, 0, 0, 0, "");
-               but= uiDefBut(block, TEX, 1, "Name:",                                   110, (short)(70-20*a), 110, 20, prop->name, 0, 31, 0, 0, "");
+               uiDefButS(block, MENU, B_CHANGE_PROP, pupstr,           50, (short)(50-20*a), 60, 20, &prop->type, 0, 0, 0, 0, "");
+               but= uiDefBut(block, TEX, 1, "Name:",                                   110, (short)(50-20*a), 110, 20, prop->name, 0, 31, 0, 0, "");
                uiButSetFunc(but, make_unique_prop_names_cb, prop->name, (void*) 1);
                
                if(prop->type==PROP_BOOL) {
-                       uiDefButBitI(block, TOG, 1, B_REDR, "True",             220, (short)(70-20*a), 55, 20, &prop->data, 0, 0, 0, 0, "");
-                       uiDefButBitI(block, TOGN, 1, B_REDR, "False",   270, (short)(70-20*a), 55, 20, &prop->data, 0, 0, 0, 0, "");
+                       uiDefButBitI(block, TOG, 1, B_REDR, "True",             220, (short)(50-20*a), 55, 20, &prop->data, 0, 0, 0, 0, "");
+                       uiDefButBitI(block, TOGN, 1, B_REDR, "False",   270, (short)(50-20*a), 55, 20, &prop->data, 0, 0, 0, 0, "");
                }
                else if(prop->type==PROP_INT) 
-                       uiDefButI(block, NUM, B_REDR, "",                       220, (short)(70-20*a), 110, 20, &prop->data, -10000, 10000, 0, 0, "");
+                       uiDefButI(block, NUM, B_REDR, "",                       220, (short)(50-20*a), 110, 20, &prop->data, -10000, 10000, 0, 0, "");
                else if(prop->type==PROP_FLOAT) 
-                       uiDefButF(block, NUM, B_REDR, "",                       220, (short)(70-20*a), 110, 20, (float*) &prop->data, -10000, 10000, 100, 3, "");
+                       uiDefButF(block, NUM, B_REDR, "",                       220, (short)(50-20*a), 110, 20, (float*) &prop->data, -10000, 10000, 100, 3, "");
                else if(prop->type==PROP_STRING) 
-                       uiDefBut(block, TEX, B_REDR, "",                                220, (short)(70-20*a), 110, 20, prop->poin, 0, 127, 0, 0, "");
+                       uiDefBut(block, TEX, B_REDR, "",                                220, (short)(50-20*a), 110, 20, prop->poin, 0, 127, 0, 0, "");
                else if(prop->type==PROP_TIME) 
-                       uiDefButF(block, NUM, B_REDR, "",                       220, (short)(70-20*a), 110, 20, (float*) &prop->data, -10000, 10000, 100, 3, "");
+                       uiDefButF(block, NUM, B_REDR, "",                       220, (short)(50-20*a), 110, 20, (float*) &prop->data, -10000, 10000, 100, 3, "");
                
-               uiDefButBitS(block, TOG, PROP_DEBUG, B_REDR, "D",               330, (short)(70-20*a), 20, 20, &prop->flag, 0, 0, 0, 0, "Print Debug info");
+               uiDefButBitS(block, TOG, PROP_DEBUG, B_REDR, "D",               330, (short)(50-20*a), 20, 20, &prop->flag, 0, 0, 0, 0, "Print Debug info");
                
                a++;
                prop= prop->next;
index 19fb9d01cbf8ae1dd99256a021b56f8e06db4108..8bdec219354df7a15b2fe343fd6649c6f1f2c2ff 100644 (file)
@@ -1279,6 +1279,10 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
        //int userigidbody = SYS_GetCommandLineInt(syshandle,"norigidbody",0);
        //bool bRigidBody = (userigidbody == 0);
 
+       // object has physics representation?
+       if (!(blenderobject->gameflag & OB_PHYSICS))
+               return;
+
        // get Root Parent of blenderobject
        struct Object* parent= blenderobject->parent;
        while(parent && parent->parent) {
@@ -1310,6 +1314,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
 
        objprop.m_isCompoundChild = isCompoundChild;
        objprop.m_hasCompoundChildren = (blenderobject->gameflag & OB_CHILD) != 0;
+       objprop.m_margin = blenderobject->margin;
 
        if ((objprop.m_isactor = (blenderobject->gameflag & OB_ACTOR)!=0))
        {
index 6653026f28a1b4e4b903a19a9c4610abb1d5f5a2..248d2f49b0b5ff8a01eaa2db03b115cadc929a75 100644 (file)
@@ -86,6 +86,7 @@ struct KX_ObjectProperties
        bool    m_disableSleeping;
        bool    m_hasCompoundChildren;
        bool    m_isCompoundChild;
+       double  m_margin;
        KX_BoundBoxClass        m_boundclass;
        union {
                KX_BoxBounds    box;
index 6507bf501e4b097cbf77535d6dd2e1995e98a278..b3f24d972818040e925d4e85e799089246bc4093 100644 (file)
@@ -699,6 +699,7 @@ void        KX_ConvertBulletObject( class   KX_GameObject* gameobj,
        ci.m_gravity = btVector3(0,0,0);
        ci.m_localInertiaTensor =btVector3(0,0,0);
        ci.m_mass = objprop->m_dyna ? shapeprops->m_mass : 0.f;
+       ci.m_margin = objprop->m_margin;
        shapeInfo->m_radius = objprop->m_radius;
        isbulletdyna = objprop->m_dyna;
        
@@ -786,7 +787,7 @@ void        KX_ConvertBulletObject( class   KX_GameObject* gameobj,
                return;
        }
 
-       bm->setMargin(0.06);
+       bm->setMargin(ci.m_margin);
 
 
                if (objprop->m_isCompoundChild)
index 4da9143fc3d8177c9335657f8d5368605dc656e3..8ba138df4373ce11460e131a2c2bf900d5eff29e 100644 (file)
@@ -277,7 +277,9 @@ void                CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta
                if (m_collisionShape)
                {
                        // new shape has no scaling, apply initial scaling
+                       m_collisionShape->setMargin(m_cci.m_margin);
                        m_collisionShape->setLocalScaling(m_cci.m_scaling);
+                       
                        if (m_cci.m_mass)
                                m_collisionShape->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor);
                }
index a685c4669441c3314cb665c59bc79a07bcdf1bf1..7d55851ebf66f4bff630c38f4358d25c86a2b6b3 100644 (file)
@@ -145,6 +145,7 @@ struct CcdConstructionInfo
                m_friction(0.5f),
                m_linearDamping(0.1f),
                m_angularDamping(0.1f),
+               m_margin(0.06f),
                m_collisionFlags(0),
                m_bRigid(false),
                m_collisionFilterGroup(DefaultFilter),
@@ -165,6 +166,7 @@ struct CcdConstructionInfo
        btScalar        m_friction;
        btScalar        m_linearDamping;
        btScalar        m_angularDamping;
+       btScalar        m_margin;
        int                     m_collisionFlags;
        bool            m_bRigid;