Hi.
I'm trying to incorporate BulletCollision Library into my Multibody dynamics code.
In doing so, I got the following runtime error:
Assertion failed: (unsigned char*)ptr >= m_pool && (unsigned char*)ptr < m_pool + m_maxElements * m_elemSize, file d:\pirocore\publiccodes\bullet-2.62\src\linearmath\btpoolallocator.h, line 66
I have no idea why this happens.
The situation is as follows:
[1] in initializing simulator, I register the alternative BoxBoxCollisionAlgorithm by
...
((btCollisionDispatcher *) gworld->getDispatcher())->registerCollisionCreateFunc(BOX_SHAPE_PROXYTYPE, BOX_SHAPE_PROXYTYPE, new BoxBoxCollisionAlgorithm::CreateFunc);
...
[2] in every simulation step. collision() is called coded as follows:
void mySimulator::collision()
{
// First reserve the previous contact data
contactdyn->ReserveContacts();
bool post_collision = contactdyn->IsPostCollision();
// Next, find a current contact data
if (gworld)
gworld->performDiscreteCollisionDetection();
int numManifolds = gworld->getDispatcher()->getNumManifolds();
// Candidate contacts
std::vector<ContactInfo *> contacts;
for (int i = 0; i < numManifolds; i++)
{
btPersistentManifold* contactManifold = gworld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
contactManifold->refreshContactPoints(obA->getWorldTransform(),obB->getWorldTransform());
Body *bodyA = static_cast<Body *>(obA->getUserPointer());
Body *bodyB = static_cast<Body *>(obB->getUserPointer());
int numContacts = contactManifold->getNumContacts();
if (numContacts == 0)
continue;
for (int j = 0; j < numContacts; j++)
{
btManifoldPoint& pt = contactManifold->getContactPoint(j);
btVector3 ptA = pt.getPositionWorldOnA();
btVector3 ptB = pt.getPositionWorldOnB();
Vector3D normal(pt.m_normalWorldOnB.x(), pt.m_normalWorldOnB.y(), pt.m_normalWorldOnB.z());
HTransform T_0_2C1;
ContactFrameByNormal(normal, T_0_2C1.R);
T_0_2C1.r.Set(ptB.x(), ptB.y(), ptB.z());
ContactInfo *contact = NULL;
contact = new ContactInfo(bodyA, bodyB, ContactInfo::VF, T_0_2C1, 0.0, new ContactID_Cube());
contacts.push_back(contact);
//you can un-comment out this line, and then all points are removed
//contactManifold->clearManifold();
// collsiion and contact resolution algorithm follows...
}
[3] After free falling being followd by collision with the ground, the Assertion failed error happens
after a while. The screen looks as follows:
t = 0.4470
t = 0.4480
t = 0.4490
t = 0.4500
t = 0.4510
t = 0.4520 <-- collision here
dVector(v_post : dim +12)
-1.2313 -0.7130 -1.3302 -1.2313 +0.7130 -1.3302 +1.2313 +0.7130 -1.3302 +1.2313 -0.7130 -1.3302
dVector(V_pre : dim +6)
+0.0000 -4.4341 +0.0000 +0.0000 +0.0000 +0.0000
dVector(V_post : dim +6)
+0.0000 +1.3302 -0.0000 -0.0000 -0.0000 +0.0000
t = 0.4520 <-- after collision resolution, free states
t = 0.4530
t = 0.4540
t = 0.4550
t = 0.4560
t = 0.4570
t = 0.4580
t = 0.4590
t = 0.4600
t = 0.4610
t = 0.4620
t = 0.4630
t = 0.4640
t = 0.4650
t = 0.4660
t = 0.4670
Assertion failed: (unsigned char*)ptr >= m_pool && (unsigned char*)ptr < m_pool + m_maxElements * m_elemSize, file d:\pirocore\publiccodes\bullet-2.62\src\linea
rmath\btpoolallocator.h, line 66
----------------------
Another question:
The reason using the alternative BoxBoxCollisionAlgorithm is that it gives the exact number of contacts, e.g. 4 for a face of the cube is in contact with the ground, whereas the default
algorithm gives only one. Is there any way to generate the four contacts for the default algorithm ?
Thanks in advance..
Error in btPoolAllocator.h with alternative BoxBoxCollision
-
- Posts: 1
- Joined: Wed Oct 03, 2007 2:37 pm