MADEAPPS / newton-dynamics

Newton Dynamics is an integrated solution for real time simulation of physics environments.
http://www.newtondynamics.com
Other
940 stars 182 forks source link

Getting compound assert in debug mode with latest build #169

Closed TrevorCash closed 4 years ago

TrevorCash commented 5 years ago

image

JulioJerez commented 5 years ago

ah yes that's one optimization that I made over the weekend wit Dave. It is support to generate much better contact set for all collision shapes, but I could no have the branch of the code trigger with compounds that I have. could you make if a favor and comment out the assert and let it go, and tell me if the respond is better of worse than enabling the define //#define DE_USE_OLD_CONTACT_FILTER in file dgWorld.h?

On Mon, May 20, 2019 at 4:04 PM Trevor Cash notifications@github.com wrote:

[image: image] https://user-images.githubusercontent.com/2559371/58057195-4a2b4e00-7b21-11e9-8c7d-a6cd19913877.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MADEAPPS/newton-dynamics/issues/169?email_source=notifications&email_token=AB6EPJDDNL6VCPOORAOHQILPWMU75A5CNFSM4HOGCOU2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GU2WTNA, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6EPJGLVOV7NDI6JTEWYBDPWMU75ANCNFSM4HOGCOUQ .

JulioJerez commented 5 years ago

Hi, Also when the assert happens, if possible can you take a screen shot of the scene I a curious as to what kind of collision configuration is producing so many contacts. Basically I am trying to improve the quality of the simulation by filtering the contact that aren't essential to form the system matrix because the are linear combination of other contacts. With simple convex this is easy, since the collision is a convex 2d polygon, so any polygon simplification is better that nothing. For compounds this is more difficult.

On Mon, May 20, 2019, 5:23 PM Julio Jerez jerezjulio0@gmail.com wrote:

ah yes that's one optimization that I made over the weekend wit Dave. It is support to generate much better contact set for all collision shapes, but I could no have the branch of the code trigger with compounds that I have. could you make if a favor and comment out the assert and let it go, and tell me if the respond is better of worse than enabling the define //#define DE_USE_OLD_CONTACT_FILTER in file dgWorld.h?

On Mon, May 20, 2019 at 4:04 PM Trevor Cash notifications@github.com wrote:

[image: image] https://user-images.githubusercontent.com/2559371/58057195-4a2b4e00-7b21-11e9-8c7d-a6cd19913877.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MADEAPPS/newton-dynamics/issues/169?email_source=notifications&email_token=AB6EPJDDNL6VCPOORAOHQILPWMU75A5CNFSM4HOGCOU2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GU2WTNA, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6EPJGLVOV7NDI6JTEWYBDPWMU75ANCNFSM4HOGCOUQ .

TrevorCash commented 5 years ago

Hi Julio, yeah I'll check it out when I get to my computer.

Get Outlook for Androidhttps://aka.ms/ghei36


