dgCollisionBVH::GetCollidingFaces m_meshData

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: dgCollisionBVH::GetCollidingFaces m_meshData

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

I scaled it that small for the sample and show the issue.
but typically I was not using scale function in newton 2, so the mesh scale was set on vertices while the collision creation. Scaling the mesh at runtime offer a lot of possibilities this is why I switch the collision creation to use the body scale feature.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

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

you can still use scale, but with in reasonable ranges, a scale factor of 0.001 mean that the values are on eh order of 1000, using or so, so internally the engine end up dealing with values that really large and really small.

while scale is a arithmetic thing in practice you can no have arvitrally large or arbitrary small scale and some point you have to hold the number with some representation and you stat losing Presidion.

this is part of what is happing the seat has value that are really big compared to the but when scale they become tiny, and the since contact tolerance is about 0.001 the solve can no fin a good contact for the four small legs.

can you set up the demo again with a more reasonable scale?

in my test I scaled by ten, and it seem to works fine.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgCollisionBVH::GetCollidingFaces m_meshData

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

hmm, you mean applying a scale ratio on collision creation to get larger collisions and then apply the scale difference ?
like creating collision with a * 10.0 scale on vertices and apply a 0.1 scale on body after creation ?
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

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

I could determine the ratio with the object bounding box I think, to always create a collision of 10 meter size for example.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby Julio Jerez » Tue Oct 28, 2014 12:05 pm

what is suppose to be the size of the seat, the way I see the enter seat is or the order of few centimeters in size, this mean that the legs are of eth order of milimeters
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby arkeon » Tue Oct 28, 2014 1:16 pm

the scale in the 3D scene for the seat is 0.01 to match in meter, so the feets must be some centimeter. and it's working correctly in my scene.

But the real problem focused in this sample is not the seat (I should removed it) but the box with the joint that trigger the virtual call crash when colliding on the collision tree. since the collision tree.

I don't think the crash happen with the seat, only with the box with joint.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby Julio Jerez » Tue Oct 28, 2014 1:37 pm

yes, but in the demo you made the scale 0.001, and that make feet millimeters which is too close to the collision tolerances.
when I set to 0.01 is works fine. or a least no so many error.
this does not addresses the problem of generation more than 16 contacts, but the scale creates a extra problem that the engine is not design to handle.
The 16 contact limit I am aware and I though this would be a good time to fix, but the I realize that this is due to size not contact limit.

on the other chash
isn't the bug with the joint and is a different bug, or is that supposed to be on this test?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dgCollisionBVH::GetCollidingFaces m_meshData

Postby arkeon » Tue Oct 28, 2014 1:47 pm

yes, but try with this code.

just collide several time the box with the joint on the collision tree.
at a moment the virtual call error 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];
  float scale = 1.0f;

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

  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 (0.0f);
  dVector size(0.1f, 0.1f, 0.1f, 0.1f);
  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,  scale * 0.5f, scale);
    NewtonBodySetContinuousCollisionMode(boxbody, 1);

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

  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(spherecol);
  }

   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 Julio Jerez » Tue Oct 28, 2014 2:36 pm

ok I will try that tonight.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Previous

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 1 guest

cron