enable -noaudio option, so it actually works (and doesn't get overwritten by a game...
authorErwin Coumans <blender@erwincoumans.com>
Sun, 28 Sep 2008 03:07:13 +0000 (03:07 +0000)
committerErwin Coumans <blender@erwincoumans.com>
Sun, 28 Sep 2008 03:07:13 +0000 (03:07 +0000)
add -nojoystick commandline option: it takes 5 seconds everytime to start the game engine, while there IS no joystick.

In other words: blender -noaudio -nojoystick improves workflow turnaround times for P - ESC from 7 seconds to 1 second!

Improved Bullet soft body advanced options, still work-in-progress. Make sure to create game Bullet soft bodies from scratch, it is not compatible with last weeks builds.

13 files changed:
source/blender/blenkernel/intern/bullet.c
source/blender/makesdna/DNA_object_force.h
source/blender/src/buttons_logic.c
source/blender/src/space.c
source/creator/creator.c
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
source/gameengine/Ketsji/KX_Scene.cpp
source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
source/gameengine/Physics/Bullet/CcdPhysicsController.h
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp

index 8e07566981982b1e06d962050929b81f06576bae..eeec4d0bd4e8ce5570e93270d81c1041cd8931be 100644 (file)
@@ -45,10 +45,43 @@ BulletSoftBody *bsbNew(void)
        
        bsb= MEM_callocN(sizeof(BulletSoftBody), "bulletsoftbody");
                
-       bsb->flag = OB_BSB_SHAPE_MATCHING;
+       bsb->flag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT;
        bsb->linStiff = 0.5f;
        bsb->angStiff = 1.0f;
        bsb->volume = 1.0f;
+
+       
+       bsb->viterations        =       0;
+       bsb->piterations        =       2;      
+       bsb->diterations        =       0;
+       bsb->citerations        =       4;
+       
+       bsb->kSRHR_CL           =       0.1f;
+       bsb->kSKHR_CL           =       1.f;
+       bsb->kSSHR_CL           =       0.5f;
+       bsb->kSR_SPLT_CL        =       0.5f;
+       
+       bsb->kSK_SPLT_CL        =       0.5f;
+       bsb->kSS_SPLT_CL        =       0.5f;
+       bsb->kVCF                       =       1;
+       bsb->kDP                        =       0;
+
+       bsb->kDG                        =       0;
+       bsb->kLF                        =       0;
+       bsb->kPR                        =       0;
+       bsb->kVC                        =       0;
+
+       bsb->kDF                        =       0.2f;
+       bsb->kMT                        =       0.05;
+       bsb->kCHR                       =       1.0f;
+       bsb->kKHR                       =       0.1f;
+
+       bsb->kSHR                       =       1.0f;
+       bsb->kAHR                       =       0.7f;
+       bsb->collisionflags = 0;
+       //bsb->collisionflags = OB_BSB_COL_CL_RS + OB_BSB_COL_CL_SS;
+       bsb->numclusteriterations = 64;
+
        return bsb;
 }
 
index 081b83c3d02b85ae71cb59463d6dc1c154104abc..21c5242a703cafb9526aaafa2e80ca4df45fc468 100644 (file)
@@ -85,14 +85,56 @@ typedef struct SBVertex {
 } SBVertex;
 
 typedef struct BulletSoftBody {
-       int flag;               /* various boolean options */
-       float linStiff; /* linear stiffness 0..1 */
-       float angStiff; /* angular stiffness 0..1 */
-       float volume;   /* volume preservation 0..1 */
+       int flag;                               /* various boolean options */
+       float linStiff;                 /* linear stiffness 0..1 */
+       float   angStiff;               /* angular stiffness 0..1 */
+       float   volume;                 /* volume preservation 0..1 */
+
+       int     viterations;            /* Velocities solver iterations */
+       int     piterations;            /* Positions solver iterations */
+       int     diterations;            /* Drift solver iterations */
+       int     citerations;            /* Cluster solver iterations */
+
+       float   kSRHR_CL;               /* Soft vs rigid hardness [0,1] (cluster only) */
+       float   kSKHR_CL;               /* Soft vs kinetic hardness [0,1] (cluster only) */
+       float   kSSHR_CL;               /* Soft vs soft hardness [0,1] (cluster only) */
+       float   kSR_SPLT_CL;    /* Soft vs rigid impulse split [0,1] (cluster only) */
+
+       float   kSK_SPLT_CL;    /* Soft vs rigid impulse split [0,1] (cluster only) */
+       float   kSS_SPLT_CL;    /* Soft vs rigid impulse split [0,1] (cluster only) */
+       float   kVCF;                   /* Velocities correction factor (Baumgarte) */
+       float   kDP;                    /* Damping coefficient [0,1] */
+
+       float   kDG;                    /* Drag coefficient [0,+inf] */
+       float   kLF;                    /* Lift coefficient [0,+inf] */
+       float   kPR;                    /* Pressure coefficient [-inf,+inf] */
+       float   kVC;                    /* Volume conversation coefficient [0,+inf] */
+
+       float   kDF;                    /* Dynamic friction coefficient [0,1] */
+       float   kMT;                    /* Pose matching coefficient [0,1] */
+       float   kCHR;                   /* Rigid contacts hardness [0,1] */
+       float   kKHR;                   /* Kinetic contacts hardness [0,1] */
+
+       float   kSHR;                   /* Soft contacts hardness [0,1] */
+       float   kAHR;                   /* Anchors hardness [0,1] */
+       int             collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
+       int             numclusteriterations;   /* number of iterations to refine collision clusters*/
+
 } BulletSoftBody;
 
 /* BulletSoftBody.flag */
 #define OB_BSB_SHAPE_MATCHING  2
