force collision bound type to be convex hull or concave triangle mesh for soft bodies
authorErwin Coumans <blender@erwincoumans.com>
Sat, 27 Sep 2008 00:36:18 +0000 (00:36 +0000)
committerErwin Coumans <blender@erwincoumans.com>
Sat, 27 Sep 2008 00:36:18 +0000 (00:36 +0000)
set collision margin between soft and mesh back to .3, smaller is not useable (yet)

extern/bullet2/src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.cpp
source/blender/src/buttons_logic.c

index 9da765372d1b42063608d630b9529c1dcfb24743..61a57ea5da93f0e9cbd9199c2fdafa291b3f6b07 100644 (file)
@@ -32,7 +32,7 @@ subject to the following restrictions:
 #include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
 #include "BulletSoftBody/btSoftBody.h"
 
-#define BT_SOFTBODY_TRIANGLE_EXTRUSION btScalar(0.06)//make this configurable
+#define BT_SOFTBODY_TRIANGLE_EXTRUSION btScalar(0.3)//make this configurable
 
 btSoftBodyConcaveCollisionAlgorithm::btSoftBodyConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
 : btCollisionAlgorithm(ci),
@@ -142,9 +142,9 @@ void btSoftBodyTriangleCallback::processTriangle(btVector3* triangle,int partId,
                normal*= BT_SOFTBODY_TRIANGLE_EXTRUSION;
 //             other=(triangle[0]+triangle[1]+triangle[2])*0.333333f;
 //             other+=normal*22.f;
-               btVector3       pts[6] = {triangle[0]+normal,
-                       triangle[1]+normal,
-               triangle[2]+normal,
+               btVector3       pts[6] = {triangle[0],
+                       triangle[1],
+               triangle[2],
                triangle[0]-normal,
                triangle[1]-normal,
                triangle[2]-normal};
index e36e51d9686014e5e704ef7554a40e2dd131060b..388989fdbfb03ed22959654ef57d452e9e726e2d 100644 (file)
@@ -2974,6 +2974,9 @@ static void check_body_type(void *arg1_but, void *arg2_object)
        case OB_BODY_TYPE_SOFT:
                ob->gameflag |= OB_COLLISION|OB_DYNAMIC|OB_SOFT_BODY|OB_ACTOR;
                ob->gameflag &= ~(OB_RIGID_BODY);
+               ob->gameflag |= OB_BOUNDS;
+               if (ob->boundtype<OB_BOUND_POLYH)
+                       ob->boundtype=OB_BOUND_POLYH;
                break;
        }
 }
@@ -3112,9 +3115,16 @@ void buttons_bullet(uiBlock *block, Object *ob)
                                &ob->gameflag, 0, 0, 0, 0,
                                "Specify a collision bounds type");
                if (ob->gameflag & OB_BOUNDS) {
-                       uiDefButS(block, MENU, REDRAWVIEW3D, "Collision Bounds%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull%x5|Triangle 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|",
-                               90, 105, 150, 19, &ob->boundtype, 0, 0, 0, 0, "Selects the collision type");
+                       //only allow convex hull/triangle mesh for soft bodies
+                       if (ob->body_type==OB_BODY_TYPE_SOFT)
+                       {
+                               uiDefButS(block, MENU, REDRAWVIEW3D, "Collision Bounds%t|Convex Hull%x5|Triangle Mesh%x4",
+                                       90, 105, 150, 19, &ob->boundtype, 0, 0, 0, 0, "Selects the collision type");
+                       } else
+                       {
+                               uiDefButS(block, MENU, REDRAWVIEW3D, "Collision Bounds%t|Box%x0|Sphere%x1|Cylinder%x2|Cone%x3|Convex Hull%x5|Triangle Mesh%x4",
+                                       90, 105, 150, 19, &ob->boundtype, 0, 0, 0, 0, "Selects the collision type");
+                       }
                        uiDefButBitI(block, TOG, OB_CHILD, B_REDR, "Compound", 240,105,110,19, 
                                        &ob->gameflag, 0, 0, 0, 0, 
                                        "Add Children");