Page 1 of 1
btGjkEpaSolver2 error
Posted: Thu Aug 28, 2008 12:22 am
by sandeep_slash
I'm doing a simple collision check between a composite object and a BvhTriangleMesh in my app.
I don't know why, but I'm getting this error in btGjkEpaSolver2::Penetration(....)
Code: Select all
Run-Time Check Failure #2 - Stack around the variable 'gjk' was corrupted.
Run-Time Check Failure #2 - Stack around the variable 'epa' was corrupted.
Re: btGjkEpaSolver2 error
Posted: Thu Aug 28, 2008 1:50 am
by Nathanael
You have to provide more information and/or code sample to reproduce the problem.
Re: btGjkEpaSolver2 error
Posted: Sat Aug 30, 2008 1:02 am
by sandeep_slash
Alrite,
This is the stuff which I tried in one of the BulletDemos and it works fine....
Code: Select all
btCollisionShape* pBoxShape;
btCollisionShape* pCylinderShape;
btTransform childTransform;
m_pParentShape = new btCompoundShape;
btTransform parentTransform;
parentTransform.setIdentity();
parentTransform.setOrigin(btVector3(0, 5, 0));
//Body Part1
pBoxShape = new btBoxShape(btVector3(1.73667014, 0.848335028, 1.68590808));
childTransform.setIdentity();
childTransform.setOrigin(btVector3(0, 0.710668027, -1.82743204));
m_pParentShape->addChildShape(childTransform, pBoxShape);
//Body Part2
pBoxShape = new btBoxShape(btVector3(1.48286009, 1.10214508, 1.86357510));
childTransform.setIdentity();
childTransform.setOrigin(btVector3(0, 0.888335049, 0));
m_pParentShape->addChildShape(childTransform, pBoxShape);
//Body Part3
pBoxShape = new btBoxShape(btVector3(1.60976505, 0.340715021, 1.22905004));
childTransform.setIdentity();
childTransform.setOrigin(btVector3(0, 0.634525001, 1.71321750));
m_pParentShape->addChildShape(childTransform, pBoxShape);
//Wheel1
pCylinderShape = new btCylinderShape(btVector3(0.416858017, 0.213810027, 0.416858017));
//childTransform.setIdentity();
childTransform.getBasis().setRotation(btQuaternion(0, 0.707, 0.0, 1.0));
childTransform.setOrigin(btVector3(0.989859045, 0.225648522, 1.57362199));
m_pParentShape->addChildShape(childTransform, pCylinderShape);
//Wheel2
pCylinderShape = new btCylinderShape(btVector3(0.416858017, 0.213810027, 0.416858017));
//childTransform.setIdentity();
childTransform.getBasis().setRotation(btQuaternion(0, 0.707, 0.0, 1.0));
childTransform.setOrigin(btVector3(-0.989859045, 0.225648522, 1.57362199));
m_pParentShape->addChildShape(childTransform, pCylinderShape);
//Wheel3
pCylinderShape = new btCylinderShape(btVector3(0.416858017, 0.213810027, 0.416858017));
//childTransform.setIdentity();
childTransform.getBasis().setRotation(btQuaternion(0, 0.707, 0.0, 1.0));
childTransform.setOrigin(btVector3(0.989859045, 0.225648522, -1.57362199));
m_pParentShape->addChildShape(childTransform, pCylinderShape);
//Wheel4
pCylinderShape = new btCylinderShape(btVector3(0.416858017, 0.213810027, 0.416858017));
//childTransform.setIdentity();
childTransform.getBasis().setRotation(btQuaternion(0, 0.707, 0.0, 1.0));
childTransform.setOrigin(btVector3(-0.989859045, 0.225648522, -1.57362199));
m_pParentShape->addChildShape(childTransform, pCylinderShape);
m_collisionShapes.push_back(m_pParentShape);
m_pParentBody = DemoApplication::localCreateRigidBody(1.0f, parentTransform, m_pParentShape);
I've the same stuff in my game, running on the XBOX 360. I'm doing collision between this composite object and a static BvhTriangleMesh....
Re: btGjkEpaSolver2 error
Posted: Sun Aug 31, 2008 12:44 am
by Nathanael
I can see two likely possibilities for your problem:
1- when GjkEpa2::Penetration is called , there's just not enough stack space free to allocation instances of epa on it, if so, you can try to allocate epa on the heap, here's a quick patch to test that:
Code: Select all
case GJK::eStatus::Inside:
{
EPA& epa(*(new EPA()));
EPA::eStatus::_ epa_status=epa.Evaluate(gjk,-guess);
if(epa_status!=EPA::eStatus::Failed)
{
btVector3 w0=btVector3(0,0,0);
for(U i=0;i<epa.m_result.rank;++i)
{
w0+=shape.Support(epa.m_result.c[i]->d,0)*epa.m_result.p[i];
}
results.status = sResults::Penetrating;
results.witnesses[0] = wtrs0*w0;
results.witnesses[1] = wtrs0*(w0-epa.m_normal*epa.m_depth);
results.normal = -epa.m_normal;
results.distance = -epa.m_depth;
delete &epa;
return(true);
} else { delete &epa;results.status=sResults::EPA_Failed; }
}
2- EPA has a bug, and address epa::m_sv_store and/or epa::m_fv_store beyond allocated limits.
Its unlikely but possible, if patch#1 doesn't work, that the next thing to look at.
Hope it help,
Nathanael.
Re: btGjkEpaSolver2 error
Posted: Tue Sep 02, 2008 7:34 pm
by sandeep_slash
Thanks for your reply Nathanael...
The problem is, it never comes inside the switch(gjk_status) statement. gjk_status is always "Valid"
One more thing I noticed is, in eStatus::_ Evaluate(const tShape& shapearg,const btVector3& guess)
shapearg.m_shapes looks invalid....
When I enable Win32ThreadSupport, it crashes in SpuCollisionShapes.cpp
int getShapeTypeSize(int shapeType) ===> //unsupported shapetype, please add here
I guess itz a common problem related to collision shape
Re: btGjkEpaSolver2 error
Posted: Tue Sep 02, 2008 7:54 pm
by sandeep_slash
in btGjkEpaSolver2::Penetration() func...
I tried stepping through gjk.Evaluate(...) function, and it actually stepped into (SpuGjkEpa2.cpp) eStatus::_ Evaluate()...
Thatz quite strange coz I've disabled MultiThreaded support.....
So I guess therez something wrong with my implementation.....
Re: btGjkEpaSolver2 error
Posted: Tue Sep 02, 2008 9:54 pm
by sandeep_slash
Nevermind... I fixed the issue..
thnx..