Object bounces forever

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Object bounces forever

Postby nathanf534 » Mon Jul 18, 2011 7:37 pm

I have a very simple setup, there is a 10x10x1 static box positioned at the origin, and there is a 1x1x1 Sphere above the box. I add gravity to the sphere, and it falls to the box and continues to bounce forever. (It should bounce a few times and eventually slow to a stop). I have used Newton several times before and never encountered something like this. I am using the default elasticity/friction etc.

I have tried manually setting elasticity. Setting it to 0 somewhat reduces how high the ball bounces, but it still bounces forever.

I should also note, if I change the sphere to a box, it works fine.

Here is the Newton related code (Im using Newton with Irrlicht):
Code: Select all
nWorld=NewtonCreate();

//ADD GROUND
   ISceneNode* mapNode=smgr->addCubeSceneNode(10,0,-1,vector3df(0),vector3df(0),vector3df(1,0.1,1));
   NewtonBody* mapBody=NewtonCreateBody(nWorld,NewtonCreateBox(nWorld,10,1,10,0,NULL),&mapNode->getAbsoluteTransformation().pointer()[0]);
   UserData* userData = new UserData;//struct for holding Irrlicht ISceneNode*
   userData->node=mapNode;
   NewtonBodySetUserData(mapBody,userData);

   //ADD SPHERE
   ISceneNode* node=smgr->addSphereSceneNode(1,8,0,-1,vector3df(0,1,0),vector3df(0),vector3df(1,1,1));
   NewtonBody* nodeBody=NewtonCreateBody(nWorld,NewtonCreateSphere(nWorld,1,1,1,0,NULL),&node->getAbsoluteTransformation().pointer()[0]);
   NewtonBodySetMassMatrix(nodeBody,1,1,1,1);
   NewtonBodySetForceAndTorqueCallback(nodeBody,NewtonApplyForceAndTorqueCallback);
   NewtonBodySetTransformCallback(nodeBody,NewtonSetTransformCallback);
   userData = new UserData;
   userData->node=node;
   NewtonBodySetUserData(nodeBody,userData);
       
       .....

      NewtonUpdate(nWorld,17);  //This is in a loop that is called 60 times per second





and here are the callbacks
Code: Select all
void World::NewtonSetTransformCallback(const NewtonBody* body, const float* matrix, int threadIndex){
   void* data= NewtonBodyGetUserData(body);
   UserData* userData=(UserData*)data;
   ISceneNode* node = (ISceneNode*)userData->node;
   matrix4 mat;
   mat.setM(matrix);
   node->setPosition(mat.getTranslation());
   node->setRotation(mat.getRotationDegrees());
}
void World::NewtonApplyForceAndTorqueCallback(const NewtonBody* body,float timestep, int threadIndex){
   float force[] = {0,-5,0};
   NewtonBodyAddForce(body,&force[0]);
}
nathanf534
 
Posts: 19
Joined: Sun Jul 11, 2010 9:01 am

Re: Object bounces forever

Postby Julio Jerez » Wed Jul 20, 2011 8:28 am

Umm I do not know what could this be, do you have a running test?

spheres are the simpler objects
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Object bounces forever

Postby nathanf534 » Thu Jul 21, 2011 3:22 pm

Setting continuous collision mode fixed the problem, although the sphere wasn't moving fast at all and it still bounced wrong at 400 FPS, so im not sure if its a bug or thats just how it works. If you want I can send a simple example with the .exe and src
nathanf534
 
Posts: 19
Joined: Sun Jul 11, 2010 9:01 am

Re: Object bounces forever

Postby Julio Jerez » Fri Jul 22, 2011 9:01 pm

Ah is setting continues collision mode fix teh problems, then what means is that the the softness wat set too high.

The softness is a penalty value that convet teh penetrion into a spring force, it should be small.
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

cron