Common bug(s) in PhysX, Havok and Bullet SOLVED! - fixed timesteps/maxSubStep

Started by
23 comments, last by ApochPiQ 15 years, 7 months ago
Quote:Original post by abaraba1
in essence - instead of to cap number of iterations you "cap" or "scale"(with the 1st algo) the accumulator/deltaTime which is in practice very similar thing only the later appear smoother because of the way how the FRAMES get *distributed* in the real time - but indeed it is a difficult thing to imagine..

I tried your algorithm together with my own physics library (but without a computation I didn't understand) and it does indeed look smoother than before [smile]
(Of course, when adding a bunch of too many objects.)

The part I don't understand how it works is the following computation:
Quote:Original post by abaraba1
+(STEP*anmDT*fpsTensor)

I like your idea of making it look smoother but allowing some slower motion, because it can make a game playable even on bad systems. I can understand though, if that makes the game easier, that some people still prefer striving for real time even when performance is bad. (Though, it may be possible to mark records/achievements under that condition with a symbol of invalidity.)

Quote:Original post by grhodes_at_work
Dim_Yimma_H described what is going on here rather elegantly,

I'm glad to hear that, thank you!

Quote:Original post by grhodes_at_work
Just giving my honest, straightforward opinion and pointing out some things that any forum member who peruses this thread should be aware of, e.g., the legal stuff which really doesn't belong here.

At first I thought that legal stuff was meant to sound amusing, with "prove to me you're human being", but in the end I'm not sure.
Advertisement
Dim_Yimma_H,
>>"I tried your algorithm together with my own physics library (but without a computation I didn't understand) and it does indeed look smoother than before"

thank you!
now forgive me i'll skip over the rest of what you said as i want to keep this message as short as possible, but i'll address every single thing in my "conclusion" after i clear up some "side-stuff" that turned out to be an issue in this whole "thing", i dont want to discuss this side-stuff i want to get it out of the way and so we can continue to talk about algorithms

like this thing:
>>"At first I thought that legal stuff was meant to sound amusing, with "prove to me you're human being", but in the end I'm not sure."
//----------------------------------------------------------------------------


grhodes_at_work,
- thank you, i dont need to "fight" for this anymore


>>"The problem "solved" by abaraba1 is real.."

1.) could you remove the quotation marks then?
because, it practically solves one problem and address the other in the most desirable way considering the circumstances.

But maybe most importantly - IT SEEM TO REMOVE SOME ERRORS with original algo,
its about "geometrical interpolation" this physics engines use today - it seem that they first introduce the error, then try to fix it with something that in itself causes further inaccuracies - can you comment on that? tell me what Physics library you use and i'll show you exactly what i mean.




>>"The presentation was a bit long and rambling, and the purpose wasn't really made clear"


- obviously it turns out i have a problem communicating with the most of "the world" ...People are different. Cultures are different, languages are different, moral and ethical norms differ from family to family, form town to town, from country to country and from planet to planet (see Star Trek). English is not my 1st language, i use dictionary a lot and i have sense of humor that not many people get, unfortunately. So, please...


2.) Please give me an example of my "rambling" so i know what to avoid in the future. Please copy/paste sentence or two so i know exactly what do you mean by that, otherwise i can not improve, thank you.



3.) the purpose i said was this:
//---------------------------------------------------
* A lot of substeps: physics can be the bottleneck
* Few substeps: moon gravity effects
- it practically solves both problems related to subSteps/maxSubSteps..
//----------------------------------------------------------------------




4.) long? ..is that bad?
/------------------------------------------------------------------------
A) # deltaTime= (simDT * N) + anmDT
(time used to simulate and render last frame)

B) undersampling is only possible if the time to execute one simulation step is smaller than the fixed time step
/------------------------------------------------------------------------

