Jump to content



Photo
* * * * * 13 votes

VP physics overhaul


  • This topic is locked This topic is locked
1002 replies to this topic

#1 mukuste

mukuste

    Pinball Fan

  • VP Dev Team
  • PipPipPipPip
  • 854 posts

  • Flag: ---------

  • Favorite Pinball: Centaur

Posted 09 April 2014 - 01:29 AM

*
POPULAR

Time to let the cat out of the bag on this one! For over a month now, I've been hard at work on an overhaul of the VP physics engine, and my hiatus from the DX9 port has allowed me to make much better progress on this recently. What started with some simple tweaks and bugfixes has developed into an extensive modification, with several crucial parts completely rewritten. I'm very excited to present this to the world since I'm convinced that this will be a huge step forward for VP in terms of realism.

Here are the main changes from mainline VP:

  • Physics framerate raised from 100 Hz to 1000 Hz. This may seem excessive, but performance is still surprisingly good, and further optimizations are possible in the future. After experiencing the smoothness and precision that this affords, I didn't really want to go back.
  • Physics now always use a fixed timestep. This eliminates all FPS dependence of the physics code. In particular, gameplay with vsync at 60fps seems very smooth now for the first time.
  • Proper simulation of ball spin. VP9 had some rudimentary ball spin code, but it was only for visual effect and had no effect on ball behavior. Now, rotational effects are fully simulated: the ball will properly pick up spin from moving over the playfield and other objects, and collisions with playfield objects will take the spin into account to deflect the ball properly.
  • Simulation of friction on contact and collisions. This goes hand in hand with the previous point since friction with the playfield is the main source of ball spin, and frictional effects during collisions cause the ball to deflect according to spin. VP9 has a pretty simplistic friction model which simply slows down the ball, but this is way more realistic now. In particular, the ball will now properly transition from sliding over the playfield to rolling on it. This means that it will first convert some translational kinetic energy into rotational energy until it enters a natural roll, at which point friction doesn't do much anymore and the ball is free to roll. The stored up rotational energy has the effect that the ball needs a bit more force put into it to get it to move or stop it again, which is exactly the effect that JF has been trying to emulate with his BMPR routine. You'll see that with this physics mod, BMPR is not needed anymore.
  • Flippers have been pretty much rewritten from scratch. They are now simulated as true dynamic rigid bodies which have forces from the solenoid, the return spring and the ball acting on them and accelerate accordingly. They will also properly bounce off their stoppers instead of just moving to maximum extension and then stopping. In practice, this means that flipper/ball interaction is now much more realistic and less binary. Post passes, light taps, cradle separations, drop and live catches: those are now all possible, and without any special scripting hacks. Another real eye opener was the addition of friction to flippers: aiming is greatly improved, and all shots on the playfield (including center shots and backhands) are immediately attainable without any oblique correction!

There's still quite a bit of stuff to do (better nudging is a big one), but the gain in realism and nuance is already huge at this point in my humble opinion. After playing some tables with this mod for a while, going back to vanilla VP physics feels floaty, slippery and generally a bit wonky.

Unfortunately, with so many drastic changes, this new physics engine is not completely backwards compatible with old tables. Several physics parameters have to be retuned for these new features to work. I'll however shortly post a test build with which you can play around a bit.

 

Latest version download: Physmod5

Test table CFTBL (Melon/UncleWilly): http://www.vpforums....=27#entry264695

General information and parameter tuning guide: https://github.com/c...ki/VP10-Physics


Edited by mukuste, 18 May 2014 - 11:29 AM.


#2 atlantis1982

atlantis1982

    Neophyte

  • Members
  • Pip
  • 3 posts

  • Flag: ---------

  • Favorite Pinball: Undecided

Posted 09 April 2014 - 01:39 AM

Looking forward to reading the progress. With the dramatic change from the old, do you feel this is going to be a main feature for VP10?

#3 mukuste

mukuste

    Pinball Fan

  • VP Dev Team
  • PipPipPipPip
  • 854 posts

  • Flag: ---------

  • Favorite Pinball: Centaur

Posted 09 April 2014 - 01:43 AM

Note: this is outdated, check first post for link to most recent version.

Download a test build of the physics mod and the accompanying default table below.

 

Press F11 to get a visualization of ball spin.

 

Old VP tables will not work with this version unmodified!

 

 

