Migration from 1.5 to 2 issues

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Migration from 1.5 to 2 issues

Postby bjtp » Thu Nov 12, 2009 7:59 am

Lacking a 64bit version of 1.53, I tried to port an old application from 1.53 to 2.x. Is there any "collected" documentation to help this process?

For example, the old version used autoactive callbacks of bodies (to detect sleeping/reactivation), what would be the 2.x replacement? Deriving the body-class and override set/getfreeze?

Thank you ...
bjtp
 
Posts: 5
Joined: Thu Nov 12, 2009 7:51 am

Re: Migration from 1.5 to 2 issues

Postby JernejL » Thu Nov 12, 2009 8:45 am

In 2,0 you no longer have to reactivate bodies manually, they get automaticly reactivated when you apply sufficient forces in forcetorque callback, which is now always called for all bodies.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Migration from 1.5 to 2 issues

Postby bjtp » Thu Nov 12, 2009 10:03 am

The autoactive callback was used to alter the state of an application entity connected with the newton body. Well, I guess I have to redesign the main application in order to migrate ...
bjtp
 
Posts: 5
Joined: Thu Nov 12, 2009 7:51 am

Re: Migration from 1.5 to 2 issues

Postby Julio Jerez » Thu Nov 12, 2009 10:26 am

why? you just do not use activate it soudl work teh exact same way.

in 1.53 yuo need activate because teh frce callback was never call for sliping bodies, bu tah m ake teh game logoc too complicated,
nwo force callback are alway call, so all you nee to do is apply the forces, or impulse there. The body will wakeup if the forces brake equilbrium
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Migration from 1.5 to 2 issues

Postby bjtp » Thu Nov 12, 2009 11:37 am

Well, there are several bodies handled by newton. In 1.53, if they come to equilibrium, they sleep/freeze and autoactive-callback is called (that is what the callback was needed for primarily). The callback informs the entity system about the state change. Now, with 2.x, that is no longer possible. That means I have to implement a different communcation layer/protocol between newton and the entity system.

I'd like to know if there is some documentation about migrating from 1.5 to 2, because it would make things much easier.
bjtp
 
Posts: 5
Joined: Thu Nov 12, 2009 7:51 am

Re: Migration from 1.5 to 2 issues

Postby Julio Jerez » Thu Nov 12, 2009 11:59 am

But the same funtionality is still there
NEWTON_API int NewtonBodyGetSleepState (const NewtonBody* body); // check if a body is in sleep mode
NEWTON_API int NewtonBodyGetAutoSleep (const NewtonBody* body); // set automatic sleep mode
NEWTON_API void NewtonBodySetAutoSleep (const NewtonBody* body, int state); // Get automatic sleep mode


NEWTON_API int NewtonBodyGetFreezeState(const NewtonBody* body); // freeze aboy from simulation
NEWTON_API void NewtonBodySetFreezeState (const NewtonBody* body, int state);


the only part it is not there is the activation call back for when the body goes to sleep.
You do not need it in 2.0 because the force and torque call back is called for all objects even if there are frozeng or sleeping.
You can do in the force call back what you were doing in the activation callback.

this make the logic much simpler in both side, In the applicaion side you can see force and torqe as an update funtion for each body.
In the engine side it simply the logic from the solve side, since it does no have to make those callbacks from there.

1.53 keept mutiple body list: active, inactive, frozzen and so on, this is very nice for simple core but it makes muticore programing very
complicated, it end up doing a lot of atomics checks to move object from list to list.
since 2.0 moves more bodies than 1.53 it is better to juts keep one list and make one pass calling all bodies and the do all the prossesing.

The changing from 1.53 to 2.0 are dictated by the muthreaded nature of 2.0
in a way 2.0 is slower than 1.53 in object management but this is the price you pay for new tecnology.
the streamlining in the solver and the collision more than make up for the object manager simplications.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Migration from 1.5 to 2 issues

Postby bjtp » Thu Nov 12, 2009 2:12 pm

I understood that "sleep" means the body does not react to collisions any more?!
bjtp
 
Posts: 5
Joined: Thu Nov 12, 2009 7:51 am

Re: Migration from 1.5 to 2 issues

Postby Julio Jerez » Thu Nov 12, 2009 2:27 pm

bjtp wrote:I understood that "sleep" means the body does not react to collisions any more?!

not.
it means that body and all of the bodies that are in contact with the body are in static equilibrium, therefore the engine do not need to speed time calculation contact and reaction forces.

for expplae say you have a biox at rest on teh floor.

the collesion calculate the normal, and teh resting forces, once teh box settle teh engine save the last contact and forces, and skip all calculation in teh body.
the diffrent with 1.5 is tha in 1.5 you did no get more force updates, so if you want to activate teh body you had to explicitly activated it.
with 2.0 the body keep getting the force callback and you apply the gravity, teh eth body check if tah force added to teh oteh internal force add to zero, and if teh velocity is also zero.
if it is teh body is keep hsi sleep status.
if for example you change the gravity, or the velocity, or move teh body, teh body teh chek will fali and it teh body lose it status.
the reason for this is the the force call back can be call from a array the is devided into the number of active cores and each core do an eqaul amput of work.

basically applict a force, a velocity, or telporting teh body wake up a body from slepping.

you also have frezze, and island axctivation with are more poweful for LOD controll.
believe me 2.0 is superior to 1.5 in every aspect.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Migration from 1.5 to 2 issues

Postby bjtp » Thu Nov 12, 2009 2:59 pm

I have no doubt it is. I still have not yet figured out how it works and what the major differences to 1.5 are - to adapt the application.

Still, the above was very helpful, thank you.
bjtp
 
Posts: 5
Joined: Thu Nov 12, 2009 7:51 am

Re: Migration from 1.5 to 2 issues

Postby Julio Jerez » Thu Nov 12, 2009 3:14 pm

check out the beginers tutorial tuturials in the wiki, ther are more fucus and cover many of the issues you are worrie about.
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