Static scene collision transformation

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Static scene collision transformation

Postby manny » Sat Mar 29, 2014 9:01 pm

We're having issues with static scene collisions, we've got one big scene collision we're using for triangle collisions.
If we want to transform (offset in this case) collision geometry, we do the following:

Code: Select all
NewtonSceneCollisionBeginAddRemove (sceneCollision);
NewtonSceneCollisionSetSubCollisionMatrix(sceneCollision, _sceneCollisionNodes[collisionIndex], transformation.components);
NewtonSceneCollisionEndAddRemove (sceneCollision);


However, rigid bodies don't seem to respond to translated collision geometry but they also don't respond to the previous position.
If we're debug drawing the collision geometry with
Code: Select all
NewtonCollisionForEachPolygonDo
it is at the new location.

Is there anything else that needs to be done for the subcollision to become active?
http://www.instaLOD.io - InstaLOD - State of the art 3D optimization
manny
Site Admin
Site Admin
 
Posts: 131
Joined: Tue Feb 11, 2014 6:49 pm

Re: Static scene collision transformation

Postby Julio Jerez » Sun Mar 30, 2014 1:14 pm

you do not have to do anything, if you see it in debug they is should collide.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Static scene collision transformation

Postby manny » Sun Mar 30, 2014 1:17 pm

Julio Jerez wrote:you do not have to do anything, if you see it in debug they is should collide.

Interesting, that does not seem to be the case.
http://www.instaLOD.io - InstaLOD - State of the art 3D optimization
manny
Site Admin
Site Admin
 
Posts: 131
Joined: Tue Feb 11, 2014 6:49 pm

Re: Static scene collision transformation

Postby manny » Sun Mar 30, 2014 1:53 pm

Julio, I have uploaded a video that demonstrates the issue: http://www.made-apps.com/Media/Document ... on_ray.mp4
The video shows a prototype of our upcoming game, the player starts on the first road tile (with the signs), the blue lines represent the physics geometry as passed from Newton to our debug renderer, white lines are the actually rendered geometry. The tile will be respawned at the end of the road, once it's out of the frustum.
After the cut in the video, the player reaches the end of the road as initially spawned and enters the first tile again, which has been translated as described in my earlier post.
The player in this case is a ray-cast car, but neither the rays nor the rigid body collide with the translated geometry. The matrix we use to translate is (as you can imagine) neither rotated nor scaled.
http://www.instaLOD.io - InstaLOD - State of the art 3D optimization
manny
Site Admin
Site Admin
 
Posts: 131
Joined: Tue Feb 11, 2014 6:49 pm

Re: Static scene collision transformation

Postby Julio Jerez » Sun Mar 30, 2014 6:29 pm

Maybe there is a problem with the Broadphase not updating the AABB of the compound. for what I can see this is happing, but it is hard check without a reproducible test case

If this is reproducible could you send me a test demo that can be tested?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Static scene collision transformation

Postby manny » Sun Mar 30, 2014 6:35 pm

Yes, it's reproducible, at least in this game. I'll create a test case using your demo project first thing tomorrow.
http://www.instaLOD.io - InstaLOD - State of the art 3D optimization
manny
Site Admin
Site Admin
 
Posts: 131
Joined: Tue Feb 11, 2014 6:49 pm

Re: Static scene collision transformation

Postby Julio Jerez » Sun Mar 30, 2014 6:37 pm

Ha cool Tahy will make even easier to debug.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Static scene collision transformation

Postby manny » Mon Mar 31, 2014 7:31 am

Julio, I have uploaded a test case demonstrating the issue. You can just copy & paste this into your sandbox project into the "SceneCollision.cpp" file.
Grab it here: https://gist.github.com/Manny-MADE/9890303
I took me a bit to figure out why I wasn't able to reproduce it - translation seemed to work, but then it hit me: this only happens when it's placed outside the AABB of the scene collision, and I was right about this.

