Hinge Joint collision problem

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Hinge Joint collision problem

Postby Neo » Wed Jul 11, 2012 12:28 pm

Now I'm working on my tank war game, and I had made the tank into hinge joints(two for tracks, one for turret, both of their parent body are the tank's main body).
But when I start to run my game, I noticed that the collision bitween this hinge and other collision primitives became wierld....

When tank(the hinge joint) hit the ground(there's a gap of 1~5 unit bitween the tank's initial position and floor), it would bounce back at an incredible high speed(>4000unit)
and fly out of the world directly if the mass of the tank were a little bit larger(simply happens when mass bigger than 30).

However other collision object(they are not joints, just primitive collision and convex hull) won't act like that, even their mass are very large(a mass of 60 is still OK).

Also, when a a high speed newtonBody hit the joint,for example, a high speed bullet hit the tank, the joint would act in same way above(bounce out of world at a very high speed in several miliscends), but the non-jointed collision won't perform like that...

Why do this happen? And how can Ifix that?
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: Hinge Joint collision problem

Postby Neo » Fri Jul 13, 2012 10:02 am

Is there anyone who knows why did this happen?
Previouslly, I use the NewtonConstraintCreateHinge to create my hinge joint, now I've changed to the CreateCustomHinge(using the joint library),
but the problem still exist...
In other words, when a high speed object hits my hinge joint, the hinge joint suddenly disappeared. Then I fixed a camera on it. And finally I found that the joint doesn't disapear, it just flys out of the newton world and totally out of control...
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: Hinge Joint collision problem

Postby Julio Jerez » Fri Jul 13, 2012 11:36 am

Are you using core 300?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hinge Joint collision problem

Postby Neo » Fri Jul 13, 2012 12:06 pm

Julio Jerez wrote:Are you using core 300?

Yes, I got the latest version via svn..
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: Hinge Joint collision problem

Postby Julio Jerez » Fri Jul 13, 2012 2:39 pm

can you make a video or the bug?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hinge Joint collision problem

Postby Neo » Fri Jul 13, 2012 3:13 pm

Julio Jerez wrote:can you make a video or the bug?

Yeah, I'm uploading video just now...
this video shows that the primitive collision(first shoot), is OK, but the collision with the joint
is kind of wield(second shoot the bullet seems hit myself somehow :oops: )
this video shows same problem, but this time, I shoot another tank which has the same constructure as the one that is under my control(another one which is green framed).You see, when bullet hit the tank, it disapears. And in the material call back , I let the bullet trigger an explosion at the hit point, the destroy the bullet body. It turns out the collision works out well with simple newton bodies, but might has some problems with more complex joint..
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: Hinge Joint collision problem

Postby JoeJ » Fri Jul 13, 2012 5:26 pm

Have you asserts working in debug mode? Looks like NaNs.
Can you plot the matrix you give to the hinge at creation,
and body matrices after expolsion?
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Hinge Joint collision problem

Postby Neo » Fri Jul 13, 2012 11:46 pm

JoeJ wrote:Have you asserts working in debug mode? Looks like NaNs.
Can you plot the matrix you give to the hinge at creation,
and body matrices after expolsion?

Okey, I set break points in the material callback and transform callback,
and use NewtonBodyGetMatrix and NewtonBodyGetVelocity to show the matrix and velocity of the bullet and tank body the bullet hitted
Here is the result:
Code: Select all
the pinAndChildFrame Matrice I passed to CustomCreateHinge
1.0000000  0.00000000 0.00000000 0.00000000
0.00000000 1.0000000  0.00000000 0.00000000
0.00000000 0.00000000 1.0000000  0.00000000
-18.607262 1.7473046  24.520824  1.0000000

shell velocity(when hit)
X=-64.161194
Y=-1.3764944
Z=11.480826    

bullet Matrix(when hit)
0.17551193      -0.28075954      0.98407686     0.00000000
0.024814840     0.99940181      0.024087407   0.00000000
-0.98416442      0.020192077    0.17610364     0.00000000
-17.723471       2.1775150        23.266514      1.0000000

body matrix(before hit)
0.99999845          -0.00010514980     -0.0017423163     0.00000000
8.7603934e-005     0.99994934         -0.010067442        0.00000000
0.0017432865       0.010067275         0.99994779          0.00000000
-18.722149          -0.13792588         24.223007             1.0000000

body velocity(before hit)
(I forgot to copy, but I remembered that it's nearly zero)

body velocity(after hit)
X=-4903605.0
Y=29876860.
Z=6027570.0

body matrix(after hit)
0.79143405      0.60095459      0.11173981     0.00000000
-0.54375011     0.77567464     -0.32041329    0.00000000
-0.27922755     0.19282746     0.94066441     0.00000000
-80405.414       489785.19       98837.211      1.0000000

other infomation:
body's mass: 50
bullet's mass:1
gravity: 5

You see, after the collsion occured, body's velocity become incredibly high, and obviously it will go out of the newton world after next NewtonUpdate
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: Hinge Joint collision problem

Postby JoeJ » Sat Jul 14, 2012 5:29 am

So anything looks right :( at least, we can exclude something.
I've added the joint lib to my project and did some testing.
Created 2 boxes, and put 1 or 2 custom hinges between them.
I pick them up, bang them around, smash them against other objects, but anything works as expected.
I don't have an idea, but i'd recommend to you to do the same - create 2 simple boxes and put a single hinge between
to see if the problem also happens on that simple cofiguration. Here is my setup code, maybe you can copy paste most of it.

Code: Select all
Shape *shapeB1 = CreateBoxShape (30, 3, 3); // box dimension
         Shape *shapeB0 = CreateBoxShape (30, 3, 3);

         dMatrix transB1 = GetIdentityMatrix();
         transB1[3] = dVector(10,10,0); // box position
         Body* bodyB1 = CreateRigidBody (30, transB1, shapeB1);
         
         dMatrix transB0 = GetIdentityMatrix();
         transB0[3] = dVector(10,20,0);
         Body* bodyB0 = CreateRigidBody (30, transB0, shapeB0);
         
         dMatrix pinsAndPivoFrame = GetIdentityMatrix();
         pinsAndPivoFrame[3] = dVector(10,15,0);
         CustomHinge *chj = new CustomHinge (pinsAndPivoFrame, bodyB0, bodyB1);
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Hinge Joint collision problem

Postby Julio Jerez » Sat Jul 14, 2012 9:27 am

when you run it in debug mode are you getting any asserts?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hinge Joint collision problem

Postby Neo » Sat Jul 14, 2012 10:47 am

Julio Jerez wrote:when you run it in debug mode are you getting any asserts?

I have disabled the asserts, because when the game start running, there comes a lot of assert error from the core library, before it really turn to my code.
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: Hinge Joint collision problem

Postby Julio Jerez » Sat Jul 14, 2012 11:28 am

There might your problem, you should have zero asserts at all time, with teh asserts on.
having an assert means something is wrong some where.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hinge Joint collision problem

Postby Neo » Sat Jul 14, 2012 11:34 am

Julio Jerez wrote:There might your problem, you should have zero asserts at all time, with teh asserts on.
having an assert means something is wrong some where.

Er....What I'm doing now is to rebuild a new project for testing. Making a similiar joint but formed by primary boxes.
And assert error occurs just an empty world has created...
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: Hinge Joint collision problem

Postby Julio Jerez » Sat Jul 14, 2012 11:37 am

can you first reenable the asserts, and run in debug mode, and tell me where the asserts are happening?
In newton Asserts are seriuos issues.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Hinge Joint collision problem

Postby Neo » Sat Jul 14, 2012 11:54 am

Julio Jerez wrote:can you first reenable the asserts, and run in debug mode, and tell me where the asserts are happening?
In newton Asserts are seriuos issues.

Well, my mistake...assert error occurs when I try to add body...
error information:
file:dgBody.h
line:762
Expression: dgAbsf (val-1.0f)<1.0e-5f
application break at the line NewtonCreateBody

second type of assert error
file:dgmatrix.cpp
line:56
Expression:dgAbsf(w2+x2+y2+z2-dgFloat32(2.0f))<dgFloat32(1.0e-3f)
application break at the same position

file dgQuaternion.cpp
line 80
Expression:err<dgFloat32(1.0e-2f)

.... too many but similiar error.
then the program terminated.
But everything works well when I switch to release dll...
What do those errors mean?
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests