Skip to content

Minimal 2D cloth simulation in Rust using Verlet + distance constraints (PBD). macroquad + nalgebra. Wind toggle, simple floor collision; fast and readable.

Notifications You must be signed in to change notification settings

Enberkay/verlet-cloth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Verlet Cloth Simulation

A real-time cloth physics simulation using Verlet integration, written in Rust with Macroquad.

Features

  • Position-based dynamics with Verlet integration
  • Structural, shear, and bending constraints
  • Interactive mouse dragging
  • Dynamic wind simulation
  • Pin/unpin particles
  • Adjustable constraint iterations
  • Floor collision

Controls

  • Left Mouse - Drag particles
  • P - Pin/unpin particle at cursor
  • W - Toggle wind on/off
  • B - Toggle bending constraints
  • Up/Down - Adjust constraint iterations
  • Left/Right - Adjust wind strength
  • R - Reset cloth

Building

cargo build --release

Running

cargo run --release

Project Structure

  • particle.rs - Particle and edge data structures
  • physics.rs - Physics integration and constraint solving
  • cloth.rs - Cloth mesh generation and utilities
  • rendering.rs - Drawing and UI functions
  • main.rs - Main loop and input handling

Dependencies

  • macroquad - Graphics and windowing
  • nalgebra - Linear algebra
  • rand - Random number generation

About

Minimal 2D cloth simulation in Rust using Verlet + distance constraints (PBD). macroquad + nalgebra. Wind toggle, simple floor collision; fast and readable.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages