NewtonTreeCollisionAddFace slow as hell

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: NewtonTreeCollisionAddFace slow as hell

Postby Julio Jerez » Sat Jul 21, 2012 3:38 pm

if you have problems tell what kind of mesh you have, I can modify the class so that is is easier.

I only made the infinite plane demo because if is eassy, late I will complete the user hieghfield which is also simular
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonTreeCollisionAddFace slow as hell

Postby PJani » Thu Jul 26, 2012 9:23 pm

Hmm i have idea how to make on demand loading of chunks using usermesh. But first i will need to add some callbacks in your library.

Where can i add callback which would "inform" my engine of AABB query in newton world?, so i can load needed chunks and then in LRU mode unload them from cache. This must work for both ray casting and regular queries.
| 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: NewtonTreeCollisionAddFace slow as hell

Postby Julio Jerez » Fri Jul 27, 2012 7:51 am

when you vrate the user shape you pass the pointe to all the callbacks

Code: Select all
m_collision = NewtonCreateUserMeshCollision (world, &minBox[0], &maxBox[0], this,  PlaneCollisionCollideCallback, PlaneMeshCollisionRayHitCallback,
                         PlaneCollisionDestroyCallback, PlaneCollisionGetCollisionInfo, PlaneCollisionGetFacesInAABB,
                         UserCollisionSerializationCallback, 0);

they have these forms
Code: Select all
   static void PlaneCollisionDestroyCallback(void* userData)
   static int PlaneCollisionGetFacesInAABB (void* me, const dFloat* p0, const dFloat* p1, const dFloat** vertexArray, int* vertexCount, int* vertexStrideInBytes, const int* indexList, int maxIndexCount, const int* userDataList)
   static void UserCollisionSerializationCallback (void* const userData, NewtonSerializeCallback function, void* const serializeHandle)
   static void PlaneCollisionGetCollisionInfo (void* const userData, NewtonCollisionInfoRecord* const infoRecord)
   static dFloat PlaneMeshCollisionRayHitCallback (NewtonUserMeshCollisionRayHitDesc* const rayDesc)
   static void PlaneCollisionCollideCallback (NewtonUserMeshCollisionCollideDesc* const collideDesc)


the callback you write then yoursel at the high level and pass the pointer, there are samples in teh plane collsion demo in teh sandboxSDK demos.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonTreeCollisionAddFace slow as hell

Postby PJani » Fri Jul 27, 2012 8:06 am

Yeah i know that, but the problem here is the minBox maxBox are defining global boundaries(not somekind of grid) which means the collision is not infinitive and is static...now callback part works for one chunk. I dont want to load whole world to memory because my world is in "double" coordinates(later on i will switch to double precision build)...meaning i cant afford to load every chunk at once.
| 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: NewtonTreeCollisionAddFace slow as hell

Postby Julio Jerez » Fri Jul 27, 2012 8:53 am

what box are you talking about. The box tha you pass in is the size of the full collsion shape, that does no mean that the objt will laod all the data, it iwll only us ethat box for teh braodphase aabb test
sure your meshes must have a size that you in advance.

if you shape is for exampel a planet, mixBox and Max Box is the AABB of teh plane.
but collision will no check teh whle planet at once, only the objext that are penetration the shape

in teh demo code you can see that the aabb of the object coilliding with the static shape is an argument to the callback

Code: Select all
   static void PlaneCollisionCollideCallback (NewtonUserMeshCollisionCollideDesc* const collideDesc)
   {
      dInfinitePlane* me = (dInfinitePlane*) collideDesc->m_userData;

      dVector p0 (collideDesc->m_boxP0[0], collideDesc->m_boxP0[1], collideDesc->m_boxP0[2]);
      dVector p1 (collideDesc->m_boxP1[0], collideDesc->m_boxP1[1], collideDesc->m_boxP1[2]);
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonTreeCollisionAddFace slow as hell

Postby PJani » Fri Jul 27, 2012 9:12 am

Hmm are saying i need to set my aabb to max double and min double?

Because i was playing with your demo and when i reach the edges of your plane objects are starting to fall off

dVector minBox (-0.1f, -2000.0f, -2000.0f);
dVector maxBox ( 0.1f, 2000.0f, 2000.0f);
Are you using rotated coordinate system in demos? x for up?
| 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: NewtonTreeCollisionAddFace slow as hell

Postby Sweenie » Fri Jul 27, 2012 9:51 am

Hmm are saying i need to set my aabb to max double and min double?


Thats the way I understand it.

Basically provide an "infinite" large AABB which will mean the callbacks(collision and raycast) will always be called since the checked body's AABB will always
fit inside this "infinite" AABB.
The checked body's AABB will be provided inside the collisioncallback.

Something I've been wondering though is when NewtonUserMeshCollisionGetFacesInAABB is called?
Since NewtonUserMeshCollisionCollideCallback recieves the intersecting polygons for a given AABB what purpose does NewtonUserMeshCollisionGetFacesInAABB have?
Is it for debugging or what is the difference between those two callbacks?
Sweenie
 
Posts: 503
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: NewtonTreeCollisionAddFace slow as hell

Postby PJani » Fri Jul 27, 2012 10:08 am

I think thats for visual mesh if i am not mistaken
| 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: NewtonTreeCollisionAddFace slow as hell

Postby PJani » Fri Jul 27, 2012 10:19 am

Code: Select all
dFloat bound = 8000.0f; //8km for float //1764km for double

      dFloat vec_min[4] = {-bound,-bound,-bound,0};
      dFloat vec_max[4] = {bound,bound,bound,0};

      NewtonCollision* col = NewtonCreateUserMeshCollision(world,vec_min,vec_max, this, &_usermeshCollideCallback, &_usermeshRayHitCallback, &_usermeshDestroyCallback, &_usermeshGetCollisionInfo, &_usermeshGetFacesInAABB, &_usermeshSerialize, 0);

I don't get it why collide callback is not beeing called 0_0 rayhit callback is working fine.
| 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: NewtonTreeCollisionAddFace slow as hell

Postby Julio Jerez » Mon Jul 30, 2012 9:28 am

did you set a break point?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonTreeCollisionAddFace slow as hell

Postby PJani » Mon Jul 30, 2012 9:30 am

actually i didn't i added std::cout << __FUNCTION __ << std::endl at beginning of callback. :roll:
| 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: NewtonTreeCollisionAddFace slow as hell

Postby Julio Jerez » Mon Jul 30, 2012 11:12 am

set a break point on thisi function
dgFloat32 dgCollisionUserMesh::RayCast (const dgVector& localP0, const dgVector& localP1, dgContactPoint& contactOut, const dgBody* const body, void* const userData, OnRayPrecastAction preFilter) const
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonTreeCollisionAddFace slow as hell

Postby PJani » Mon Jul 30, 2012 11:26 am

NewtonUserMeshCollisionRayHitCallback is working fine! I mean its being called. my raycast callback is not fully functinal.

NewtonUserMeshCollisionCollideCallback doesn't give any sign of life.

I will check this next week.
| 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

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron