Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: [Video] Networked Physics (Truevision + PhysX)  (Read 5424 times)
Mietze
Community Member
*
Posts: 415

Pleeease, don't let it crash!


WWW
« on: April 02, 2009, 06:50:06 AM »

Hi there

I'm working on networked physics for some time and I just got something that (IMHO) worths to show ya. Since I experienced TV3D's built in Newton Game Dynamics to suck (simulation is not fps-rate independent, there is no character controller etc.) I decided to give NVIDIAs PhsyX a try and it's working perfectly! The phsysics simulation is only running on a networked server here. The client just controls a remote capsule object. The rest is interpolated (linear for position and spheric-linear for rotations) over an interval of 100ms. There is no spline or other curvish interpolation yet. But I will give it a try for the position interpolation, since linear is probably the worst interpolation method for this. Maybe you have an idea about cubic spline dead reckoning?

Video:
http://www.youtube.com/watch?v=n4XZNDr-nzQ

Comments are welcome Smiley
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Hypnotron
Customers
Community Member
*****
Posts: 1046


« Reply #1 on: April 02, 2009, 11:14:18 AM »

awesome!

physX definitely seems to be the way to go.  newton has way too many problems one of those being the extreme slowness of Julio in releasing updates. 
Logged
SylvainTV
Administrator
Community Member
*****
Posts: 4946


WWW
« Reply #2 on: April 03, 2009, 06:25:50 AM »

Nice !

Julio is not too slow to release updates.
We're a little slow to integrate them. That's because we wanted Newton2.0 to be in a usable state before integrating it.

First Newton2.0 version will be available in the next TV release.
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
Waterman
Moderator
Community Member
*****
Posts: 1157


« Reply #3 on: April 22, 2009, 04:03:57 PM »

Hi there