that above is all the information necessary,
the rest was mostly copy/paste source code and explanation of practical workings for the ones who did want to learn more about it, the others could happily scroll down.. i basically repeat one and the same thing over and over again and trying to say it in many different ways and still could not make anyone believe for the whole month, so i was actually afraid it will be too short.. yet again

interestingly,
i got a lot of that "long post" comment in the last month,
at the end it always turned out to mean: -"eh, i can't really be bothered to read all that"..


- why is the "long" a bad thing? is your message not long?

at least i talk about an algorithm and give source code that just by itself is sufficient to understand the point if reader has some basic programming skills, i mean the algorithm is, what? ...3-5 lines long?

..and you talk about what YOU like and what YOU don't like.. i like cats by the way, but what does that has to do with the rest of us and what does that has to do with the matter in question?



5.)
>>"I DO NOT LIKE that there is a claim of intellectual property rights claim in the original post.."

- why? ..the reason?
i see copyright notes in every single source file i open on my computer,
why would companies and everyone else have such rights and not me?

again, i do not want to discuss this here, i want to get it out of the way - who do i talk to? where the information about this can be found?


but dont we all program so we could benefit from it in some way, say - money -, so maybe this actually is very interesting and important subject to anyone who comes up with new algorithms, new ideas, new Intellectual Property..

- but, do humans need such a thing at all?
- how is this connected to the IP nonsense related to poor video drivers and whole DRIVERS ON LINUX issue? why is there no full graphic accelerated drivers for kernels? why only drivers for windowing systems? wheres acceleration on PS2 Linux? whats all the "taboo" around the damn graphics drivers and algorithms?

that should be OURS!!
IP is rubbish, we mut SHARE and COMMUNICATE if we want to progress!

..this was my WHOLE POINT with silly copyright notice (btw, since then i got angry, so - patent pending ;-)



>>"..DO NOT post it unless you warn people"

- why?
unless you state the reason we dont know if you're actually right or wrong about that?

>>"And, really, proprietary information should not be posted here in public threads, in my opinion"

why not?
it is free for humans, for human public on public forums.. that, i hope, should cover most of us


>>"Secondly, I do not believe this algorithm is protectable under intellectual property rules"

ok, now you're getting close to my point,
but why does all this bothers you so much, all you say "don't do" and how you "don't like", but why?


>>"At least for commercial game development, solutions such as the one presented here can be very beneficial to support eye candy physics, but I don't immediately see it as a huge benefit for gameplay physics."

- there is no such categorization,
but even if there was the most of the benefit will actually be with "gameplay physics" or whichever "physics" is more computationally expensive



>>..the technical support provided by nVidia/Ageia, Havok, and others already advise customers to do something along these lines."

No!

they advise this:
* A lot of substeps: physics can be the bottleneck
* Few substeps: moon gravity effects

and this:
http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30262482.aspx

and this:
http://developer.nvidia.com/forums/index.php?showtopic=2203
http://developer.nvidia.com/forums/index.php?showtopic=2149




>>"I really have no time to go and test the solution."

it would have taken less time to test the solution than to write your e-mail, you as a moderator have a responsibility to make such an important issue CLEAR

by the number of visits to this thread its obvious people want to know, and since no one believes me - its you, as an authority, as a "Principal Scientist" to make it clear and explain it to the public if indeed my English and communication skills are that bad, its you who should correct it and make it clear instead of just pointing finger at what you do not like without giving any reason and explanation - im just an unemployed, uneducated dude, i dont know any better, but i did my best and did it to the boundaries of my ability - thats my excuse, whats yours?


I apologize if some of this seems harsh,
but you talk about everything else except what is important - the algorithm, about which you can not probably really talk unless you have seen it or tested it.

Hi,

Maybe I'm misinterpreting something here (English isn't my first language either) but I can't get rid of the feeling that you're taking the algorithm a bit too seriously. It's not as if you found the holy grail of physics simulation. Still you're talking about the "responsibility" of moderators to promote "such an important issue". There's no such responsibility.

