Body Stops Moving Before Equilibrium

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Body Stops Moving Before Equilibrium

Postby michDS » Thu Jun 07, 2012 4:09 am

In my bowling game, which uses Newton version 2.35, sometimes a pin that's been hit and is moving stops and "freezes" before it should be reaching equilibrium. Here is the issue presented in a quick video:

http://www.digitalsmoke.us/Newton200_Issue.mov

All the objects are set to auto-sleep, and the pins are never explicitly set to freeze or unfreeze. Any ideas why this might be happening? I did not experience this issue with prior versions of Newton.

Thanks,
Michelle
michDS
 
Posts: 33
Joined: Fri Aug 12, 2011 3:47 pm

Re: Body Stops Moving Before Equilibrium

Postby Julio Jerez » Thu Jun 07, 2012 7:29 am

I am guessing you have the inertia of teh pin set wrong set wrong.
what kind of shape is teh pin and howp you set teh inertia?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Body Stops Moving Before Equilibrium

Postby michDS » Thu Jun 07, 2012 3:10 pm

Each pin is a single cylinder shape. The inertia is set using:

mr^2/2
m(3r^2 + h^2)/12

I'm pretty sure we've set that up correctly. Also, we were not experiencing this issue with version 2.31 of Newton. I am suspecting the following change in dgBodyMasterList.cpp caused the issue:

// note this is in observation (to prevent bodies from not going to sleep inside triggers
body0->m_equilibrium = body0->m_invMass.m_w ? false : true;
body1->m_equilibrium = body1->m_invMass.m_w ? false : true;

// body0->Unfreeze();
// body1->Unfreeze();

When I change these lines back to how they were in version 2.31, the problem seems to go away. Any ideas?

Michelle
michDS
 
Posts: 33
Joined: Fri Aug 12, 2011 3:47 pm

Re: Body Stops Moving Before Equilibrium

Postby Julio Jerez » Thu Jun 07, 2012 5:49 pm

I made many fixes to core 200, I do not remember why that was done, but I am sure they is solution.

can you convert over to core 300? It is very eassy and many of those issues are resolved.

if you can not, in any case since 2.35 is teh last version of core 200, you can keep the local changes
and use untill you made the transition to core 300.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Body Stops Moving Before Equilibrium

Postby michDS » Thu Jun 07, 2012 6:10 pm

Well... we are getting close to releasing our game for Android, so I'm trying to avoid making riskier changes such as switching versions. Is core 300 still in alpha state, or do you think it would be safe to switch and release our game with it?

I think you mentioned in a different thread that the change was made because the freeze state of the body was being modified without notifying the user: http://newtondynamics.com/forum/viewtopic.php?f=12&t=6946&hilit=body+stops+moving
michDS
 
Posts: 33
Joined: Fri Aug 12, 2011 3:47 pm

Re: Body Stops Moving Before Equilibrium

Postby Julio Jerez » Thu Jun 07, 2012 6:51 pm

are you making teh pin frozeen, becaus ethey are not in equlibrium whe you place then?

what happen if you mak ethe autosleep? do teh fall and this is why you make the frozzen?

if this is the case, I beileve you need to make them active bu using the one time frozzen trick.
bascially you make a flag on of off in the body that represent the body.

then in the contact callback, teh vey first time is call you set the flag off and they will will naturally.
that was the solution that was done for the dominos on teh thread.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Body Stops Moving Before Equilibrium

Postby michDS » Fri Jun 08, 2012 1:45 am

The pins are not frozen when the puck is launched at them, but I do use NewtonBodySetFreezeState() to freeze pins that I want to hide. For example, I hide pins after they've been knocked down on the table or completely outside the table (instead of deleting and re-creating them for the next turn).

So basically to hide a pin, I give it a NULL collision, call NewtonBodySetFreezeState(true), and also move it outside the physics world. Then when I make the pin visible again, I set its collision, position, and call NewtonBodySetFreezeState(false).

If I remove the calls to NewtonBodySetFreezeState(), things seem to be working fine. So by placing an object outside the physics world, will that object not be simulated anymore? If so, then I don't need to use NewtonBodySetFreezeState() at all. Is there a better way to "deactivate" a body w/out deleting it?
michDS
 
Posts: 33
Joined: Fri Aug 12, 2011 3:47 pm

Re: Body Stops Moving Before Equilibrium

Postby Julio Jerez » Fri Jun 08, 2012 7:54 am

placing the object outsde the workd will stop then from being simulated yes.
but set freeze show also work, are you sure you are not calling freeze on the wrong pin.

the problem tha was fixed was a real bug, it sure work teh way it si now in yor code as well.

a quick way to deativated could be moving the body outside of view and set the force callback to NULL.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
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 1 guest