implemented rolling friction, using a contact constraint. Useful to get rolling spheres to rest, even on a slightly sloped plane.
See http://www.youtube.com/watch?v=RV7sBAsKu4M and Bullet/Demos/RollingFrictionDemo Fixes in FractureDemo (mouse picking constraint needs to be removed, otherwise constraint solver crashes/asserts)
This commit is contained in:
@@ -18,8 +18,7 @@ subject to the following restrictions:
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "LinearMath/btHashMap.h"
|
||||
|
||||
#include "GLDebugDrawer.h"
|
||||
static GLDebugDrawer sDebugDraw;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +27,7 @@ int main(int argc,char** argv)
|
||||
|
||||
BasicDemo ccdDemo;
|
||||
ccdDemo.initPhysics();
|
||||
ccdDemo.getDynamicsWorld()->setDebugDrawer(&sDebugDraw);
|
||||
|
||||
|
||||
#ifdef CHECK_MEMORY_LEAKS
|
||||
ccdDemo.exitPhysics();
|
||||
|
||||
@@ -12,7 +12,7 @@ IF (USE_GLUT)
|
||||
SET(SharedDemoSubdirs
|
||||
OpenGL AllBulletDemos ConvexDecompositionDemo
|
||||
CcdPhysicsDemo ConstraintDemo SliderConstraintDemo GenericJointDemo Raytracer
|
||||
RagdollDemo ForkLiftDemo BasicDemo RaytestDemo VoronoiFractureDemo GyroscopicDemo FractureDemo Box2dDemo BspDemo MovingConcaveDemo VehicleDemo
|
||||
RagdollDemo ForkLiftDemo BasicDemo RollingFrictionDemo RaytestDemo VoronoiFractureDemo GyroscopicDemo FractureDemo Box2dDemo BspDemo MovingConcaveDemo VehicleDemo
|
||||
UserCollisionAlgorithm CharacterDemo SoftDemo
|
||||
CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo
|
||||
ConvexHullDistance
|
||||
@@ -48,6 +48,7 @@ ELSE (USE_GLUT)
|
||||
CollisionInterfaceDemo
|
||||
ConcaveDemo
|
||||
ConstraintDemo
|
||||
RollingFrictionDemo
|
||||
ConvexDecompositionDemo
|
||||
InternalEdgeDemo
|
||||
GimpactTestDemo
|
||||
|
||||
@@ -223,7 +223,7 @@ void CcdPhysicsDemo::initPhysics()
|
||||
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
|
||||
btRigidBody* body = new btRigidBody(rbInfo);
|
||||
|
||||
body->setRollingFriction(0.3);
|
||||
//add the body to the dynamics world
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
}
|
||||
@@ -282,7 +282,7 @@ void CcdPhysicsDemo::initPhysics()
|
||||
|
||||
btRigidBody* body = localCreateRigidBody(mass,trans,shape);
|
||||
|
||||
|
||||
body->setRollingFriction(0.1);
|
||||
///when using m_ccdMode
|
||||
if (m_ccdMode==USE_CCD)
|
||||
{
|
||||
|
||||
@@ -336,8 +336,22 @@ void btFractureDynamicsWorld::removeRigidBody(btRigidBody* body)
|
||||
if (body->getInternalType() & CUSTOM_FRACTURE_TYPE)
|
||||
{
|
||||
btFractureBody* fbody = (btFractureBody*)body;
|
||||
btAlignedObjectArray<btTypedConstraint*> tmpConstraints;
|
||||
|
||||
for (int i=0;i<fbody->getNumConstraintRefs();i++)
|
||||
{
|
||||
tmpConstraints.push_back(fbody->getConstraintRef(i));
|
||||
}
|
||||
|
||||
//remove all constraints attached to this rigid body too
|
||||
for (int i=0;i<tmpConstraints.size();i++)
|
||||
btDiscreteDynamicsWorld::removeConstraint(tmpConstraints[i]);
|
||||
|
||||
m_fractureBodies.remove(fbody);
|
||||
}
|
||||
|
||||
|
||||
|
||||
btDiscreteDynamicsWorld::removeRigidBody(body);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ void GyroscopicDemo::initPhysics()
|
||||
tr.setIdentity();
|
||||
tr.setOrigin(positions[i]);
|
||||
body->setCenterOfMassTransform(tr);
|
||||
body->setAngularVelocity(btVector3(0,0,1000));
|
||||
body->setAngularVelocity(btVector3(0,0,15));
|
||||
body->setLinearVelocity(btVector3(0,.2,0));
|
||||
body->setFriction(btSqrt(1));
|
||||
m_dynamicsWorld->addRigidBody(body);
|
||||
|
||||
@@ -787,7 +787,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
|
||||
dof6->setAngularLowerLimit(btVector3(0,0,0));
|
||||
dof6->setAngularUpperLimit(btVector3(0,0,0));
|
||||
|
||||
m_dynamicsWorld->addConstraint(dof6);
|
||||
m_dynamicsWorld->addConstraint(dof6,true);
|
||||
m_pickConstraint = dof6;
|
||||
|
||||
dof6->setParam(BT_CONSTRAINT_STOP_CFM,0.8,0);
|
||||
@@ -806,7 +806,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
|
||||
} else
|
||||
{
|
||||
btPoint2PointConstraint* p2p = new btPoint2PointConstraint(*body,localPivot);
|
||||
m_dynamicsWorld->addConstraint(p2p);
|
||||
m_dynamicsWorld->addConstraint(p2p,true);
|
||||
m_pickConstraint = p2p;
|
||||
p2p->m_setting.m_impulseClamp = mousePickClamping;
|
||||
//very weak constraint for picking
|
||||
|
||||
@@ -72,6 +72,7 @@ end
|
||||
"RagdollDemo",
|
||||
"Raytracer",
|
||||
"RaytestDemo",
|
||||
"RollingFrictionDemo",
|
||||
"SimplexDemo",
|
||||
"SliderConstraintDemo",
|
||||
"TerrainDemo",
|
||||
|
||||
Reference in New Issue
Block a user