Enabling Bodies

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Enabling Bodies

Postby Yezide » Thu Sep 29, 2011 7:26 am

When I make static (mass==0) move by directly setting the matrix and velocity, I need to make sure all bodies that might collide with the moving are enabled (non-sleeping).

What is the correct function to do this? I have tried changing the freeze mode, but that has no effect. Right now I have to do it a little hackish and add a small impulse on all bodies nearby that are not enabled, but this feels awfully hackish and might give bad results. I thought about turning off autosleep when in proximity to the moving static, but that does not feel right + means I have to use kinda complicated code to keep track of everything.

What would be the correct way to go about?
User avatar
Yezide
 
Posts: 173
Joined: Tue Oct 18, 2005 4:31 am

Re: Enabling Bodies

Postby Julio Jerez » Thu Sep 29, 2011 1:25 pm

The simplest way will be to iterate over each contact connecting that body to another body and destroy the contact joint
Code: Select all
void DeleteAllContacts (NewtonBody* const body)
{
   NewtonJoint* nextJoint;
   NewtonWorld* const world = NewtonBodyGetWorld (body);
   for (NewtonJoint* joint = NewtonBodyGetFirstContactJoint(body); joint; joint = nextJoint) {
      nextJoint = NewtonBodyGetNextContactJoint(body, joint);
      NewtonDestroyJoint(world, joint);
   }
}


If you want to be clever you can check at what function RemoveConstraint in file physics\dgBodyMasterList.cpp does when a joint is delete,
Here it is
Code: Select all
void dgBodyMasterList:: (dgConstraint* const constraint)
{
   m_constraintCount = m_constraintCount - 1;
   _ASSERTE (((dgInt32)m_constraintCount) >= 0);

   dgBody *const body0 = constraint->m_body0;
   dgBody *const body1 = constraint->m_body1;
   _ASSERTE (body0);
   _ASSERTE (body1);
   _ASSERTE (body0 == constraint->m_link1->GetInfo().m_bodyNode);
   _ASSERTE (body1 == constraint->m_link0->GetInfo().m_bodyNode);

   body0->m_equilibrium = dgUnsigned32 (body0->m_invMass.m_w ? false : true);
   body1->m_equilibrium = dgUnsigned32 (body1->m_invMass.m_w ? false : true);

   body0->m_masterNode->GetInfo().Remove(constraint->m_link0);
   body1->m_masterNode->GetInfo().Remove(constraint->m_link1);

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


Basically the ste the equlibrium flag to false, and tehn call unfreeze, but I beleiv that delete the joint is better because what the equelibrim flag does is that leter all contact jopint will be deleted.


Yeside has you tryed core 300?
if beleive tha for you core 300, is better because it is designed for Console port, and is better at mutithreading.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Enabling Bodies

Postby Yezide » Thu Sep 29, 2011 2:04 pm

Thanks a bunch! Will try out next week (of on trip now).

Will get the latest version next week too! Just started on getting all the physics up and running :)
User avatar
Yezide
 
Posts: 173
Joined: Tue Oct 18, 2005 4:31 am

Re: Enabling Bodies

Postby Yezide » Thu Oct 06, 2011 12:48 pm

Tried and it works perfectly! Thanks!
User avatar
Yezide
 
Posts: 173
Joined: Tue Oct 18, 2005 4:31 am

Re: Enabling Bodies

Postby Yezide » Thu Oct 06, 2011 12:55 pm

And just downloaded the latest on Google code and that was only core 200. Where can I get 300? :)
User avatar
Yezide
 
Posts: 173
Joined: Tue Oct 18, 2005 4:31 am

Re: Enabling Bodies

Postby Julio Jerez » Thu Oct 06, 2011 1:07 pm

ther are tow folders
coreLibrary_200 and coreLibrary_300

the demos are using core 200 still. but soon I will swith then to use core 300, and made a new check in
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Enabling Bodies

Postby Yezide » Thu Oct 06, 2011 1:13 pm

Hmm only one folder in the rar I downloaded, this one: http://code.google.com/p/newton-dynamic ... r&can=2&q=
User avatar
Yezide
 
Posts: 173
Joined: Tue Oct 18, 2005 4:31 am

Re: Enabling Bodies

Postby Julio Jerez » Thu Oct 06, 2011 1:21 pm

Oh I see, you are downloading the package from google source, that is an image of a VS project.
That is what I used to distibuted before it when open source. I simple added the source files and the projects to it.

you should sync to SVN to get the later version, that way you will get an image of my Deveploment forder.
they are very much the same in what they share, but there is more stuff in SVN plus the latest bug fixes.
The organization is very clean, so it will not bload it up your machine.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Enabling Bodies

Postby Yezide » Thu Oct 06, 2011 4:26 pm

AH! Now I found the svn url.

Using core_300 now.
User avatar
Yezide
 
Posts: 173
Joined: Tue Oct 18, 2005 4:31 am

Re: Enabling Bodies

Postby Yezide » Thu Oct 06, 2011 4:29 pm

Ooops.

Tried it and everything just fell through the floor.

Are there any special changes I need to do to the code compared to core_200 or some setup I must do?
User avatar
Yezide
 
Posts: 173
Joined: Tue Oct 18, 2005 4:31 am

Re: Enabling Bodies

Postby Julio Jerez » Thu Oct 06, 2011 4:43 pm

Ha the interface level it should be 100% compatible with core 200.

what shape are you using for floor?
did you run in debug build?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Enabling Bodies

Postby Yezide » Fri Oct 07, 2011 3:08 am

I am using the release build.

And have tried box shape and tree collision, all fail.
User avatar
Yezide
 
Posts: 173
Joined: Tue Oct 18, 2005 4:31 am

Re: Enabling Bodies

Postby Julio Jerez » Fri Oct 07, 2011 7:17 am

do you have a simple test I can try?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Enabling Bodies

Postby Yezide » Fri Oct 07, 2011 9:57 am

Will try and do something next week!

Even very simple setups fail though, tried with just a static box and a dynamic box and the two went through eachother.

I found this code in dgWorldDynamicUpdate.cpp (line 132):
Code: Select all
//   if (world->m_singleIslandMultithreading) {
if (0) {


Might that be the problem?
User avatar
Yezide
 
Posts: 173
Joined: Tue Oct 18, 2005 4:31 am

Re: Enabling Bodies

Postby Julio Jerez » Fri Oct 07, 2011 12:25 pm

Yezide wrote:I found this code in dgWorldDynamicUpdate.cpp (line 132):
Code: Select all
//   if (world->m_singleIslandMultithreading) {
if (0) {

Might that be the problem?


I do not think so, I do that to test one part or anopteh of teh engine
basicall that makes the engine run in muttreadind but a Island Granularity
I beleibe is work but I will check it out,'
you can try
Code: Select all
//   if (world->m_singleIslandMultithreading) {
if (1) {


and the will run the engine mutthreaded at a joint granularity level.
in the future tah will be the defult and preferred mode for core 300
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron