Vertex Clouds behave differently in Debug and Release

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Vertex Clouds behave differently in Debug and Release

Postby Julio Jerez » Wed Nov 14, 2018 3:01 pm

I think I found what could cause these kind of bugs.
when I optimize the engine I made and assumption that turn out to be too weak.
joint connect two bodies, and we know that by design at least one of the bodies must be a no zero mass.

for simplicity long, long time ago I made the rule that if a contact work on a compound, then the one body wit the compound would be body zero. and this work for a long time.

Than later I made another assumption that if a joint has a body wire zero mass then that body will be the on entry 1.
the two rule contradict each other is a contact is a compound with zero mass.
It is time to remove that compound assumption

Code: Select all
it is this part here
void dgWorld::CalculateContacts (dgBroadPhase::dgPair* const pair, dgInt32 threadIndex, bool ccdMode, bool intersectionTestOnly)
{
   dgContact* const contact = pair->m_contact;
   dgBody* const body0 = contact->m_body0;
   dgBody* const body1 = contact->m_body1;
   const dgContactMaterial* const material = contact->m_material;
   dgCollisionParamProxy proxy(contact, pair->m_contactBuffer, threadIndex, ccdMode, intersectionTestOnly);

   pair->m_flipContacts = false;
   proxy.m_timestep = pair->m_timestep;
   proxy.m_maxContacts = DG_MAX_CONTATCS;
   proxy.m_skinThickness = material->m_skinThickness;

   if (body1->m_collision->IsType(dgCollision::dgCollisionScene_RTTI)) {
      SceneContacts(pair, proxy);
   } else if (body0->m_collision->IsType (dgCollision::dgCollisionScene_RTTI)) {
      contact->SwapBodies();
      pair->m_flipContacts = -1;
      SceneContacts (pair, proxy);

   } else if (body0->m_collision->IsType (dgCollision::dgCollisionCompound_RTTI)) {
      CompoundContacts (pair, proxy);
   } else if (body1->m_collision->IsType (dgCollision::dgCollisionCompound_RTTI)) {


// this brakes down if the solve assume that body zero must be a non zero mass body
      contact->SwapBodies();
      pair->m_flipContacts = -1;
      CompoundContacts (pair, proxy);


I nee to fox that this weekend
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vertex Clouds behave differently in Debug and Release

Postby misho » Wed Nov 14, 2018 5:08 pm

Ok, I updated to the latest build and did a lot of case testing - and I am at a loss as to why this is happening. Moreover, I was unable to reproduce the same problem in the demo sandbox. Here is the simple test case data - a simple cloud vertex made of 8 vertices (a box), and, it's equivalent (although slightly longer) collision primitive of type BOX.

Code: Select all
///////////////////////////// CLOUDVERTEX VERTICES//////////////////////////
RELEASE VERSION
X: -6.201506   Y: -14.977961   Z: 50.856400
X: 6.201504   Y: -14.977961   Z: 50.856400
X: -6.201506   Y: -27.605566   Z: 50.856400
X: 6.201504   Y: -27.605566   Z: 50.856400
X: -6.201506   Y: -14.977961   Z: 131.699890
X: 6.201504   Y: -14.977961   Z: 131.699890
X: -6.201506   Y: -27.605566   Z: 131.699890
X: 6.201504   Y: -27.605566   Z: 131.699890
///////////////////////////// COLLISION PRIMITIVE BOX //////////////////////////
TBParseCollisionShapes: Collision type: Box.
Dim X: 12.403000   Dim Y: 12.628000   Dim Z: 104.819000
Pos X: 0.000000      Pos Y: -21.292000   Pos Z: 79.114998
Pitch: 0.000000      Roll: 0.000000      Yaw: 0.000000


These are the dimensions printed just before they are submitted to NewtonCreateBox() and NewtonCreateConvexHull() respectively. The box primitive works in both Release and Debug. The Cloud vertex works in Debug, but NOT in Release (objects fall through).

I am at a loss as to why this is happening... I'd appreciate any comments or suggestions on how to debug this or what may be the cause...
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 552
Joined: Tue May 04, 2010 10:13 am

Re: Vertex Clouds behave differently in Debug and Release

Postby misho » Wed Nov 14, 2018 5:11 pm

Julio Jerez wrote:I think I found what could cause these kind of bugs.


Oooops!!! I just saw this! Thanks for the update, Julio!! I'm glad there might be a fix for this! :wink:
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 552
Joined: Tue May 04, 2010 10:13 am

Re: Vertex Clouds behave differently in Debug and Release

Postby misho » Sun Nov 25, 2018 4:41 am

Julio Jerez wrote:I think I found what could cause these kind of bugs.
...
I nee to fox that this weekend


Hi Julio - were you able to fix this?
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 552
Joined: Tue May 04, 2010 10:13 am

Re: Vertex Clouds behave differently in Debug and Release

Postby Julio Jerez » Mon Nov 26, 2018 12:51 pm

I have not done yet, I was debugging some hard to find bug that I had in the vehicle solver.
I took me almost the hold pass week rewriting it, and moving the core solver to the d animation library so that it can be use for pylhysic base any nation as week as for vehicles.
There where some serious bug that I believe I have fix now.

I will try to get that compound fixed sometime this week of course, besacue is a serius bug.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vertex Clouds behave differently in Debug and Release

Postby misho » Mon Nov 26, 2018 6:59 pm

Julio Jerez wrote:I will try to get that compound fixed sometime this week of course, besacue is a serius bug.


Sounds good, thanks for the update!
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 552
Joined: Tue May 04, 2010 10:13 am

Re: Vertex Clouds behave differently in Debug and Release

Postby Julio Jerez » Thu Dec 06, 2018 8:12 pm

are you saying that those 8 point generate a different collision bug in debug than the do in release?
that can't be possible a bug like that would show every where. there has to be some else.

I added a fix that was in fact a bug if a the first body of a joint was a static body.
and also the bug that assume compound with always be the second body of a contact.
there where some assert warning about that and I finally got to fixed the begging of the week.
That was what I meant when I said. " I think I found what can cause these kind of bug"
so I expect those problems to be fix now.

if not there most be some else related to how you are using it but I am not clear as to if you are saying the bug is on makin a mesh or making a convex shape.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vertex Clouds behave differently in Debug and Release

Postby misho » Sat Dec 08, 2018 8:32 pm

First, let me explain how I use Newton: I create a nice, detailed, textured visual model in 3D editor (3DS MAX) which is then converted to FSX format used by FSX's display engine. Here is the in-game screenshot of the VISUAL scene I have, and I labeled major components:

Image

(I'm showing the rocket in this image, but from now on I'll omit it because it is a separate Newton body - I'll only concentrate on the launch pad from now on.)

Then, I use that visual model as a basis in creating collision primitives. I design them also in 3DS MAX, and use parameters (radius, height, etc) to define primitive collision objects in Newton. With rockets, it is pretty simple, mostly cylinders and cones. The following images show the collision objects, NOT the actual visual models.

Ok, with that clarified, let me show you the process I went through:

Below is the initial STATIC compound collision of the above scene: a rocket launch platform and tower, plus a surrounding concrete structure. For this initial trial, I used primitive collision objects, in this case ALL boxes, as such: (This is what Newton sees)

Image

The tall box object is the launch tower, object below it is the launch platform (where rocket stands), and the bottom boxes are approximation of the concrete launch platform, with a "flame trench" (where rocket flame is diverted).

Next, I wanted to increase the detail of the whole structure so that it looks more like the visual object in the top image, so instead of using boxes, I re-created the whole object using a bunch of vertex cloud collision objects, organised in a STATIC compound collision. The whole object now looked like this:

Image

As you can see, this compound collision has much more detail and a lot of concave areas, and because of that I broke it down to many smaller parts, all vertex cloud collision objects. To show you how it all looks, I "exploded" the model (moved the parts away from each other) just so you can see the individual parts:

Image

As you can see, there are 25 individual vertex cloud collision objects in this static compound collision.

So, that's the set up. Now, for the bug:

Before, I used primitive collision objects (boxes, cones, spheres) as per top image, to define my compound collisions. Everything worked fine, in both Release and Debug.

After this switch, I noticed that Debug version worked fine, and Release version did not. I noticed for example that the launch tower, a tall box which is a very simple vertex cloud collision (a box with 8 vertices) that replaced a primitive box collision object, was present in Debug, but completely absent in Release (object falls through). Note, I don't "see" visually that this object is missing, but I conclude that is missing (or misplaced) because objects fall through where the collision object is supposed to be.

After sync on December 6, I noticed that the same simple box has now "re-appeared", but it is slightly off-set, as per my 3 images I posted in the other thread, which show the leaning rocket part.

This is just one of the manifestations of the problem: My other post with 3 images also showed "dangling" rocket panels that came loose for no reason (only in Release - they were fine in Debug). I checked and re-checked my code, and there is absolutely nothing I do differently for release or debug versions, so I am concluding that the problem is somewhere inside Newton.

I hope this helps!
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 552
Joined: Tue May 04, 2010 10:13 am

Re: Vertex Clouds behave differently in Debug and Release

Postby misho » Fri Dec 21, 2018 9:30 pm

While the problem described in this thread is being looked at, I've reverted back to primitive collisions in my models. For now, where I need a "hollow" cone, I replaced it with a solid cone collision primitive.

As of late, I noticed worsening performance of the collision engine, and in this case, a crash:

Here is what the objects look like when put together, in place:

Image

And, just for clarity, this is how they fit together:

Image

There are 5 bodies, put together from compound primitives - cones and boxes. They are attached and held together by a "hard" hinge (class dCustomHinge). With this arrangement, I get a crash when I try to detach green objects:

Code: Select all
Line 825: dgCholeskyApplyRegularizer(m_auxiliaryRowCount, m_massMatrix11, diagDamp);
in dgSkeletonContainer.cpp


which goes into

Code: Select all
Line 99 in chkstk.asm (MS assembler code)


If I remove 2 cone collision primitives on the red compound collision (the ones that get covered by green objects), everything works ok.

I've also noticed a severe performance degradation that seems to come in "waves"... my visual FPS falls from ~60 to ~25, and then gradually back to 60. I have rigged a button that immediately gets rid of all newton bodies except a user-controlled body. If I do that when performance drops, it instantaneously goes back to 60 fps. I rigged that to see whether the culprit is the graphics engine or physics engine, and it seems to be the physics engine.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 552
Joined: Tue May 04, 2010 10:13 am

Re: Vertex Clouds behave differently in Debug and Release

Postby Julio Jerez » Fri Dec 21, 2018 9:51 pm

Line 825: dgCholeskyApplyRegularizer(m_auxiliaryRowCount, m_massMatrix11, diagDamp);
in dgSkeletonContainer.cpp

this should never happens.
This mean you have a configuration with loops that is forming an ill conditioned mass matrix that can not be inverted. Something is wrong in the way you are connecting the joints. is so wrong that is running out of stack space.
Line 99 in chkstk.asm (MS assembler code)

probably too many self collision between bodies.

there is a trick you can do, there is a newton object called aggregate that you can use to wrap your rocket, the there you can apply make the entire set non self collidable.
you do not want the to collidind among them self I assume.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vertex Clouds behave differently in Debug and Release

Postby misho » Sat Dec 22, 2018 12:48 am

Julio Jerez wrote:Something is wrong in the way you are connecting the joints. is so wrong that is running out of stack space.


Yeah - but why is it that if I remove 2 sub-collisions from the red object, everything is ok? That doesn't suggest that I am somehow improperly connecting the joints :roll:

Julio Jerez wrote:there is a trick you can do, there is a newton object called aggregate that you can use to wrap your rocket, the there you can apply make the entire set non self collidable.
you do not want the to collidind among them self I assume.


The bodies that make up the rocket do not collide among themselves, of course... but during the rocket launch, parts of the rocket are detached and thrown away, and at that point yes, I want those parts to behave normally, and of course, collide if something goes wrong during the flight (like a rocket accident or flight anomaly)

From my observations, the most problems I have is when I try to create a "hollow" (concave) object out of sub-collisions, and how these objects interact with other bodies. The green objects are such objects, they are "bent", represented by 3 slabs. I have another hollow object like that, and it also shows really weird "bounciness" when I detach it. and - I have to say, I didn't observe this before, the recent builds only seem to have this problem.

You'd probably be able to see this and perhaps trace it when you set up Flight Simulator, but I think I might be able to quickly set up a test case and see if I get the same odd behavior in sandBox.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 552
Joined: Tue May 04, 2010 10:13 am

Re: Vertex Clouds behave differently in Debug and Release

Postby misho » Sat Dec 22, 2018 4:47 am

Ok, I created a scene that resembles what I have, but I am unable to reproduce. I did get an assert in
Code: Select all
dgSkeletonContainer.cpp, Line 87:

         dgAssert (m_dof > 0);


This happens when I delete 3 hinges I created (It actually happens on any hinge deletion). You can find the source code here. Press button "2" to destroy 3 hinges that hold 3 curved panels in place.

I also set the scene very very far from the origin (more than 6 million units) to reproduce the location on the earth surface. I noticed that when the location is so far away, the movement is very "steppy" (jerky). I did compile with double_precision config - why isn't position using double precision?

Anyway, it looks like it will be, after all, necessary for you to locate the source of this problem by Installing FSX and my simulator.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 552
Joined: Tue May 04, 2010 10:13 am

Re: Vertex Clouds behave differently in Debug and Release

Postby Julio Jerez » Sat Dec 22, 2018 12:25 pm

misho wrote:
Code: Select all
dgSkeletonContainer.cpp, Line 87:

         dgAssert (m_dof > 0);



without look at anything , I can tell you that thsi is big part of teh problem, no sure hwo yo ugot a joint with not dof but I like to check that out.
I have to leave now but later today I will check it out, also I will get the app from steam to see what it si that is happens.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Vertex Clouds behave differently in Debug and Release

Postby misho » Sat Dec 22, 2018 2:31 pm

Good to hear, thanks Julio!
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 552
Joined: Tue May 04, 2010 10:13 am

Re: Vertex Clouds behave differently in Debug and Release

Postby misho » Sun Dec 23, 2018 4:41 am

Just a quick q:

If I had a case where two objects had to be placed so that their collisions are initially overlapping - is there a way to control, the amount of "repulsion" between the two objects until they "exit" from each other? Or ultimately, is it possible to turn this repulsion off, and let them overlap until they are separated by external force?
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 552
Joined: Tue May 04, 2010 10:13 am

PreviousNext

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 1 guest