ChinosInternationalCC / chinoPinball

Openframeworks Pinball with the Bullet 3D engine
http://chinosinternationalcc.github.io/chinoPinball
GNU General Public License v3.0
9 stars 10 forks source link

Ball is passing through a kinematic object #19

Closed ovicin closed 10 years ago

ovicin commented 10 years ago

@kubamarkiewicz I observed that if the ball hits a kinematic object while we apply the transformation is passing through (it doesn't hit the lever). Did you observed this thing?

I also started to implement the hammer as kinematic object, I am not sure if this is the best way though. @carlesgutierrez what do you think about this?

kubamarkiewicz commented 10 years ago

I have seen it, it is like in quantum mechanics, there is an effect called tunneling. Before I moved the rotation axis (it was in the center of the lever) it was working perfectly. Now the lever is moving so fast, that in one frame it can skip the ball and the collision is not detected. I case of the hammer I think there will be no problem, because it is too long to skip the ball.

Anyway to fix this we can try to increase the frame rate, for example to 120 fps. Then collisions will be calculated more precisely. Also we can try to slow down the lever or make it shorter.

kubamarkiewicz commented 10 years ago

Sometimes the ball is also passing through the wall.

I was trying to increase bullet internal frame rate. In Bullet library there is a function:

btDynamicsWorld::stepSimulation(btScalar timeStep, int maxSubSteps=1, btScalar fixedTimeStep)

http://stackoverflow.com/questions/12778229/stepsimulation-bullet-physics We need to change the third parameter fixedTimeStep - this is the internal step interval, by default 1/60 second.

I have changed it directly in addons/ofxBullet/src/ofxBulletWorldRigid.cpp in method update(), to the world->stepSimulation() I have added third parameter: 1./240.

void ofxBulletWorldRigid::update() {
    if(!checkWorld()) return;
    // should this run on delta time? //
    world->stepSimulation(1.0f/60.0f, 6, 1./240. );

This changes internal step from 1/60 to 1/240 second and I think it helps.

The problem is that we can only change this parameter directly in ofxBullet library ... or we can create our own ChinoPinballWorld class that extends ofxBulletWorldRigid and overwrite method update(), what do you think?

carlesgutierrez commented 10 years ago

hey what happened at the end ? Did u used stepSimulation() to solved it? It's always using this stepSimulator at that frame?

The other solution for a while could be to create bigger objects for the walls ( only internally ), after draw thinner walls, but for levers or internal collision objects that's a shame ..

2014-02-17 15:17 GMT+01:00 Kuba Markiewicz notifications@github.com:

Closed #19https://github.com/ChinosInternationalCC/chinoPinball/issues/19 .

Reply to this email directly or view it on GitHubhttps://github.com/ChinosInternationalCC/chinoPinball/issues/19 .

Carles Gutiérrez

kubamarkiewicz commented 10 years ago

hey, yes I changed parameters in stepSimulation(), you can see it chinoWorld class. I had to create this class and extend ofxBulletWorld, because there is no other way to change parameters. I set frame rate to 1/240s and it works like a charm :)

2014-02-17 20:07 GMT+01:00 carles notifications@github.com:

hey what happened at the end ? Did u used stepSimulation() to solved it? It's always using this stepSimulator at that frame?

The other solution for a while could be to create bigger objects for the walls ( only internally ), after draw thinner walls, but for levers or internal collision objects that's a shame ..

2014-02-17 15:17 GMT+01:00 Kuba Markiewicz notifications@github.com:

Closed #19< https://github.com/ChinosInternationalCC/chinoPinball/issues/19> .

Reply to this email directly or view it on GitHub< https://github.com/ChinosInternationalCC/chinoPinball/issues/19> .

Carles Gutiérrez

Reply to this email directly or view it on GitHubhttps://github.com/ChinosInternationalCC/chinoPinball/issues/19#issuecomment-35313350 .