I'm working on networked physics for some time and I just got something that (IMHO) worths to show ya. Since I experienced TV3D's built in Newton Game Dynamics to suck (simulation is not fps-rate independent, ...

In what sense is the simulation not fps-rate independent?
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
Hypnotron
Customers
Community Member
*****
Posts: 1046


« Reply #4 on: April 23, 2009, 01:36:07 AM »

I interpreted this to mean that the current version of newton cannot be made to behave deterministically with our without using a fixed time step.
Logged
Mietze
Community Member
*
Posts: 415

Pleeease, don't let it crash!


WWW
« Reply #5 on: April 23, 2009, 10:31:37 AM »

Agreed. And this definately sucks!
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
AriusEso
Customers
Community Member
*****
Posts: 940

Esoteric


« Reply #6 on: April 23, 2009, 11:00:09 AM »

I thought TV had SimulateFixedStep() for this?

Not that I can ever get it working without it locking my app or causing random access violations. Though the same can be said of any Newton based function really. Sad
Logged

-...-

Hypnotron
Customers
Community Member
*****
Posts: 1046


« Reply #7 on: April 23, 2009, 11:14:07 PM »

Like I said, everything I've heard (and I could be wrong) is that even with fixedtimestep, Newton does not behave exactly the same way every time for a given set of conditions.  This is supposed to be fixed (i think) in 2.0 unless it was fixed earlier in an update.  But I'm fairly certain I remember this being a real issue in the version of Newton tv3d had at some point... perhaps still.
Logged
Mietze
Community Member
*
Posts: 415

Pleeease, don't let it crash!


WWW
« Reply #8 on: April 23, 2009, 11:17:44 PM »

Like I said, everything I've heard (and I could be wrong) is that even with fixedtimestep, Newton does not behave exactly the same way every time for a given set of conditions.
Agreed No. 2
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Waterman
Moderator
Community Member
*****
Posts: 1157


« Reply #9 on: April 24, 2009, 08:12:35 PM »

I'm totally surprised by this. Basically it implies that running the same test case twice produces different results.

In other words, set up a scenario with physics objects and call Simulate 0.01 (once only!) - the bodies move to new positions.

Now reset everything so the scenario is identical and repeat the iteration (again it includes one only call Simulate 0.01) - and the objects move to new positions but not the same positions as in the first run.

Newton does not care WHEN you do the call to Simulate, it ONLY cares about the argument to Simulate. Anyone can easily implement a fixed step solution by simply accumulating time increments. So that for example the only Simulate call ever sent to Newton is Simulate 0.01. And if the application in that case runs for 1000 seconds, there are exactly 100000 calls to Simulate, each with an argument of 0.01. Period. If that's not repeatable, then there is a random factor involved - but computers are not fuzzy unless coded to be (e.g. use a time sample, or a memory image, something that is not repeated between two test runs although the rest is identical).

Hence i suspect that you Mietze don't know at all what you are talking about, you just say it sucks. Sorry, no offense intended be aware. You are just not scientific, and it often bothers me how stupid TV3D users are re. physics in general.

I can easily believe that Simulate 0.01 and Simulate 0.01 does NOT produce the same result as Simulate 0.02 - that's an obvious result of the calculation model Julio uses. Other than that, i suspect that the "sucking" problem is more specifically related to some phenomen people are regularly experiencing with Newton while expecting different results.

A common reason for unexpected ("random", "non-deterministic") problems is selecting the wrong numerical space. Compare to for example handling neutrons with sledgehammers - they don't fit together.

An other thing people do not understand is that physics is rarely repeatable to the "absolute" level (zeroes and ones) in real life. We talk physics! There are environmental factors involved with physics and it's totally WRONG to expect for example that shooting twice in a row with the same cannon causes the second projectile to hit the first one (20 kilometers away).
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
Mietze
Community Member
*
Posts: 415

Pleeease, don't let it crash!


WWW
« Reply #10 on: April 25, 2009, 12:38:01 PM »

Hence i suspect that you Mietze don't know at all what you are talking about, you just say it sucks.
No comment, but your statements are totally correct.

All I say is, that an object with a linear velocity of {1, 0, 0} does not move the same distance in a given time between 20FPS or 2000FPS, even with fixed step and correct elapsed time, which definately is a huge problem, since every machine is unique and not every machine runs the main loop at the same interval. Using vertical synch might help, but this wouldn't solve the issue for ppl running the program with <60 FPS.. sigh.
« Last Edit: April 25, 2009, 12:54:30 PM by Mietze » Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Hypnotron
Customers
Community Member
*****
Posts: 1046


« Reply #11 on: April 26, 2009, 09:04:43 AM »

You could have saved people a fair bit of reading Waterman by simply saying "I don't think that it is broken." 

Logged
Hypnotron
Customers
Community Member
*****
Posts: 1046


« Reply #12 on: April 26, 2009, 09:11:24 AM »

An other thing people do not understand is that physics is rarely repeatable to the "absolute" level (zeroes and ones) in real life. We talk physics! There are environmental factors involved with physics and it's totally WRONG to expect for example that shooting twice in a row with the same cannon causes the second projectile to hit the first one (20 kilometers away).

Real life is not a rigid body simulation!


Found several threads about Newton that are relevant... this first one I believe is the one I recalled hearing about and why I had heard people (Sylvain too I think..) mention that it would be fixed in 2.0

http://www.newtondynamics.com/forum/viewtopic.php?f=9&t=4857&p=34677&hilit=deterministic#p34677

Quote
Newton 1.53 is a determanistic engine, however it had one fault. It kept an internal cache which may or may not throw networking off a bit. Newton 2.0 (beta) has fixed that issue by allowing you to flush the cache. So for the networking side of things Newton 2.0 should be perfect for your needs.

This jives with my recollection because determinism is mostly important for people doing networked physics.

http://www.newtondynamics.com/forum/viewtopic.php?f=9&t=5054&p=36378&hilit=deterministic#p36338
http://www.newtondynamics.com/forum/viewtopic.php?f=12&t=5063

More issues with regard to multiple threads?  Not sure if this is in regard to 2.0 beta or 1.5x.
« Last Edit: April 26, 2009, 09:22:17 AM by Hypnotron » Logged
Waterman
Moderator
Community Member
*****
Posts: 1157


« Reply #13 on: April 26, 2009, 05:16:10 PM »

You could have saved people a fair bit of reading Waterman by simply saying "I don't think that it is broken." 

Ok. I rarely write long replies (actually i rarely write any replies these days) but here is clarification. You are free to ignore it.

Over the years i have seen many people having issues with duplicated physics. It's obvious that not many understand all the concerns affecting the whole. Hence i don't see a problem in discussing this?

"Broken" or "fixed" or "deterministic" aren't categoric terms. Newton physics tries to offer solution for a variety of needs, ranging from simple to complex. The behaviour that makes some people say it's "broken" may be a problem for a few users while yet the majority never experience it.

Still people tend to classify physics engines as deterministic or non-deterministic. But when placing that word in the context of physics it's meaning changes. By definition, the term "deterministic" gives little room for interpretion. Still i find it acceptable to use the word to describe characteristics of a sequence of calculations when put in the context of 3D physics simulation. The user or coder may experience the dynamics he/she simulates as deterministic if the visaulization of it is sufficiently repetitive. Thus, the word has a practical meaning and that meaning is not necessarily the same as it's theoretical meaning.

My original (and persisting) claim was that Newton dynamics is deterministic. It was a reaction against someone downclassifying it based on, what i believe, loose premises. Newton allows for sufficiently repetitive behaviour to be called deterministic...

...provided that you set up the scenario in a way that allows it to be deterministic in the first place.

This is where many users fail. The environment that "holds" the physics engine introduces dozens of potential pitfalls, that each increases the risk of losing the predictable/repetitive behaviour of the calculation. Even though the physics engine may be internally fully fit to be called deterministic, the environment can (and will) still be inaccurate. For example:

1) The time sample taken from hardware is not fully precise.

