Contact point changes depending on height

xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: Contact point changes depending on height

Post by xexuxjy »

I know you will have other shapes later , but can you try it with a simple SphereShape first? this would help to isolate where the discrepancies are.
sara
Posts: 39
Joined: Thu Mar 24, 2011 3:50 pm

Re: Contact point changes depending on height

Post by sara »

Ok, here is a very simple example of a bullet demo.

What I am doing is printing the total force when the first contact is detected. I enabled ccd, so that every time I run the demo (which can be done pressing space), I should get the same force. This is just not happening. I am not sure why, but ccd is not working.

I am trying to do a demo, so that if I throw an object from different heights, the contact points are always the same, and the forces increment.

Oh, by the way, I am using BoxShape in this demo.
You do not have the required permissions to view the files attached to this post.
xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: Contact point changes depending on height

Post by xexuxjy »

I added some further logging to your demo just so I could see what the manifoldpoint data was as your force data was quite variable as you mentioned. I then ran a couple of different scenarios (different timesteps , ccd enabled or disabled) and got the following results which look pretty consistent (using space to reset the simulation for four results per test). I'm not sure where the variation in your forces is coming from (possibly your At value from getDeltaTimeMicroseconds ?) . I know this doesn't answer your original question about differing values for different heights and I may still have mis-understood what you're trying to do , but it looks like bullet is giving consistent results.

edit - Just tried adding At to the logging and theres definitely variation :
mp[1] dis [-0.175003] imp [4.08125] at [0.016386]
mp[1] dis [-0.175003] imp [4.08125] at [0.017517]
mp[1] dis [-0.175003] imp [4.08125] at [0.016816]
mp[1] dis [-0.175003] imp [4.08125] at [0.021761]
mp[1] dis [-0.175003] imp [4.08125] at [0.017432]


Hope this was some help......

Code: Select all

				for(int j = 0; j < numContacts; j++)
				{
					btManifoldPoint& pt = contactManifold->getContactPoint(j);
					if(firstContact)
					{
						cout << "mp["<< j <<"] dis [" << pt.getDistance() << "] imp [" << pt.getAppliedImpulse() <<"]" << endl;
					}	
...



CCD Disabled m_dynamicsWorld->stepSimulation(ms / 1000000.f);
generating font at resolution 1024,600
mp[0] dis [-0.175003] imp [6.80079]
mp[1] dis [-0.175003] imp [4.0793]
mp[2] dis [-0.175003] imp [6.8042]
mp[3] dis [-0.175003] imp [4.08332]

mp[0] dis [-0.175003] imp [6.80079]
mp[1] dis [-0.175003] imp [4.0793]
mp[2] dis [-0.175003] imp [6.8042]
mp[3] dis [-0.175003] imp [4.08332]

mp[0] dis [-0.175003] imp [6.80079]
mp[1] dis [-0.175003] imp [4.0793]
mp[2] dis [-0.175003] imp [6.8042]
mp[3] dis [-0.175003] imp [4.08332]


CCD Disabled m_dynamicsWorld->stepSimulation(ms / 1000000.f,1,1./180.);
generating font at resolution 1024,600
mp[0] dis [-0.0666237] imp [6.85929]
mp[1] dis [-0.0666237] imp [4.11439]
mp[2] dis [-0.0666237] imp [6.86273]
mp[3] dis [-0.0666237] imp [4.11845]

mp[0] dis [-0.0666237] imp [6.85929]
mp[1] dis [-0.0666237] imp [4.11439]
mp[2] dis [-0.0666237] imp [6.86273]
mp[3] dis [-0.0666237] imp [4.11845]

mp[0] dis [-0.0666237] imp [6.85929]
mp[1] dis [-0.0666237] imp [4.11439]
mp[2] dis [-0.0666237] imp [6.86273]
mp[3] dis [-0.0666237] imp [4.11845]

mp[0] dis [-0.0666237] imp [6.85929]
mp[1] dis [-0.0666237] imp [4.11439]
mp[2] dis [-0.0666237] imp [6.86273]
mp[3] dis [-0.0666237] imp [4.11845]


CCD Enabled m_dynamicsWorld->stepSimulation(ms / 1000000.f,1,1./180.);

generating font at resolution 1024,600
mp[0] dis [-0.0666237] imp [6.86061]
mp[1] dis [-0.0666237] imp [4.11636]
mp[2] dis [-0.0666237] imp [6.86061]
mp[3] dis [-0.0666237] imp [4.11637]

mp[0] dis [-0.0666237] imp [6.86061]
mp[1] dis [-0.0666237] imp [4.11636]
mp[2] dis [-0.0666237] imp [6.86061]
mp[3] dis [-0.0666237] imp [4.11637]

mp[0] dis [-0.0666237] imp [6.86061]
mp[1] dis [-0.0666237] imp [4.11636]
mp[2] dis [-0.0666237] imp [6.86061]
mp[3] dis [-0.0666237] imp [4.11637]

mp[0] dis [-0.0666237] imp [6.86061]
mp[1] dis [-0.0666237] imp [4.11636]
mp[2] dis [-0.0666237] imp [6.86061]
mp[3] dis [-0.0666237] imp [4.11637]


CCD Enabled m_dynamicsWorld->stepSimulation(ms / 1000000.f);

generating font at resolution 1024,600
mp[0] dis [-0.175003] imp [6.80209]
mp[1] dis [-0.175003] imp [4.08125]
mp[2] dis [-0.175003] imp [6.8021]
mp[3] dis [-0.175003] imp [4.08126]

mp[0] dis [-0.175003] imp [6.80209]
mp[1] dis [-0.175003] imp [4.08125]
mp[2] dis [-0.175003] imp [6.8021]
mp[3] dis [-0.175003] imp [4.08126]

mp[0] dis [-0.175003] imp [6.80209]
mp[1] dis [-0.175003] imp [4.08125]
mp[2] dis [-0.175003] imp [6.8021]
mp[3] dis [-0.175003] imp [4.08126]

mp[0] dis [-0.175003] imp [6.80209]
mp[1] dis [-0.175003] imp [4.08125]
mp[2] dis [-0.175003] imp [6.8021]
mp[3] dis [-0.175003] imp [4.08126]
sara
Posts: 39
Joined: Thu Mar 24, 2011 3:50 pm

Re: Contact point changes depending on height

Post by sara »

Hey xexuxjy, you're the man! That was very helpful!!

Setting At to a specific value fixed the problem I had with same simulation, different forces.

But I still get higher forces with lower heights. Here is an example:

height: 23
mp[0] dis [-0.10828] imp [7.79799] at [0.0007]
mp[1] dis [-0.10828] imp [4.67879] at [0.0007]
mp[2] dis [-0.10828] imp [7.798] at [0.0007]
mp[3] dis [-0.10828] imp [4.6788] at [0.0007]
35648
height: 24
mp[0] dis [-0.052723] imp [7.31186] at [0.0007]
mp[1] dis [-0.052723] imp [4.38712] at [0.0007]
mp[2] dis [-0.052723] imp [7.31187] at [0.0007]
mp[3] dis [-0.052723] imp [4.38712] at [0.0007]
33425.7

By the way, to change the height, press 8 or 5. The penetration and the impulses if I drop the object from 23 meters is higher than if I drop the object from 24 meters. This is very inconvenient for my final application. How can I fix that?