dgCollisionBVH::GetCollidingFaces m_meshData

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby arkeon » Sat Oct 25, 2014 12:56 pm

No for now I could not, the hand is controlled with a leapmotion.
and I don't know the sandbox tools and api enough to make this quickly.

I'll do some more test removing things step by step and see when the bug stop.

For now I know that remove the return 0 from the onAABBOverlap remove the bug. but not sure this is the only related thing. the collision on the body is disabled in the callback when the hand is lost.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby arkeon » Sat Oct 25, 2014 1:04 pm

ho sometimes the hand act strangely just like the collision hapend between the hand box or finger and the collision tree. but the collision seems to be the 1:1 scale not the current scale.

I'll try to make a video to be more precise.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby arkeon » Sat Oct 25, 2014 1:38 pm

The hand here have only a box and a part of the first finger with a ball and socket joint.
The hand position is controlled by forces and torque.

arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby Julio Jerez » Sat Oct 25, 2014 2:38 pm

Is the problem a crash of a bad behavior?
has you implement a function to show the contacts. There are examples in PhysicsUtils.cpp file.
Julio Jerez
Moderator
Moderator
 
Posts: 11048
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby arkeon » Sat Oct 25, 2014 2:41 pm

the real problem is the crash :)
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby Julio Jerez » Sat Oct 25, 2014 3:19 pm

can you send me a runtime demo that is linked to the DLLs?
Julio Jerez
Moderator
Moderator
 
Posts: 11048
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby arkeon » Sat Oct 25, 2014 3:22 pm

Do you have a leap motion ?

I'm trying to reproduce this in the sample demos. But i'm not sure of what produce the case.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby arkeon » Sat Oct 25, 2014 4:11 pm

Yes ! I could reproduce the issue in the sandbox !

the resources link is in my other post

take the box with the ballandsocket joint, and make it touch the collision tree several times.
The virtual call issue happen.
Code: Select all
int bEnableContact = 1;

static int UserOnAABBOverlap (const NewtonMaterial* const material, const NewtonBody* const body0, const NewtonBody* const body1, int threadIndex)
{
   return bEnableContact = !bEnableContact;
}

