Odd slowdown with 1k+ FPS

Post Reply
anfractu0us
Posts: 3
Joined: Fri Nov 30, 2012 10:23 pm

Odd slowdown with 1k+ FPS

Post by anfractu0us » Fri Oct 12, 2018 1:32 am

Hello! So, sparing long stories and non-sequiturs, I've come across an issue that I can't quite seem to fix. Upon entering a scene/map that my engine renders over or around 1000 FPS my player character moves extremely choppy, as do all other actors present. This changes slightly if I play around with stepSimulation values - choppy, extremely slow but constant movement, weird angular values - and setting them to higher values simply just lowers the FPS to the point where it acts as expected which is also undesirable. My main loop is set up ala Gaffers timestep/what was boilerplated on the wiki.

Code: Select all

while(run)
	render
	get current time
	pass delta time to stepSimulation
	scene events(things like running timers/callbacks, locking rigid bodies to mesh bones etc.)
	dt-game tick (set to 8)
	while(dt>=game tick)
		input polling
		scene update (movement, ai decisions, setting states/animations)
	gl swap
I'm using Lua for my actors and have made a bit of the Bullet functions available to it via LuaBridge, so I'm calling the relevant functions directly. As for how I'm doing movement, every actor has an assigned rigid body; some have additional rigid bodies for things like hitboxes etc. I use setLinearVelocity for whichever actor is moving, and have it set immediately to the actors maximum movement speed for now. I've read setLinearVelocity begins to function oddly at higher/lower frame rates; swapping to applyImpulse and applyForce both did not achieve the desired movement effect and also had the same problems at higher frame rates. I'm kind of at a loss - the only thing I can think of is the collision callback is clearing forces quicker than they can be reapplied but with the mediawiki down I've been having trouble verifying if that was mentioned on the old articles, or if that's indeed what occurs (and as such if there's a better callback setup than what was given on the wiki.) Thanks so much!

EDIT: Forgot to mention I'm using the 2.87 release of Bullet!

PcChip
Posts: 26
Joined: Sun May 20, 2018 3:09 pm

Re: Odd slowdown with 1k+ FPS

Post by PcChip » Sun Nov 11, 2018 12:36 am

how are you getting the current location of your rigid bodies to update the 3D position of your meshes?

this is what I'm using that works for me: myRigidBody->getMotionState()->getWorldTransform(tempTransform);

this may also apply - see last post (mine) viewtopic.php?f=9&t=9573&p=40971#p40971

anfractu0us
Posts: 3
Joined: Fri Nov 30, 2012 10:23 pm

Re: Odd slowdown with 1k+ FPS

Post by anfractu0us » Fri Nov 16, 2018 5:17 pm

nx.scene->node_rigid(a.node)->getWorldTransform().getOpenGLMatrix(mat);

is my code, the odd issue I noticed was switching to motion state actually caused jerkiness regardless of fps and was even worse in the particular scene that hits 1k fps. :(

PcChip
Posts: 26
Joined: Sun May 20, 2018 3:09 pm

Re: Odd slowdown with 1k+ FPS

Post by PcChip » Tue Dec 11, 2018 3:08 am

the way I would approach this is to first bring your framerate down to the range of 30fps - 240fps , so that you can see what it looks like in real world scenarios (because 1k fps behavior is meaningless)

also I believe if you're using setLinearVelocity , you need a per-tick callback to keep setting it every internal tick

Post Reply