BAM Dynamic Flipper Breakthrough !!
Page 3 of 22

Author:  Gimli [ Wed Jul 11, 2018 12:45 pm ]
Post subject:  Re: BAM Dynamic Flipper Breakthrough !!


there is a weird glitch when you hold the ball with the left flipper,
in Dynamic Omega demo in the monster bash table I am tweaking.

see post above

Rav! :D

Author:  ravarcade [ Wed Jul 11, 2018 6:24 pm ]
Post subject:  Re: BAM Dynamic Flipper Breakthrough !!

@Gimli: I will look a it tommorow.



... and another FP error fixed. For me, it was one of most annoying bug: broken flipper geometry and stupid ball direction after some hits.

See this image, at red line:
When ball is hit near flipper tip sometimes it fly, like top surface was not flat but concave.

There are 2 different sources of problem:
1. shape of flipper:
At image some dimmension are not realistic, but this way problem is more visibly.
Flipper physic-sim-model have 3 parts: 2 cylinders (red and green circles) and space between point P0 & P1.
FP by default uses black points on image and surface in pink color is part of flipper.
You can see, that white surface from flipper is "missing".

In new BAM i use "white" P0 and P1 points instead "black". Result: Top flipper surface is flat, not concaved.

... but it was not only problem ...
2. When ball hit flipper in place near tip, physics engine reports 2 contacts with flipper: one with line between P0 and P1, second with green cylinder.... and for some reason ball is bounced always like from cylinder.
So, even if we have "flat" top surface, that surface is ignored and ball is bounced only by green-cylinder.
Stupind newton physics engine.
I have found way to force on physics engine to ignore in some cases "green-cylinder". Fix is complicated and require calculations when is real ball-flipper-contact-point and prediction of collisions. I can guess, that my fix will not remove all errors, but i hope it will be almost all.

Bad thing about fix for that second case is: It require in Flipper_prehit subroutine (even empty one).
So, all table with "dynamic flipper" will work instantly, old table may still require some script modification. Here is example of required code:
Dim RightFlipperExt, LeftFlipperExt
Sub BAM_Init()
   Set RightFlipperExt      = xBAM.Flipper("RightFlipper")
   Set LeftFlipperExt       = xBAM.Flipper("LeftFlipper")
End Sub
Sub LeftFlipper_prehit()
End Sub
Sub RightFlipper_prehit()   
End Sub

Author:  blindpeser [ Thu Jul 12, 2018 1:00 am ]
Post subject:  Re: BAM Dynamic Flipper Breakthrough !!

Stunning! How did you find out that?

Author:  blue [ Thu Jul 12, 2018 2:21 am ]
Post subject:  Re: BAM Dynamic Flipper Breakthrough !!

blindpeser wrote:
Stunning! How did you find out that?

known fact with FP, and not just the flippers. FP also gets very confused when you have two objects overlapping that are set to different materials, like metal and rubber. This results in the ball skipping or seeming to hit something when there is nothing there, and even sometimes just stopping and falling back downwards. I've noticed it's usually at the point where two objects set to 2 different physics intersect.

The best way to combat that is actually very simple. Just have the ball travel along a non-rendered wall instead. really good for long looping shots, and seems to help with the gates as well. There is some big collision and physics problems there, interesting you found it's the same problems (so to speak) with the flippers.

@Rav - The ball has been doing that with the flippers since day 1. :)
I always felt as well that the ball was "sinking" into the flipper (hence my flipper wall technique) so that's another one you have fixed. I have also noticed that FP can do strange things when it strikes a object with multiple control points, like a very finely shaped round rubber tip. I've actually had the ball balance perfectly on the top of rubbers and just stay there (especialy with exe from SlamTilt) and am finding the less control points the better. It makes sense with the flippers as you were describing your problem would have the same problem.

Wow, the one thing we are all learning is just how bad FP stock physics really are.

Author:  ravarcade [ Thu Jul 12, 2018 3:41 am ]
Post subject:  Re: BAM Dynamic Flipper Breakthrough !!

Ball speed & FPS in XML.

Ball speed and FPS param in physics XML are related.
First some experiments. We want to find max ball speed on table.
I use NewtonPhysicsTick to read max ball speed. Here is my code snipet:
Dim maxballspeed : maxballspeed = 0
Sub NewtonPhysicsTick()
   Dim ball
   Set ball = xBAM.BallCloseTo(0,0)
   If ball.Exist Then
      If ball.Speed > maxballspeed Then
         maxballspeed = ball.Speed
         AddDebugText "max speed is: " & maxballspeed
      End If
   End If
End Sub

Sub FuturePinball_KeyPressed(ByVal KeyCode)
   If KeyCode = 79 Then
      maxballspeed = 0
   End If
    ' .... more stuffs here

What this code do:
For every physics simulation frame it try to find ball on playfield and if ball exists it reads ball speed.
When it checks if it is faster than previous max ball speed.
In FuturePinball_KeyPressed is use "1" key on numpad to reset "maxballspeed".
This way i can check max ball speed, when it is hit by plunger, reset it and find max ball speed when i play.
For default FP physics i get:
- ~2700 after pluger hit.
- ~1800 after flipper hit fast moving ball.

What that values means?
Ball can traver up to 2700 mm in 1 second. So, if i split it by physics sim FPS i get: 2700 / 256 = ~10.5 mm between 2 physics frames.
For normal play it will be: 1800 / 256 = ~7 mm
Ball diameter is 27 mm.
Do you see where may you have problems? Gate is "thin" object. In one frame ball may not touch gate (no collision) in next frame gate may be 10 mm "inside" ball and physics engine will have to solve what to do.
You can guess, that on some tables ball may be faster.
How it looks at current "Moster bash" beta table?
- ~2200 after hit by plunger
- ~4850 after flipper hit fast moving ball (i guess ball may go faster)
And FPS in XML? Well FPS = 295
So, we have: 4850 / 295 = 16.4 mm. Over half of ball can sink into wall before collison will be detected. I guess if you have gate with metal part 17? 18? 19? mm above playfield sometimes ball can fly under gate without hit detection.
Evene if gate will be hit, ball center may be already at other side of gate and physics engine may decide to spin gate in oposite direction.

This is realy fast ball... almost 5 m/s .... or ... 18 km/h .... or ... 11 mph ... well maybe not that fast :)
Any way.... my advise: limit ball speed hited by flippers or increase FPS.

My next post will be about flipper rubber elastic coeficient and new demo table.

Author:  TheNalex [ Thu Jul 12, 2018 9:31 am ]
Post subject:  Re: BAM Dynamic Flipper Breakthrough !!

blue wrote:
blindpeser wrote:
Stunning! How did you find out that?

Wow, the one thing we are all learning is just how bad FP stock physics really are.

It has some flaw but considering the complexity of a physics engine and that it was a one man product, it's not that bad ;)

BTW, it's a fantastic new Rav!!!

Author:  Gimli [ Thu Jul 12, 2018 9:32 am ]
Post subject:  Re: BAM Dynamic Flipper Breakthrough !!

Hi Rav,

You are right, the maximum ball speeds are high in my Monster Bash Demo...
Is there a way to limit the maximum and not effect the speed otherwise ?
A "Speed Limiter" or "Speed Governor"

I suppose using dynamic flipper changes at certain ball speeds can mute this problem
( for example I could use the Ball speed Vector when ball speed are really high
and use the Vertical Velocity Vector / Contact point the rest of time?)

But having a speed limiter if possible might be better ?

At low speeds, higher Flipper Mass / Flipper Omega / Flipper Elasticity seem preferable for hitting all targets. I believe flipper accuracy in my Linear Omega and Mass Versions is excellent at all speeds....

but at high speeds , you are right the ball can blast through gates and walls etc...

Also please remember to check the left flipper glitch on the LinearOmega
version. It happens every time you hold the ball with the left flipper....

Also, I am getting periodic crashes related to "CInt on line 654

Author:  ravarcade [ Thu Jul 12, 2018 5:31 pm ]
Post subject:  Re: BAM Dynamic Flipper Breakthrough !!

I will think about ball speed limiter, but i can't promise anything.

About that CInt error.
Please replace "CInt" with "Round". This should fix problem.

here is another beta... v231

Change log:
- fixed "crazy left flipper" on monster bash... and again flipper omega i calculated little different
- added AngleDiff property to FlipperExt - this is very simple: difference in angle between current flipper angle and "start angle". This property allow for easy detection if flipper is in motion or lay flat at start angle

Now cherry on pie: OnPreHitFlipperSettings_bounceControl

Sub OnPreHitFlipperSettings_bounceControl(FlipperExt)
   ' Params to tweak
   const base_elasticCoef                        = 0.8  ' very bouncy flipper rubber
   const expected_ball_speed_after_hit           = 240  ' calc elasticCoef to get desired ball speed after ball hit flipper
   const minimum_elasticCoef_to_scale_fast_balls = 0.05 ' we will add this to calculated elastiCoef, so ball after hit will have aditional 5% of speed before hit
   const reduction_for_flipper_in_motion         = 0.20 ' if flipper is not in starting point, reduce elasticCoef by 20%
   const min_elasticCoef                         = 0.02 ' 2%, ball will almost glue to flipper, this is minimum value

   If FlipperExt.Hit Then
      Dim elasticCoef
      ' ball_speed_after_hit = elastic_coef * ball_speed_before_hit
      ' so, elastic_coef = expected_ball_speed_after_hit / ball_speed_before hit !
      elasticCoef = expected_ball_speed_after_hit / xBAM.Ball.Speed

      ' now add little bit to preserv atleast 5% of ball speed before hit (not all balls should end with 240 mm/s)
      elasticCoef = elasticCoef + minimum_elasticCoef_to_scale_fast_balls

      ' make sure, we do not have elasticCoef higher than base value
      If elasticCoef > base_elasticCoef Then elasticCoef = base_elasticCoef

      ' now, reduce elastic coef if flipper is not at StartAngle (1 deg difference or more required)
      If FlipperExt.AngleDiff > 1 Then elasticCoef = elasticCoef - reduction_for_flipper_in_motion

      ' ... finally make sure, that elasticCoef will not be "negative" or to small
      If elasticCoef < min_elasticCoef Then elasticCoef = min_elasticCoef

      FlipperExt.SetMaterial elasticCoef

      ' some debug info:
      Dim raport
      raport = ""
      If expected_ball_speed_after_hit / xBAM.Ball.Speed < (base_elasticCoef-0.2) Then raport = raport & "[slowdown]"
      If FlipperExt.AngleDiff > 1 Then raport = raport & "[flipper in air]"
      AddDebugText "bouncCtrl: " & Round(elasticCoef*100) & "% " & raport
   End If
End Sub

@Gimli: you should add it to your monster bash.
This moddification shows 2 things:
- one constant value in physics XML for objects like flippers don't have any chance to create realistic physics
- how brilliant is idea of dynamic flippers params

This version change only elastiCoef for flipper, but in my opinion makes big difference in game play.
In short it allows for easy control how ball bounce from flippers.
Goal is: keep ball slow, bounce and close to flippers. It should make game easier for players. It allows for:
- very bouncy flippers .... but only for slow balls, so ball will not jump away from flipper
- reduce speed of fast balls to speed desired by table dev. It allows for example to control where fast ball from ramp bounced from flippe will fly. This should make game play easier...
- reduce speed of bounced ball if flipper is activated (not at "start angle")... so it is easier to capture ball on flipper

All that without lossing control over flipper shots.
It may be easly combined with other "OnPreHitFlipperSettings". So, you can in main "OnPreHitFlipperSettings" subroutine call OnPreHitFlipperSettings_bounceControl to make game play easier and OnPreHitFlipperSettings_linearomega to controll shots.
... and table devs can add code to change behaviour during game.

Author:  Gimli [ Thu Jul 12, 2018 6:47 pm ]
Post subject:  Re: BAM Dynamic Flipper Breakthrough !!

ravarcade wrote:
-how brilliant is idea of dynamic flippers params

I am so glad this is opening up a new vista for us.
I was just following the bread crumbs left by you and smoke. I remembered all the unexplored BAM physics tweaks and so when blindpeser laid down the gauntlet
once again claiming FP physics were poor...I had an epiphany and connected the dots.

It does open Pandora's box as there are so many things to explore...but any improvement is a major gain..

It would be awesome if this reinvigorates FP and validates all your amazing work !

@Gimli: you should add it to your monster bash.

Wow! Rav the "Bounce Control" routine works very well. :shock:
I added to monster bash both with and without linearomega control and it was awesome.

Thanks for fixing the left flipper bug and crash bug !
I won't have much time in next 4 days as we have guests visiting.

I am interested to hear if blue and the others have tried any of this! :D

Author:  ravarcade [ Fri Jul 13, 2018 4:22 pm ]
Post subject:  Re: BAM Dynamic Flipper Breakthrough !!

bam beta.... v232

This is RC. I hope to release it in next 24h.

- added xBAM.BallSpeedLimit. Add linke like this:
xBAM.BallSpeedLimit = 3000
to set maximum ball speed
- improved CTRL-C command in flippers menu. Now it will put in clippboard whole template like this:
Dim LeftFlipperExt, RightFlipperExt
Sub BAM_Init()
   Set LeftFlipperExt       = xBAM.Flipper("LeftFlipper")
   Set RightFlipperExt      = xBAM.Flipper("RightFlipper")
End Sub

Sub LeftFlipper_prehit()
   OnPreHitFlipperSettings LeftFlipperExt
End Sub

Sub RightFlipper_prehit()
   OnPreHitFlipperSettings RightFlipperExt
End Sub

' === Dynamic Flipper Settings ===
Sub OnPreHitFlipperSettings(FlipperExt)
   ' Add flipper params moddifications here
End Sub

@Gimli: xBAM.BallSpeedLimit... well it works, but for example in your monster bash it creates one more problem to handle for you.
If you limit ball speed to 3000 your "super fast flippers" may be faster than ball.

Also, there is one more cool things you can do:
You can set in physics XML flippers omega low (lets say 15?). You will see, that flipper without ball rotate slow and control flipper omega (like it is done in "linearOmega) in prehit. This way:
- ball will get hit with same speed as it gets now.
- flippers will not look always as "overpowered" like it looks now.
- .... and when flipper hit ball, when drag ball, when flipper will move faster.... so user will get impression, that flipper will hit ball stronger when you push button harder. (Just ty it).

Page 3 of 22 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group