Skip to content

Decomposition of a 6 points / 2 triangles giving strange results #147

@Pindrought

Description

@Pindrought

I am decomposing a window of a model of a vehicle I have.
image

For some reason, this is resulting in 8 convex hulls. I don't understand why this would ever be anything other than 1 convex hull.

It also seems to run slow in debug mode, but maybe that is just inevitable due to the STL. It takes about 13 seconds to process this mesh that is just a single face even when I am only using a recursion depth of 2.

I cannot provide the asset, because I do not have the rights to distribute it, but here is an example of code to process the same vertices from the primitive.

VHACD::IVHACD::Parameters params;
params.m_maxRecursionDepth = 2;
VHACD::IVHACD* vhacdInterface = VHACD::CreateVHACD();

std::vector<VHACD::Vertex> vertices = {
	{-0.068349301815032959, 0.77032583951950073, 0.23267269134521484 },	
	{-0.068349301815032959, 0.77032583951950073, 0.23267269134521484 },
	{-0.068349301815032959, 0.24485522508621216, 0.075129270553588867 },
	{-0.57871705293655396 ,0.24485522508621216 ,0.075129270553588867 },	
	{-0.57871705293655396 ,0.24485522508621216 ,0.075129270553588867 },	
	{-0.57871705293655396 ,0.77032572031021118 ,0.23267269134521484 }
};

std::vector<VHACD::Triangle> triangles = {
	{4, 2, 1 },
	{5, 3, 0 }
};

std::vector<double> points;
for (int i = 0; i < vertices.size(); i++)
{
	points.push_back(vertices[i].mX);
	points.push_back(vertices[i].mY);
	points.push_back(vertices[i].mZ);
}

std::vector<uint32_t> triangleIndices;
for (int i = 0; i < triangles.size(); i++)
{
	triangleIndices.push_back(triangles[i].mI0);
	triangleIndices.push_back(triangles[i].mI1);
	triangleIndices.push_back(triangles[i].mI2);
}

bool success = vhacdInterface->Compute(points.data(),
										points.size() / 3,
										triangleIndices.data(),
										triangleIndices.size() / 3,
										params);
if (success == true)
{
	int n = vhacdInterface->GetNConvexHulls();
	//^n = 8
}

Am I doing something wrong here or any ideas? Could all of the points lying on the same plane be causing issues here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions