Avoid Newton raycast crash with small triangles

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Avoid Newton raycast crash with small triangles

Postby pHySiQuE » Mon Oct 21, 2013 5:14 pm

In dgAABBPolygonSoup.cpp, you can change this function so it will not crash if a small triangle is encountered. The section inside the ================= lines is what I added:
Code: Select all
      DG_INLINE dgFloat32 RayDistance (const dgFastRayTest& ray, const dgTriplex* const vertexArray) const
      {
         //==========================================================
         //This prevents a crash when small triangles are encountered
         if (vertexArray == NULL) return dgFloat32(1.2f);
         //==========================================================
         dgVector minBox (&vertexArray[m_indexBox0].m_x);
         dgVector maxBox (&vertexArray[m_indexBox1].m_x);
         return ray.BoxIntersect(minBox, maxBox);
      }
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Avoid Newton raycast crash with small triangles

Postby Julio Jerez » Mon Oct 21, 2013 5:17 pm

On what line of ray.BoxIntersect funtion it crashes.

It should not crash regarless of the triangle size. that will be a seriuslly bad bug.
and how testing for the vertex array being NULL willcan detect a small triangle (vertexArray == NULL)

adding that test there should no nesssary, a NULL vertex array should be checked before that function is called because that funtion is part of the
backbone of the face quieries, OBB quieries, and almoslt every colling function that clip a line against the OBB of a shape or a tree node.
for most those cases vertexArray is a non NULL constant pointer. What funtion were you calling that cases that crash?
That fix is not right.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Avoid Newton raycast crash with small triangles

Postby pHySiQuE » Tue Nov 05, 2013 11:40 pm

I think this was being caused by a model that had a lot of "tags" in the hierarchy. Each "tag" was a separate object in the model that only had a single triangle, with the vertices all at the position (0,0,0).

http://www.leadwerks.com/werkspace/topi ... entry61770

If you don't have an account for our forum just let me know and I will create one for you. But I think I did already.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Avoid Newton raycast crash with small triangles

Postby Julio Jerez » Wed Nov 06, 2013 8:26 am

what is a tag?

this is what I get when I click the link
Sorry, we couldn't find that!
[#103139]
You do not have permission to view this forum.
Need Help?
•Click here to log in
•Our help documentation
•Contact the community administrator
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Avoid Newton raycast crash with small triangles

Postby pHySiQuE » Fri Nov 15, 2013 3:10 am

By "tag" I mean an object in the hierarchy with a single triangle with all three points at 0,0,0. Some modeling programs export things this way.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Avoid Newton raycast crash with small triangles

Postby Julio Jerez » Fri Nov 15, 2013 11:38 am

are you trying to cast a triangle with three equal vertices? that's no a triangle, that's a point
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Avoid Newton raycast crash with small triangles

Postby pHySiQuE » Fri Nov 15, 2013 11:51 am

I'm aware of that, but all my users know is their model they got from Turbosquid crashes my program.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Avoid Newton raycast crash with small triangles

Postby Julio Jerez » Fri Nov 15, 2013 12:24 pm

there are some very dirty meshes out there, for that newton has a tool that can be use to precondition mesh.
newtonMesh, you simple make the mesh and call remove joint, or triangulate. this will make and optimal triangulation.
you can use that to detect bad faces for filter then or fix the mesh.
the you can call NewtonCollision* NewtonCreateTreeCollisionFromMesh (const NewtonWorld* const newtonWorld, const NewtonMesh* const mesh, int shapeID);
and than will make a more rigorous collision tree the simple begine/end

I believe that newton collision tree does has some limited mesh cleanup, but it can no be as rigorous as what newton Mesh does because collision tree has to be fast.
you can also create the newton mesh and call save OFF and sned it to me so that I can debug it.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron