Newton 2 - Freeze & sleep

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Newton 2 - Freeze & sleep

Postby Aphex » Sat Aug 23, 2008 12:56 pm

Hi all,

I'm seeing some funny business with freeze state after moving to Newton 2 - anyone know the difference between freeze and sleep in the API?
I thought they were the same thing - if so why are they both there? BC?
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: Newton 2 - Freeze & sleep

Postby brianhammond » Mon Aug 25, 2008 10:42 pm

AFAIK a frozen body is not in the list of bodies to simulate while a sleeping body can be (when awakened by another body colliding with it). Newton figures out when to put a body to sleep (I suppose when it stops moving for some predetermined time duration) if its autosleep flag is set (NewtonBodySetAutoSleep).
User avatar
brianhammond
 
Posts: 14
Joined: Thu Sep 06, 2007 7:59 pm

Re: Newton 2 - Freeze & sleep

Postby nova_cat » Tue Aug 26, 2008 11:05 am

It seems several APIs related to 'AutoFreeze' have been either removed or renamed to 'AutoSleep' in Newton 2 beta16 according to the changelist. Dont know whether it is a version issue..
nova_cat
 
Posts: 1
Joined: Mon Jul 21, 2008 7:42 am

Re: Newton 2 - Freeze & sleep

Postby brianhammond » Tue Aug 26, 2008 11:07 am

I thought that was because Newton knows when to autofreeze something. Perhaps not.
User avatar
brianhammond
 
Posts: 14
Joined: Thu Sep 06, 2007 7:59 pm

Re: Newton 2 - Freeze & sleep

Postby Aphex » Tue Aug 26, 2008 2:51 pm

Yeah that was part of my confusion - the names sleep/freeze interchanging between versions.
Old Newton worked fine as my code is, but moving to (what I thought) the new functions are gives me some unexpected results and frozen bodies...
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: Newton 2 - Freeze & sleep

Postby Julio Jerez » Tue Aug 26, 2008 4:03 pm

what problems are you having?
can you list the functions you are getting confused with?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 2 - Freeze & sleep

Postby Aphex » Tue Aug 26, 2008 5:02 pm

Functions are:
Code: Select all
   NEWTON_API int  NewtonBodyGetSleepState (const NewtonBody* body);
   NEWTON_API int  NewtonBodyGetAutoSleep (const NewtonBody* body);
   NEWTON_API void NewtonBodySetAutoSleep (const NewtonBody* body, int state);
   NEWTON_API int  NewtonBodyGetFreezeState(const NewtonBody* body);
   NEWTON_API void NewtonBodySetFreezeState (const NewtonBody* body, int state);


They might not be problems I'm having, but things are behaving differently to Newton1.5:
Static bodies with zero mass are now being shown as 'unfrozen' when in contact with dynamic bodies (using GetFreezeState).
On creation, some bodies are 'freezing' when they never used to (despite calling SetAutoSleep(0)).
So I'm suspecting things have changed, or I'm using the wrong function this time..? Is there a difference between frozen and asleep? What do they mean in Newton terms?
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: Newton 2 - Freeze & sleep

Postby Julio Jerez » Tue Aug 26, 2008 5:29 pm

Oh I see.
There are two flag in a rigid body.
auto_sleep_flag and freeze_flag
freeze_fag is controlled by the functions
int NewtonBodyGetFreezeState(const NewtonBody* body);
void NewtonBodySetFreezeState (const NewtonBody* body, int state);

the two function stop a body form being simulate even i fteh body has no reached the state of equilibrium.
Say you want to place by box in mid air and you do not wan it to fall even if gravity is acting of it.
For the you careate the bdy an dyou call
NewtonBodySetFreezeState(body, int state)
the body will not move until eney of these evene happens:
a collision, an impulse, of a call to function
NewtonBodySetFreezeState (body, 0);
basically it is a one time flag, the is control by the application.
must applications do not need use this flag if bodies are in equlibrium when they are created,

auto_sleep_flag is controlled by the functions i scontrolled by
int NewtonBodyGetSleepState (const NewtonBody* body);
int NewtonBodyGetAutoSleep (const NewtonBody* body);
void NewtonBodySetAutoSleep (const NewtonBody* body, int state);

when auto_sleep_flag is one, a body will not be simulated if the body and all of the other bodies linked to that body by a joint are in equilibrium. If autosleo is zero the body will always simulated.
You set auto_sleep_flag using NewtonBodySetAutoSleep (const NewtonBody* body, int state);

int NewtonBodyGetAutoSleep (const NewtonBody* body);
tell you if the body is sleeping. (meanning is in equlibrium and aouto sleep flag is one
int NewtonBodyGetSleepState (const NewtonBody* body);
tell you if the flag autosleep is one zero
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton 2 - Freeze & sleep

Postby brianhammond » Tue Aug 26, 2008 6:13 pm

Julio Jerez wrote:int NewtonBodyGetAutoSleep (const NewtonBody* body);
tell you if the body is sleeping. (meanning is in equlibrium and aouto sleep flag is one
int NewtonBodyGetSleepState (const NewtonBody* body);
tell you if the flag autosleep is one zero


I believe those 2 are backwards.

Thanks for the info!
User avatar
brianhammond
 
Posts: 14
Joined: Thu Sep 06, 2007 7:59 pm

Re: Newton 2 - Freeze & sleep

Postby Aphex » Wed Aug 27, 2008 3:13 am

Yep thanks for the info - just what I needed :)
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 22 guests