+#define OB_BSB_UNUSED 4
+#define OB_BSB_BENDING_CONSTRAINTS 8
+#define OB_BSB_AERO_VPOINT 16 /* aero model, Vertex normals are oriented toward velocity*/
+#define OB_BSB_AERO_VTWOSIDE 32 /* aero model, Vertex normals are flipped to match velocity */
+
+/* BulletSoftBody.collisionflags */
+#define OB_BSB_COL_SDF_RS      2 /* SDF based rigid vs soft */
+#define OB_BSB_COL_CL_RS       4 /* Cluster based rigid vs soft */
+#define OB_BSB_COL_CL_SS       8 /* Cluster based soft vs soft */
+#define OB_BSB_COL_VF_SS       16 /* Vertex/Face based soft vs soft */
+
 
 typedef struct SoftBody {
        struct ParticleSystem *particles;       /* particlesystem softbody */
index cec04910de512804b1a374521a1a2795d4c6cebd..dcb0f8742106d821b2e565dc0d338c9dc8756fd7 100644 (file)
@@ -2970,6 +2970,9 @@ static void check_body_type(void *arg1_but, void *arg2_object)
                ob->gameflag |= OB_BOUNDS;
                if (ob->boundtype<OB_BOUND_POLYH)
                        ob->boundtype=OB_BOUND_POLYH;
+               /* create a BulletSoftBody structure if not already existing */
+               if (!ob->bsoft)
+                       ob->bsoft = bsbNew();
                break;
        }
 }
@@ -2984,55 +2987,88 @@ static uiBlock *advanced_bullet_menu(void *arg_ob)
        /* use this for a fake extra empy space around the buttons */
        uiDefBut(block, LABEL, 0, "", -5, -10, 255, 140, NULL, 0, 0, 0, 0, "");
 
-       uiDefButBitI(block, TOG, OB_ACTOR, 0, "Sensor actor",
-                               xco, yco, 118, 19, &ob->gameflag, 0, 0, 0, 0,
-                               "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");
-       }
+               if (ob->gameflag & OB_SOFT_BODY) {
 
-       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, 
-                               "Collision margin");
-       } else {
-               uiDefButF(block, NUM, 0, "Margin", 
-                               xco, yco, 118, 19, &ob->margin, 0.0, 1.0, 1, 0, 
-                               "Collision margin");
-       }
-       if (ob->gameflag & OB_SOFT_BODY) {
-               /* create a BulletSoftBody structure if not already existing */
-               if (!ob->bsoft)
-                       ob->bsoft = bsbNew();
                if (ob->bsoft)
                {
+                       xco = 0;
+                       uiDefButF(block, NUMSLI, 0, "LinStiff ", xco, yco, 238, 19, 
+                               &ob->bsoft->linStiff, 0.0, 1.0, 1, 0,
+                               "Linear stiffness of the soft body vertex spring");
+                       yco -= 25;
+                       xco = 0;
+
                        uiDefButBitI(block, TOG, OB_BSB_SHAPE_MATCHING, 0, "Shape matching", 
-                                               xco+=120, yco, 118, 19, &ob->bsoft->flag, 0, 0, 0, 0, 
-                                               "Enable soft body shape matching goal");
+                               xco, yco, 118, 19, &ob->bsoft->flag, 0, 0, 0, 0, 
+                               "Enable soft body shape matching goal");
+                       
+                       uiDefButBitI(block, TOG, OB_BSB_BENDING_CONSTRAINTS, 0, "Bending Constraints", 
+                               xco+=120, yco, 118, 19, &ob->bsoft->flag, 0, 0, 0, 0, 
+                               "Enable bending constraints");
+
                        yco -= 25;
                        xco = 0;
-                       uiDefButF(block, NUMSLI, 0, "LinStiff ", xco, yco, 238, 19, 
-                                       &ob->bsoft->linStiff, 0.0, 1.0, 1, 0,
-                                       "Linear stiffness of the soft body vertex spring");
+                       uiDefButBitI(block, TOG, OB_BSB_COL_CL_RS, 0, "Cluster Col. RS", 
+                               xco, yco, 118, 19, &ob->bsoft->collisionflags, 0, 0, 0, 0, 
+                               "Enable cluster collision between soft and rigid body");
+                       uiDefButBitI(block, TOG, OB_BSB_COL_CL_SS, 0, "Cluster Col. SS", 
+                               xco+=120, yco, 118, 19, &ob->bsoft->collisionflags, 0, 0, 0, 0, 
+                               "Enable cluster collision between soft and soft body");
                        yco -= 25;
+
+                       xco = 0;
+/*
+                       uiDefButBitI(block, TOG, OB_BSB_AERO_VTWOSIDE, 0, "Aero model",
+                               xco, yco, 118, 19, &ob->bsoft->flag, 0, 0, 0, 0,
+                               "Enable aero model, vertex normals are flipped to match velocity");
+               
+                       yco -= 25;
+*/
+
+
+                       
+                       /*
                        uiDefButF(block, NUMSLI, 0, "AngStiff ", xco, yco, 238, 19, 
-                                       &ob->bsoft->angStiff, 0.0, 1.0, 1, 0, 
-                                       "Angular stiffness of the soft body vertex spring");
+                       &ob->bsoft->angStiff, 0.0, 1.0, 1, 0, 
+                       "Angular stiffness of the soft body vertex spring");
                        yco -= 25;
                        uiDefButF(block, NUMSLI, 0, "Volume ", xco, yco, 238, 19, 
-                                       &ob->bsoft->volume, 0.0, 1.0, 1, 0, 
-                                       "Factor of soft body volume preservation");
+                       &ob->bsoft->volume, 0.0, 1.0, 1, 0, 
+                       "Factor of soft body volume preservation");
+                       */
+
                }
 
