User mesh doesn't work

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

User mesh doesn't work

Postby PJani » Tue Oct 08, 2013 11:44 am

I don't get why but usermesh collision doesn't work as it should. Collide callback is beeing called but object just passes thru. I realy dont know what i am missing.
parameters
Code: Select all
   struct QuadFaceIndexStruct
   {
      int indices[4];
      int material_index;
      int normal_index;
      int normals[4];
      int diag_optimiz;
   };

   static float sajz = 16.0f;
   static int test_count[1] = {4};
   static QuadiFaceIndexStruct[1] test_index = {0,1,2,3,0,4,4,4,4,4,22};
   static Ogre::Vector3[5] test_vertex = {Ogre::Vector3(0,1,0),Ogre::Vector3(sajz,1,0),Ogre::Vector3(sajz,1,sajz),Ogre::Vector3(0,1,sajz),Ogre::Vector3(0,1,0)};
   

This is create for usermesh collision.
Code: Select all
      dfVec3 vec_max(sajz,sajz,sajz);
      dfVec3 vec_min(0,0,0);
      
      NewtonCollision* col = NewtonCreateUserMeshCollision(world, &vec_min.x, &vec_max.x, this
                           , _usermeshCollideCallback
                           , _usermeshRayHitCallback
                           , _usermeshDestroyCallback
                           , _usermeshGetCollisionInfo
                           , _usermeshAABBTest
                           , _usermeshGetFacesInAABB
                           , _usermeshSerialize, 0);


      m_body = new OgreNewt::Body(W, col, 0, position);
      m_body->setUserData(new PhysicsUserDataProxy(m_body, this, this));

      NewtonDestroyCollision(col);

usermesh collide callback
Code: Select all
   void TerrainPhysicalChunk::_collisionCollideCallback(NewtonUserMeshCollisionCollideDesc* const collideDescData)
   {
      collideDescData->m_faceCount = 1;
      collideDescData->m_vertexStrideInBytes = sizeof(Ogre::Vector3);
      
      collideDescData->m_faceIndexCount = (int*)test_count;
      collideDescData->m_faceVertexIndex = (int*)test_index;
      
      collideDescData->m_vertex = (float*)(test_vertex[0].ptr());
   }
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: User mesh doesn't work

Postby Julio Jerez » Tue Oct 08, 2013 12:12 pm

Maybe this is wrong
static Ogre::Vector3[5] test_vertex = {Ogre::Vector3(0,1,0),Ogre::Vector3(sajz,1,0),Ogre::Vector3(sajz,1,sajz),Ogre::Vector3(0,1,sajz),Ogre::Vector3(0,1,0)};

in the polygon is a ground level it should be
static Ogre::Vector3[5] test_vertex = {Ogre::Vector3(0,0,0),Ogre::Vector3(sajz,0,0),Ogre::Vector3(sajz,0,sajz),Ogre::Vector3(0,0,sajz),Ogre::Vector3(0,1,0)};
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: User mesh doesn't work

Postby PJani » Tue Oct 08, 2013 4:56 pm

Nop i tried with that no difference.
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: User mesh doesn't work

Postby Julio Jerez » Tue Oct 08, 2013 5:13 pm

maybe the windin is wrong, try inverting it. I beleiev newton and Ogree use inverted system.

My guess is tha the normal should face down, and the winding hould be inverted.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: User mesh doesn't work

Postby PJani » Wed Oct 09, 2013 5:47 am

Ok i just stumbled on something REALLY weird... I was debugging and stepping thru the code...

function in coreLibrary_300\source\physics\dgCollisionUserMesh.cpp
Code: Select all
void dgCollisionUserMesh::GetCollidingFaces (dgPolygonMeshDesc* const data) const

line 161
Code: Select all
const dgVector& faceNormal = vertex[normalIndex * stride];


when newton tries to do
const dgVector& faceNormal = vertex[4*3];

which should yield dgVector(0,1,0) yields zero vector

this part gets called
Code: Select all
   DG_INLINE dgVector (const dgFloat32 a)
      : m_type(_mm_set_ps1(a))
   {
   }

instead of(i think)
Code: Select all
   DG_INLINE dgVector (const dgFloat32* const ptr)
      :m_type(_mm_loadu_ps (ptr))
   {
      m_type = _mm_and_ps (m_type, m_triplexMask.m_type);
   }




this solution should work
Code: Select all
const dgVector& faceNormal = vertex+normalIndex * stride;


