[SOLVED] Unsigned short height fields produce weird behavior

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

[SOLVED] Unsigned short height fields produce weird behavior

Postby pHySiQuE » Mon Sep 02, 2013 6:48 pm

Recently Newton regained the ability to use unsigned shorts for heightfield collisions. I believe there is a problem with the physics on these types of heightfields. When a ball bounces on the terrain, it shoots off with too much energy and sometimes passes right through the terrain.
Last edited by pHySiQuE on Thu Sep 05, 2013 1:29 am, edited 1 time in total.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Unsigned short height fields produce weird behavior

Postby Julio Jerez » Mon Sep 02, 2013 8:35 pm

I have never seen a ball rolling over a height field doing what you say, do you have a demo that you can show doing that?
can you display the patch of the mesh and the contact normal around the ball as it rolls.

The only way that some like that can happen is if the mesh around the object is constructed wrong. But even if the mesh was constructed wrong
there is not way and object can should out with more energy after a collision that the energy that was before the collision.

you can place two objects at 100% interpenetration and the will separate slowly with a constant velocity.
This is because Newton is not a impulsive engine, Newton is is fact an action-reaction force based engine, this mean conservation of momentum and conservation of energy is preserved.
I do not know what could be wrong, but I do no believe it the mesh being made of 16 or 32 bit integers.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unsigned short height fields produce weird behavior

Postby pHySiQuE » Mon Sep 02, 2013 8:59 pm

Here is a video of the behavior:
http://www.leadwerks.com/post/terrain.mov

My best guess was the unsigned short heightfields weren't working right, since that was a relatively recent change and no one else is using them.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Unsigned short height fields produce weird behavior

Postby Julio Jerez » Mon Sep 02, 2013 10:13 pm

weren't using them?

also can you sow the wire frame mesh of the hieghtfield and the ball and the collide?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unsigned short height fields produce weird behavior

Postby Julio Jerez » Mon Sep 02, 2013 10:43 pm

The one thing I notice is that the ball gain lot of velocity after the collision. There could be a bug, but as far as I know there is nothing in the collision system that can make a object to do that.
that, to me is a sign of some parameter being wrong.

maybe you can ado this.
in you code some where insert a call to function
void NewtonSerializeToFile (const NewtonWorld* const newtonWorld, const char* const filename);

then try calling it right after you soot the ball, making sure the ball has it initial velocity.
this will save the scene to a file.
then try opening it up in the sandBox demo, to see if it works.

see if is fail there, and then send it to me so that I can debug it.

also can you try this on a PC, that can rule out that the bug is platform specific.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unsigned short height fields produce weird behavior

Postby pHySiQuE » Tue Sep 03, 2013 1:25 am

Here is the serialized file. I won't have access to a PC until tomorrow morning.
test.newton.zip
(9.24 KiB) Downloaded 180 times
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Unsigned short height fields produce weird behavior

Postby Julio Jerez » Tue Sep 03, 2013 10:42 am

Ok, I debugged and yes there was the kind of bug that could produce that kind of behavior.

sync to SVN and build, it should be fine now.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unsigned short height fields produce weird behavior

Postby pHySiQuE » Tue Sep 03, 2013 12:33 pm

Awesome, what was the problem?
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Unsigned short height fields produce weird behavior

Postby Julio Jerez » Tue Sep 03, 2013 1:06 pm

the engine build the triangle patch as index list vertex list in a first pass, setting the share edge normals to the face normal.
them is a secund pass determine if a edge normal shoudl point teh adjacent face normal.

the bug was that that in one direction when an edge normal had to be changed to point to the adjcent face normal,
the code was write the new index int teh worng destination changing the terrain mesh patch.

you would see it if you enabled debug display, using the collision mesh call back function
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unsigned short height fields produce weird behavior

Postby pHySiQuE » Tue Sep 03, 2013 4:31 pm

There was also a "fix" I made in the source that was causing a problem. -_-
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Unsigned short height fields produce weird behavior

Postby pHySiQuE » Tue Sep 03, 2013 8:10 pm

My custom player controller still gets tossed around on the terrain quite a bit. When I go to the top of the hill here I get pushed to the side:
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Unsigned short height fields produce weird behavior

Postby Julio Jerez » Wed Sep 04, 2013 11:28 am

I am no sure if I saw what the problem was on the video.
How can the collision tose you away, is your player controller a rigid body?

In any case, I suggest that you sync to SVN, I made some refactoring of the how the scale was handle by collision instances, so that later I can add
general global scale. local scale is not general enough to support scaling of compound collision, because a local scale applied to a child shape is one fact a global scale. These chmnage may have affected some o fteh code, but I beleiev it is all done now

Please sync again so that you have the latest update and try again. them tell me if the problem is still there?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unsigned short height fields produce weird behavior

Postby pHySiQuE » Wed Sep 04, 2013 3:15 pm

Seems to be working perfectly now. I don't have the same terrain, but I created a similar one with some very uneven sections, and the problem seems to be gone now with the latest build. Thank you.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests