Newbie help: CCD and tunneling

Post Reply
cricket3
Posts: 3
Joined: Mon Sep 20, 2010 8:58 pm

Newbie help: CCD and tunneling

Post by cricket3 »

I'm trying to develop a simple pinball game using bullet. I've learned a lot so far but there are still big parts of this (incredible) engine I have to learn.

The ball in my pinball game is often moves faster than its own radius - a problem I've been looking out for since reading the FAQ at http://www.bulletphysics.org/mediawiki- ... hysics_FAQ

Initially the ball was passing through some static rigid bodies. I was able to make that go away by increasing the fixedTimeStep in stepSimulation to 1/240. (I suspect that if the ball gets going fast enough it will pass through objects again, but I'm reluctant to increase it again for performance reasons.)

The flippers are kinematic rigid bodies, rectangular boxes, that rotate 60 degrees around a pivot point near one end. I interpolate the flippers' motion by incrementing the rotation of its world transform by 1/4th for each internal world tick. (So with timeStep=1/60 and fixedTimeStep=1/240, it takes one stepSimulation to complete the rotation.)

Is this the right way to rotate the kinematic body or can somebody suggest a better approach?

Here is where I could really use some help:

When I flip a flipper while the ball is rolling along its length, the ball is pushed away as I would expect as long as the ball is on the part of the flipper closest to the pivot point. When I let the ball roll to the tip of the flipper before flipping, however, it passes through. I'm guessing that this is because the flipper is moving more than the ball's radius per interpolation step. (Increasing the number of interpolation steps makes this go away, but it also slows down the flipper, effecting the motion of the ball.)

According to http://www.bulletphysics.org/mediawiki- ... n_Clamping it sounds like I can't use motion clamping because the objects are already in contact - in my case the ball is rolling down the flipper.

I'm trying to understand the other suggestions listed in the FAQ but as a newbie to physics-programming I'm afraid I haven't been able to figure out how to apply them to solve this problem. I appreciate any suggestions!
cricket3
Posts: 3
Joined: Mon Sep 20, 2010 8:58 pm

Re: Newbie help: CCD and tunneling

Post by cricket3 »

Any tips?
cricket3
Posts: 3
Joined: Mon Sep 20, 2010 8:58 pm

Re: Newbie help: CCD and tunneling

Post by cricket3 »

Bump - last try.

Is my question so basic that asking it demonstrates that I'm over my head? Or is this something that bullet doesn't have a straightforward way of doing?

I'm still hoping there is some way to get this to work.
Antonz
Posts: 16
Joined: Wed Nov 17, 2010 10:57 am

Re: Newbie help: CCD and tunneling

Post by Antonz »

Hi.

I have similar problems with a some differences:
- I'm using btConvexHullShape for flippers, not boxes;
- and also I cannot afford bumping fixed step resolution to 1/240 or higher (when problems with too fast rotating flippers go away) because of huge performance drop (my game is targeted for Android devices with FPU), I'll prefer to stay at 1/120 at most, default 1/60 will be even more preferable. Currently I'm testing at 1/150 rate on PC and seems that it's not enough.

I have some ideas on how to do additional computations for Ball vs Flipper only when flipper is rotating.
  1. Create extruded (along rotation) convex shape for flippers, covering all angle between steps and replace flipper's mesh with it when it moving. Caveats: afraid that it can cause interpenetration or excessive forces at then start/end of movement, when replacements occur.
  2. Subclass btConvexShape for flippers and each fixed step also do many "virtual" sub-rotations with enough precission, do manual check for collision between ball(s) and flipper and apply force to ball, if penetration occurs. Or it should be contact point? Not decided yet. Also, how it must be calculated, where to look?
  3. Extension of previous idea: also remove rigid body of flipper from world when it's rotating to prevent any issues and calculate force that needs to be applied to ball manually. But this still can cause issues at the start/end of movement.
Also, how to take in account CCD options on ball in 2) or 3) method?

By the way - my scale is currently somewhat crazy - ball is 100m in diameter, so gravity is -9810. Seems to work fine for collisions between ball and board, but I'm planning to scale it down by 100 (so ball will be 1m and gravity -98.10).

I'll start trying various methods and report if anything positive comes...
Antonz
Posts: 16
Joined: Wed Nov 17, 2010 10:57 am

Re: Newbie help: CCD and tunneling

Post by Antonz »

Looked into CCD code of Bullet. OK, so CCD is working for ball when it's moving fast and collides with static geometry or non-moving flipper. But obviously it's not working for kinematic rotating flipper (no movement, and also sphere shape used for CCD will not help here). Seems that I can do a convexSweepTest() for flipper's rigid body each sub-step giving it start and end transforms (with only rotation here) and it should find a point of collision. But what to do next, how to correctly calculate force to push the ball away? What happens if after my manual check a flipper still reaches a ball and pushes it again more? I'm not happy with idea of making flipper a ghost non-collidable object for a duration of time when it rotates, because then I should also do manual CCD check for a ball too.
Antonz
Posts: 16
Joined: Wed Nov 17, 2010 10:57 am

Re: Newbie help: CCD and tunneling

Post by Antonz »

Is there an example with moving/rotating kinematic/ghost object pushing a rigid body using forces when they collide?
Post Reply