[Solved] Exception when testing manifold points
Posted: Thu Apr 02, 2015 1:46 am
Hi,
I'm testing a simulation and trying to get contact infomation.
The code is written in C++/Cli and using BulletSharp version 2.83.
@ World setup
-------------------------------------------------------------------------------------------------------
void InitializePhysics()
{
CollisionConfig = gcnew DefaultCollisionConfiguration();
Dispatcher = gcnew CollisionDispatcher(CollisionConfig);
Broadphase = gcnew DbvtBroadphase();// For MLCP
DantzigSolver^ mlcp = gcnew DantzigSolver();
MlcpSolver^ sol = gcnew MlcpSolver(mlcp);
Solver = sol;
World = gcnew DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConfig);
World->Gravity = Vector3(0, -9.8, 0);
ContactSolverInfo^ SolverInfo = World->SolverInfo;
SolverInfo->MinimumSolverBatchSize = 1;// For MLCP
World->SetInternalTickCallback(gcnew BulletSharp::DynamicsWorld::InternalTickCallback(this, &PhysicsSimulation::MotorPreTickCallback), this, true);
// Do RigidBodies, Constraints initiate
// ...
}
-------------------------------------------------------------------------------------------------------
@ Simulation loop
-------------------------------------------------------------------------------------------------------
void simUpdate()
{
world->stepSimulation(stepTime);
int numManifolds = World->Dispatcher->NumManifolds;// OK
if (numManifolds > 0){
for (int i = 0; i < numManifolds; i++){
PersistentManifold^ contactManifold = World->Dispatcher->GetManifoldByIndexInternal(i);// heapfree error exeception here...
...
}
}
...
}
-------------------------------------------------------------------------------------------------------
An exception shows up everytime when executing this line:
"PersistentManifold^ contactManifold = World->Dispatcher->GetManifoldByIndexInternal(i);"
And the exception is a heapfree stack error in "free.c" file.
Shown in this screencapture: It always happened as the simulation began several seconds(1~5s randomly).
A world with only two rigidbodies(cube and ground) was tested, and the problem is still there.
I've look into the BulletSharp source code and find nothing wired...
Besides, the code runs fine in my C# version, but not in C++/Cli version.
Any ideas? Thanks!
I'm testing a simulation and trying to get contact infomation.
The code is written in C++/Cli and using BulletSharp version 2.83.
@ World setup
-------------------------------------------------------------------------------------------------------
void InitializePhysics()
{
CollisionConfig = gcnew DefaultCollisionConfiguration();
Dispatcher = gcnew CollisionDispatcher(CollisionConfig);
Broadphase = gcnew DbvtBroadphase();// For MLCP
DantzigSolver^ mlcp = gcnew DantzigSolver();
MlcpSolver^ sol = gcnew MlcpSolver(mlcp);
Solver = sol;
World = gcnew DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConfig);
World->Gravity = Vector3(0, -9.8, 0);
ContactSolverInfo^ SolverInfo = World->SolverInfo;
SolverInfo->MinimumSolverBatchSize = 1;// For MLCP
World->SetInternalTickCallback(gcnew BulletSharp::DynamicsWorld::InternalTickCallback(this, &PhysicsSimulation::MotorPreTickCallback), this, true);
// Do RigidBodies, Constraints initiate
// ...
}
-------------------------------------------------------------------------------------------------------
@ Simulation loop
-------------------------------------------------------------------------------------------------------
void simUpdate()
{
world->stepSimulation(stepTime);
int numManifolds = World->Dispatcher->NumManifolds;// OK
if (numManifolds > 0){
for (int i = 0; i < numManifolds; i++){
PersistentManifold^ contactManifold = World->Dispatcher->GetManifoldByIndexInternal(i);// heapfree error exeception here...
...
}
}
...
}
-------------------------------------------------------------------------------------------------------
An exception shows up everytime when executing this line:
"PersistentManifold^ contactManifold = World->Dispatcher->GetManifoldByIndexInternal(i);"
And the exception is a heapfree stack error in "free.c" file.
Shown in this screencapture: It always happened as the simulation began several seconds(1~5s randomly).
A world with only two rigidbodies(cube and ground) was tested, and the problem is still there.
I've look into the BulletSharp source code and find nothing wired...
Besides, the code runs fine in my C# version, but not in C++/Cli version.
Any ideas? Thanks!