Fix bug in rigid body constraint buttons drawing, and while we are at it, add 'Collis...
authorErwin Coumans <blender@erwincoumans.com>
Fri, 10 Oct 2008 05:12:57 +0000 (05:12 +0000)
committerErwin Coumans <blender@erwincoumans.com>
Fri, 10 Oct 2008 05:12:57 +0000 (05:12 +0000)
source/blender/makesdna/DNA_constraint_types.h
source/blender/src/buttons_object.c
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h

index ecfb7dc..fe19cf6 100644 (file)
@@ -520,6 +520,7 @@ typedef enum B_CONSTRAINTCHANNEL_FLAG {
 
 /* Rigid-Body Constraint */
 #define CONSTRAINT_DRAW_PIVOT 0x40
+#define CONSTRAINT_DISABLE_LINKED_COLLISION 0x80
 
 /* important: these defines need to match up with PHY_DynamicTypes headerfile */
 #define CONSTRAINT_RB_BALL             1
index 8ba56b8..fceba11 100644 (file)
@@ -1497,16 +1497,20 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
                                int offsetY = 150;
                                int textButWidth = ((width/2)-togButWidth);
                                
-                               uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Cone Twist%x4|Generic (experimental)%x12",//|Extra Force%x6",
-                                                                                               *xco, *yco-25, 150, 18, &data->type, 0, 0, 0, 0, "Choose the joint type");
                 height = 140;
                                if (data->type==CONSTRAINT_RB_GENERIC6DOF)
                                        height = 270;
                                if (data->type==CONSTRAINT_RB_CONETWIST)
                                        height = 200;
                                
-                uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
-                               
+                               uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
+
+                               uiDefButI(block, MENU, B_CONSTRAINT_TEST, "Joint Types%t|Ball%x1|Hinge%x2|Cone Twist%x4|Generic (experimental)%x12",//|Extra Force%x6",
+                                                                                               *xco, *yco-25, 150, 18, &data->type, 0, 0, 0, 0, "Choose the joint type");
+
+                               uiDefButBitS(block, TOG, CONSTRAINT_DISABLE_LINKED_COLLISION, B_CONSTRAINT_TEST, "Collision", *xco+155, *yco-25, 111, 18, &data->flag, 0, 24, 0, 0, "Enable Collision Between Linked Bodies");                          
+
+
                                uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "toObject:", *xco, *yco-50, 130, 18, &data->tar, "Child Object");
                                uiDefButBitS(block, TOG, CONSTRAINT_DRAW_PIVOT, B_CONSTRAINT_TEST, "ShowPivot", *xco+135, *yco-50, 130, 18, &data->flag, 0, 24, 0, 0, "Show pivot position and rotation");                              
                                
@@ -1586,6 +1590,7 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
                                                uiDefButF(block, NUM, B_CONSTRAINT_TEST, "", *xco+(width-textButWidth-5), *yco-offsetY, (textButWidth), 18, &(data->maxLimit[5]), -extremeAngZ, extremeAngZ, 0.1,0.5,"max z limit"); 
                                        uiBlockEndAlign(block);
                                }
+                               
                        }
                        break;
                case CONSTRAINT_TYPE_CLAMPTO:
index 97ed6f4..9c699b6 100644 (file)
@@ -2478,7 +2478,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
                                                                (float)dat->pivY,(float)dat->pivZ,
                                                                (float)axis0.x(),(float)axis0.y(),(float)axis0.z(),
                                                                (float)axis1.x(),(float)axis1.y(),(float)axis1.z(),