-       }
+       } else
+       {
 
+               
+               xco = 0;
+
+               uiDefButBitI(block, TOG, OB_ACTOR, 0, "Sensor actor",
+                                       xco, yco, 118, 19, &ob->gameflag, 0, 0, 0, 0,
+                                       "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, 
+                                       "Collision margin");
+               } else {
+                       uiDefButF(block, NUM, 0, "Margin", 
+                                       xco, yco, 118, 19, &ob->margin, 0.0, 1.0, 1, 0, 
+                                       "Collision margin");
+               }
+       }
                        
        uiBlockSetDirection(block, UI_TOP);
 
index 13e6281de2a34945451a25cdf486476c29629555..bc5541f1bcfc0838f8a9b0119d6cadab8c4155d0 100644 (file)
@@ -388,7 +388,11 @@ void space_set_commmandline_options(void) {
        if ( (syshandle = SYS_GetSystem()) ) {
                /* User defined settings */
                a= (U.gameflags & USER_DISABLE_SOUND);
-               SYS_WriteCommandLineInt(syshandle, "noaudio", a);
+               /* if user already disabled audio at the command-line, don't re-enable it */
+               if (a)
+               {
+                       SYS_WriteCommandLineInt(syshandle, "noaudio", a);
+               }
 
                a= (U.gameflags & USER_DISABLE_MIPMAP);
                GPU_set_mipmap(!a);
index dffa755b2648bf5e4e78cc4862b272c8b948f6db..8d46d1b130b1ed5de61f3dba59c026a8065073ba 100644 (file)
@@ -219,6 +219,7 @@ static void print_help(void)
        printf ("\nMisc options:\n");
        printf ("  -d\t\tTurn debugging on\n");
        printf ("  -noaudio\tDisable audio on systems that support audio\n");
+       printf ("  -nojoystick\tDisable joystick support\n");
        printf ("  -h\t\tPrint this help text\n");
        printf ("  -y\t\tDisable automatic python script execution (scriptlinks, pydrivers, pyconstraints, pynodes)\n");
        printf ("  -P <filename>\tRun the given Python script (filename or Blender Text)\n");
@@ -493,6 +494,14 @@ int main(int argc, char **argv)
                                                audio = 0;
                                                if (G.f & G_DEBUG) printf("setting audio to: %d\n", audio);
                                        }
+                                       if (BLI_strcasecmp(argv[a], "-nojoystick") == 0) {
+                                               /**
+                                                       don't initialize joysticks if user doesn't want to use joysticks
+                                                       failed joystick initialization delays over 5 seconds, before game engine start
+                                               */
+                                               SYS_WriteCommandLineInt(syshandle,"nojoystick",1);
+                                               if (G.f & G_DEBUG) printf("disabling nojoystick\n");
+                                       }
                                        break;
                                }
                        }
index cc1412495610c7a7a7d891d6347bfaa613373245..0d58810e1561f3c9ce7191dc8c1b35b9d87a34b8 100644 (file)
@@ -170,6 +170,13 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
                NG_NetworkDeviceInterface* networkdevice = new
                        NG_LoopBackNetworkDeviceInterface();
                
+               //
+               SYS_SystemHandle hSystem = SYS_GetSystem();
+               bool noaudio = SYS_GetCommandLineInt(hSystem,"noaudio",0);
+
+               if (noaudio)/*(noaudio) intrr: disable game engine audio (openal) */
+                       SND_DeviceManager::SetDeviceType(snd_e_dummydevice);
+
                // get an audiodevice
                SND_DeviceManager::Subscribe();
                SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
index 784a103f3e3e290e3813312c234118ddd41dc30f..66eed4201eeef08a5c8b731525bccd21661011f6 100644 (file)
@@ -1323,20 +1323,86 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
        objprop.m_softbody = (blenderobject->gameflag & OB_SOFT_BODY) != 0;
        objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0;
        
-       ///for game soft bodies
-       if (blenderobject->bsoft)
+       if (objprop.m_softbody)
        {
-               objprop.m_linearStiffness = blenderobject->bsoft->linStiff;
-               objprop.m_angularStiffness = blenderobject->bsoft->angStiff;
-               objprop.m_volumePreservation = blenderobject->bsoft->volume;
-               objprop.m_gamesoftFlag = blenderobject->bsoft->flag;
+               ///for game soft bodies
+               if (blenderobject->bsoft)
+               {
+                       objprop.m_gamesoftFlag = blenderobject->bsoft->flag;
+                                       ///////////////////
+                       objprop.m_soft_linStiff = blenderobject->bsoft->linStiff;
+                       objprop.m_soft_angStiff = blenderobject->bsoft->angStiff;               /* angular stiffness 0..1 */
+                       objprop.m_soft_volume= blenderobject->bsoft->volume;                    /* volume preservation 0..1 */
+
+                       objprop.m_soft_viterations= blenderobject->bsoft->viterations;          /* Velocities solver iterations */
+                       objprop.m_soft_piterations= blenderobject->bsoft->piterations;          /* Positions solver iterations */
+                       objprop.m_soft_diterations= blenderobject->bsoft->diterations;          /* Drift solver iterations */
+                       objprop.m_soft_citerations= blenderobject->bsoft->citerations;          /* Cluster solver iterations */
+
+                       objprop.m_soft_kSRHR_CL= blenderobject->bsoft->kSRHR_CL;                /* Soft vs rigid hardness [0,1] (cluster only) */
+                       objprop.m_soft_kSKHR_CL= blenderobject->bsoft->kSKHR_CL;                /* Soft vs kinetic hardness [0,1] (cluster only) */
+                       objprop.m_soft_kSSHR_CL= blenderobject->bsoft->kSSHR_CL;                /* Soft vs soft hardness [0,1] (cluster only) */
+                       objprop.m_soft_kSR_SPLT_CL= blenderobject->bsoft->kSR_SPLT_CL;  /* Soft vs rigid impulse split [0,1] (cluster only) */
+
+                       objprop.m_soft_kSK_SPLT_CL= blenderobject->bsoft->kSK_SPLT_CL;  /* Soft vs rigid impulse split [0,1] (cluster only) */
+                       objprop.m_soft_kSS_SPLT_CL= blenderobject->bsoft->kSS_SPLT_CL;  /* Soft vs rigid impulse split [0,1] (cluster only) */
+                       objprop.m_soft_kVCF= blenderobject->bsoft->kVCF;                        /* Velocities correction factor (Baumgarte) */
+                       objprop.m_soft_kDP= blenderobject->bsoft->kDP;                  /* Damping coefficient [0,1] */
+
+                       objprop.m_soft_kDG= blenderobject->bsoft->kDG;                  /* Drag coefficient [0,+inf] */
+                       objprop.m_soft_kLF= blenderobject->bsoft->kLF;                  /* Lift coefficient [0,+inf] */
+                       objprop.m_soft_kPR= blenderobject->bsoft->kPR;                  /* Pressure coefficient [-inf,+inf] */
+                       objprop.m_soft_kVC= blenderobject->bsoft->kVC;                  /* Volume conversation coefficient [0,+inf] */
+
+                       objprop.m_soft_kDF= blenderobject->bsoft->kDF;                  /* Dynamic friction coefficient [0,1] */
+                       objprop.m_soft_kMT= blenderobject->bsoft->kMT;                  /* Pose matching coefficient [0,1] */
+                       objprop.m_soft_kCHR= blenderobject->bsoft->kCHR;                        /* Rigid contacts hardness [0,1] */
+                       objprop.m_soft_kKHR= blenderobject->bsoft->kKHR;                        /* Kinetic contacts hardness [0,1] */
+
+                       objprop.m_soft_kSHR= blenderobject->bsoft->kSHR;                        /* Soft contacts hardness [0,1] */
+                       objprop.m_soft_kAHR= blenderobject->bsoft->kAHR;                        /* Anchors hardness [0,1] */
+                       objprop.m_soft_collisionflags= blenderobject->bsoft->collisionflags;    /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
+                       objprop.m_soft_numclusteriterations= blenderobject->bsoft->numclusteriterations;        /* number of iterations to refine collision clusters*/
                
-       } else
-       {
-               objprop.m_linearStiffness = 0.5;//blenderobject->bsoft->linStiff;
-               objprop.m_angularStiffness = 1.f;//blenderobject->bsoft->angStiff;
-               objprop.m_volumePreservation = 1.f;//blenderobject->bsoft->volume;
-               objprop.m_gamesoftFlag = 1;//blenderobject->bsoft->flag;
+               } else
+               {
+                       objprop.m_gamesoftFlag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT;
+                       
+                       objprop.m_soft_linStiff = 0.5;;
+                       objprop.m_soft_angStiff = 1.f;          /* angular stiffness 0..1 */
+                       objprop.m_soft_volume= 1.f;                     /* volume preservation 0..1 */
+
+
+                       objprop.m_soft_viterations= 0;
+                       objprop.m_soft_piterations= 1;
+                       objprop.m_soft_diterations= 0;
+                       objprop.m_soft_citerations= 4;
+
+                       objprop.m_soft_kSRHR_CL= 0.1f;
+                       objprop.m_soft_kSKHR_CL= 1.f;
+                       objprop.m_soft_kSSHR_CL= 0.5;
+                       objprop.m_soft_kSR_SPLT_CL= 0.5f;
+
+                       objprop.m_soft_kSK_SPLT_CL= 0.5f;
+                       objprop.m_soft_kSS_SPLT_CL= 0.5f;
+                       objprop.m_soft_kVCF=  1;
+                       objprop.m_soft_kDP= 0;
+
+                       objprop.m_soft_kDG= 0;
+                       objprop.m_soft_kLF= 0;
+                       objprop.m_soft_kPR= 0;
+                       objprop.m_soft_kVC= 0;
+
+                       objprop.m_soft_kDF= 0.2f;
+                       objprop.m_soft_kMT= 0.f;
+                       objprop.m_soft_kCHR= 1.0f;
+                       objprop.m_soft_kKHR= 0.1f;
+
+                       objprop.m_soft_kSHR= 1.f;
+                       objprop.m_soft_kAHR= 0.7f;
+                       objprop.m_soft_collisionflags= OB_BSB_COL_SDF_RS + OB_BSB_COL_VF_SS;
+                       objprop.m_soft_numclusteriterations= 16;
+               }
        }
 
        objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0;