You're asking why this thread has so many views? Easy: the title suggest another appearance of someone who claims to have found the answer - like the one claiming to have found the solution for copy protection. Those threads tend to be quite entertaining, although in a sad way. It's not as if PhysX, Havok and Bullet have been created by a bunch of idiots, so if someone claims to have found a major bug and/or solution in all three implementation it's suspicious to say the least.

Luckily what the title suggests doesn't turn out to be true: you're actually very focused on one real problem and I really appreciate that. But the way you present your findings is simply disadvantageous: very long posts (which distracts people), no code tags (unreadable code), the explicit note of you taking everyone to court who uses the algorithm commercially.

Personally, I doubt that what you describe hasn't been done before and I also don't expect it to be "unbelievably important". But then again, I'm probably not in the position to evaluate it. If you think the algorithm you describe is of scientific importance write a paper about it and have it reviewed. Maybe you get published in an appropriate journal.

But please stop complaining about people not testing and worshiping your ten lines of code at once. People will acknowledge you where acknowledgment is due. You can't enforce it.

Please consider this post constructive criticism. No offense intended.
Andre Loker | Personal blog on .NET

Eppur si muove
So, you quote Galilei. Do you think that we're (I'm) ignorants just like the people back at Galilei's time? Or did you only want to bring an example of a case where it took a (long) while before someone got acknowledged? Or something completely different? Anyway, I think that a snappy catchphrase is not really useful in a discussion.
Andre Loker | Personal blog on .NET
>>"But please stop complaining about people not testing and worshiping your ten lines of code at once."

just test it please,
tho worshiping sounds amusing.. any feedback is welcome, i do like criticism, but you have to argue some point, you can not just go on saying stuff without an ARGUMENT, please read carefully every single word i said and feel free to QUOTE anything and then argue your point.. of course, you might save yourself some time if you do test it first - seeing is believing, i ask nothing more but you to see for yourself ..dont believe me, of course not!

i worship agi_shi's code,
i had it wrong way around at first, it was much uglier - thanks agi_shi, you're welcome any time to tell us more about it!


"People, I just want to say, you know, can we all get along? Can we get along? Can we stop making it, making it horrible for the older people and the kids?...It’s just not right. It’s not right. It’s not, it’s not going to change anything. We’ll, we’ll get our justice....Please, we can get along here. We all can get along. I mean, we’re all stuck here for a while. Let’s try to work it out. Let’s try to beat it. Let’s try to beat it. Let’s try to work it out."

[Edited by - abaraba1 on September 16, 2008 10:44:34 AM]
>>"..write a paper about it and have it reviewed."
- where/who can review it?


>>"Personally, I doubt that what you describe hasn't been done before.."
- i agree,
and actually i never thought so ..but, how to go about finding that one out?


>>"..and I also don't expect it to be "unbelievably important"."
- in the context where this function is executed every 'tick' - yes,
because that might be a good place to optimize and if there is some error in this function it might accumulate and cause who knows what...

but really - no, you right.
this is whats really important:

//-----------------------------------------------------------------------------
it is a DESIGN TIME DECISION, this means that you must be aware of how much time it takes CPU to execute stepSimulation() - as same as you have little FPS counter at the design-time, so you should have "simDT" and if that number ever gets to "red" (close to fixedStep) you try to design with larger fixedStep or you try to optimize, basically im saying - its the CPU that is critical for determining and deciding on min. sys. requirements because of (simDT * N) ..GPU scales much better, smoother


in any case, in the design time,
you want to go for the LARGEST POSSIBLE fixedTimeStep you can get by (aiming at low frequency eg. 10Hz) just so you can support that lower class CPU or you have more time to render..
//-----------------------------------------------------------------------------


this is all still only my opinion of course,
Dim_Yimma_H is the only person in the world that confirmed it in practice, thanks!
hehee sorry to have dragged you into this, but you're the human-man, you'll be fine..

