Jump to content

Physics With No Calculations Drops FPS


Pryme8
 Share

Recommended Posts

Why when I attach physics to a scene, but do absolutely nothing with it, like no collision tests nothings happening, I get a super sharp drop in fps from about 30 in the scene to about 9...

Im really hoping to figure this out by tomorrow and have been holding off asking trying to figure it out, but I am running out of time now!

Link to comment
Share on other sites

Just ignore the error that drops at the end that's just from something else you just caught me mid changes on something else and this was happening before I was doing that, plus the physics stuff is ahead on the stack so it happens first anyways.
 

Link to comment
Share on other sites

- Are the physics bodies sleeping or active?

I used this code to sleep at creation:

var pb = mesh.physicsImpostor.physicsBody;
pb.sleepSpeedLimit = 0.01;
pb.sleepTimeLimit = 5.0;
mesh.physicsImpostor.sleep();

(I do wake up the player on every frame, that wakes up every other body it gets into contact:)

this.player.physicsImpostor.wakeUp();

- Another tip: the console really slows down if you write per frame. (even if its not shown in the developer tools). This took me some hairs pulled out, console writing can half the fps.
- the debug screen can also lower the fps, as compositing the DOM on a canvas is really slow in chrome. Firefox is slightly better in this. If I switch on debug screen on a QHD resolution, it shows 40fps, without it 60fps. HD resolution_ 5-10fps difference. (Showing fps in a Canvas2D text is faster.)

Link to comment
Share on other sites

I'll give that a shot that's what I was thinking, and nothing is moving really yet and no imposters are moving and really only one will so the octree being dynamic is not hard I think I just need to push the moving object to the dynamic array for it.  But yeah tommrow morning I'll strip out the webworkers and see if that's the issue thanks for offering input.

Link to comment
Share on other sites

And one more piece of code, which allows sleeping and:

this.physics_engine._physicsPlugin.world.broadphase = new CANNON.SAPBroadphase( this.physics_engine._physicsPlugin.world );
this.physics_engine._physicsPlugin.world.allowSleep = true;

CannonJS uses a "NaiveBroadphase" which is very slow at few (50?) bodies. (check everything collides with everything I think)
SAP (Single Axis) Broadphase sorts out bodies at one axis, this allows a few hundred bodies to work seamlessly.
There is a grid broadphase which may be even faster in your city.

Even if all bodies are not moving and static, if they are not sleeping, they are checked for collision with each other.
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...