Pryme8 Posted October 29, 2016 Share Posted October 29, 2016 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! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 29, 2016 Share Posted October 29, 2016 This should not happen, can you repro on the pG? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 29, 2016 Author Share Posted October 29, 2016 no, but I can upload a video best I can do. Sorry its kinda their property. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 29, 2016 Author Share Posted October 29, 2016 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. Quote Link to comment Share on other sites More sharing options...
BitOfGold Posted October 29, 2016 Share Posted October 29, 2016 - 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.) Quote Link to comment Share on other sites More sharing options...
BitOfGold Posted October 29, 2016 Share Posted October 29, 2016 Oh and try it without scene.workerCollisions , but with physics. The worker collisions does not help for me. But, using an octree for collision and selection does help. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 29, 2016 Author Share Posted October 29, 2016 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. Quote Link to comment Share on other sites More sharing options...
BitOfGold Posted October 29, 2016 Share Posted October 29, 2016 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. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted October 29, 2016 Author Share Posted October 29, 2016 Wow, where did you come from I think I have a new friend. I think it was the webworkers, and the debug display, just too much for my lil oll laptop... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.