Fixing a bad mesh

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Fixing a bad mesh

Postby Slick » Thu Nov 21, 2013 8:29 pm

I have a mesh that creates an assert when bringing it into Newton. It is quite a large world mesh. It has worked in prior versions of Newton. How would I go about working out where in the mesh the badly formed triangle or whatever is so I can fix it?
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: Fixing a bad mesh

Postby Julio Jerez » Thu Nov 21, 2013 9:24 pm

can you save it as on off file?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fixing a bad mesh

Postby Slick » Fri Nov 22, 2013 12:36 pm

I'll see if I can. Here is the assert.

11-22-2013 8-34-24 AM.png
11-22-2013 8-34-24 AM.png (8.32 KiB) Viewed 4730 times
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: Fixing a bad mesh

Postby Julio Jerez » Fri Nov 22, 2013 2:47 pm

Oh that is a face areas is almos zero, it coe be a face in te himput mesh, or a face resulting from a prossess.
can I see the trace stack, because Sanity is called form many places.
also if you save the Mesh as a OFF, I will import teh mesh eactuly as it is in the mesh format, whi mean I can recrate the and reproduce the error.

in general the wath to fix the mesh is my calling void NewtonMeshFixTJoints (const NewtonMesh* const mesh)
after it is created, or after some funtion is applied to the mesh.

try to save it as an OFF file. by calling this function
void NewtonMeshSaveOFF(const NewtonMesh* const mesh, const char* const filename)
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fixing a bad mesh

Postby Julio Jerez » Sun Nov 24, 2013 3:57 pm

I load the OFF in the editor , by I did no see any assert, what operation do did you do that caused the assert.
can you show me the trace start that lest to the assert?

when you load the mesh did you call NewtonMeshFixTJoints (mesh); after you load it?
That the function that is use to repair meshes with anomally

This is how it looks in the editor
city.png
city.png (69.42 KiB) Viewed 4693 times
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fixing a bad mesh

Postby Slick » Sun Nov 24, 2013 7:09 pm

I'll try the NewtonMeshFixTJoints function. I'll also see if I can get you a trace.
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: Fixing a bad mesh

Postby Slick » Mon Nov 25, 2013 12:34 pm

I will try and check this today. It just occurred to me because it is an assert did you run the model editor in debug so you could catch asserts? I think in release the model loaded for me too.
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: Fixing a bad mesh

Postby Julio Jerez » Mon Nov 25, 2013 1:05 pm

I run in debug yes.

also when you test again, first sync to SVN so that we test wit the same code, I made a bunch of changes,
this is the code I pasted in the editor to test the error

file ..\newton-dynamics\applications\modelEditor\standardPlugins\dImportExporters\OffExportImport.cpp
Code: Select all
bool OffImport::Import (const char* const fileName, dPluginInterface* const interface)
{
   dScene* const scene = interface->GetScene();
   dAssert (scene);
   NewtonWorld* const world = scene->GetNewtonWorld();
   NewtonMesh* const mesh = NewtonMeshLoadOFF (world, fileName);
   if (mesh) {
      // some OFF files are vert dirty, make sure we do not have any degenerated faces
/*
NewtonMesh* xxx = mesh;
NewtonCollision* collision = NewtonCreateConvexHullFromMesh (world, xxx, 0, 0);
NewtonMesh* xxx1 = NewtonMeshCreateFromCollision(collision);
NewtonMeshTriangulate (xxx1);
int vertexCount = NewtonMeshGetVertexCount(xxx1);
int actualCount = 0;
for (void* vertex = NewtonMeshGetFirstVertex(xxx1); vertex; vertex = NewtonMeshGetNextVertex(xxx1, vertex))
{
   ++actualCount;
}
dAssert(actualCount == vertexCount );
*/

      NewtonMeshFixTJoints (mesh);

      dPluginScene* const asset = new dPluginScene(world);

      dString name (GetNameFromPath(fileName));
      name = name.SubString (0, name.Find ('.'));
      
      dPluginScene::dTreeNode* const sceneNode = asset->CreateSceneNode (asset->GetRoot());
      dSceneModelInfo* const sceneNodeInfo = (dSceneModelInfo*) asset->GetInfoFromNode(sceneNode);
      sceneNodeInfo->SetName(name.GetStr());   

      dPluginScene::dTreeNode* const meshNode = asset->CreateMeshNode(sceneNode);
      dMeshNodeInfo* const instance = (dMeshNodeInfo*) asset->GetInfoFromNode(meshNode);
      instance->SetName ((name + "_mesh").GetStr());
      instance->ReplaceMesh (mesh);

      interface->MergeScene (asset);
      asset->Release();

      return true;
   }

   return false;
}



