valbok / bvh3

8 stars 1 forks source link

Stackoverflow error due to infinite recursion #1

Open mmmovania opened 2 months ago

mmmovania commented 2 months ago

Hey, I was trying to use your library for some work. I noticed that for simple cloth geometry, the buidtree function does not return from recursion and ultimately gives a stack overflow. My code is this may be I am doing anything wrong but you can take a look.

typedef NBvh3::KDop<16> TKDop16;
typedef NBvh3::Node<TKDop16> TNodeKDop16;
TNodeKDop16* pRoot;
NBvh3::TVertices triangles;
for (i = 0; i < indices.size(); i += 3) {
   glm::vec3 p1 = X[indices[i]];
   glm::vec3 p2 = X[indices[i + 1]];
   glm::vec3 p3 = X[indices[i + 2]];

   NBvh3::SVertex v1(p1.x, p1.y, p1.z);
   NBvh3::SVertex v2(p2.x, p2.y, p2.z);
   NBvh3::SVertex v3(p3.x, p3.y, p3.z);

   triangles.push_back(v1);
   triangles.push_back(v2);
   triangles.push_back(v3);
}
pRoot = NBvh3::buildTree<TKDop16>(triangles);

And this is the error that I get on my win10 x64 machine with MS Visual Studio 2019 community edition. image Any ideas on what could be causing this and how to fix this?

valbok commented 2 months ago

HI! Thanks for the interest. Could you please share a sample which crashes? Is it related to the indices?