User mesh doesn't work

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: User mesh doesn't work

Postby Julio Jerez » Thu Oct 24, 2013 4:58 pm

PJani wrote:is it possible to have one array for face normals and another for vertexes? Because vertexes are prebuild into vector in my case and they are just sitting in the RAM for most of the time. Normals are not and they need to be computed for faces.


as it is now, not, but that's one case where you can make use of the thread id.
you make one local local bugger per thread ID, and you copy te hvertex faces, and teh afte that you compute the normals (face and edge) and you copy the after the vertex array.
This is exactly whe the heighfield terrain does it. This works because in general the patch is small
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 » Fri Oct 25, 2013 3:42 am

What if object is much bigger instead of i don't know 2m x 2m x 2m is much much larger like 20m x 20m x 20m. What is the best practice to handle this?
| 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 » Fri Oct 25, 2013 7:10 am

that dos not happens because the obb of the codling object is always smaller. in the case that that happens the function data->PolygonBoxDistance (faceNormal, indexCount, indexArray, stride, vertex);
that filter that faces as they generated.

your function should only generate the faces that interest that AABB that is passed by the callback. this is better to have a small buffer per thread to generate the faces on the buffer.

if the face is a 20 x 20 x 20 of bigger, that's where the ob tree representation of the voxel help you, you can generate the patch at a lower resolution.
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 » Fri Oct 25, 2013 4:42 pm

is OBB or AAB?
| 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 » Fri Oct 25, 2013 5:03 pm

there difference bewten AABB or obb in newton.
all aabb are local to the body, and the take a matrix, so I guess that makes then OBB

The important point is that in the call back you get an AABB that is aligned to the collision shape matrix.
for example if to make a plane and you rotated 45 degree, the call back will gives an AABB rotated 45 degree in relation to the world,
but it will be aligned to the collision shape axis.
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 Nov 19, 2013 8:43 am

Ok finally i got it working with usermesh and DC and it works like a charm.

But the thing is i am using debug version of newton...i was testing with large number of usermesh collision bodies(about 750 bodies ok i know...its a lot but...just for science)(each representing its own section in 3D space)and for some reason. Even all the bodies are static they were using a lot of cpu time(14ms for nothing(no dynamic bodies no raycasting nothing which is for my standards overkill for static world with no dynamic querying stuff)).

Anyway i was wondering is possible to set infinitive aabb for usermesh so i can use only one body with usermesh for whole world(its easier for me to manage loading and unloading of chunks and other optimization stuff)?
| 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 Nov 19, 2013 10:58 am

PJani wrote:Anyway i was wondering is possible to set infinitive aabb for usermesh so i can use only one body with usermesh for whole world(its easier for me to manage loading and unloading of chunks and other optimization stuff)?


you can do better than that. basically instead of making one static body and one user mesh collision for each collision shape.
make one single static body body with a scene collision and add all the user meshes collision to the scene collision.
then your cpu time will be reduced to about the time that take to process just one body on the broad phase.
the scene collision has interface to adding removing and moving collision shapes, and can contain all other collision shapes as child shapes.
there is not limit as to how many you can add and their performance is independent of the child count for all operations.

The problem you mention is will be fix when I made the persistence broad phase.
That was the method in core 200, and then made the broad phase a component off he engine, I mad eth parallel broadphasewiet the idea to migrate to GPU
and the I decide to postpone eh GPU, and instead I made the scene collision.

However I will make the persistence brophaphase because that one will be useful for large scenes with lot of dymimicc object that ate sleeping.
but for now scene collision do the job.
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 Nov 19, 2013 11:59 am

Hmm i didn't see that collision type its new for me, but i think it will be no problem to implement it is same interface as for compound ! :) Newton changed a lot in all of these years :D I must say thats pretty cool 8) will test it asap :)
| 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 PJani » Tue Nov 19, 2013 12:23 pm

I am wondering why are edge normals needed? What is their purpose.
| 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 PJani » Tue Nov 19, 2013 1:26 pm

Ok i tested the scene collision...and i am getting one assetion i think its a bug when i destroy all of usermeshes in the scene collision.
Attachments
assert.png
assert.png (12.95 KiB) Viewed 4329 times
| 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 Nov 19, 2013 1:44 pm

what di you do? you crate and scene and added user mesh, then It crashed.
to narrow the bug, can you do the same by add some other collision shape instead of user mesh, see if that work, and we will know more.
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 Nov 19, 2013 4:36 pm

Code: Select all
      

///creation
dfVec3 vec_max = dfVec3(CHUNK_METRIC_SIZE) + margin;
      dfVec3 vec_min = dfVec3(0.0f) - margin;
      
      NewtonCollision* col = NewtonCreateUserMeshCollision(world, &vec_min.x, &vec_max.x, this
                           , _usermeshCollideCallback
                           , _usermeshRayHitCallback
                           , _usermeshDestroyCallback
                           , _usermeshGetCollisionInfo
                           , _usermeshAABBTest
                           , _usermeshGetFacesInAABB
                           , _usermeshSerialize, 0);
      
      NewtonBody* nb = tcm->getOgreNewtBody()->getNewtonBody();

      NewtonCollision* const nc_root = NewtonBodyGetCollision(nb);

      NewtonSceneCollisionBeginAddRemove(nc_root);

      scene_node = NewtonSceneCollisionAddSubCollision(nc_root, col);

      float matrix[16];
      OgreNewt::Converters::QuatPosToMatrix(Ogre::Quaternion::IDENTITY, position, matrix);

      NewtonSceneCollisionSetSubCollisionMatrix(nc_root, scene_node, matrix);

      NewtonSceneCollisionEndAddRemove(nc_root);

      NewtonDestroyCollision(col);
   }

//destruction
   TerrainPhysicalChunk::~TerrainPhysicalChunk()
   {
      NewtonBody* nb = getProxiedTerrainChunk()->getTerrainChunkManager()->getOgreNewtBody()->getNewtonBody();

      std::cout << getProxiedTerrainChunk()->getTerrainChunkManager()->numberOfProxyChunksLoaded() << std::endl;

      NewtonCollision* const nc_root = NewtonBodyGetCollision(nb);

      NewtonSceneCollisionBeginAddRemove(nc_root);


      NewtonSceneCollisionRemoveSubCollision(nc_root, scene_node);

      NewtonSceneCollisionEndAddRemove(nc_root);

   }


assertion happens when is trying to remove usermesh which is pre last in scene colisioon
| 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 PJani » Tue Nov 19, 2013 4:59 pm

Ok i added this peace of code right after the creation of NewtonCreateSceneCollision and it works...no assertions when clearing all of the bodies...(I dont destroy these two Sub Collisions via AddRemove i leave them in there)
If i only create one Null collision this fails with that assertion specified(again i am not removing null collisions via AddRemove) in the attachment.

I tried the same with others and the same thing persists
Code: Select all
      for(int i=0;i<2;i++){
         NewtonCollision* col = NewtonCreateNull(universe->getPhysicsManager()->getWorld()->getNewtonWorld());
         
         NewtonBody* nb = getOgreNewtBody()->getNewtonBody();

         NewtonCollision* const nc_root = NewtonBodyGetCollision(nb);

         NewtonSceneCollisionBeginAddRemove(nc_root);

         NewtonSceneCollisionAddSubCollision(nc_root, col);

         NewtonSceneCollisionEndAddRemove(nc_root);

         NewtonDestroyCollision(col);
      }



I think your nodes in the tree are not colapsing the right way when you try to remove the last two elements...
Attachments
assert0.png
assert0.png (12.59 KiB) Viewed 4315 times
| 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 Nov 19, 2013 5:36 pm

PJani wrote:I am wondering why are edge normals needed? What is their purpose.

edge normal are important for physical behavior when a rigid body moves across two faces that shape and edge.
basically each edge has an index to the normal of the adjacent face that share the same edge.
tshi aloo tehe conat calcution detrning the edge is convex or concave. fi et hedge si concave then conta is ignored, if tedg is convex the teh noraml is teh normal on the surce of the other shape.

on the code fragment, tha sodul work. I am pasting that on teh user mesh demo, and see if I can recreate the bug.
finally, yes it does not look like, but newton has a lot lot of feature.
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 » Tue Nov 19, 2013 6:08 pm

Ok I made this test funtion to emulate what you did and I did not get the crash or assert
Code: Select all
    static void TestAddingUserMeshToSceneCollsion (NewtonWorld* const world)
    {
        NewtonCollision* const sceneCollision = NewtonCreateSceneCollision (world, 0);
        dMatrix matrix (GetIdentityMatrix());
        NewtonBody* const body = NewtonCreateDynamicBody(world, sceneCollision, &matrix[0][0]);
        NewtonDestroyCollision(sceneCollision);

        // make a use mesh collision for testing
        dVector minBox(-100.0f, -100.0f, -100.0f, 0.0f);
        dVector maxBox(100.0f, 100.0f, 100.0f, 0.0f);
        NewtonCollision* const collision = NewtonCreateUserMeshCollision (world, &minBox[0], &maxBox[0], NULL,
            NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0);

        // add some use mesh collision
        NewtonCollision* const rootScene = NewtonBodyGetCollision(body);
        NewtonSceneCollisionBeginAddRemove(rootScene);
        void* const node = NewtonSceneCollisionAddSubCollision(rootScene, collision);
        NewtonSceneCollisionEndAddRemove(rootScene);
        NewtonDestroyCollision(collision);

        // test empty the sub collision shapes
        NewtonCollision* const rootScene1 = NewtonBodyGetCollision(body);
        NewtonSceneCollisionBeginAddRemove(rootScene1);
        NewtonSceneCollisionRemoveSubCollision(rootScene1, node);
        NewtonSceneCollisionEndAddRemove(rootScene1);

        // delete the body
        NewtonDestroyBody(body);
    }


see if you cn apast that code into you project, and made the change that cause the malfuntion.
also teh code is in te hsandbox demo, you can simple sync to snv and add teh chaneg there
the function is in demo ../demosSandbox\sdkDemos\toolBox\UserPlaneCollision.cpp line 354
you can uncomnet that lien and see hwo it works.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron