Quads and NewtonTreeCollision

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Quads and NewtonTreeCollision

Postby nyon » Wed Jul 13, 2011 1:18 pm

Hi,

I have some question concerning the creation of tree collision objects with quads. At the moment I use NewtonTreeCollisionAddFace(collision, 4, face, sizeof(float)*3, 1); with CCW-ordered vertices per quad. Often this works, but sometimes NewtonTreeCollisionAddFace or NewtonTreeCollisionEndBuild crashes(with optimize == 1 more often than optimize == 0).
When optimize == 1 it crashes in a file called dgAABBPolygonSoup.cpp in ImproveTotalFitness on line 437.
When optimize == 0 it crashes in a file called dgPolyhedra.cpp in CloseBounds on line 295 and 280.
I'm not quite sure, but i think it has something to do with the edges that are generated by Newton between my quads. They are aligned on X, Y or Z axis, flat, and are 1.0fx1.0f in size.

Are there any experiences with this kind of problem, or adding quads in general?

edit: Does it bother Newton, if I create Collisions or Bodies while it is updating?(NewtonUpdate)
edit2: I also tried the precompiled Newton binaries(DLL instead of static lib). They do also crash. I'm using Code-Blocks with MingW and the new Newton v 2.33. All other rigid bodies in Newton work as expected.

Best regards,

nyon
nyon
 
Posts: 5
Joined: Wed Jul 13, 2011 11:02 am

Re: Quads and NewtonTreeCollision

Postby Julio Jerez » Mon Jul 18, 2011 8:47 am

can you post a set of faces that make these funtion crash? or a test demo that make teh crash happens?

Newton Tree collison should never ever crash, under normal circuntances.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Quads and NewtonTreeCollision

Postby nyon » Wed Jul 20, 2011 5:17 am

Hello there,
thanks for your reply.
Somehow i fixed it by activating both, sse/mmx for my application and sse/mmx for the newton library. However, this fix is just working for newton version 2.31.
But there is still a crash when building collisions and bodies in newton. Am i allowed in Newton to create Collision Objects while creating Body Objects and vise versa?
Perhaps the former crash had to do something with it aswell... When it comes back, i'll post some polygondata to let you reproduce the problem.

At the moment I create Collisions and finish tree buildings while Newton is updating. I'm not create bodies during newton's update.

Best regards,
nyon

edit:
This quad seem to crash at NewtonTreeCollisionAddFace... is this possible?
This is the debug output i create before adding a face.
Code: Select all
float faces[] = {
                 32.000000, 26.000000, -1.000000, // Quad 0
                 32.000000, 26.000000, 0.000000,
                 32.000000, 25.000000, 0.000000,
                 32.000000, 25.000000, -1.000000,
// no more output since it crashed
nyon
 
Posts: 5
Joined: Wed Jul 13, 2011 11:02 am

Re: Quads and NewtonTreeCollision

Postby Julio Jerez » Wed Jul 20, 2011 8:20 am

I do no think so, I pasted in a funtion liek this.

Code: Select all
void xxxxx (NewtonWorld* const world)
{
   NewtonCollision* const collision = NewtonCreateTreeCollision(world, 0);
   NewtonTreeCollisionBeginBuild(collision);

   float faces[] = {
      32.000000, 26.000000, -1.000000, // Quad 0
      32.000000, 26.000000, 0.000000,
      32.000000, 25.000000, 0.000000,
      32.000000, 25.000000, -1.000000};
   NewtonTreeCollisionAddFace(collision, 4, &faces[0], 3 * sizeof (float), 0);

   NewtonTreeCollisionEndBuild(collision, 0);
   NewtonReleaseCollision(world, collision);
}



and it does not crashes, is that how you are doint it?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Quads and NewtonTreeCollision

Postby nyon » Wed Jul 20, 2011 12:21 pm

Hello,

thanks for the reply. When I'm optimizing it, it will crash. But somehow it seems to crash when adding the face. But since it does not crash with your code, it has to be some kind of weird multithreading issue.
So the question persists: Does it bother Newton when i add bodies or create collision objects while some other bodies or collision objects are created?

nyon
nyon
 
Posts: 5
Joined: Wed Jul 13, 2011 11:02 am

Re: Quads and NewtonTreeCollision

Postby Julio Jerez » Wed Jul 20, 2011 1:17 pm

I tested with optimization too an dit di no crashe either.

Not i will not work from a newton update, if it is a mutipthread called, this is because the memory manager is not thread safe.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Quads and NewtonTreeCollision

Postby nyon » Wed Jul 20, 2011 1:50 pm

So when i create two collision objects simultaneously it might crash?
Then I have to buffer all Newton calls... alright.
nyon
 
Posts: 5
Joined: Wed Jul 13, 2011 11:02 am

Re: Quads and NewtonTreeCollision

Postby Julio Jerez » Wed Jul 20, 2011 7:52 pm

it will crash defininitlly yes. you can queue and build it after the Netwon Update.
one thing It can be done is to make the memory manager thread safe, it is not too diffcult.
I did not do it because lock and unlock is expensive, and the engine rely of the speed of the chunk memory allocation for everything.
I will be desatruos to the engine making the manager thread safe.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Quads and NewtonTreeCollision

Postby nyon » Thu Jul 21, 2011 9:25 am

Thanks for your reply.
I finally fixed it by putting it into the mainthread. Without optimizing its quite fast at building the collision tree in real time.

Nice engine.
Thanks a lot, and keep up the good work.
nyon
 
Posts: 5
Joined: Wed Jul 13, 2011 11:02 am

Re: Quads and NewtonTreeCollision

Postby JernejL » Fri Jul 22, 2011 4:14 am

nyon wrote:Without optimizing its quite fast at building the collision tree in real time.


You should optimize it, then save it in serialized form, it would result in even faster loading.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Quads and NewtonTreeCollision

Postby Julio Jerez » Fri Jul 22, 2011 2:26 pm

what Jernel say is correct. if a collision tree is made of irregular size faces, of clostered faces at irregular densities, top down algorithm to select best partition pnae do not lead to AABB trees with optimal partition. So far I know bottom up algorithm are better, but ther are very, very slow, and the improvement is no enought to justfiy the slowness.

The Volume minimization based of Red/Black tree rotations lead near perfect trees, but this I mean trees for whic volume queires vist the smalled numbe of possible nodes.
The could be important for large tress.
It also allowd for dynamic trees, which is the method it use for scene collision.

In fact that method use in Netwopn 1 and 2 I was usin a Muti Resolution grid, a 3d ioen in newton 1 and a 2d for newton 2 but teh mutigrid si no very good for mutothreaded
so newton 3 for Broadphase nwo use teh same algorithm that is use for scene collisions.
I am also planning to add the dynamics trees option to newton 3. This will make trees dynamics, meaning that fase can be added and removed at run time,
and the balancing will amorized the time doring mutiples newton updates. Scene collison uses that method to re balance the tree whe a primitice is moved so it can also be part of the collision tree.


your best bet is to make all the tree and serialize them as asset, nothing can be faster than that.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests