Bullet HACD error

Post Reply
sky
Posts: 3
Joined: Mon May 12, 2014 7:32 am

Bullet HACD error

Post by sky »

Hi,everybody,I was using Bullet HACD to decomposition my concave object,but there was a problem, my program crashed!
5.png
5.png (17.69 KiB) Viewed 7241 times
and I found it crashed here:
6.png
6.png (47.64 KiB) Viewed 7241 times
But I didn't know why m_dummyVertex became a wild pointer here.
Here is my code:

btCompoundShape* DoDecomposition(double* aVertices, int aVerticesCount, int* aIndices, int aTriCount)
{
std::vector< HACD::Vec3<HACD::Real> > points;
std::vector< HACD::Vec3<long> > triangles;

for (int i = 0; i < aVerticesCount; i++)
{
int index = i * 3;
HACD::Vec3<HACD::Real> vertex(aVertices[index], aVertices[index + 1], aVertices[index + 2]);
points.push_back(vertex);
}

for (int i = 0; i < aTriCount; i++)
{
int index = i * 3;
HACD::Vec3<long> triangle(aIndices[index], aIndices[index + 1], aIndices[index + 2]);
triangles.push_back(triangle);
}

HACD::HACD myHACD;
myHACD.SetPoints(&points[0]);
myHACD.SetNPoints(points.size());
myHACD.SetTriangles(&triangles[0]);
myHACD.SetNTriangles(triangles.size());
myHACD.SetCompacityWeight(0.1);
myHACD.SetVolumeWeight(0.0);

// HACD parameters
// Recommended parameters: 2 100 0 0 0 0
size_t nClusters = 2;
double concavity = 100;
bool invert = false;
bool addExtraDistPoints = false;
bool addNeighboursDistPoints = false;
bool addFacesPoints = false;

myHACD.SetNClusters(nClusters); // minimum number of clusters
myHACD.SetNVerticesPerCH(100); // max of 100 vertices per convex-hull
myHACD.SetConcavity(concavity); // maximum concavity
myHACD.SetAddExtraDistPoints(addExtraDistPoints);
myHACD.SetAddNeighboursDistPoints(addNeighboursDistPoints);
myHACD.SetAddFacesPoints(addFacesPoints);

myHACD.Compute();
nClusters = myHACD.GetNClusters();
.....


Could anyone help me? Thanks!
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: Bullet HACD error

Post by gjaegy »

I have got the exact same issue here. I am currently trying to figure out what happens.

It seems to happen with a specific mesh only...
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Bullet HACD error

Post by Basroil »

Looks like it's trying to delete the previous/next vertex a second time, maybe m_size isn't decreasing properly and it's >1 when it should be == and therefore calling the previous/next during delete()?
gjaegy
Posts: 178
Joined: Fri Apr 18, 2008 2:20 pm

Re: Bullet HACD error

Post by gjaegy »

I have fixed the bug. See https://github.com/bulletphysics/bullet3/pull/277 for details.
Post Reply