-                                                               (float)axis2.x(),(float)axis2.y(),(float)axis2.z());
+                                                               (float)axis2.x(),(float)axis2.y(),(float)axis2.z(),dat->flag);
                                                        if (constraintId)
                                                        {
                                                                //if it is a generic 6DOF constraint, set all the limits accordingly
index dea6225..fb37ede 100644 (file)
@@ -435,7 +435,7 @@ static PyObject* gPyCreateConstraint(PyObject* self,
                        PHY_IPhysicsController* physctrl2 = (PHY_IPhysicsController*) physicsid2;
                        if (physctrl) //TODO:check for existance of this pointer!
                        {
-                               int constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ);
+                               int constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ,0);
                                
                                KX_ConstraintWrapper* wrap = new KX_ConstraintWrapper((enum PHY_ConstraintType)constrainttype,constraintid,PHY_GetActiveEnvironment());
                                
index 91655e9..82fa084 100644 (file)
@@ -33,6 +33,7 @@ subject to the following restrictions:
 
 #include "PHY_IMotionState.h"
 
+#define CCD_CONSTRAINT_DISABLE_LINKED_COLLISION 0x80
 
 bool useIslands = true;
 
@@ -882,13 +883,16 @@ int                       CcdPhysicsEnvironment::createUniversalD6Constraint(
                                                const btVector3& linearMinLimits,
                                                const btVector3& linearMaxLimits,
                                                const btVector3& angularMinLimits,
-                                               const btVector3& angularMaxLimits
+                                               const btVector3& angularMaxLimits,int flags
 )
 {
 
+       bool disableCollisionBetweenLinkedBodies = (0==(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION));
+
        //we could either add some logic to recognize ball-socket and hinge, or let that up to the user
        //perhaps some warning or hint that hinge/ball-socket is more efficient?
        
+       
        btGeneric6DofConstraint* genericConstraint = 0;
        CcdPhysicsController* ctrl0 = (CcdPhysicsController*) ctrlRef;
        CcdPhysicsController* ctrl1 = (CcdPhysicsController*) ctrlOther;
@@ -918,7 +922,7 @@ int                 CcdPhysicsEnvironment::createUniversalD6Constraint(
        if (genericConstraint)
        {
        //      m_constraints.push_back(genericConstraint);
-               m_dynamicsWorld->addConstraint(genericConstraint);
+               m_dynamicsWorld->addConstraint(genericConstraint,disableCollisionBetweenLinkedBodies);
 
                genericConstraint->setUserConstraintId(gConstraintUid++);
                genericConstraint->setUserConstraintType(PHY_GENERIC_6DOF_CONSTRAINT);
@@ -1488,10 +1492,13 @@ int                     CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
                                                                                                        float pivotX,float pivotY,float pivotZ,
                                                                                                        float axisX,float axisY,float axisZ,
                                                                                                        float axis1X,float axis1Y,float axis1Z,
-                                                                                                       float axis2X,float axis2Y,float axis2Z
+                                                                                                       float axis2X,float axis2Y,float axis2Z,int flags
                                                                                                        )
 {
 
+       bool disableCollisionBetweenLinkedBodies = (0==(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION));
+
+
 
        CcdPhysicsController* c0 = (CcdPhysicsController*)ctrl0;
        CcdPhysicsController* c1 = (CcdPhysicsController*)ctrl1;
@@ -1683,7 +1690,7 @@ int                       CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
                                        pivotInA);
                        }
 
-                       m_dynamicsWorld->addConstraint(p2p);
+                       m_dynamicsWorld->addConstraint(p2p,disableCollisionBetweenLinkedBodies);
 //                     m_constraints.push_back(p2p);
 
                        p2p->setUserConstraintId(gConstraintUid++);
@@ -1753,7 +1760,7 @@ int                       CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
                        if (genericConstraint)
                        {
                                //m_constraints.push_back(genericConstraint);
-                               m_dynamicsWorld->addConstraint(genericConstraint);
+                               m_dynamicsWorld->addConstraint(genericConstraint,disableCollisionBetweenLinkedBodies);
                                genericConstraint->setUserConstraintId(gConstraintUid++);
                                genericConstraint->setUserConstraintType(type);
                                //64 bit systems can't cast pointer to int. could use size_t instead.
@@ -1819,7 +1826,7 @@ int                       CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
                        if (coneTwistContraint)
                        {
                                //m_constraints.push_back(genericConstraint);
-                               m_dynamicsWorld->addConstraint(coneTwistContraint);
+                               m_dynamicsWorld->addConstraint(coneTwistContraint,disableCollisionBetweenLinkedBodies);
                                coneTwistContraint->setUserConstraintId(gConstraintUid++);
                                coneTwistContraint->setUserConstraintType(type);
                                //64 bit systems can't cast pointer to int. could use size_t instead.
@@ -1858,7 +1865,7 @@ int                       CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
                        hinge->setAngularOnly(angularOnly);
 
                        //m_constraints.push_back(hinge);
-                       m_dynamicsWorld->addConstraint(hinge);
+                       m_dynamicsWorld->addConstraint(hinge,disableCollisionBetweenLinkedBodies);
                        hinge->setUserConstraintId(gConstraintUid++);
                        hinge->setUserConstraintType(type);
                        //64 bit systems can't cast pointer to int. could use size_t instead.
index 3d9d544..74384dd 100644 (file)
@@ -127,7 +127,7 @@ protected:
                        float pivotX,float pivotY,float pivotZ,
                        float axisX,float axisY,float axisZ,
                        float axis1X=0,float axis1Y=0,float axis1Z=0,
-                       float axis2X=0,float axis2Y=0,float axis2Z=0
+                       float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
                        );
 
 
@@ -139,7 +139,7 @@ protected:
                        const btVector3& linearMinLimits,
                        const btVector3& linearMaxLimits,
                        const btVector3& angularMinLimits,
-                       const btVector3& angularMaxLimits
+                       const btVector3& angularMaxLimits,int flags
                        );
 
                virtual void    setConstraintParam(int constraintId,int param,float value,float value1);
index d78958b..ba196b5 100644 (file)
@@ -92,8 +92,7 @@ void DummyPhysicsEnvironment::setGravity(float x,float y,float z)
 int                    DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
                float pivotX,float pivotY,float pivotZ,float axisX,float axisY,float axisZ,
                        float axis1X,float axis1Y,float axis1Z,
-                       float axis2X,float axis2Y,float axis2Z
-
+                       float axis2X,float axis2Y,float axis2Z,int flag
                )
 {
        
index 975be84..a92b1e7 100644 (file)
@@ -58,7 +58,7 @@ public:
                        float pivotX,float pivotY,float pivotZ,
                        float axisX,float axisY,float axisZ,
                        float axis1X=0,float axis1Y=0,float axis1Z=0,
-                       float axis2X=0,float axis2Y=0,float axis2Z=0
+                       float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
                        );
 
        virtual void            removeConstraint(int    constraintid);
index 80e4dc4..3be5e02 100644 (file)
@@ -111,8 +111,8 @@ int SumoPhysicsEnvironment::createConstraint(
        float pivotX,float pivotY,float pivotZ,
        float axisX,float axisY,float axisZ,
        float axis1X,float axis1Y,float axis1Z,
-       float axis2X,float axis2Y,float axis2Z
-
+       float axis2X,float axis2Y,float axis2Z,
+       int flag
        )
 {
        int constraintid = 0;
index 100adf9..65b07a7 100644 (file)
@@ -63,7 +63,7 @@ public:
                        float pivotX,float pivotY,float pivotZ,
                        float axisX,float axisY,float axisZ,
                        float axis1X=0,float axis1Y=0,float axis1Z=0,
-                       float axis2X=0,float axis2Y=0,float axis2Z=0
+                       float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
 
                        );
 
index 98496fb..0e9c571 100644 (file)
@@ -129,7 +129,7 @@ class PHY_IPhysicsEnvironment
                        float pivotX,float pivotY,float pivotZ,
                        float axis0X,float axis0Y,float axis0Z,
                        float axis1X=0,float axis1Y=0,float axis1Z=0,
-                       float axis2X=0,float axis2Y=0,float axis2Z=0
+                       float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
                )=0;
                virtual void            removeConstraint(int    constraintid)=0;
                virtual float           getAppliedImpulse(int   constraintid){ return 0.f;}