if you open the editor project and you build in debug, you can uncomment the code fragment and see if the assert happens.
remember to build the editor in debug first.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fixing a bad mesh

Postby Julio Jerez » Mon Nov 25, 2013 1:22 pm

another thing, this is for when after we after we fin this bug.
if you take you meshes and you convet the to newton mesh and then you call convert to polygon, the until will clean up the mesh mush better that what newton collsion trees does.
in generate the mesh becomes or the order of tree time smaller and the collision is far superior and faster, fewer contacts and better shared edges across faces
I quickly did that in the editor and this is how clean it looks
city.png
city.png (62.82 KiB) Viewed 4667 times
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fixing a bad mesh

Postby Slick » Mon Nov 25, 2013 1:29 pm

Yep that looks much cleaner. I haven't had a chance today to try in my code but I will. I see you call NewtonMeshTriangulate is that the same as "call convert to polygon" that you referenced. I also see you mentioned NewtonMeshFixTJoints.

What is the preferred list of functions to call?

The other day I tried to load .off to the editor but I didn't see any option to load it.

I haven't synched to SVN since 11/06 so let's see.
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: Fixing a bad mesh

Postby Julio Jerez » Mon Nov 25, 2013 2:53 pm

In newton SDK these two function complement each other.
Code: Select all
void NewtonMeshPolygonize (const NewtonMesh* const mesh);
void NewtonMeshTriangulate (const NewtonMesh* const mesh);


as of last night only NewtonMeshPolygonize was calling FixTJoint afte teh trigulation an dtha was a suttle bug that I fixed.

if you do not want your mesh topology to be changed, but you want anomalies to be fixed, you can call
Code: Select all
void NewtonMeshFixTJoints (const NewtonMesh* const mesh);


If you open the editor, in the File menu you will see Import/Export submenu, you can chose any of the file format listed
so far it has .off, .obj, .fbx, .dae and direct mesh serialization

after you load you mesh, you can select any submesh ( a child of a scene node) and from the meny you can triangulate or convert it mesh to polygons.

you say you have not updated in some time, that may be why I do not see the problem,
it may have being fiexed inderectly or some change move the bug to a different place.

The model editor is still a work in progress, after I complete the fbx imports export plugin,
I will add the Inspector window so that more command can me apply to meshes, so far it is still very limited. but you can see where it is heading to.

the one thing that the editor already do is that It can be use to fix meshes that otherwise are hard to fix using
modeling package like 3dsMas, maya, or blender.
for that you can write in that let you import or export to you format, for that there is FBX plugin is an example but it is too complex.
I will write a very simple plugin to import export to simple format so that people use as example to make their own plugins.
I will probably use some made up ascii format similar to what 3dxmax do.

On reason to call convert to polygon on a mesh that was a polygonal mesh when exported from a modeling packages like max,
is that those packages can deal with polygons that are not really flat convex faces, but if you use a faces like that to make a collision,
then it will be an ill formed face that will fail collision at some point.
newton collsion tree optimized does not deal with that, but newtonMesh do.

if the mesh was a triangular mesh to begin with, as most mesh are, then there is not problem,
but you still want to turn it in a polygonal mesh for faster and better contact calculations.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Fixing a bad mesh

Postby Slick » Mon Nov 25, 2013 3:53 pm

I think that one point that the assert was called on was a point in the perimeter wall around the mesh that I sent you. It is that simple tall wall that wraps around the edge of the entire mesh in the picture.

I will update to latest SVN and report back after I have a chance to test.
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: Fixing a bad mesh

Postby Slick » Tue Nov 26, 2013 1:45 pm

It looks like the same assert after updating to SVN r1284.

11-26-2013 9-44-13 AM.png
11-26-2013 9-44-13 AM.png (82.41 KiB) Viewed 4646 times
Slick
 
Posts: 330
Joined: Sat Feb 07, 2004 7:24 pm
Location: LA last and France now

Re: Fixing a bad mesh

Postby Julio Jerez » Tue Nov 26, 2013 2:05 pm

use my mistake, I chek in somethonmg that was no complete. I put the hack back in until I fix that bug.
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 0 guests

cron