wrapped up first version of the FractureDemo
move 'split impulse' / position solver before velocity solver, so that applied impulse is available for fracture add btSliderConstraint::getAngularPos see http://code.google.com/p/bullet/issues/detail?id=489
This commit is contained in:
@@ -73,45 +73,37 @@ void FractureDemo::initPhysics()
|
|||||||
|
|
||||||
//m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
//m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
||||||
|
|
||||||
m_dynamicsWorld = new btFractureDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
btFractureDynamicsWorld* fractureWorld = new btFractureDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
||||||
|
m_dynamicsWorld = fractureWorld;
|
||||||
|
|
||||||
|
m_dynamicsWorld->getDispatchInfo().m_convexMaxDistanceUseCPT = true;
|
||||||
|
m_ShootBoxInitialSpeed=100;
|
||||||
|
|
||||||
//m_splitImpulse removes the penetration resolution from the applied impulse, otherwise objects might fracture due to deep penetrations.
|
//m_splitImpulse removes the penetration resolution from the applied impulse, otherwise objects might fracture due to deep penetrations.
|
||||||
m_dynamicsWorld->getSolverInfo().m_splitImpulse = true;
|
m_dynamicsWorld->getSolverInfo().m_splitImpulse = true;
|
||||||
|
|
||||||
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
|
{
|
||||||
|
|
||||||
///create a few basic rigid bodies
|
///create a few basic rigid bodies
|
||||||
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
btCollisionShape* groundShape = new btBoxShape(btVector3(50,1,50));
|
||||||
// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
|
/// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),0);
|
||||||
|
|
||||||
m_collisionShapes.push_back(groundShape);
|
m_collisionShapes.push_back(groundShape);
|
||||||
|
|
||||||
btTransform groundTransform;
|
btTransform groundTransform;
|
||||||
groundTransform.setIdentity();
|
groundTransform.setIdentity();
|
||||||
groundTransform.setOrigin(btVector3(0,-50,0));
|
groundTransform.setOrigin(btVector3(0,0,0));
|
||||||
|
localCreateRigidBody(0.f,groundTransform,groundShape);
|
||||||
//We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here:
|
|
||||||
{
|
|
||||||
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 recommended, 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
|
|
||||||
m_dynamicsWorld->addRigidBody(body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
///create a few basic rigid bodies
|
||||||
|
btCollisionShape* shape = new btBoxShape(btVector3(1,1,1));
|
||||||
|
m_collisionShapes.push_back(shape);
|
||||||
|
btTransform tr;
|
||||||
|
tr.setIdentity();
|
||||||
|
tr.setOrigin(btVector3(5,2,0));
|
||||||
|
localCreateRigidBody(0.f,tr,shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
//create a few dynamic rigidbodies
|
//create a few dynamic rigidbodies
|
||||||
@@ -143,31 +135,38 @@ void FractureDemo::initPhysics()
|
|||||||
btTransform trans;
|
btTransform trans;
|
||||||
trans.setIdentity();
|
trans.setIdentity();
|
||||||
|
|
||||||
btVector3 pos(i*2*CUBE_HALF_EXTENTS ,10,0);
|
btVector3 pos(i*2*CUBE_HALF_EXTENTS ,20,0);
|
||||||
trans.setOrigin(pos);
|
trans.setOrigin(pos);
|
||||||
|
|
||||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||||
btDefaultMotionState* myMotionState = new btDefaultMotionState(trans);
|
btDefaultMotionState* myMotionState = new btDefaultMotionState(trans);
|
||||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);
|
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,colShape,localInertia);
|
||||||
btFractureBody* body = new btFractureBody(rbInfo, m_dynamicsWorld);
|
btFractureBody* body = new btFractureBody(rbInfo, m_dynamicsWorld);
|
||||||
|
body->setLinearVelocity(btVector3(0,-10,0));
|
||||||
body->setActivationState(ISLAND_SLEEPING);
|
|
||||||
|
|
||||||
m_dynamicsWorld->addRigidBody(body);
|
m_dynamicsWorld->addRigidBody(body);
|
||||||
body->setActivationState(ISLAND_SLEEPING);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
clientResetScene();
|
|
||||||
|
fractureWorld->stepSimulation(1./60.,0);
|
||||||
|
fractureWorld->glueCallback();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FractureDemo::clientResetScene()
|
||||||
|
{
|
||||||
|
exitPhysics();
|
||||||
|
initPhysics();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FractureDemo::clientMoveAndDisplay()
|
void FractureDemo::clientMoveAndDisplay()
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
@@ -204,11 +203,10 @@ void FractureDemo::showMessage()
|
|||||||
glColor3f(0, 0, 0);
|
glColor3f(0, 0, 0);
|
||||||
char buf[124];
|
char buf[124];
|
||||||
|
|
||||||
int lineWidth=350;
|
int lineWidth=380;
|
||||||
int xStart = m_glutScreenWidth - lineWidth;
|
int xStart = m_glutScreenWidth - lineWidth;
|
||||||
int yStart = 20;
|
int yStart = 20;
|
||||||
|
|
||||||
glRasterPos3f(xStart, yStart, 0);
|
|
||||||
btFractureDynamicsWorld* world = (btFractureDynamicsWorld*)m_dynamicsWorld;
|
btFractureDynamicsWorld* world = (btFractureDynamicsWorld*)m_dynamicsWorld;
|
||||||
if (world->getFractureMode())
|
if (world->getFractureMode())
|
||||||
{
|
{
|
||||||
@@ -217,12 +215,14 @@ void FractureDemo::showMessage()
|
|||||||
{
|
{
|
||||||
sprintf(buf,"Glue mode");
|
sprintf(buf,"Glue mode");
|
||||||
}
|
}
|
||||||
GLDebugDrawString(xStart,20,buf);
|
GLDebugDrawString(xStart,yStart,buf);
|
||||||
yStart+=20;
|
|
||||||
glRasterPos3f(xStart, yStart, 0);
|
|
||||||
sprintf(buf,"f to toggle fracture/glue mode");
|
sprintf(buf,"f to toggle fracture/glue mode");
|
||||||
yStart+=20;
|
yStart+=20;
|
||||||
GLDebugDrawString(xStart,yStart,buf);
|
GLDebugDrawString(xStart,yStart,buf);
|
||||||
|
sprintf(buf,"space to restart, mouse to pick/shoot");
|
||||||
|
yStart+=20;
|
||||||
|
GLDebugDrawString(xStart,yStart,buf);
|
||||||
|
|
||||||
resetPerspectiveProjection();
|
resetPerspectiveProjection();
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
@@ -246,15 +246,6 @@ void FractureDemo::displayCallback(void) {
|
|||||||
swapBuffers();
|
swapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FractureDemo::keyboardCallback(unsigned char key, int x, int y)
|
|
||||||
{
|
|
||||||
if (key=='f')
|
|
||||||
{
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
PlatformDemoApplication::keyboardCallback(key,x,y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FractureDemo::keyboardUpCallback(unsigned char key, int x, int y)
|
void FractureDemo::keyboardUpCallback(unsigned char key, int x, int y)
|
||||||
{
|
{
|
||||||
@@ -269,17 +260,6 @@ void FractureDemo::keyboardUpCallback(unsigned char key, int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FractureDemo::shootBox(const btVector3& destination)
|
void FractureDemo::shootBox(const btVector3& destination)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -359,16 +339,22 @@ void FractureDemo::exitPhysics()
|
|||||||
delete shape;
|
delete shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_collisionShapes.clear();
|
||||||
|
|
||||||
delete m_dynamicsWorld;
|
delete m_dynamicsWorld;
|
||||||
|
m_dynamicsWorld=0;
|
||||||
|
|
||||||
delete m_solver;
|
delete m_solver;
|
||||||
|
m_solver=0;
|
||||||
|
|
||||||
delete m_broadphase;
|
delete m_broadphase;
|
||||||
|
m_broadphase=0;
|
||||||
|
|
||||||
delete m_dispatcher;
|
delete m_dispatcher;
|
||||||
|
m_dispatcher=0;
|
||||||
|
|
||||||
delete m_collisionConfiguration;
|
delete m_collisionConfiguration;
|
||||||
|
m_collisionConfiguration=0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,10 +67,10 @@ class FractureDemo : public PlatformDemoApplication
|
|||||||
|
|
||||||
virtual void displayCallback();
|
virtual void displayCallback();
|
||||||
|
|
||||||
virtual void keyboardCallback(unsigned char key, int x, int y);
|
|
||||||
|
|
||||||
virtual void keyboardUpCallback(unsigned char key, int x, int y);
|
virtual void keyboardUpCallback(unsigned char key, int x, int y);
|
||||||
|
|
||||||
|
virtual void clientResetScene();
|
||||||
|
|
||||||
static DemoApplication* Create()
|
static DemoApplication* Create()
|
||||||
{
|
{
|
||||||
FractureDemo* demo = new FractureDemo;
|
FractureDemo* demo = new FractureDemo;
|
||||||
|
|||||||
@@ -7,17 +7,19 @@
|
|||||||
|
|
||||||
btFractureDynamicsWorld::btFractureDynamicsWorld ( btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration)
|
btFractureDynamicsWorld::btFractureDynamicsWorld ( btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver,btCollisionConfiguration* collisionConfiguration)
|
||||||
:btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration),
|
:btDiscreteDynamicsWorld(dispatcher,pairCache,constraintSolver,collisionConfiguration),
|
||||||
m_fracturingMode(false)
|
m_fracturingMode(true)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void btFractureDynamicsWorld::glueCallback(btScalar timeStep)
|
void btFractureDynamicsWorld::glueCallback()
|
||||||
{
|
{
|
||||||
|
|
||||||
int numManifolds = getDispatcher()->getNumManifolds();
|
int numManifolds = getDispatcher()->getNumManifolds();
|
||||||
|
|
||||||
|
///first build the islands based on axis aligned bounding box overlap
|
||||||
|
|
||||||
btUnionFind unionFind;
|
btUnionFind unionFind;
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@@ -102,7 +104,7 @@ void btFractureDynamicsWorld::glueCallback(btScalar timeStep)
|
|||||||
|
|
||||||
btAlignedObjectArray<btCollisionObject*> removedObjects;
|
btAlignedObjectArray<btCollisionObject*> removedObjects;
|
||||||
|
|
||||||
//update the sleeping state for bodies, if all are sleeping
|
///iterate over all islands
|
||||||
for ( startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
|
for ( startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
|
||||||
{
|
{
|
||||||
int islandId = unionFind.getElement(startIslandIndex).m_id;
|
int islandId = unionFind.getElement(startIslandIndex).m_id;
|
||||||
@@ -129,19 +131,25 @@ void btFractureDynamicsWorld::glueCallback(btScalar timeStep)
|
|||||||
numObjects++;
|
numObjects++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///Then for each island that contains at least two objects and one fracture object
|
||||||
if (fractureObjectIndex>=0 && numObjects>1)
|
if (fractureObjectIndex>=0 && numObjects>1)
|
||||||
{
|
{
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
btFractureBody* fracObj = (btFractureBody*)getCollisionObjectArray()[fractureObjectIndex];
|
btFractureBody* fracObj = (btFractureBody*)getCollisionObjectArray()[fractureObjectIndex];
|
||||||
|
|
||||||
|
///glueing objects means creating a new compound and removing the old objects
|
||||||
|
///delay the removal of old objects to avoid array indexing problems
|
||||||
removedObjects.push_back(fracObj);
|
removedObjects.push_back(fracObj);
|
||||||
m_fractureBodies.remove(fracObj);
|
m_fractureBodies.remove(fracObj);
|
||||||
|
|
||||||
btAlignedObjectArray<btScalar> massArray;
|
btAlignedObjectArray<btScalar> massArray;
|
||||||
|
|
||||||
|
btAlignedObjectArray<btVector3> oldImpulses;
|
||||||
|
btAlignedObjectArray<btVector3> oldCenterOfMassesWS;
|
||||||
|
|
||||||
|
oldImpulses.push_back(fracObj->getLinearVelocity()/1./fracObj->getInvMass());
|
||||||
|
oldCenterOfMassesWS.push_back(fracObj->getCenterOfMassPosition());
|
||||||
|
|
||||||
btScalar totalMass = 0.f;
|
btScalar totalMass = 0.f;
|
||||||
|
|
||||||
|
|
||||||
@@ -178,9 +186,15 @@ void btFractureDynamicsWorld::glueCallback(btScalar timeStep)
|
|||||||
btCollisionObject* otherCollider = getCollisionObjectArray()[i];
|
btCollisionObject* otherCollider = getCollisionObjectArray()[i];
|
||||||
|
|
||||||
btRigidBody* otherObject = btRigidBody::upcast(otherCollider);
|
btRigidBody* otherObject = btRigidBody::upcast(otherCollider);
|
||||||
|
//don't glue/merge with static objects right now, otherwise everything gets stuck to the ground
|
||||||
|
///todo: expose this as a callback
|
||||||
if (!otherObject || !otherObject->getInvMass())
|
if (!otherObject || !otherObject->getInvMass())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
oldImpulses.push_back(otherObject->getLinearVelocity()*(1.f/otherObject->getInvMass()));
|
||||||
|
oldCenterOfMassesWS.push_back(otherObject->getCenterOfMassPosition());
|
||||||
|
|
||||||
removedObjects.push_back(otherObject);
|
removedObjects.push_back(otherObject);
|
||||||
m_fractureBodies.remove((btFractureBody*)otherObject);
|
m_fractureBodies.remove((btFractureBody*)otherObject);
|
||||||
|
|
||||||
@@ -221,6 +235,16 @@ void btFractureDynamicsWorld::glueCallback(btScalar timeStep)
|
|||||||
btFractureBody* newBody = new btFractureBody(totalMass,0,newCompound,localInertia, &massArray[0], numChildren,this);
|
btFractureBody* newBody = new btFractureBody(totalMass,0,newCompound,localInertia, &massArray[0], numChildren,this);
|
||||||
newBody->recomputeConnectivity(this);
|
newBody->recomputeConnectivity(this);
|
||||||
newBody->setWorldTransform(fracObj->getWorldTransform()*shift);
|
newBody->setWorldTransform(fracObj->getWorldTransform()*shift);
|
||||||
|
|
||||||
|
//now the linear/angular velocity is still zero, apply the impulses
|
||||||
|
|
||||||
|
for (int i=0;i<oldImpulses.size();i++)
|
||||||
|
{
|
||||||
|
btVector3 rel_pos = oldCenterOfMassesWS[i]-newBody->getCenterOfMassPosition();
|
||||||
|
const btVector3& imp = oldImpulses[i];
|
||||||
|
newBody->applyImpulse(imp, rel_pos);
|
||||||
|
}
|
||||||
|
|
||||||
addRigidBody(newBody);
|
addRigidBody(newBody);
|
||||||
|
|
||||||
|
|
||||||
@@ -255,21 +279,19 @@ struct btFracturePair
|
|||||||
|
|
||||||
void btFractureDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo)
|
void btFractureDynamicsWorld::solveConstraints(btContactSolverInfo& solverInfo)
|
||||||
{
|
{
|
||||||
//todo: add some logic
|
// todo: after fracture we should run the solver again for better realism
|
||||||
|
// for example
|
||||||
// save all velocities
|
// save all velocities and if one or more objects fracture:
|
||||||
// 1) that if a fracture object break
|
// 1) revert all velocties
|
||||||
// 2) revert all velocties
|
// 2) apply impulses for the fracture bodies at the contact locations
|
||||||
// 3) apply impulses for the fracture bodies at the contact locations
|
// 3)and run the constaint solver again
|
||||||
// 4)and run the constaint solver again
|
|
||||||
|
|
||||||
btDiscreteDynamicsWorld::solveConstraints(solverInfo);
|
btDiscreteDynamicsWorld::solveConstraints(solverInfo);
|
||||||
|
|
||||||
fractureCallback(solverInfo.m_timeStep);
|
fractureCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btFractureBody* btFractureDynamicsWorld::addNewBody(const btTransform& oldTransform,btScalar* masses, btCompoundShape* oldCompound)
|
||||||
void btFractureDynamicsWorld::addNewBody(const btTransform& oldTransform,btScalar* masses, btCompoundShape* oldCompound)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -288,6 +310,7 @@ void btFractureDynamicsWorld::addNewBody(const btTransform& oldTransform,btScala
|
|||||||
newBody->setCollisionFlags(newBody->getCollisionFlags()|btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
newBody->setCollisionFlags(newBody->getCollisionFlags()|btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
||||||
newBody->setWorldTransform(oldTransform*shift);
|
newBody->setWorldTransform(oldTransform*shift);
|
||||||
addRigidBody(newBody);
|
addRigidBody(newBody);
|
||||||
|
return newBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
void btFractureDynamicsWorld::addRigidBody(btRigidBody* body)
|
void btFractureDynamicsWorld::addRigidBody(btRigidBody* body)
|
||||||
@@ -398,7 +421,10 @@ void btFractureDynamicsWorld::breakDisconnectedParts( btFractureBody* fracObj)
|
|||||||
}
|
}
|
||||||
if (numShapes)
|
if (numShapes)
|
||||||
{
|
{
|
||||||
addNewBody(fracObj->getWorldTransform(),&masses[0],newCompound);
|
btFractureBody* newBody = addNewBody(fracObj->getWorldTransform(),&masses[0],newCompound);
|
||||||
|
newBody->setLinearVelocity(fracObj->getLinearVelocity());
|
||||||
|
newBody->setAngularVelocity(fracObj->getAngularVelocity());
|
||||||
|
|
||||||
numIslands++;
|
numIslands++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,16 +438,17 @@ void btFractureDynamicsWorld::breakDisconnectedParts( btFractureBody* fracObj)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
void btFractureDynamicsWorld::fractureCallback( btScalar timeStep)
|
void btFractureDynamicsWorld::fractureCallback( )
|
||||||
{
|
{
|
||||||
|
|
||||||
btAlignedObjectArray<btFracturePair> sFracturePairs;
|
btAlignedObjectArray<btFracturePair> sFracturePairs;
|
||||||
|
|
||||||
if (!m_fracturingMode)
|
if (!m_fracturingMode)
|
||||||
{
|
{
|
||||||
glueCallback(timeStep);
|
glueCallback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,15 +469,18 @@ void btFractureDynamicsWorld::fractureCallback( btScalar timeStep)
|
|||||||
totalImpact += manifold->getContactPoint(p).m_appliedImpulse;
|
totalImpact += manifold->getContactPoint(p).m_appliedImpulse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// printf("totalImpact=%f\n",totalImpact);
|
||||||
|
|
||||||
static float maxImpact = 0;
|
static float maxImpact = 0;
|
||||||
if (totalImpact>maxImpact)
|
if (totalImpact>maxImpact)
|
||||||
maxImpact = totalImpact;
|
maxImpact = totalImpact;
|
||||||
|
|
||||||
//some threshold otherwise resting contact would break objects after a while
|
//some threshold otherwise resting contact would break objects after a while
|
||||||
if (totalImpact < 10)
|
if (totalImpact < 40.f)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// printf("strong impact\n");
|
// printf("strong impact\n");
|
||||||
|
|
||||||
|
|
||||||
//@todo: add better logic to decide what parts to fracture
|
//@todo: add better logic to decide what parts to fracture
|
||||||
@@ -549,7 +579,7 @@ void btFractureDynamicsWorld::fractureCallback( btScalar timeStep)
|
|||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// printf("fracturing\n");
|
// printf("fracturing\n");
|
||||||
|
|
||||||
for (int i=0;i<sFracturePairs.size();i++)
|
for (int i=0;i<sFracturePairs.size();i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,11 +17,7 @@ class btFractureDynamicsWorld : public btDiscreteDynamicsWorld
|
|||||||
|
|
||||||
bool m_fracturingMode;
|
bool m_fracturingMode;
|
||||||
|
|
||||||
void glueCallback(btScalar timeStep);
|
btFractureBody* addNewBody(const btTransform& oldTransform,btScalar* masses, btCompoundShape* oldCompound);
|
||||||
|
|
||||||
void fractureCallback( btScalar timeStep);
|
|
||||||
|
|
||||||
void addNewBody(const btTransform& oldTransform,btScalar* masses, btCompoundShape* oldCompound);
|
|
||||||
|
|
||||||
void breakDisconnectedParts( btFractureBody* fracObj);
|
void breakDisconnectedParts( btFractureBody* fracObj);
|
||||||
|
|
||||||
@@ -42,6 +38,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool getFractureMode() const { return m_fracturingMode;}
|
bool getFractureMode() const { return m_fracturingMode;}
|
||||||
|
|
||||||
|
///normally those callbacks are called internally by the 'solveConstraints'
|
||||||
|
void glueCallback();
|
||||||
|
|
||||||
|
///normally those callbacks are called internally by the 'solveConstraints'
|
||||||
|
void fractureCallback();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //_BT_FRACTURE_DYNAMICS_WORLD_H
|
#endif //_BT_FRACTURE_DYNAMICS_WORLD_H
|
||||||
|
|||||||
@@ -1115,12 +1115,13 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(
|
|||||||
//should traverse the contacts random order...
|
//should traverse the contacts random order...
|
||||||
int iteration;
|
int iteration;
|
||||||
{
|
{
|
||||||
|
solveGroupCacheFriendlySplitImpulseIterations(bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer,stackAlloc);
|
||||||
|
|
||||||
for ( iteration = 0;iteration<infoGlobal.m_numIterations;iteration++)
|
for ( iteration = 0;iteration<infoGlobal.m_numIterations;iteration++)
|
||||||
{
|
{
|
||||||
solveSingleIteration(iteration, bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer,stackAlloc);
|
solveSingleIteration(iteration, bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer,stackAlloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
solveGroupCacheFriendlySplitImpulseIterations(bodies ,numBodies,manifoldPtr, numManifolds,constraints,numConstraints,infoGlobal,debugDrawer,stackAlloc);
|
|
||||||
}
|
}
|
||||||
return 0.f;
|
return 0.f;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,7 +236,10 @@ public:
|
|||||||
btScalar getTargetAngMotorVelocity() { return m_targetAngMotorVelocity; }
|
btScalar getTargetAngMotorVelocity() { return m_targetAngMotorVelocity; }
|
||||||
void setMaxAngMotorForce(btScalar maxAngMotorForce) { m_maxAngMotorForce = maxAngMotorForce; }
|
void setMaxAngMotorForce(btScalar maxAngMotorForce) { m_maxAngMotorForce = maxAngMotorForce; }
|
||||||
btScalar getMaxAngMotorForce() { return m_maxAngMotorForce; }
|
btScalar getMaxAngMotorForce() { return m_maxAngMotorForce; }
|
||||||
btScalar getLinearPos() { return m_linPos; }
|
|
||||||
|
btScalar getLinearPos() const { return m_linPos; }
|
||||||
|
btScalar getAngularPos() const { return m_angPos; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// access for ODE solver
|
// access for ODE solver
|
||||||
|
|||||||
Reference in New Issue
Block a user