index 6325c9365fd0b9bc01ad8cc73fd2b78a98778f1d..53486cecf732342e270b65e657b70e1a59ec7d58 100644 (file)
@@ -88,10 +88,44 @@ struct KX_ObjectProperties
        bool    m_hasCompoundChildren;
        bool    m_isCompoundChild;
 
-       float   m_linearStiffness;
-       float m_angularStiffness;
-       float   m_volumePreservation;
+       /////////////////////////
+
        int             m_gamesoftFlag;
+       float   m_soft_linStiff;                        /* linear stiffness 0..1 */
+       float   m_soft_angStiff;                /* angular stiffness 0..1 */
+       float   m_soft_volume;                  /* volume preservation 0..1 */
+
+       int             m_soft_viterations;             /* Velocities solver iterations */
+       int             m_soft_piterations;             /* Positions solver iterations */
+       int             m_soft_diterations;             /* Drift solver iterations */
+       int             m_soft_citerations;             /* Cluster solver iterations */
+
+       float   m_soft_kSRHR_CL;                /* Soft vs rigid hardness [0,1] (cluster only) */
+       float   m_soft_kSKHR_CL;                /* Soft vs kinetic hardness [0,1] (cluster only) */
+       float   m_soft_kSSHR_CL;                /* Soft vs soft hardness [0,1] (cluster only) */
+       float   m_soft_kSR_SPLT_CL;     /* Soft vs rigid impulse split [0,1] (cluster only) */
+
+       float   m_soft_kSK_SPLT_CL;     /* Soft vs rigid impulse split [0,1] (cluster only) */
+       float   m_soft_kSS_SPLT_CL;     /* Soft vs rigid impulse split [0,1] (cluster only) */
+       float   m_soft_kVCF;                    /* Velocities correction factor (Baumgarte) */
+       float   m_soft_kDP;                     /* Damping coefficient [0,1] */
+
+       float   m_soft_kDG;                     /* Drag coefficient [0,+inf] */
+       float   m_soft_kLF;                     /* Lift coefficient [0,+inf] */
+       float   m_soft_kPR;                     /* Pressure coefficient [-inf,+inf] */
+       float   m_soft_kVC;                     /* Volume conversation coefficient [0,+inf] */
+
+       float   m_soft_kDF;                     /* Dynamic friction coefficient [0,1] */
+       float   m_soft_kMT;                     /* Pose matching coefficient [0,1] */
+       float   m_soft_kCHR;                    /* Rigid contacts hardness [0,1] */
+       float   m_soft_kKHR;                    /* Kinetic contacts hardness [0,1] */
+
+       float   m_soft_kSHR;                    /* Soft contacts hardness [0,1] */
+       float   m_soft_kAHR;                    /* Anchors hardness [0,1] */
+       int             m_soft_collisionflags;  /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
+       int             m_soft_numclusteriterations;    /* number of iterations to refine collision clusters*/
+
+       /////////////////////////
        
        double  m_margin;
        KX_BoundBoxClass        m_boundclass;
index c5dbabe24fc6d684bf1f31ddfaf7a2fe56e11115..e4c7e7f9317264ef55d86d782a844420d5b6d0b4 100644 (file)
@@ -1024,10 +1024,45 @@ void    KX_ConvertBulletObject( class   KX_GameObject* gameobj,
        ci.m_angularDamping = 1.f - shapeprops->m_ang_drag;
        //need a bit of damping, else system doesn't behave well
        ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behaviour
-       ci.m_linearStiffness = objprop->m_linearStiffness;
-       ci.m_angularStiffness= objprop->m_angularStiffness;
-       ci.m_volumePreservation= objprop->m_volumePreservation;
+       
+       
+       ///////////////////
        ci.m_gamesoftFlag = objprop->m_gamesoftFlag;
+       ci.m_soft_linStiff = objprop->m_soft_linStiff;
+       ci.m_soft_angStiff = objprop->m_soft_angStiff;          /* angular stiffness 0..1 */
+       ci.m_soft_volume= objprop->m_soft_volume;                       /* volume preservation 0..1 */
+
+       ci.m_soft_viterations= objprop->m_soft_viterations;             /* Velocities solver iterations */
+       ci.m_soft_piterations= objprop->m_soft_piterations;             /* Positions solver iterations */
+       ci.m_soft_diterations= objprop->m_soft_diterations;             /* Drift solver iterations */
+       ci.m_soft_citerations= objprop->m_soft_citerations;             /* Cluster solver iterations */
+
+       ci.m_soft_kSRHR_CL= objprop->m_soft_kSRHR_CL;           /* Soft vs rigid hardness [0,1] (cluster only) */
+       ci.m_soft_kSKHR_CL= objprop->m_soft_kSKHR_CL;           /* Soft vs kinetic hardness [0,1] (cluster only) */
+       ci.m_soft_kSSHR_CL= objprop->m_soft_kSSHR_CL;           /* Soft vs soft hardness [0,1] (cluster only) */
+       ci.m_soft_kSR_SPLT_CL= objprop->m_soft_kSR_SPLT_CL;     /* Soft vs rigid impulse split [0,1] (cluster only) */
+
+       ci.m_soft_kSK_SPLT_CL= objprop->m_soft_kSK_SPLT_CL;     /* Soft vs rigid impulse split [0,1] (cluster only) */
+       ci.m_soft_kSS_SPLT_CL= objprop->m_soft_kSS_SPLT_CL;     /* Soft vs rigid impulse split [0,1] (cluster only) */
+       ci.m_soft_kVCF= objprop->m_soft_kVCF;                   /* Velocities correction factor (Baumgarte) */
+       ci.m_soft_kDP= objprop->m_soft_kDP;                     /* Damping coefficient [0,1] */
+
+       ci.m_soft_kDG= objprop->m_soft_kDG;                     /* Drag coefficient [0,+inf] */
+       ci.m_soft_kLF= objprop->m_soft_kLF;                     /* Lift coefficient [0,+inf] */
+       ci.m_soft_kPR= objprop->m_soft_kPR;                     /* Pressure coefficient [-inf,+inf] */
+       ci.m_soft_kVC= objprop->m_soft_kVC;                     /* Volume conversation coefficient [0,+inf] */
+
+       ci.m_soft_kDF= objprop->m_soft_kDF;                     /* Dynamic friction coefficient [0,1] */
+       ci.m_soft_kMT= objprop->m_soft_kMT;                     /* Pose matching coefficient [0,1] */
+       ci.m_soft_kCHR= objprop->m_soft_kCHR;                   /* Rigid contacts hardness [0,1] */
+       ci.m_soft_kKHR= objprop->m_soft_kKHR;                   /* Kinetic contacts hardness [0,1] */
+
+       ci.m_soft_kSHR= objprop->m_soft_kSHR;                   /* Soft contacts hardness [0,1] */
+       ci.m_soft_kAHR= objprop->m_soft_kAHR;                   /* Anchors hardness [0,1] */
+       ci.m_soft_collisionflags= objprop->m_soft_collisionflags;       /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
+       ci.m_soft_numclusteriterations= objprop->m_soft_numclusteriterations;   /* number of iterations to refine collision clusters*/
+
+       ////////////////////
 
        ci.m_collisionFilterGroup = (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) : short(CcdConstructionInfo::StaticFilter);
        ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter);
index 6eeb732c1e32c9e8c31cbfa3eb149c50d5b69ef2..f5d6d7e8e0aeddc132af146e6799c737e95d62ad 100644 (file)
@@ -159,7 +159,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
 
        KX_NetworkEventManager* netmgr = new KX_NetworkEventManager(m_logicmgr, ndi);
        
-       SCA_JoystickManager *joymgr     = new SCA_JoystickManager(m_logicmgr);
+       
 
        m_logicmgr->RegisterEventManager(alwaysmgr);
        m_logicmgr->RegisterEventManager(propmgr);
@@ -170,7 +170,15 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
        m_logicmgr->RegisterEventManager(rndmgr);
        m_logicmgr->RegisterEventManager(raymgr);
        m_logicmgr->RegisterEventManager(netmgr);
-       m_logicmgr->RegisterEventManager(joymgr);
+
+
+       SYS_SystemHandle hSystem = SYS_GetSystem();
+       bool nojoystick= SYS_GetCommandLineInt(hSystem,"nojoystick",0);
+       if (!nojoystick)
+       {
+               SCA_JoystickManager *joymgr     = new SCA_JoystickManager(m_logicmgr);
+               m_logicmgr->RegisterEventManager(joymgr);
+       }
 
        m_soundScene = new SND_Scene(adi);
        MT_assert (m_networkDeviceInterface != NULL);
index f17cfb79e92afbd4ea4da12f8bdeca4610745cdf..166731459e7b1882516b464b5a0678c9e970f437 100644 (file)
@@ -288,26 +288,69 @@ void CcdPhysicsController::CreateRigidbody()
                m_object = psb;
 
                //psb->m_cfg.collisions =       btSoftBody::fCollision::SDF_RS;//btSoftBody::fCollision::CL_SS+ btSoftBody::fCollision::CL_RS;
-               psb->m_cfg.collisions   =       btSoftBody::fCollision::SDF_RS + btSoftBody::fCollision::VF_SS;//CL_SS;
-               //psb->m_cfg.collisions =       btSoftBody::fCollision::CL_SS + btSoftBody::fCollision::CL_RS;
                
-               //btSoftBody::Material* pm=psb->appendMaterial();
-               btSoftBody::Material*   pm=psb->m_materials[0];
+               //psb->m_cfg.collisions =       btSoftBody::fCollision::SDF_RS + btSoftBody::fCollision::VF_SS;//CL_SS;
                
-               pm->m_kLST                              =       m_cci.m_linearStiffness;
-               pm->m_kAST                              =       m_cci.m_angularStiffness;
-               pm->m_kVST                              =       m_cci.m_volumePreservation;
                
+               //btSoftBody::Material* pm=psb->appendMaterial();
+               btSoftBody::Material*   pm=psb->m_materials[0];
+               pm->m_kLST                              =       m_cci.m_soft_linStiff;
+               pm->m_kAST                              =       m_cci.m_soft_angStiff;
+               pm->m_kVST                              =       m_cci.m_soft_volume;
+               psb->m_cfg.collisions = 0;
 
