NewtonMaterialSetContactNormalDirection assert

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

NewtonMaterialSetContactNormalDirection assert

Postby Cannos » Tue Jan 03, 2017 7:21 pm

Does the assert in NewtonMaterialSetContactNormalDirection make sense? It complains if the desired normal is different from current normal. The only time you'd call this function is to specifically change the normal.

Code: Select all
   dgAssert (dgAbsf (normal.DotProduct3(material->m_normal) - dgFloat32(1.0f)) <dgFloat32 (0.01f));


1) If the assert is to make sure you're actually changing the value, it seems like < should maybe be >?

2) Or if the assert is to make sure the desired normal is a unit vector, then I think it should be normal.DotProduct3(normal)
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: NewtonMaterialSetContactNormalDirection assert

Postby Julio Jerez » Tue Jan 03, 2017 8:07 pm

is there so that the use know that he is setting the normal to a wacky direction.
say a ball fall on the ground and the normal point up.

if you override the direction for some special effect, you can ado that up to certain point.
if you set the normal horizontal, the is as there is no contact whatever, of you se to point down is act as if the object are pulling apart and no actin will be taken.
that code tells you that you are change the normal to point outsize the hemisphere of action of a contact point which is most certainly a mistake.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonMaterialSetContactNormalDirection assert

Postby Cannos » Tue Jan 03, 2017 9:30 pm

Okay, in that case, the 0.01f difference it allows between the dot product and 1.0 represents a change of only 8.1 degrees between the current and desired normal before asserting.

Since you mentioned the hemisphere of action, is this assert meant to check that the directions are not perpendicular? If so, should it be this instead?

Code: Select all
dgAssert (normal.DotProduct3(material->m_normal) > dgFloat32 (0.01f));



In my particular test case, I'm getting contacts along edges of horizontal polygons that I need to force to be straight up. But the contact normals I'm receiving can up up to 55 degrees away from straight up.
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: NewtonMaterialSetContactNormalDirection assert

Postby Julio Jerez » Tue Jan 03, 2017 9:46 pm

Code: Select all
dgAssert (normal.DotProduct3(material->m_normal) > dgFloat32 (0.01f));

ha yes that's correct I'll fix it

In my particular test case, I'm getting contacts along edges of horizontal polygons that I need to force to be straight up. But the contact normal I'm receiving can up up to 55 degrees away from straight up.

are you on latest 3.14 there is special contact post preprocessing code to prevent that for happening.

if tow polygon share an edge and the dihedral angle is convex you should never get a bogus normal.
if the dihedral angle is concave you should get two contact one on each face. if is no that then some is wrong. I test extensively and seems to work. look at this video.
https://www.youtube.com/watch?v=qMy7vqK7mvc&t=7s

the new algorithm is far better that the one in early 3.14 and older.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonMaterialSetContactNormalDirection assert

Postby Cannos » Wed Jan 04, 2017 3:02 am

Yes, I'm on 3.14. In this case, the polys are part of different meshes so their edges are lined up, but they aren't strictly sharing the same edge. More specifically, I have a ground mesh adjacent to a box, with the top of the box at the ground plane. I'm sliding an object across the ground and I want it to continue to slide smoothly across the top of the box without it looking like it hit a bump.

Because these are separate objects, I'm expecting to get some contacts along the edges of the ground mesh or box that don't point straight up, so doing some fixup via NewtonMaterialSetContactNormalDirection was expected.
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: NewtonMaterialSetContactNormalDirection assert

Postby Julio Jerez » Wed Jan 04, 2017 10:17 am

Cannos wrote:Yes, I'm on 3.14. In this case, the polys are part of different meshes so their edges are lined up, but they aren't strictly sharing the same edge.

ha yes is doe not handle that, it would be nice to but, at this time is better to leave to the end application. I will make that change you'd mentioned.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
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 18 guests

cron