also migrate frame accumulator to world state instead of it being a static variable in some weird timeline i have multiple physics sims running at once
This commit is contained in:
parent
cb86b34076
commit
5ba9983594
@ -469,6 +469,7 @@ namespace pod {
|
||||
uf::stl::vector<pod::PhysicsBody*> bodies;
|
||||
uf::stl::vector<pod::Constraint*> constraints;
|
||||
|
||||
float timeAccumulator = 0.0f;
|
||||
pod::Vector3f gravity = { 0, -9.81f, 0 };
|
||||
pod::BVH dynamicBvh;
|
||||
pod::BVH staticBvh;
|
||||
|
||||
@ -68,17 +68,13 @@ void uf::physics::tick( pod::World& world, float dt ) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
UF_PHYSICS_TIMER_MULTITRACE_START("Tick Step Begin");
|
||||
static float accumulator = 0;
|
||||
accumulator += dt;
|
||||
|
||||
float timestep = uf::physics::settings.timestep;
|
||||
|
||||
while ( accumulator >= timestep ) {
|
||||
world.timeAccumulator += dt;
|
||||
while ( world.timeAccumulator >= timestep ) {
|
||||
if ( uf::physics::settings.substeps > 0 ) uf::physics::substep( world, timestep, uf::physics::settings.substeps );
|
||||
else uf::physics::step( world, timestep );
|
||||
accumulator -= timestep;
|
||||
world.timeAccumulator -= timestep;
|
||||
UF_PHYSICS_TIMER_MULTITRACE("Tick Accumulation Step");
|
||||
}
|
||||
UF_PHYSICS_TIMER_MULTITRACE_END("Tick Step Complete");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user