-               
-               //pm->m_kAST = 0.01f;
-               //pm->m_kVST = 0.001f;
-               psb->generateBendingConstraints(2,pm);
-               psb->m_cfg.piterations = 4;
-               psb->m_cfg.viterations = 4;
-               psb->m_cfg.diterations = 4;
-               psb->m_cfg.citerations = 4;
-               if (m_cci.m_gamesoftFlag & 2)//OB_SB_GOAL)
+               if (m_cci.m_soft_collisionflags & CCD_BSB_COL_CL_RS)
+               {
+                       psb->m_cfg.collisions   +=      btSoftBody::fCollision::CL_RS;
+               } else
+               {
+                       psb->m_cfg.collisions   +=      btSoftBody::fCollision::SDF_RS;
+               }
+               if (m_cci.m_soft_collisionflags & CCD_BSB_COL_CL_SS)
+               {
+                       psb->m_cfg.collisions += btSoftBody::fCollision::CL_SS;
+               } else
+               {
+                       psb->m_cfg.collisions += btSoftBody::fCollision::VF_SS;
+               }
+
+
+               psb->m_cfg.kSRHR_CL = m_cci.m_soft_kSRHR_CL;            /* Soft vs rigid hardness [0,1] (cluster only) */
+               psb->m_cfg.kSKHR_CL = m_cci.m_soft_kSKHR_CL;            /* Soft vs kinetic hardness [0,1] (cluster only) */
+               psb->m_cfg.kSSHR_CL = m_cci.m_soft_kSSHR_CL;            /* Soft vs soft hardness [0,1] (cluster only) */
+               psb->m_cfg.kSR_SPLT_CL = m_cci.m_soft_kSR_SPLT_CL;      /* Soft vs rigid impulse split [0,1] (cluster only) */
+
+               psb->m_cfg.kSK_SPLT_CL = m_cci.m_soft_kSK_SPLT_CL;      /* Soft vs rigid impulse split [0,1] (cluster only) */
+               psb->m_cfg.kSS_SPLT_CL = m_cci.m_soft_kSS_SPLT_CL;      /* Soft vs rigid impulse split [0,1] (cluster only) */
+               psb->m_cfg.kVCF = m_cci.m_soft_kVCF;                    /* Velocities correction factor (Baumgarte) */
+               psb->m_cfg.kDP = m_cci.m_soft_kDP;                      /* Damping coefficient [0,1] */
+
+               psb->m_cfg.kDG = m_cci.m_soft_kDG;                      /* Drag coefficient [0,+inf] */
+               psb->m_cfg.kLF = m_cci.m_soft_kLF;                      /* Lift coefficient [0,+inf] */
+               psb->m_cfg.kPR = m_cci.m_soft_kPR;                      /* Pressure coefficient [-inf,+inf] */
+               psb->m_cfg.kVC = m_cci.m_soft_kVC;                      /* Volume conversation coefficient [0,+inf] */
+
+               psb->m_cfg.kDF = m_cci.m_soft_kDF;                      /* Dynamic friction coefficient [0,1] */
+               psb->m_cfg.kMT = m_cci.m_soft_kMT;                      /* Pose matching coefficient [0,1] */
+               psb->m_cfg.kCHR = m_cci.m_soft_kCHR;                    /* Rigid contacts hardness [0,1] */
+               psb->m_cfg.kKHR = m_cci.m_soft_kKHR;                    /* Kinetic contacts hardness [0,1] */
+
+               psb->m_cfg.kSHR = m_cci.m_soft_kSHR;                    /* Soft contacts hardness [0,1] */
+               psb->m_cfg.kAHR = m_cci.m_soft_kAHR;                    /* Anchors hardness [0,1] */
+
+
+
+               if (m_cci.m_gamesoftFlag & CCD_BSB_BENDING_CONSTRAINTS)//OB_SB_GOAL)
+               {
+                       psb->generateBendingConstraints(2,pm);
+               }
+
+               psb->m_cfg.piterations = m_cci.m_soft_piterations;
+               psb->m_cfg.viterations = m_cci.m_soft_viterations;
+               psb->m_cfg.diterations = m_cci.m_soft_diterations;
+               psb->m_cfg.citerations = m_cci.m_soft_citerations;
+
+               if (m_cci.m_gamesoftFlag & CCD_BSB_SHAPE_MATCHING)//OB_SB_GOAL)
                {
                        psb->setPose(false,true);//
                } else
@@ -315,27 +358,14 @@ void CcdPhysicsController::CreateRigidbody()
                        psb->setPose(true,false);
                }
 
-               psb->m_cfg.kDF                          =       0.5;
-               //psb->m_cfg.kMT                                =       0.05;
-               psb->m_cfg.piterations          =       5;
-               
-               psb->m_cfg.piterations          =       5;
-               //psb->m_cfg.kVC                                =       20;
 
+               
                psb->randomizeConstraints();
 
-/*
-               psb->m_cfg.kDF = 0.1f;//1.f;
-               psb->m_cfg.kDP          =       0.0001;
-               //psb->m_cfg.kDP                =       0.005;
-               psb->m_cfg.kCHR         =       0.1;
-               //psb->m_cfg.kVCF = 0.1f;
-               psb->m_cfg.kVCF = 0.0001f;
-               //psb->m_cfg.kAHR = 0.1f;
-               psb->m_cfg.kAHR = 0.0001f;
-               psb->m_cfg.kMT = 0.1f;
-               //psb->m_cfg.kDF=1;
-               */
+               if (m_cci.m_soft_collisionflags & (CCD_BSB_COL_CL_RS+CCD_BSB_COL_CL_SS))
+               {
+                       psb->generateClusters(m_cci.m_soft_numclusteriterations);
+               }
 
 //             psb->activate();
 //             psb->setActivationState(1);
@@ -343,14 +373,10 @@ void CcdPhysicsController::CreateRigidbody()
                
                //psb->m_materials[0]->m_kLST   =       0.1+(i/(btScalar)(n-1))*0.9;
                psb->setTotalMass(m_cci.m_mass);
