BGE patch: bullet buttons UI change after discussion with Erwin: use a drop down...
authorBenoit Bolsee <benoit.bolsee@online.be>
Tue, 16 Sep 2008 22:52:42 +0000 (22:52 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Tue, 16 Sep 2008 22:52:42 +0000 (22:52 +0000)
source/blender/blenkernel/intern/object.c
source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_object_types.h
source/blender/python/api2_2x/Object.c
source/blender/src/buttons_logic.c
source/gameengine/Converter/BL_BlenderDataConversion.cpp

index e63d6047cc63d55afa005b089227a7ce2d5aefe1..6cbcba65f5631d3a72095eeed45ef6227b8306d6 100644 (file)
@@ -960,7 +960,7 @@ 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_PHYSICS;
+       ob->gameflag= OB_PROP|OB_COLLISION;
        ob->margin = 0.0;
 
        /* NT fluid sim defaults */
index 6add88284c2d7cac8e3807335477144286945cb2..f3f1a99cdbff5dae200b7c77073557200dc8d9ae 100644 (file)
@@ -7794,7 +7794,7 @@ 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->gameflag |= OB_COLLISION;
                        ob->margin = 0.06;
                }
        }
index 3708db3fd38fa57bf13c598340f86f792f346b03..66bdaf2c98b8222953fa7c8ab50a28fb53a7ab9d 100644 (file)
@@ -212,7 +212,8 @@ typedef struct Object {
 
        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 @@ extern Object workob;
 #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
index 45d6bfa3c01073645a7a88a5d3dddf13cc85022e..0d5af06377c112c08483fa7021912aad0fb508e0 100644 (file)
@@ -3519,8 +3519,8 @@ static int Object_setRBMass( BPy_Object * self, PyObject * args )
 
 /* 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 @@ static PyObject *M_Object_RBFlagsDict( void )
 
        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 @@ static PyObject *M_Object_RBFlagsDict( void )
                                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 ) );
index 5a689050ff01728824ee7c6b62e7e3563d9f89ed..e16443460a118aae92041b851965f9c704a04d5c 100644 (file)
@@ -2849,10 +2849,10 @@ void buttons_enji(uiBlock *block, Object *ob)
 
 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 @@ void buttons_ketsji(uiBlock *block, Object *ob)
        }
 }
 
+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,
-                               "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");
+       uiBut *but;
 
-                               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");
+       /* 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;
 
-                               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");
-                       }
+       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");
+               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, 
+                                       "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, 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 @@ void buttons_bullet(uiBlock *block, Object *ob)
                                        &ob->gameflag, 0, 0, 0, 0, 
                                        "Add Children");
                }
-               uiBlockEndAlign(block);
        }
+       uiBlockEndAlign(block);
 }
 
 static void check_controller_state_mask(void *arg1_but, void *arg2_mask)
index 8bdec219354df7a15b2fe343fd6649c6f1f2c2ff..c3992d02eee9d6414bc9f6b6060d442d200f35b3 100644 (file)
@@ -1280,7 +1280,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
        //bool bRigidBody = (userigidbody == 0);
 
        // object has physics representation?
-       if (!(blenderobject->gameflag & OB_PHYSICS))
+       if (!(blenderobject->gameflag & OB_COLLISION))
                return;
 
        // get Root Parent of blenderobject