Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step physics world after updating its data, rather than before #248

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/systems/collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ void CollisionSystem::update(float delta)
world = new b2World(b2Vec2(0, 0));
if (delta <= 0.0f)
return;
world->Step(delta, 4, 8);

// Go over each entity with physics, and create/update bodies if needed.
for(auto [entity, transform, physics] : sp::ecs::Query<Transform, Physics>()) {
Expand Down Expand Up @@ -109,6 +108,8 @@ void CollisionSystem::update(float delta)
physics.angular_velocity_user_set = false;
}
}

world->Step(delta, 4, 8);

// Go over each body in the physics world, and update the entity, or delete the body if the entity is gone.
auto now = engine->getElapsedTime();
Expand Down
Loading