From: NewtonDynamics notifications@github.com Sent: Tuesday, May 21, 2019 9:36:56 AM To: MADEAPPS/newton-dynamics Cc: Trevor Cash; Author Subject: Re: [MADEAPPS/newton-dynamics] Getting compound assert in debug mode with latest build (#169)

Hi, Also when the assert happens, if possible can you take a screen shot of the scene I a curious as to what kind of collision configuration is producing so many contacts. Basically I am trying to improve the quality of the simulation by filtering the contact that aren't essential to form the system matrix because the are linear combination of other contacts. With simple convex this is easy, since the collision is a convex 2d polygon, so any polygon simplification is better that nothing. For compounds this is more difficult.

On Mon, May 20, 2019, 5:23 PM Julio Jerez jerezjulio0@gmail.com wrote:

ah yes that's one optimization that I made over the weekend wit Dave. It is support to generate much better contact set for all collision shapes, but I could no have the branch of the code trigger with compounds that I have. could you make if a favor and comment out the assert and let it go, and tell me if the respond is better of worse than enabling the define //#define DE_USE_OLD_CONTACT_FILTER in file dgWorld.h?

On Mon, May 20, 2019 at 4:04 PM Trevor Cash notifications@github.com wrote:

[image: image] https://user-images.githubusercontent.com/2559371/58057195-4a2b4e00-7b21-11e9-8c7d-a6cd19913877.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MADEAPPS/newton-dynamics/issues/169?email_source=notifications&email_token=AB6EPJDDNL6VCPOORAOHQILPWMU75A5CNFSM4HOGCOU2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GU2WTNA, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6EPJGLVOV7NDI6JTEWYBDPWMU75ANCNFSM4HOGCOUQ .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/MADEAPPS/newton-dynamics/issues/169?email_source=notifications&email_token=AATQ3C27W6EWB5O6ZH6GWV3PWQJJPA5CNFSM4HOGCOU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV4J3RI#issuecomment-494443973, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AATQ3C3QOAONX4LGAYQV4BLPWQJJPANCNFSM4HOGCOUQ.

TrevorCash commented 5 years ago

I got the assert again - but its hard to reproduce. I can tell you though that the compounds look like this: Capture

There are 3 boxes that form a compound shown by the blue lines if you look closely. All other objects are simple shapes.

TrevorCash commented 5 years ago

I can comment out the assert - so then it doesn't crash - but its hard to tell a behavioral difference with my setup.

JulioJerez commented 5 years ago

umm that very unsettling, if you look at the lien whe the assert come from

                        if (contactCount > (DG_MAX_CONTATCS - 2 * (DG_CONSTRAINT_MAX_ROWS / 3))) {

ifdef DE_USE_OLD_CONTACT_FILTER

                            contactCount = m_world->OldReduceContacts(contactCount, contacts, DG_CONSTRAINT_MAX_ROWS / 3, proxy.m_contactJoint->GetPruningTolerance());

else

                            dgAssert(0);
                            contactCount = m_world->PruneContacts(contactCount, contacts, proxy.m_contactJoint->GetPruningTolerance(), 16);

endif

                        }

,

the temp buffer is 128 contacts minus the max contacts per colliding pair which is 16t, therefore the contact count has to be larger than 90 contacts for the function to be called. I do not think that shape can generate that many contact points unless the mesh under the L shape box is a very high resolution mesh, is that the case?

but anyway before I remove the assert I will add a trace, just to make sure the call is trigger because of a large number of contact and no because of a bug. I almost have never seem that function to be trigger

The contact reduction is call when the number contacts calculate exceeded the maximum number on the temp buffer capacity.

In any case what the code does in the contacts final contacts set should be the extreme points of the convex hull of the set, about four or maybe five contacts which should produce a much higher quality collision resolution than if we for example 4 contacts for each leg since the interior contacts
can will generate a force value that can be recreated by the vale force at the corners.

TrevorCash commented 5 years ago

There are lots of bodies in the scene - about 70 bodies - is the temp buffer global?

JulioJerez commented 5 years ago

no the temp buffer is per colliding pairs. But if a compound has many shapes and the ground has many faces the it can generate many contacts.

On Tue, May 21, 2019 at 11:19 AM Trevor Cash notifications@github.com wrote:

There are lots of bodies in the scene - about 70 bodies - is the temp buffer global?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MADEAPPS/newton-dynamics/issues/169?email_source=notifications&email_token=AB6EPJFKXCYJ5RFIIP4E2G3PWQ4JVA5CNFSM4HOGCOU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV4YAQQ#issuecomment-494501954, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6EPJGC2M63UJ655J2UBPLPWQ4JVANCNFSM4HOGCOUQ .

TrevorCash commented 5 years ago

ok - in my scene there are no complex bodies. just basic shapes - cylinders and boxes.

JulioJerez commented 5 years ago

that was my impression, what about the floor is the floor a high resolution mesh? I would be interesting to see what causing all those contacts.

TrevorCash commented 5 years ago

its actually a 2d array of boxes. making up a compound - Ah that must be it - didnt think of that. There are 100*100 boxes

JulioJerez commented 5 years ago

ah I see, assuming the worse case say a the L shape lies sideway. this means all shape hit the floor, also assuming thet the contact count is 92 contacts, if each colliding pair or convex between the compounds generate on average 6 contacts, this means that 92 / 6 = 12 the l shape his approximately 12 boxes of the compound floor. seems reasonable. I am goint to remove the assert 0, and commite the code.

Is there any reason you use a compound or boxes for floor, I like the idea because it stress test the engine, in fact there is a shape called scene collision that is design for that kind of things.

but for your case I believe it will be far more effecient to use a polygonal mesh for floor. I do not know if you know but the engine has a sophisticated polygon optimization proccess that simplify a collison mesh to maximize the surface area of each face while keeping the error within the the numerical precision of double, (pratically zero error between the origional and the collision mesh) the collision mesh is very efficient for these cases.
unless you are using the compound for some other reasons.

.

TrevorCash commented 5 years ago

yeah they are boxes only because thats how the code evolved - Really it should be a single flat plane or something. As it is the boxes are part of the scene collision.

TrevorCash commented 5 years ago

Oh Sorry I told you wrong. I do have 100x100 boxes - but there is only one box for the collision. I looked at the code too quickly. :/

JulioJerez commented 5 years ago

100x100? does this mean one box of 100 unit by 100 unit or a compound of 100 x 100 small boxes? 🤔 hikes!!!

On Wed, May 22, 2019 at 1:08 PM Trevor Cash notifications@github.com wrote:

Oh Sorry I told you wrong. I do have 100x100 boxes - but there is only one box for the collision. I looked at the code too quickly. :/

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/MADEAPPS/newton-dynamics/issues/169?email_source=notifications&email_token=AB6EPJFOIB3BODVQHS2VJXLPWWR2LA5CNFSM4HOGCOU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWAFYFY#issuecomment-494951447, or mute the thread https://github.com/notifications/unsubscribe-auth/AB6EPJACIU5YOMUSXLLGVNLPWWR2LANCNFSM4HOGCOUQ .

TrevorCash commented 5 years ago

As far as the physics is concerned there is only 1 box that represents the ground. Sorry for the confusion.

JulioJerez commented 5 years ago

Yes I know that, what I want to know is how many sub shapes are touching the aabb of the L shape body, that will explain the source of so many contact for a shape that seem very simple. If there aren't enough sub shapes there is bug. And bugs have a way to show up.

TrevorCash commented 5 years ago

got the assert in debug mode again - this time I was working with simple box shapes: image

JulioJerez commented 5 years ago

I removed all the assert from the file please sync and try again.

JulioJerez commented 5 years ago

oh wait, you said you were playing with simplee boxes? can I get a repro test, I am curious to find out why that is. I very rarerly seem those asserts.

TrevorCash commented 5 years ago

here is a demo: https://drive.google.com/open?id=19czDAmXuzggpCeHHyOvdskDerV6CxmQO

JulioJerez commented 5 years ago

It turned out there is a bug that does affect the posporcesing of of contacts generated by compounds, or more specifically contracts that do not lie on a plane. I will fix that tonight and them test it with you demo. It affect a user that just reported in the forum, so Icommitted a temp fix until I write a better volume filter.

TrevorCash commented 5 years ago

Sounds Good, better compound behavior sounds great.

Also let me know if you make a gitlab account, I'll add you to the my repository in case you want to build there.

JulioJerez commented 4 years ago

I believe this was fioxed.