2) The frame rates on two parallel systems are not identical. Even though one uses fixed steps, the accumulation of time itself introduces inaccuracy. It's easy to prove the inaccuracy of accumulation. Calculate (in code) the sum of 1. The answer is 1 - highly predictable. Then calculate the sum of 0.1+0.1+...+0.1, that is a 10-cycle loop that accumulates the value 0.1. The answer is 1, of course. Now calculate the sum of 0.0001+0.0001+...+0.0001. The result is no longer 1. It's close to 1 though. Here are the results for 10^0...10^7 when using double precision in my system:

1 1 1.000000000000001 1.000000000000001 0.9999999999999068 0.9999999999980841 1.000000000007918 0.9999999997501702

Even if two computers run identical calculations, a 2000 FPS system may send a different number of calls to SimulateFixedstep 0.05 than a 23-FPS system, during a total time of for example n minutes. Naturally, having the CPU in 32-bit fp mode makes it much worse (and as some may know, DirectX sets the CPU to that mode by default).

3) Mistakes originating from users not understanding numerical space: Say that you develop a perfectly repetivite (a "deterministic") sequence of physics behaviour. A shooting fight with hit detection in a FPS. It works superiorly well when it performs at around world position (0,0,0). Then move the sequence to world position (0,0,10000) and see how it goes completely off.

4) Using multiple threads. At a critical point, which one kicks first? A hits B and kicks C or B hits C before being hit by A? If the physics calculation doesn't suffuciently manage the distribution of tasks, the execution order may deliver unexpected, non-deterministic results.

Etcetera etcetera. Deterministic is imo a bad word in this context. "Highly" or "poorly" deterministic would be more appropriate, "accuracy" probably best. As usual, the advice is:

1) Use doubles, set the CPU to full precision (TVEngine.SetFPUPrecision). 2009 is a good year to skip the 32-bit floats.
2) Do everything as close to (0,0,0) as possible.
3) Use short (in time) parallel & independent sequences if possible.
4) Use a master/slave solution for networked physics.
5) Don't expect 100% precision - you won't get it.
Logged

Things should be described as simply as possible - but not simpler [A. Einstein]
gasdeveloper
Community Member
*
Posts: 9


« Reply #14 on: May 18, 2009, 05:33:20 AM »

What I think waterman is saying in short is, if you use floats the equations in Newton are going to produce different results. in the core of the computer a float is not a precision value. I wouldn't use one if I was flying to the moon. I would miss by a mile or a 100. Floats shouldn't be used if accuracy is needed. However in a game I find that it doesn't matter as much in less in it is a simulator of some sort. like flight or something. even then the amount it is off is so little that it doesn't matter.
Logged
Hypnotron
Customers
Community Member
*****
Posts: 1046


« Reply #15 on: May 18, 2009, 01:23:08 PM »

Sorry, i'm not buying it.

Imprecision is a completely different subject to determinism.  Barring bugs in the processor itself like the old P90 FDIV bug, x86 cpus of the last 10 years at least follow the same specification for floating point math.  That means that all inputs being equal, the results will be the same when running the same algorithm.  Sure there will be imprecision but that imprecision will be the same on all of these x86 machines because they're following the same spec.

Logged
Mietze
Community Member
*
Posts: 415

Pleeease, don't let it crash!


WWW
« Reply #16 on: May 18, 2009, 03:04:19 PM »

Sure there will be imprecision but that imprecision will be the same on all of these x86 machines because they're following the same spec.
Agreed.
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Hypnotron
Customers
Community Member
*****
Posts: 1046


« Reply #17 on: July 22, 2011, 02:31:00 AM »

*bump* because i came across this article mentioned on gamasutra

http://gafferongames.com/networking-for-game-programmers/floating-point-determinism/

has about all the info you need to know re: deterministic issues and floating point math.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks