Crashing in NewtonWorldForEachBodyInAABBDo

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Crashing in NewtonWorldForEachBodyInAABBDo

Postby Bird » Wed Aug 28, 2013 4:07 pm

I'm getting intermittent crashing when calling NewtonWorldForEachBodyInAABBDo from my code in the latest SVN version.

Crash happens on line 611 of dgCollisionConvexPolygon.cpp and it's because dgContactPoint* contactsOut is assigned a null pointer(proxy.m_contacts)

Here's a video of what's happening when it crashes.
http://hurleyworks.com/media/flash/PaintCrash/PaintCrash.html

-Bird
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Crashing in NewtonWorldForEachBodyInAABBDo

Postby Julio Jerez » Wed Aug 28, 2013 4:55 pm

yes that looks bad, yes a null Poniter will be worng there. I will check it out tonight

how is that call related to NewtonWorldForEachBodyInAABBDo?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crashing in NewtonWorldForEachBodyInAABBDo

Postby Bird » Wed Aug 28, 2013 5:27 pm

how is that call related to NewtonWorldForEachBodyInAABBDo?


It isn't. :) I thought that was the last Newton call I make but I was wrong. In the NewtonBodyIterator callback from NewtonWorldForEachBodyInAABBDo , I'm calling NewtonCollisionIntersectionTest and that's when the crash happens.

-Bird
Last edited by Bird on Wed Aug 28, 2013 8:18 pm, edited 1 time in total.
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Crashing in NewtonWorldForEachBodyInAABBDo

Postby Julio Jerez » Wed Aug 28, 2013 5:35 pm

can you show me the function that you you wrote? so that I have an idea what coudl be happeningg?

-I mean are you calling NewtonCollisionIntersectionTest for a NewtonWorldForEachBodyInAABBDo?
-are you calling from inside a newton update
-also are you calling using mlthethreadeds.

if you show me the function yo uwrote I can past a sampel in the sand box maybe we can reproduce the crash
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crashing in NewtonWorldForEachBodyInAABBDo

Postby Julio Jerez » Wed Aug 28, 2013 5:41 pm

also you said this
I'm getting intermittent crashing when calling NewtonWorldForEachBodyInAABBDo from my code in the latest SVN version.

was this working before?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crashing in NewtonWorldForEachBodyInAABBDo

Postby Bird » Wed Aug 28, 2013 8:08 pm

Julio Jerez wrote:can you show me the function that you you wrote? so that I have an idea what coudl be happeningg?

-I mean are you calling NewtonCollisionIntersectionTest for a NewtonWorldForEachBodyInAABBDo?
-are you calling from inside a newton update
-also are you calling using mlthethreadeds.

if you show me the function yo uwrote I can past a sampel in the sand box maybe we can reproduce the crash

-I'm calling NewtonCollisionIntersectionTest during the NewtonBodyIterator callback set in NewtonWorldForEachBodyInAABBDo
-I am not calling from inside a Newton update.
-I am calling from a single thread only

Here's the basic code. While dragging the mouse I first call testForCollision() and NewtonBodyIterator callback is called if there are any bodies inside my mesh's AABB. And from there I call NewtonCollisionIntersectionTest ;

was this working before?

I'm not really sure if it was working before but I *think* it was. I'll go back and try some earlier revisions if you'd like.

-Bird

Code: Select all
// testForCollision
void NewtonScene::testForCollision (const BodyID & bodyID)
{   
   PhysicsBodies::iterator it = bodies_.find(bodyID);
   if ( it != bodies_.end() )
   {
      PhysicsBody::Ptr pBody = it->second;
      if( pBody )
      {
         BBox3f bbox = pBody->component->worldBound;

         dVector min( bbox.min[0], bbox.min[1], bbox.min[2] );
         dVector max( bbox.max[0], bbox.max[1], bbox.max[2] );

         NewtonWorldForEachBodyInAABBDo(world_, &min[0], &max[0], &NewtonScene::NewtonBodyIterator, pBody.get());
      }
   }
}

// NewtonBodyIterator
int NewtonScene::NewtonBodyIterator (const NewtonBody * const body, void * const userData)
{   
   NewtonEntity* entity = (NewtonEntity*)(userData);
   NewtonEntity* otherEntity = (NewtonEntity*) NewtonBodyGetUserData(body);
   
   const NewtonBody * const otherBody = (NewtonBody*)entity->component->userData;

   // not interested in self collision
   if( body == otherBody ) return 1;

   NewtonCollision* collisionA = NewtonBodyGetCollision(body);
   NewtonCollision* collisionB = NewtonBodyGetCollision(otherBody);
   NewtonWorld* const world = NewtonBodyGetWorld(body);

   dMatrix poseA;
   NewtonBodyGetMatrix(body, &poseA[0][0]);

   dMatrix poseB;
   NewtonBodyGetMatrix(otherBody,&poseB[0][0]);

   if( NewtonCollisionIntersectionTest(world,collisionA, &poseA[0][0], collisionB, &poseB[0][0],0) )
   {
      ++entity->bodyDesc.collisionInfo.numberOfCollisions;
      entity->bodyDesc.collisionInfo.collisionList.push_back( (PhysicsBody*)(otherEntity) );
   }

   return 1;
}
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Crashing in NewtonWorldForEachBodyInAABBDo

Postby Julio Jerez » Wed Aug 28, 2013 9:50 pm

one more question, are you calling in parallel?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crashing in NewtonWorldForEachBodyInAABBDo

Postby Bird » Wed Aug 28, 2013 9:58 pm

Julio Jerez wrote:one more question, are you calling in parallel?


Nope, all calls are from the same thread.

-Bird
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Crashing in NewtonWorldForEachBodyInAABBDo

Postby Julio Jerez » Thu Aug 29, 2013 9:06 am

Ok fixed.

that was a big and obvious bug, this should also work form anywhere, thread, single thread, parallel or form a newton update.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crashing in NewtonWorldForEachBodyInAABBDo

Postby Bird » Thu Aug 29, 2013 9:34 am

Julio Jerez wrote:Ok fixed.

that was a big and obvious bug, this should also work form anywhere, thread, single thread, parallel or form a newton update.

Excellent! Thanks very much for the quick fix

BTW, using the Newton collision functions are working out great for me ... so now I can let the user rapidly paint with collision detection on.

http://hurleyworks.com/media/flash/AP_Collision_Paint2/AP_Collision_Paint2.html

-Bird
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Crashing in NewtonWorldForEachBodyInAABBDo

Postby Julio Jerez » Thu Aug 29, 2013 10:11 am

Oh wow that so cool, object placement that do not overlap.

so many artist will love you. that's one of the biggest problem there have, no so much on graphics packages like Max of Maya, but when using game level editor.

I have not seem a single engine that gets that right, not even a decent job.
It is so bad that most people has come to accept it as an unsolvable problem
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 8 guests

cron