Zonciu / Box2DSharp

A C# port of Box2D
MIT License
544 stars 102 forks source link

CPU is 100% loaded because of big gravity. #1

Closed Basea closed 5 years ago

Basea commented 5 years ago

When I set gravity(Y) in world.Gravity/gravityScale for a body to a big value(40-50 gravityScale for example) I get my CPU 100% loaded. In the same time, I can create a lot of bodies with gravityScale<40 I get my processor works fine, as without these bodies at all.

Zonciu commented 5 years ago

Could you please upload a sample?

Basea commented 5 years ago

world = new World { Gravity = new System.Numerics.Vector2(0, -100), AllowSleep = true }; BodyDef bodyDef = new BodyDef { GravityScale = 10f, }; world.Step(1f/50f, 10, 10); Sorry for the delay.

Zonciu commented 5 years ago

Your sampl works well, my guess is that you did not call World.Step method at a fixed frequency, see FrameManager