3-8 fps in Sadrith Mora. Physics out the roof

Support for running, installing or compiling OpenMW

Before you submit a bug report for the first time, please read: Bug reporting guidelines
CMAugust
Posts: 285
Joined: 10 Jan 2016, 00:13

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by CMAugust »

It is highly likely that the modded Morrowind of the future will have an object complexity and density comparable to Skyrim or better. Real physics for objects is also a desired feature on OpenMW's post-1.0 roadmap. People are having trouble running vanilla content in OpenMW now - the current physics implementation getting a "tweak" may be crucial even for ultra PCs, if the aforementioned future is to exist.
User avatar
werdanith
Posts: 295
Joined: 26 Aug 2011, 16:18

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by werdanith »

I've been doing a few playthroughs of the game myself recently and I also find this to be the most game breaking issue of the engine at the moment. Port Telvannis is a 1 fps slideshow on every system I tested on.
raven
Posts: 66
Joined: 26 May 2016, 09:54

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by raven »

I've been (very) slowly digging through the code.

I think the major issue is the very generous use of ray/convex casts. They really should be used only when necessary, as they have to traverse the whole scene every time, don't benefit from time coherence (small changes from one step to the next).

It would be more efficient to update object position, check for collisions, resolve them by adjusting position. If the movement delta exceeds the radius of the moving object a ray could be used to check for tunneling, but this shouldn't happen too often in general.
User avatar
Jester
Posts: 8
Joined: 30 Nov 2016, 13:06
Location: Athens
Contact:

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by Jester »

werdanith wrote:I've been doing a few playthroughs of the game myself recently and I also find this to be the most game breaking issue of the engine at the moment. Port Telvannis is a 1 fps slideshow on every system I tested on.
I confirmed awful performance on new rigs too. So far starting a new game will improve things a slight bit (14fps tops)
Im looking for a way to convert save files from openmw to vanilla 3 days now. If anyone knows how tell me please. If we count the pros and cons atm using MGSO on vanilla is a better option even if it uses the old engine.
User avatar
psi29a
Posts: 5355
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by psi29a »

Just had a nice PM with djdduty, still alive! :)
Sent: 01 Dec 2016, 20:00
From: djdduty
To: psi29a

Yeah, I'm still alive. I think I got a little carried away with my "fix". Basically I was trying to re-implement the entire physics system using bullet's built in dynamic physics world and solver to see if their already provided code was more optimized than the physics solver that was written in openmw. This would also help since there are issues and TODOs involving dynamic physics simulation laying around, but they are post-1.0 stuff.

I remember seeing a commit or bug fix somewhere from someone who actually did the opposite of me, and removed the bullet dynamic physics world in favor of using bullet solely for collision checking, I was going to reverse these changes and profile it with tweaks of my own, but I couldn't find it again. I also don't know if they wrote this new solver if it was always used.

I definitely tracked it to the solver though, just changing the number of iterations there caused me to be able to have absolutely no performance loss when running into complex meshes at weird angles, but the loss of precision might not be a great thing even though I have yet to tunnel through objects with sheer speed speed any more than it did before I changed the number of iterations.

The other thing is, I can't change the solver without changing gameplay mechanics, like water physics and water walking, so I have to make sure I fully understand everything it is doing before I try and optimize it.

After all that, I actually haven't had much time to work on it. Work is absolutely crazy lately and we're scrambling to get releases out, end of the year nonsense. Don't worry though I haven't abandoned the project before I even started helping. :P
So there are eyes on the code!
CMAugust
Posts: 285
Joined: 10 Jan 2016, 00:13

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by CMAugust »

It sounds like Raven is on to something as well; it may be helpful for djdduty to know.
User avatar
AnyOldName3
Posts: 2666
Joined: 26 Nov 2015, 03:25

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by AnyOldName3 »

The sooner we can have a post-scarcity society so all programmers can work full time on open-source stuff the better.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by scrawl »

djdduty & others, thanks for your analysis, that gave me the kick I needed to look into this problem again.

As you've noticed, the lag happens when the movement solver gets stuck and bumps against its maximum iterations. Normally, the "getting stuck" part isn't supposed to happen - if the solver encounters an obstacle that it can not move past, it is supposed to slide off to the side of it. But there seem to be a few cases where you get "stuck" non the less, i.e. when walking into a corner or into a complex collision mesh. In these cases, apparently the solver will reflect back and forth between different faces of the collision mesh without actually moving. Perhaps there is a way to improve the sliding mechanism so that you won't get stuck.

A deeper issue is that as soon as the physics system can't keep up with simulating X seconds of physics in less than X seconds, we fall behind, have to incorporate those leftover frames in the next frame, causing us to fall behind even further, and the cycle repeats. (The article "fix your timestep" discusses this problem as the so-called Spiral of death, he explains it much better than I can). This is the reason why instead of moderate lag, we see FPS numbers below 1 when the physics system is overloaded. There isn't a way to fix this other than putting the game in slow motion or just making sure you don't fall behind.
just changing the number of iterations there caused me to be able to have absolutely no performance loss when running into complex meshes at weird angles, but the loss of precision might not be a great thing even though I have yet to tunnel through objects with sheer speed speed any more than it did before I changed the number of iterations.
The purpose of doing multiple iterations is not to fix tunneling, it is to handle stepping over more than one obstacle in the same frame (think staircases, for example), and/or getting "unstuck" via the sliding mechanism. I don't think reducing the max iterations is the right fix. I've tested reducing it to 3, and noticed there are some spots where I get stuck that worked fine with 8 iterations.

As for uncontroversial improvements, I've found one: one of the stepMove calls was not necessary in most cases. This should speed up the problematic collisions by a factor of two. Fix is pushed to master. Not sure though if that is enough for all systems.
User avatar
raevol
Posts: 3093
Joined: 07 Aug 2011, 01:12
Location: Caldera

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by raevol »

This is really exciting. Thank you for your work on this guys, I'm looking forward to any more progress on this!
User avatar
psi29a
Posts: 5355
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by psi29a »

Thank you Scrawl! I'll have to test, but this could also solve the physics problem with Ashes of Apocalypse. :)

I pointed djdduty here, so hopefully everyone looking at and attacking the problem from different directions can communicate with each other more. It is obvious that this kind of feedback helps and motivates others.
djdduty wrote: I have the branch locally, I just haven't submitted it to my remote fork yet as it's not quite in working order, especially given the fact that it completely breaks how the game handles physics even if the dynamics world was completely working.

I'll try and get it in working order, profile it, and then I'll push it up for other's to benchmark and see about implementing a real solution if that was in fact the problem.

Gook luck to you as well! Keep private messaging me if I disappear again, I tend to do that if I haven't made progress and need some more motivation.
I guess I know what I'm good at... Zini, I still have you on speed dial man. ;)
Post Reply