Crash course to adjusting physics parameters for this version:

  1. Set your Gravity to 1, and keep it there.
  2. Make sure the table slope is correctly set (6-6.5 on most modern tables)
  3. Select the flippers and adjust the first two physics parameters: Speed (this is actually flipper mass) should be around 1-2, and Strength should be somewhere from 1000-3000. I like 1.25 and 1500 as starting values for experimentation. You'll likely also want to bump up the Elasticity to 0.8-0.9. The other parameters do nothing, ignore them.
  4. Due to the extra energy needed to get the ball rolling, plungers, slingshots, bumpers, etc., typically all need to have their force upped by 20-40%.
  5. Tables which use BMPR or other physics scripts like the light tap script probably won't give very good results.

More detailed information on the flipper parameters in this post!

Attached Files


Edited by mukuste, 06 May 2014 - 08:25 AM.


#4 Les73gTx

Les73gTx

    Preschooler

  • Members
  • PipPipPipPip
  • 523 posts
  • Location:Maine

  • Flag: United States of America

  • Favorite Pinball: Power Play, BoP, JackBot, MM, AFM, CV, MB,Champions Pub, CftBL, ToM, and Many More

  • PS3 Gamer Tag: LCT0819, Les73gtx
  • 360 Gamer Tag: PissPoorShot

Posted 09 April 2014 - 01:47 AM

Awesome and thank you for this and your dedication to pinball in the virtual realm!

Sent from my SAMSUNG-SGH-I747 using Tapatalk


les73gtx___atomicpin-pc.png
                                                                      


#5 gamefixer

gamefixer

    Pinball Fan

  • Silver Supporter
  • 575 posts
  • Location:Prosper, Texas

  • Flag: United States of America

  • Favorite Pinball: BK2K

  • PS3 Gamer Tag: gamefixer
  • 360 Gamer Tag: gamefixer

Posted 09 April 2014 - 02:08 AM

fantastic news! Keep up the great work. 



#6 jpsalas

jpsalas

    Grand Schtroumpf

  • VIP
  • 6,412 posts
  • Location:I'm Spanish, but I live in Oslo (Norway)

  • Flag: Norway

  • Favorite Pinball: I like both new and old, but I guess I prefer modern tables with some rules and goals to achieve.



Posted 09 April 2014 - 02:12 AM

That's some very nice news! :)


These are my tables, sorted by date, all them playable with VPX 7 or newer:

vp.jpg

After 18 years making tables, it is time to take a rest and let new authors do their thing.

I guess at last I'll play some more pinball :). But I'm sure I'll make some table updates from time to time :)


#7 RenegadeFred

RenegadeFred

    Hobbyist

  • Members
  • PipPip
  • 11 posts

  • Flag: United States of America

  • Favorite Pinball: Funhouse

  • PS3 Gamer Tag: RenegadeFred

Posted 09 April 2014 - 02:12 AM

Man you are just a damn work horse!  Amazing work, and the difference is night and day for sure..



#8 chinzman93

chinzman93

    "All humans are vermin in the eyes of Morbo!"

  • Platinum Supporter
  • 403 posts
  • Location:Here

  • Flag: United States of America

  • Favorite Pinball: Fish Tales, BSD, AFM

Posted 09 April 2014 - 02:22 AM

Great "Secret" project! Very much looking forward to this..... :otvclap:



#9 frankrizzo2

frankrizzo2

    Hobbyist

  • Members
  • PipPip
  • 11 posts

  • Flag: ---------

  • Favorite Pinball: Ali

Posted 09 April 2014 - 02:46 AM

Very nice work! You can definitely see and feel a difference with this! There have been so many great strides in this community lately and its exciting to watch everything evolve!



#10 chinzman93

chinzman93

    "All humans are vermin in the eyes of Morbo!"

  • Platinum Supporter
  • 403 posts
  • Location:Here

  • Flag: United States of America

  • Favorite Pinball: Fish Tales, BSD, AFM

Posted 09 April 2014 - 02:56 AM

Very cool! I highly recommend trying this on one of JP's older single level tables. They can be converted quick and easily and his smurf logo ball images really help illustrate the ball spin. I did a quick convert on EBD and really enjoy it. I nice seeing the smurf image spinning around on the table...lol I did have to modify all of the objects that Mukuste mentioned (flippers, bumpers, and plungers).

 

 

Edit: I was in such a hurry to get to the crash course section of Mukuste's post, I missed the F11 to visualize the ball spin. Very Cool!

 

 

@Mukuste: Thanks for your continued efforts in improving VP. Exciting times for VP!


Edited by chinzman93, 09 April 2014 - 03:06 AM.


#11 Arcade4

Arcade4

    Pinball Fan

  • Members
  • PipPipPipPip
  • 1,686 posts
  • Location:Beaumont, TX.

  • Flag: United States of America

  • Favorite Pinball: AC/DC

Posted 09 April 2014 - 03:42 AM

Wow. What a great announcement. 

Can't wait to try this out. :)



#12 gigalula

gigalula

    Hummmm not sure yet :)

  • Platinum Supporter
  • 651 posts

  • Flag: Canada

  • Favorite Pinball: All of them from 70' to now. Even more with VP and FP :)

Posted 09 April 2014 - 03:42 AM

Cool.... Thanks



#13 tttttwii

tttttwii

    Enthusiast

  • Platinum Supporter
  • 300 posts

  • Flag: Germany

  • Favorite Pinball: Attack from Mars

Posted 09 April 2014 - 04:47 AM

Great achievement. That is, what I was always looking for. Thanks for your Hard work!

#14 BananaBoat

BananaBoat

    Enthusiast

  • Members
  • PipPipPip
  • 228 posts

  • Flag: Australia

  • Favorite Pinball: Tron LE

Posted 09 April 2014 - 04:50 AM

Awesome - does this mean you'll be back developing the DX9 port? We miss you over there ;)



#15 gtxjoe

gtxjoe

    VPF Veteran

  • VIP
  • 5,060 posts

  • Flag: United States of America

  • Favorite Pinball: Medieval Madness, AbraCadabra



Contributor

Posted 09 April 2014 - 05:10 AM

Nice surprise!

 

Stayed up to try this.  Here is a quick mod of Bob5453's flipper tester to see how it performs.  Press 1 to start the test.  The first ball does not roll down (maybe because kicker release is set to force of 0).  Anyways wait for the left flipper to flip twice then press Enter twice (Pause and unpause).  Test will continue fine after that.  

 

1st ball has delay of 200ms.  i.e. Ball is allowed to roll for 200ms from cradle position before flipper activates

The delay is increased by 20ms for each ball.  At 90 degrees, increment is reduced to 10 ms.  At about 110 degrees, reduced to 5 ms.  At 120 degrees reduced to 2.5 ms.  Debug windows will print the ball # and delay time.

 

Green light indicates ball hit that kicker.  Here are results on my slow laptop.  Hopefully even better on faster PCs

Attached File  result (Medium).jpg   88.12KB   62 downloads

 

 

Attached Files



#16 teppotee

teppotee

    Enthusiast

  • Members
  • PipPipPip
  • 382 posts
  • Location:Finland

  • Flag: Finland

  • Favorite Pinball: CV

Posted 09 April 2014 - 05:54 AM

Sounds very cool! Too bad my work laptop is not VP friendly so I will have to wait couple of days to try this. But if this increases the ball mass and makes the ball behave more realistically without the need for BMPR (lite) implementations.... great!! I have converted all my cab tables to use the BMPR lite because the default VP physics just seemed to lack something. So really looking forward to give this a spin :)

 

I hate to make another request (without even trying this yet) but since you have been looking at the ball behaviour -> would it be possible to add ball collision sounds to VP by default? I just think that it's something that should be part of the engine and not done by scripting. 

 

Does this version have the latest dx9 branch fixes as well? Or is this completely separate build?

 

Thanks for you work! Amazing stuff in last couple of months!



#17 blashyrk

blashyrk

    Pinball Fan

  • Members
  • PipPipPipPip
  • 549 posts
  • Location:Norway

  • Flag: Norway

  • Favorite Pinball: Attack from Mars, Medieval Madness, White Water

  • PS3 Gamer Tag: Blashyrk

Posted 09 April 2014 - 06:54 AM

This is really great news :) I can see I picked the right time to get into virtual pinball.

#18 mukuste

mukuste

    Pinball Fan

  • VP Dev Team
  • PipPipPipPip
  • 854 posts

  • Flag: ---------

  • Favorite Pinball: Centaur

Posted 09 April 2014 - 07:23 AM

Looking forward to reading the progress. With the dramatic change from the old, do you feel this is going to be a main feature for VP10?

 

That's the big question... I guess it should be in VP10, but I hate that VP10 seems so far off. I really want to play tables with these new physics ASAP :D On the other hand, after the DX9 compatibility version is out, maybe this is the time to start working on the VP10 branch with the physics overhaul as the first major new feature.

 

 

Very cool! I highly recommend trying this on one of JP's older single level tables. They can be converted quick and easily and his smurf logo ball images really help illustrate the ball spin. I did a quick convert on EBD and really enjoy it. I nice seeing the smurf image spinning around on the table...lol I did have to modify all of the objects that Mukuste mentioned (flippers, bumpers, and plungers).

 

 

Funny you mention it, in fact Whitewater (v1.1.1) was my main testing table recently. For reference, here are my settings (not set in stone):

Gravity 1 Slope 6

Lower flippers: Speed 1.25 Strength 2500 Elasticity 0.9

Upper flipper: Speed 1.75 Strength 3500 Elasticity 0.8

Plunger Mech strength: 55

I also went into the script and changed the whirlpool kickout as follows:

		.InitKick sw61, 127, 24

There may have been some other small adjustments I forgot now. But even with these minor tweaks, the table already plays great and much closer to videos I found of the real thing online. I can now replicate this tricky backhand shot almost exactly:

Only drawback: the whirlpool shot seems almost impossible to make now, and I haven't figured out yet why.

 

 

 

Nice surprise!

 

Stayed up to try this.  Here is a quick mod of Bob5453's flipper tester to see how it performs.  Press 1 to start the test.  The first ball does not roll down (maybe because kicker release is set to force of 0).  Anyways wait for the left flipper to flip twice then press Enter twice (Pause and unpause).  Test will continue fine after that.  

 

1st ball has delay of 200ms.  i.e. Ball is allowed to roll for 200ms from cradle position before flipper activates

The delay is increased by 20ms for each ball.  At 90 degrees, increment is reduced to 10 ms.  At about 110 degrees, reduced to 5 ms.  At 120 degrees reduced to 2.5 ms.  Debug windows will print the ball # and delay time.

 

Green light indicates ball hit that kicker.  Here are results on my slow laptop.  Hopefully even better on faster PCs

attachicon.gifresult (Medium).jpg

 

Thanks for your test! Looking pretty good. Actually, due to the elimination of the FPS dependence, the results should now be exactly the same on whatever machine you run it on. That's one of the benefits for table builders: they can now be sure that everyone gets the same experience independently of framerate.

EDIT: The flipper is relatively weak in this test, upping it to, say, 2000 seems to give better results.

 

 

 

I hate to make another request (without even trying this yet) but since you have been looking at the ball behaviour -> would it be possible to add ball collision sounds to VP by default? I just think that it's something that should be part of the engine and not done by scripting. 

 

Does this version have the latest dx9 branch fixes as well? Or is this completely separate build?

 

For ball collisions, the idea was to create a new BallCollision event on the table which hands you the two balls and their impact velocity. Would that work?

 

Yes, this is up to date with the latest SVN.


Edited by mukuste, 09 April 2014 - 07:35 AM.


#19 teppotee

teppotee

    Enthusiast

  • Members
  • PipPipPip
  • 382 posts
  • Location:Finland

  • Flag: Finland

  • Favorite Pinball: CV

Posted 09 April 2014 - 07:30 AM

I think that should work fine (the BallCollision event) -> If I understand your idea correctly it would easy to script the event (just change the volume of the sound based on the velocity) and users could still add their own collision sound if they want. Anyway that would eliminate the need for the complex B2B coding.

 

If this is as good as I hope it is -> I think it should not wait until VP10. Just create VP 9.5 that would have a new file extension. So it would be easy to identify tables that are dx9 and new physics compatible. At least that's my opinion.



#20 fuzzel

fuzzel

    spaghetti code

  • VP Dev Team
  • PipPipPipPipPip
  • 2,818 posts

  • Flag: Germany

  • Favorite Pinball: yes I have

Posted 09 April 2014 - 07:42 AM

Nice one Mukuste! I have another nice update to VP in the next few days or so. With one of the next versions you can use a real 3D mesh ball instead of the old 2D image. I try to make this new feature optional because otherwhise it would break all current tables. More infos later.