Code: Select all
/**
 * This scene demonstrates a bug in newton that disables
 * the collision between static scene node collisions and other rigid bodies or rays.
 * The reason for this seems to be that when the node collision is translated outside
 * the AABB of the compound scene collision the AABB of the compound is not updated
 * and thus the node collision is ignored.
 * Use 'F' and 'G' to toggle node collision positions and drag a box onto the node collision.
 * Another potential problem for developers  is that node collision pointers cannot be cached
 * and this is not written anywhere in the documentation.
 */
http://www.instaLOD.io - InstaLOD - State of the art 3D optimization
manny
Site Admin
Site Admin
 
Posts: 131
Joined: Tue Feb 11, 2014 6:49 pm

Re: Static scene collision transformation

Postby Julio Jerez » Mon Mar 31, 2014 11:04 am

Oh I just pasted that code in the scene collision and I am running it
I am reading this comment
/**
* This scene demonstrates a bug in newton that disables
* the collision between static scene node collisions and other rigid bodies or rays.
* The reason for this seems to be that when the node collision is translated outside
* the AABB of the compound scene collision the AABB of the compound is not updated
* and thus the node collision is ignored.
* Use 'F' and 'G' to toggle node collision positions and drag a box onto the node collision.
* Another potential problem for developers is that node collision pointers cannot be cached
* and this is not written anywhere in the documentation.
*/


this is what I see
when I hit key F I see the big part of the scene disappear, and if I touch any of the small box the fall through the map.
I expect thi Is the correct behavior

if I hi the G key then the map is restored and the collision is normal again, I also expect this behavior

you say that the bug happen when it is pace outside the AABB hwo do I do that in the test?


also you say the node are no cache, but the are. the node you get when you call NewtonSceneCollisionGetNodeByIndex never change unless you delete the node.
node are unique to their owner.

you may be trying to get a node from one scene collision instance and then use then on a copy that result from the creation of another compound.
when you create a body and you pass a collision shape, the collision in the body is a copy of the one pass in, If the passed in is a scene collision, all the children nodes will no map to the children node of the l original

can you explain me how do I make the bug happen? maybe a video

I looked at the part
Code: Select all
      if (scene->GetRootWindow()->GetKeyState ('F'))
      {
         // NOTE: if we translate the collision outside of the scene collision tree initial
         // AABB the collision won't be tracked by newton
         matrix.m_posit[0] = (maxX-minX);
         // this even happens if half of the collision is still inside the aabb
         // then only one half will collide
         // uncomment the following line to test it
         // matrix.m_posit[0] = (maxX-minX)*0.5f;
      }
      else if (scene->GetRootWindow()->GetKeyState ('G'))
      {
         // return to spawn origin
      }


but it does no seem to do the translation, I am confused as to how to make it happen.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Static scene collision transformation

Postby manny » Mon Mar 31, 2014 11:07 am

Julio Jerez wrote:
when I hit key F I see the big part of the scene disappear, and if I touch any of the small box the fall through the map.
I expect thi Is the correct behavior
...
can you explain me how do I make the bug happen? maybe a video

Julio, once 'F' has been pressed the box has been translated to the left, so you can to aim your camera to the left to see the translated box. Press 'G' to put it back at it's original position, sorry for not being very clear on how it works.
Try to place a cube inside the box by picking it, it will fall through the floor.


you say that the bug happen when it is pace outside the AABB hwo do I do that in the test?

press F to translate the collision node outside of the AABB of the scene collision.

also you say the node are no cache, but the are. the node you get when you call NewtonSceneCollisionGetNodeByIndex never change unless you delete the node.
node are unique to their owner.
Interesting. I used a cached version first, but i asserted on the result and it was not the same. See line 108. The assert is still there. I figured that if the list is being resized or some underlying memory manager swaps things around the pointer locations change.


you may be trying to get a node from one scene collision instance and then use then on a copy that result from the creation of another compound.
when you create a body and you pass a collision shape, the collision in the body is a copy of the one pass in, If the passed in is a scene collision, all the children nodes will no map to the children node of the l original

Sure, that's how i figured it'd work.

I looked at the part
CODE: SELECT ALL
but it does no seem to do the translation, I am confused as to how to make it happen.

The translation happens a few lines below, line 110 that. The code you posted is merely the construction of the translation matrix.
Last edited by manny on Mon Mar 31, 2014 11:12 am, edited 1 time in total.
http://www.instaLOD.io - InstaLOD - State of the art 3D optimization
manny
Site Admin
Site Admin
 
Posts: 131
Joined: Tue Feb 11, 2014 6:49 pm

Re: Static scene collision transformation

Postby Julio Jerez » Mon Mar 31, 2014 11:11 am

never mind I can reproduce it now.
Let me see what is wrong there.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Static scene collision transformation

Postby manny » Mon Mar 31, 2014 11:20 am

Julio Jerez wrote:never mind I can reproduce it now.
Let me see what is wrong there.

Great, might just be that the AABB needs to be recalculated.

also you say the node are no cache, but the are. the node you get when you call NewtonSceneCollisionGetNodeByIndex never change unless you delete the node.
node are unique to their owner.

you may be trying to get a node from one scene collision instance and then use then on a copy that result from the creation of another compound.
when you create a body and you pass a collision shape, the collision in the body is a copy of the one pass in, If the passed in is a scene collision, all the children nodes will no map to the children node of the l original

Just verified this again, collisionnodes cannot be cached. Uncomment the assert in line 108, run the demo, and press 'F' and it will halt in the debugger with:
Code: Select all
Assertion failed: (node == _treeCollisionNode), function Render, file ./newton-dynamics-read-only/applications/demosSandbox/sdkDemos/demos/SceneCollision.cpp, line 108.
http://www.instaLOD.io - InstaLOD - State of the art 3D optimization
manny
Site Admin
Site Admin
 
Posts: 131
Joined: Tue Feb 11, 2014 6:49 pm

Re: Static scene collision transformation

Postby Julio Jerez » Mon Mar 31, 2014 12:07 pm

Ok the bug is fixed now, sync to svn

on this
manny wrote:Just verified this again, collisionnodes cannot be cached. Uncomment the assert in line 108, run the demo, and press 'F' and it will halt in the debugger with:
Code: Select all
Assertion failed: (node == _treeCollisionNode), function Render, file ./newton-dynamics-read-only/applications/demosSandbox/sdkDemos/demos/SceneCollision.cpp, line 108.

like I said, it seems to make to are trying to find a subnode of the scene collision you created to pass as argument to for the sceneBody.

Code: Select all
// here you make  a scene collision
   ComplexScene* const visualMesh = new ComplexScene(sceneCollision);
   scene->Append (visualMesh);
 
   visualMesh->world = world;
   visualMesh->scene = scene;

// her you add the sub shape to the origin scene collision and you cache  _treeCollisionNode and _treeCollisionNodeIndex
// only _treeCollisionNodeIndex is valid across scene collisions,
   visualMesh->AddPrimitives(scene);
 
   // this is optional, finish the scene construction, optimize the collision scene
   dMatrix matrix (GetIdentityMatrix());
 

// here you crate the scene body, which make a new intact of the sceneCollision,  _treeCollisionNode is no part of this new scene collsion instace
   NewtonBody* const level = NewtonCreateDynamicBody (world, sceneCollision, &matrix[0][0]);
 
// replace the collision with the newly created one the 
   visualMesh->m_sceneCollision = NewtonBodyGetCollision(level);

//if you wan to cache treeCollisionNode then you must update the pointe here
_treeCollisionNode = NewtonSceneCollisionGetNodeByIndex (visualMesh->m_sceneCollision, _treeCollisionNodeIndex);

// and from there it will be fine
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Static scene collision transformation

Postby manny » Mon Mar 31, 2014 12:27 pm

Ah okay, so I thought that the nodes would stay the same when added, only the collision shell is changed. I'll check out the SVN commit and let's you know.
http://www.instaLOD.io - InstaLOD - State of the art 3D optimization
manny
Site Admin
Site Admin
 
Posts: 131
Joined: Tue Feb 11, 2014 6:49 pm

Re: Static scene collision transformation

Postby Julio Jerez » Mon Mar 31, 2014 1:44 pm

The sub nodes are the children of a binary three.
The contain and instance and some extra data for operating the compound collision.
The collision shape which is what takes the majority of the information is shared.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 9 guests

cron