void VirtualCallIssue (DemoEntityManager* const scene)
{
   // load the skybox
   scene->CreateSkyBox();

   NewtonBody* const body = CreateLevelMesh (scene, "flatPlane.ngd", true);

   dMatrix originMatrix;
   NewtonBodyGetMatrix(body, &originMatrix[0][0]);

   dMatrix camMatrix (dRollMatrix(-20.0f * 3.1416f /180.0f) * dYawMatrix(180.0f * 3.1416f /180.0f));
   dQuaternion rot (camMatrix);
   dVector origin (originMatrix.m_posit);
   dFloat hight = 1000.0f;
   origin = FindFloor (scene->GetNewton(), dVector (origin.m_x, hight, origin .m_z, 0.0f), hight * 2);
   

   dVector location (origin);
   location.m_x -= 0.0f;
   location.m_z -= 0.0f;
   location.m_y += 1.0f;

   int defaultMaterialID = NewtonMaterialGetDefaultGroupID (scene->GetNewton());
  NewtonMaterialSetCollisionCallback (scene->GetNewton(), defaultMaterialID, defaultMaterialID, NULL, UserOnAABBOverlap, NULL);

   dMatrix matrix (dGetIdentityMatrix());
   matrix.m_posit = location;
   matrix.m_posit.m_x = 0.0f;
   matrix.m_posit.m_y = 0.8f;
   matrix.m_posit.m_z = 0.0f;
   matrix.m_posit.m_w = 1.0f;

  NewtonCollision* seatcol = 0;
   char pathName[2048];
   GetWorkingFileName ("seat.col", pathName);

  float scale = 0.001f;

  FILE* file = fopen(pathName, "rb");
   seatcol = NewtonCreateCollisionFromSerialization (scene->GetNewton(), DemoEntityManager::DeserializeFile, file);
   fclose (file);

  if (seatcol)
  {
    NewtonMesh* nmesh = NewtonMeshCreateFromCollision(seatcol);
    DemoMesh* const visualMesh = new DemoMesh(nmesh);
     for (int i = 0 ; i < visualMesh->m_vertexCount; i ++) {
        visualMesh->m_vertex[i * 3 + 0] *= scale;
        visualMesh->m_vertex[i * 3 + 1] *= scale;
        visualMesh->m_vertex[i * 3 + 2] *= scale;
     }
     // re-optimize for render
     visualMesh->OptimizeForRender();

    NewtonBodySetCollisionScale(CreateSimpleSolid(scene, visualMesh, 10.0f, matrix, seatcol, 0), scale, scale, scale);
    NewtonBodySetMaterialGroupID(body, defaultMaterialID);

    visualMesh->Release();
    NewtonMeshDestroy(nmesh);
    NewtonDestroyCollision(seatcol);
  }

  NewtonCollision* groundcol = 0;
  matrix.m_posit.m_y = 1.0f;
 
  GetWorkingFileName ("support.col", pathName);
  file = fopen(pathName, "rb");
   groundcol = NewtonCreateCollisionFromSerialization (scene->GetNewton(), DemoEntityManager::DeserializeFile, file);
   fclose (file);

  scale = 0.5f;
  if (groundcol)
  {
    NewtonMesh* nmesh = NewtonMeshCreateFromCollision(groundcol);
    DemoMesh* const visualMesh = new DemoMesh(nmesh);
     for (int i = 0 ; i < visualMesh->m_vertexCount; i ++) {
        visualMesh->m_vertex[i * 3 + 0] *= scale;
        visualMesh->m_vertex[i * 3 + 1] *= scale;
        visualMesh->m_vertex[i * 3 + 2] *= scale;
     }
     // re-optimize for render
     visualMesh->OptimizeForRender();
    NewtonBody* body = CreateSimpleSolid(scene, visualMesh, 0.0f, matrix, groundcol, 0);
    NewtonBodySetCollisionScale(body, scale, scale, scale);
    NewtonBodySetContinuousCollisionMode(body, 1);
    NewtonBodySetMaterialGroupID(body, defaultMaterialID);

    visualMesh->Release();
    NewtonMeshDestroy(nmesh);
    NewtonDestroyCollision(groundcol);
  }

  dMatrix shapeOffsetMatrix (dRollMatrix(3.141592f/2.0f));
  dVector size(0.1f, 0.1f, 0.1f, 1.0f);
  NewtonCollision* boxcol = CreateConvexCollision(scene->GetNewton(), &shapeOffsetMatrix[0][0], size, _BOX_PRIMITIVE, defaultMaterialID);
  NewtonBody* boxbody = 0;
  if (boxcol)
  {
    NewtonMesh* nmesh = NewtonMeshCreateFromCollision(boxcol);
    DemoMesh* const visualMesh = new DemoMesh(nmesh);
     for (int i = 0 ; i < visualMesh->m_vertexCount; i ++) {
        visualMesh->m_vertex[i * 3 + 0] *= scale;
        visualMesh->m_vertex[i * 3 + 1] *= scale * 0.5f;
        visualMesh->m_vertex[i * 3 + 2] *= scale;
     }
     // re-optimize for render
     visualMesh->OptimizeForRender();

    boxbody = CreateSimpleSolid(scene, visualMesh, 10.0f, matrix, boxcol, 0);
    NewtonBodySetCollisionScale(boxbody, scale * 0.5f, scale, scale * 0.5f);
    NewtonBodySetContinuousCollisionMode(boxbody, 1);

    visualMesh->Release();
    NewtonMeshDestroy(nmesh);
    NewtonDestroyCollision(seatcol);
  }

  matrix.m_posit.m_x = 0.05f;
  NewtonCollision* spherecol = CreateConvexCollision(scene->GetNewton(), &shapeOffsetMatrix[0][0], size, _SPHERE_PRIMITIVE, defaultMaterialID);
  NewtonBody* spherebody = 0;
  if (spherecol)
  {
    NewtonMesh* nmesh = NewtonMeshCreateFromCollision(spherecol);
    DemoMesh* const visualMesh = new DemoMesh(nmesh);
     for (int i = 0 ; i < visualMesh->m_vertexCount; i ++) {
        visualMesh->m_vertex[i * 3 + 0] *= scale * 0.5f;
        visualMesh->m_vertex[i * 3 + 1] *= scale;
        visualMesh->m_vertex[i * 3 + 2] *= scale * 0.5f;
     }
     // re-optimize for render
     visualMesh->OptimizeForRender();

    spherebody = CreateSimpleSolid(scene, visualMesh, 10.0f, matrix, spherecol, 0);
    NewtonBodySetCollisionScale(spherebody, scale * 0.5f, scale, scale * 0.5f);
    NewtonBodySetContinuousCollisionMode(spherebody, 1);

    visualMesh->Release();
    NewtonMeshDestroy(nmesh);
    NewtonDestroyCollision(seatcol);
  }

   dMatrix pinMatrix (dGrammSchmidt (dVector (0.0f, -1.0f, 0.0f, 0.0f)));

   // link the two boxes
   dMatrix matrix0;
  dMatrix matrix1;
  NewtonBodyGetMatrix (boxbody, & matrix0[0][0]);
   NewtonBodyGetMatrix (spherebody, & matrix1[0][0]);
   pinMatrix.m_posit = (matrix0.m_posit + matrix1.m_posit).Scale(0.5f);
   new CustomBallAndSocket(pinMatrix, boxbody, spherebody);

   origin.m_x += 1.0f;
  origin.m_y += 1.0f;
   scene->SetCameraMatrix(rot, origin);
}
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby arkeon » Mon Oct 27, 2014 1:48 pm

Were you able to produce it ?
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby Julio Jerez » Mon Oct 27, 2014 8:10 pm

I think I know what it is but I did not have time for fixed.
This is a more complex problem.

I fact is ha nothing to do with scaling, you can test it by setting the scale of the seat to 1, and let it drop of the floor, you will see that that four small legs one is always penetration the floor. this is because the contact count exceed the maximum. an the heuristic for rejection too many contact for compounds is no very good.
Julio Jerez
Moderator
Moderator
 
Posts: 11048
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby arkeon » Tue Oct 28, 2014 4:07 am

ho ok, so when the maximum contact is reached the contact list become corrupted ?
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby Julio Jerez » Tue Oct 28, 2014 9:48 am

that's seem to be, but is not that simple as increasing the max contact size as will no solve the problem and will make other thing worse.

I believe the Max contact t size for a shape is reduced to 8 or 16 (do no remember)but at you can see when the seat land on the floor is collect at least 16, so is at least one more is collected then some have to be remove and It may remove an essencial one.

what it needs it an algorithm to better select the essential contacts and discriminate redundant contacts.
There are few way to do that, one is by solving as a complementarity program or a simplex or a linear programing problem, the pother is but using geometrical heuristic which is what is using now
The geometric heuristic is good for single convex shape shapes, because ether locus of all contact is a convex polygon, so it is easy to eliminate non essential contact by using a polygon deduction algorithm. For a compound shape the same algorithm generate unpredictable result, and I believe that the problem.

I will solve it, but I can no do during the week, it will have to be the weekend. This is similar to the problem of object placement that Bird asked me before so the engine has all the functionality already.
Julio Jerez
Moderator
Moderator
 
Posts: 11048
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby Julio Jerez » Tue Oct 28, 2014 9:55 am

her is a question, is there a reason why you use scale that are so extreme?

the seat is using a scale of 0.001 (that on is one thousand)
what I use a scale 0f 0.01 the seat land prefect on the floor, so I am thinkng that maybe the problem is that the scale is so big that the contact solver start see problem with tolerances
Julio Jerez
Moderator
Moderator
 
Posts: 11048
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby arkeon » Tue Oct 28, 2014 10:11 am

We do not control the original size of the imported object, (obj, fbx..) it depend of the modeler parameters. So to scale is high to rescale the mesh in meter units. So it can happen often.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby Julio Jerez » Tue Oct 28, 2014 10:15 am

do you have a scale feature? you can use the Newton Mesh as a inutility to scale arbitrary meshes
that seat is made in millimeters but even at that scale it look tiny when is put is the scene.

basically you have an object that is already small but that it using are really large.
Julio Jerez
Moderator
Moderator
 
Posts: 11048
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 2 guests