anyway,
even if it does work in practice that doesnt mean all my conclusions are correct

[Edited by - abaraba1 on September 17, 2008 9:13:42 AM]
Don't worry, variety in discussion is probably a good thing!

I'm thinking about the computation that decreases the accumulated time, that distributes physics steps in an achievable manner. In the case when simulation time becomes longer than real time, the following code is used in the original post:
Quote:Original post by abaraba1
accum-= (simDT >= STEP)? simDT+(STEP*anmDT*fpsTensor) : STEP

Logically, simDT, the current time that the simulation requires, must be included to be able to avoid freezing the simulation loop. In this case, simDT was divided by cnt from last frame, because that number of steps was nearly achievable, so it's the highest number of steps to aim for without risking to freeze the loop. (Though, I wonder if it's sometimes too many steps?)

If anmDT increases then it'll cause fewer physics steps, if it decreases then it'll allow more physics steps. What I don't understand, is if STEP*anmDT*fpsTensor is enough to free a particular time value, or if it's tweaking?

I'd wish to instead add the animation time divided over the physics steps. Though, I don't have any suitable debugging code now so I'm not sure about correctness.

[Edited by - Dim_Yimma_H on September 17, 2008 2:22:48 PM]
Sorry, but I have to throw my $0.02 into the bin.

It appears as though the Moderator actually agreed with you...and acknowledged that this was a real problem in the physics realm. And it appears as though you did a great job of chopping up his post to make it appear as though he was just attacking you.

Secondly, as has previously been stated, it is not his job to promote your work. He is a person like everyone else, and his job is to moderate these forums as the name suggests. And last time I recalled, moderating had nothing to do with promoting.

And on a third note, I have to say that you do have a great find there. I don't want to detract any attention away from that.

Basically, the jist of my constructive criticism, is that it didn't appear that you read all posts fully before you respond to them.
Denzel Morris (@drdizzy) :: Software Engineer :: SkyTech Enterprises, Inc.
"When men are most sure and arrogant they are commonly most mistaken, giving views to passion without that proper deliberation which alone can secure them from the grossest absurdities." - David Hume
>>"accum-= (simDT >= STEP)? simDT+(STEP*anmDT*fpsTensor) : STEP"

i dont think that anyone would really want to use that in its original form,
the point with it was to show: -"..we can always measure the time and act accordingly in a real-time"


the whole difference between the algorithms is in the way how you control the number of the iterations, and that doesn't need to be explicitly:


//-------------------------- *** ORIGINAL algo - capping the NUMBER
cnt= 0;
time= 10;

maxSteps= 5;

while(time > 0 && cnt < maxSteps)
{
step(); cnt++;
time--;
}
//--------------------------
Iterations, cnt= 5
"Time left", time= 5




//-------------------------- *** 1st algo - scaling the TIME "inside"
cnt=0;
time= 10;

scaleFactor= 1;

while(time > 0)
{
step(); cnt++;
time--;
time-= scaleFactor;
}
//--------------------------
Iterations, cnt= 5
"Time left", time= 0





//-------------------------- *** 2st algo - capping the TIME "outside"
cnt=0;
time= 10;

if(time > 5) time= 5;

while(time > 0)
{
step(); cnt++;
time--;
}
//--------------------------
Iterations, cnt= 5
"Time left", time= 0




..does this make sense?





//------------------------------------------------------------------------
now, the problem with original is that you have to guess and it manifests in two ways under certain circumstances:
1.) guess was too low for target CPU - "moon gravity effect"
2.) no matter how high - on some target 'slow enough CPU' it will "spiral to death"

..which is not a "real problem",
because you can sort it out in design-time, but the peculiar thing is that it also seem try to deal with the reminder of the time after the iterations have finished, which i think only introduces the errors and its not really necessary ..or is it?

[Edited by - abaraba1 on September 17, 2008 11:41:58 PM]

This topic is closed to new replies.

Advertisement