Still have scaling issue on collisiontree

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Still have scaling issue on collisiontree

Postby arkeon » Sat Oct 25, 2014 7:42 am

you can try different scale values, this change the behavior

Yes it's normal the object pass trough the hole, I put the object here to make it easier to see.
The issue is when you grab it on the collision mesh (not in the hole)
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Still have scaling issue on collisiontree

Postby Julio Jerez » Sat Oct 25, 2014 8:06 am

just for the record the fir thong I'd like to clarify is that Newton interface is not Cpp it is C

I see people emakin this miostake over and over
Code: Select all
      DemoMesh* const visualMesh = new DemoMesh(NewtonMeshCreateFromCollision(seatcol));


The creates and argument on the stack and passed to Demo Mesh, but the argument is no destroy upon return, you must write that kind of stuff like this

Code: Select all
      NewtonMesh* const newtonMesh = NewtonMeshCreateFromCollision(seatcol);
      DemoMesh* const visualMesh = new DemoMesh(newtonMesh);
      NewtonMeshDestroy(newtonMesh);
 


this is no the bug is just that it leaves lots of memory leaks, and I see people doing over and over despite me telling them.
Julio Jerez
Moderator
Moderator
 
Posts: 11040
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Still have scaling issue on collisiontree

Postby arkeon » Sat Oct 25, 2014 8:08 am

hehe ok I just took the code from an another demo and I must forgot this one :)
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Still have scaling issue on collisiontree

Postby Julio Jerez » Sat Oct 25, 2014 11:55 am

Ok fixed, sync and test please.
Julio Jerez
Moderator
Moderator
 
Posts: 11040
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Still have scaling issue on collisiontree

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

Yes it works correctly now.

Thanks again for your work.
arkeon
 
Posts: 261
Joined: Sat Sep 13, 2014 5:25 pm

Re: Still have scaling issue on collisiontree

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

hmm another case with the same issue :
it's worst when the continuous collision is enabled.

download medias again : http://arkeon.be/scol/tree_debug_media.rar

Code: Select all
   // 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());

   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);
    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);
    visualMesh->Release();
    NewtonMeshDestroy(nmesh);
    NewtonDestroyCollision(groundcol);
  }

   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

Previous

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 1 guest

cron