Velocities != 0 after bodies set to sleeping

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Velocities != 0 after bodies set to sleeping

Postby Cannos » Tue Nov 29, 2016 5:38 pm

I'm seeing bodies that are asleep and at equilibrium not have their velocity/omega set to 0. I assume they should be set to 0 when going to sleep as this was the behavior I saw in Newton 2.x.

From what I can tell, setting velocities to 0 on sleep happens in dgWorldDynamicUpdate::IntegrateArray(). Regarding this condition:

if (isAutoSleep && (island->m_jointCount > DG_SMALL_ISLAND_COUNT)) {...}

I'm seeing this be false as my island->m_jointCount == 2, which is not greater than DG_SMALL_ISLAND_COUNT. Does this sound right? Is this behavior intentional, and if so, is there something else I can do to force velocities to be set to zero upon going to sleep?
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: Velocities != 0 after bodies set to sleeping

Postby Julio Jerez » Tue Nov 29, 2016 6:02 pm

this behavior is intentional, in Newton 3.14 bodies has tow equilibrium state.

one is when the force acting on eth bode are zero. that dynamics equilibrium, and the other is when the forces and the velocity is zero, that's kinematic equilibrium.

is just happen that when and island is being solve many time the forces are zero, het the body is still moving with small constant velocity, so the body is set is dynamics equilibrium, and is still integrated with a higher damped value. It eventually reach zero velocity, but if is does no then the body will wake up automatically.
This is a preamble form getting away for the auto sleep feature, Newton 3.15 will not longer has auto sleep. Instead t will formalize the continue collision solver which execute force passes and Impulse passes independent for each other.
This will allowed to feature when a body can me on top of a moving body and still be sleeping. because the forces are zero, while the velocity is not.

but this solver is way more stable and accurate that 3.13 and much faster. this weekend I will post some comparison videos between 3.13 and 3.14.

This is still in experimentation stage since I committed last week.
Please let me know is there is some odd behavuir that we can adjust.
do you get some odd behevaiur
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Velocities != 0 after bodies set to sleeping

Postby Julio Jerez » Tue Nov 29, 2016 6:05 pm

Oh I see , this line
Code: Select all
if (isAutoSleep && (island->m_jointCount > DG_SMALL_ISLAND_COUNT)) {...}


may be a bug, is should probably be
Code: Select all
if (equilibrium && (island->m_jointCount > DG_SMALL_ISLAND_COUNT)) {...}

I will take a look.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Velocities != 0 after bodies set to sleeping

Postby Cannos » Tue Nov 29, 2016 6:32 pm

Okay, I suppose I'll need to work around this. I have a turn-based game that can be rewound/fast-forwarded and turns can be resimulated. The turns end when all bodies come to rest, and it assumes that velocities are zero for all bodies at the beginning of the next turn. I suppose I'll have to force all the velocities to zero at the end of a turn (using the *NoSleep methods so that it doesn't awaken the bodies).

Is this what you'd recommend? Also, are there any callbacks for when a body reaches equilibrium?
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: Velocities != 0 after bodies set to sleeping

Postby Julio Jerez » Tue Nov 29, 2016 7:53 pm

do not do anything yet, I believe line
Code: Select all
if (sleeping && (island->m_jointCount > DG_SMALL_ISLAND_COUNT)) {...}

is a bug, I believe that the small island are tread special because they may of may no have contact.
In fact there is not reason for the small island check anymore, so I believe that an overlooked, the body should go to sleep, it is checking the wrong flag.
I will check out tonight.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Velocities != 0 after bodies set to sleeping

Postby Julio Jerez » Thu Dec 01, 2016 5:55 pm

I think this is fixed now. The problem was that define DG_SMALL_ISLAND_COUNT
which is a legacy for 3.14, removing it fix the bug.
Please try again.
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 8 guests

cron