now the faceNormal is correct, but still not working

the sandbox demo is crashing for me
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: User mesh doesn't work

Postby Julio Jerez » Wed Oct 09, 2013 6:27 am

PJani wrote:line 161
Code: Select all
const dgVector& faceNormal = vertex[normalIndex * stride];



yes that was wrong

it should be this
Code: Select all
         dgVector faceNormal (&vertex[normalIndex * stride]);


I fixed now, please sync and try again, the sandbox demo should no crash
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: User mesh doesn't work

Postby Julio Jerez » Wed Oct 09, 2013 7:33 am

I found another bug, the vertex count each face was not save when a face was rejected, please sync try again

I also added the debug display callback, you click show debug line, you will see how it should look like
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: User mesh doesn't work

Postby PJani » Wed Oct 09, 2013 8:24 am

Hmm it still doesnt work...sandbox works fine

O and i use boxes for testing!

I really don't know what i am missing
Last edited by PJani on Wed Oct 09, 2013 9:16 am, edited 2 times in total.
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: User mesh doesn't work

Postby Julio Jerez » Wed Oct 09, 2013 9:05 am

try a box without scale, see if that work at all.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: User mesh doesn't work

Postby PJani » Wed Oct 09, 2013 9:21 am

Nop that doesnt work eather.

It really doesn't make any sense
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: User mesh doesn't work

Postby Julio Jerez » Wed Oct 09, 2013 9:54 am

I do not know what could be, other that debug the code myself.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: User mesh doesn't work

Postby PJani » Wed Oct 09, 2013 12:12 pm

I will try to find the problem my self. I don't want to give you more work than you have :)
What could cause this to return 0?(Its located in dgNarrowPhaseCollision.cpp line 1917)
Code: Select all
dgInt32 count1 = polygon.CalculateContactToConvexHullDescrete (proxy, scale, invScale);
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: User mesh doesn't work

Postby Julio Jerez » Wed Oct 09, 2013 12:56 pm

that function will return zero if a conve polygon a convex hul shape do not intersect.


if you can put that demo with teh other demo, I cna check it out. make sure you jusrt put a simple demo, so that I do no have to test too much.
I am curious as to why you are not getting it to work, it appear that the Layla on the otehr thread have it working
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: User mesh doesn't work

Postby PJani » Wed Oct 09, 2013 1:57 pm

Ok somehow it started working(don't ask me why 0_0).

This is how it looks...
Code: Select all
19:50:34: m_vertexes: Vector4(0, 0, 0, 1) Vector4(10, 0, 0, 1) Vector4(10, 0, 10, 1) Vector4(0, 0, 10, 1) Vector4(0, 1, 0, 1)
19:50:34: m_facecount:2
19:50:34:    m_vertexfacecount:3
19:50:34: indeces: 3 1 0 0 4 4 4 4 0
19:50:34:    m_vertexfacecount:3
19:50:34: indeces: 3 2 1 0 4 4 4 4 0

and then this happens...(compare the first and second indices) :shock: The second face just becomes the first!
Code: Select all
19:50:34: m_vertexes: Vector4(0, 0, 0, 1) Vector4(10, 0, 0, 1) Vector4(10, 0, 10, 1) Vector4(0, 0, 10, 1) Vector4(0, 1, 0, 1)
19:50:34: m_facecount:2
19:50:34:    m_vertexfacecount:3
19:50:34: indeces: 3 2 1 0 4 4 4 4 0
19:50:34:    m_vertexfacecount:3
19:50:34: indeces: 3 2 1 0 4 4 4 4 0


I don't do anything to the verticles or the indeces via code just initalize them. By any chance newton somewhere changes/copies them?
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: User mesh doesn't work

Postby Julio Jerez » Wed Oct 09, 2013 2:56 pm

Code: Select all
19:50:34: m_vertexes: Vector4(0, 0, 0, 1) Vector4(10, 0, 0, 1) Vector4(10, 0, 10, 1) Vector4(0, 0, 10, 1) Vector4(0, 1, 0, 1)
19:50:34: m_facecount:2
19:50:34:    m_vertexfacecount:3
19:50:34: indeces: 3 2 1 0 4 4 4 4 0
19:50:34:    m_vertexfacecount:3
19:50:34: indeces: 3 2 1 0 4 4 4 4 0


That looks like there is still a bug in newton, it seems the vertex index array is point alway to the same face.
I will modify the demo to pass two triangles and see if I can recreate the same bug.
what line of code did you get that from.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron