MCPcopy Create free account
hub / github.com/bitshifter/bevy-physics-weekend

github.com/bitshifter/bevy-physics-weekend @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
288 symbols 708 edges 31 files ⚖ CC 6 documented · 2% updated 2mo ago★ 37

Browse by type

Functions 249 Types & classes 39
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Game Physics in a Weekend (in Rust)

Screenshot

This project is an implementation of the Game Physics in a Weekend book using the Rust programming language and the Bevy game engine.

This has been a learning excercise for me to get a better understanding of implementing a physics engine, using Bevy and also making use of my math library glam.

Note that the code from the book and this code is for learning purposes, it's not very optimized and not intended for use in production. For real world use check out Rapier or physx-rs.

I'm using a fork of Bevy 0.5.0 that is using the latest version of glam from github.

Simulation controls

  • T - toggles pausing the simulation
  • Y - step the simulation while paused
  • R - reset the simulation

Camera controls

The Bevy Flycam plugin is used for camera movement.

  • WASD - move backwards, forwards, left and right
  • Space - move up
  • Left shift - move down
  • Escape - toggle mouse cursor lock

Differences from the book

Coordinate system

The book uses Z up and Bevy uses Y up. I've used the Bevy Y up convention here.

Matrices

The book uses row-major matrices whereas glam uses column vectors and column major matrices.

Architecture

I've mostly tried to follow the code structure in the book, however some things don't translate so well to Rust so some organisation of code has changed.

  • BodyHandle is used instead of Body* pointers. The handle is currently just wrapping an array index.
  • Body and Constraint structs are owned by BodyArena and ConstraintArena instead of being owned by PhysicsScene. This makes working with the borrow checker easier.

License

Creative Commons Zero v1.0 Universal

Extension points exported contracts — how you extend this code

browse all types & interfaces →

Core symbols most depended-on inside this repo

browse all functions →

Shape

Method 157
Function 92
Class 35
Interface 3
Enum 1

Languages

Rust100%

Modules by API surface

physics/src/shapes/shape_convex.rs33 symbols
physics/src/body.rs27 symbols
physics/src/scene.rs22 symbols
physics/src/gjk.rs22 symbols
physics/src/constraints.rs20 symbols
physics/src/shapes.rs14 symbols
physics/src/manifold.rs14 symbols
physics/src/scene_shapes.rs12 symbols
physics/src/math/vector.rs10 symbols
physics/src/math/matrix.rs9 symbols
src/main.rs8 symbols
physics/src/shapes/shape_box.rs8 symbols

For agents

$ claude mcp add bevy-physics-weekend \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page