but is gets 0.661333 here.
if I change colShape from btBoxShape to btSphereShape it will be 0.6.
Is it a bug ,or I have some mistake in my code?
My bullet version is 2.8.3, OS is windows 7. My code file is attached.
Code: Select all
///create a few basic rigid bodies
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(100.),btScalar(10.),btScalar(100)));
//keep track of the shapes, we release memory at exit.
//make sure to re-use collision shapes among rigid bodies whenever possible!
btAlignedObjectArray<btCollisionShape*> collisionShapes;
collisionShapes.push_back(groundShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,0,0));
{
btScalar mass(0.);
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)
groundShape->calculateLocalInertia(mass,localInertia);
//using motionstate is optional, it provides interpolation capabilities, and only synchronizes 'active' objects
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
//add the body to the dynamics world
dynamicsWorld->addCollisionObject(body);
}
//const btSphereShape* colShape = new btSphereShape(1);
const btBoxShape* colShape = new btBoxShape(btVector3(1, 1, 1));
btTransform from;
from.setOrigin(btVector3(0.0, 20.0, 0.0));
btTransform to;
to.setOrigin(btVector3(0.0,5.0,0.0));
CustomizedConvexResultCallback callback;
dynamicsWorld->convexSweepTest(colShape, from, to, callback);
printf("%f\n", callback.m_closestHitFraction);