-               psb->generateClusters(64);              
+               
                psb->setCollisionFlags(0);
 
-
-
-
-
-                       ///create a mapping between graphics mesh vertices and soft body vertices
+               ///create a mapping between graphics mesh vertices and soft body vertices
                {
                        RAS_MeshObject* rasMesh= GetShapeInfo()->GetMesh();
 
index 60c734838f36e164e0117c9e0941e90b57a906a7..1366764eb63186288312dbd0d586c051aa9bc4d1 100644 (file)
@@ -38,6 +38,20 @@ class btMotionState;
 class RAS_MeshObject;
 class btCollisionShape;
 
+
+#define CCD_BSB_SHAPE_MATCHING 2
+#define CCD_BSB_BENDING_CONSTRAINTS 8
+#define CCD_BSB_AERO_VPOINT 16 /* aero model, Vertex normals are oriented toward velocity*/
+#define CCD_BSB_AERO_VTWOSIDE 32 /* aero model, Vertex normals are flipped to match velocity */
+
+/* BulletSoftBody.collisionflags */
+#define CCD_BSB_COL_SDF_RS     2 /* SDF based rigid vs soft */
+#define CCD_BSB_COL_CL_RS      4 /* Cluster based rigid vs soft */
+#define CCD_BSB_COL_CL_SS      8 /* Cluster based soft vs soft */
+#define CCD_BSB_COL_VF_SS      16 /* Vertex/Face based soft vs soft */
+
+
+
 // Shape contructor
 // It contains all the information needed to create a simple bullet shape at runtime
 class CcdShapeConstructionInfo
@@ -162,9 +176,6 @@ struct CcdConstructionInfo
                m_linearDamping(0.1f),
                m_angularDamping(0.1f),
                m_margin(0.06f),
-               m_linearStiffness(1.f),
-               m_angularStiffness(1.f),
-               m_volumePreservation(1.f),
                m_gamesoftFlag(0),
                m_collisionFlags(0),
                m_bRigid(false),
@@ -189,10 +200,44 @@ struct CcdConstructionInfo
        btScalar        m_angularDamping;
        btScalar        m_margin;
 
-       btScalar        m_linearStiffness;
-       btScalar        m_angularStiffness;
-       btScalar        m_volumePreservation;
-       int                     m_gamesoftFlag;
+       ////////////////////
+       int             m_gamesoftFlag;
+       float   m_soft_linStiff;                        /* linear stiffness 0..1 */
+       float   m_soft_angStiff;                /* angular stiffness 0..1 */
+       float   m_soft_volume;                  /* volume preservation 0..1 */
+
+       int             m_soft_viterations;             /* Velocities solver iterations */
+       int             m_soft_piterations;             /* Positions solver iterations */
+       int             m_soft_diterations;             /* Drift solver iterations */
+       int             m_soft_citerations;             /* Cluster solver iterations */
+
+       float   m_soft_kSRHR_CL;                /* Soft vs rigid hardness [0,1] (cluster only) */
+       float   m_soft_kSKHR_CL;                /* Soft vs kinetic hardness [0,1] (cluster only) */
+       float   m_soft_kSSHR_CL;                /* Soft vs soft hardness [0,1] (cluster only) */
+       float   m_soft_kSR_SPLT_CL;     /* Soft vs rigid impulse split [0,1] (cluster only) */
+
+       float   m_soft_kSK_SPLT_CL;     /* Soft vs rigid impulse split [0,1] (cluster only) */
+       float   m_soft_kSS_SPLT_CL;     /* Soft vs rigid impulse split [0,1] (cluster only) */
+       float   m_soft_kVCF;                    /* Velocities correction factor (Baumgarte) */
+       float   m_soft_kDP;                     /* Damping coefficient [0,1] */
+
+       float   m_soft_kDG;                     /* Drag coefficient [0,+inf] */
+       float   m_soft_kLF;                     /* Lift coefficient [0,+inf] */
+       float   m_soft_kPR;                     /* Pressure coefficient [-inf,+inf] */
+       float   m_soft_kVC;                     /* Volume conversation coefficient [0,+inf] */
+
+       float   m_soft_kDF;                     /* Dynamic friction coefficient [0,1] */
+       float   m_soft_kMT;                     /* Pose matching coefficient [0,1] */
+       float   m_soft_kCHR;                    /* Rigid contacts hardness [0,1] */
+       float   m_soft_kKHR;                    /* Kinetic contacts hardness [0,1] */
+
+       float   m_soft_kSHR;                    /* Soft contacts hardness [0,1] */
+       float   m_soft_kAHR;                    /* Anchors hardness [0,1] */
+       int             m_soft_collisionflags;  /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
+       int             m_soft_numclusteriterations;    /* number of iterations to refine collision clusters*/
+///////////////////
+
+
 
        int                     m_collisionFlags;
        bool            m_bRigid;
index 3593aecf3d537fad533f9187a896bdadc1d74dde..763fc148a0472a5b40c70ba75a42a2343dda8c0a 100644 (file)
@@ -576,7 +576,8 @@ bool        CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
                veh->SyncWheels();
        }
 
-       m_dynamicsWorld->debugDrawWorld();
+       if (m_dynamicsWorld->getDebugDrawer() &&  m_dynamicsWorld->getDebugDrawer()->getDebugMode() >0)
+               m_dynamicsWorld->debugDrawWorld();
 
 
        CallbackTriggers();