Page 1 of 1

[Solved] Exception when testing manifold points

Posted: Thu Apr 02, 2015 1:46 am
by IresomPCH
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:
exception2.png
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. :shock:

Any ideas? Thanks!

Re: Exception when testing manifold points

Posted: Mon May 11, 2015 1:24 am
by IresomPCH
Update:

After rebuild the BulletSharp.dll with the latest bullet3(20150507-2.83.4)+BulletSharp(20150508), it seems to solved the problem. :lol:
A recent commit of BulletSharp solve the issue. The manifold related codes now work fine !