{"id":43049371,"url":"https://github.com/nikhilr612/xpbdrs","last_synced_at":"2026-01-31T10:12:59.746Z","repository":{"id":330114903,"uuid":"1121611354","full_name":"nikhilr612/xpbdrs","owner":"nikhilr612","description":"A simple eXtended Position-based Dynamics Implementation for Tetrahedralized meshes in Rust","archived":false,"fork":false,"pushed_at":"2026-01-01T04:24:12.000Z","size":407,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-02T12:33:52.395Z","etag":null,"topics":["cloth-simulation","physics-simulation","raylib","rust","softbody-simulation","xpbd"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikhilr612.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-23T09:08:51.000Z","updated_at":"2025-12-31T09:42:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/nikhilr612/xpbdrs","commit_stats":null,"previous_names":["nikhilr612/xpbdrs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nikhilr612/xpbdrs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikhilr612%2Fxpbdrs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikhilr612%2Fxpbdrs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikhilr612%2Fxpbdrs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikhilr612%2Fxpbdrs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikhilr612","download_url":"https://codeload.github.com/nikhilr612/xpbdrs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikhilr612%2Fxpbdrs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28937924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T08:53:31.997Z","status":"ssl_error","status_checked_at":"2026-01-31T08:51:38.521Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloth-simulation","physics-simulation","raylib","rust","softbody-simulation","xpbd"],"created_at":"2026-01-31T10:12:57.973Z","updated_at":"2026-01-31T10:12:59.732Z","avatar_url":"https://github.com/nikhilr612.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Xpbdrs\n\nA Rust implementation of Extended Position Based Dynamics (XPBD) for real-time simulation of deformable bodies using tetrahedral and triangulated surface meshes.\nXPBDRS provides a constraint-based physics engine implementing the Extended Position Based Dynamics algorithm which extends the classical Position Based Dynamics framework by incorporating material compliance parameters through Lagrange multiplier accumulation enabling compliance-based material modeling. The library supports multi-mesh representations, adaptive constraint optimization, and real-time visualization for interactive simulation of soft bodies, cloth dynamics, and volumetric deformation.\n\n### XPBD Algorithm\n\nThe XPBD method solves constraint systems by accumulating Lagrange multipliers over substeps, enabling proper material compliance modeling:\n\n```\nFor each substep Δt:\n  1. Predict positions: x* = x + v·Δt + a·Δt²\n  2. For each constraint C(x):\n     - Compute constraint violation δC = C(x*)\n     - Calculate compliance α = compliance / Δt²\n     - Update multiplier: Δλ = -δC / (∇C^T M^(-1) ∇C + α)\n     - Apply position correction: Δx = M^(-1) ∇C Δλ\n  3. Update velocities: v = (x_new - x_old) / Δt\n```\n\n### Constraint Types\n\n**Edge Length Constraints**: Maintain structural integrity of mesh connectivity\n- Constraint function: C(x) = |x₁ - x₂| - L₀\n- Gradient: ∇C = (x₁ - x₂) / |x₁ - x₂|\n\n**Tetrahedral Volume Constraints**: Preserve volumetric properties for soft body simulation  \n- Constraint function: C(x) = V(x₁,x₂,x₃,x₄) - V₀\n- Volume scaling parameter p_volume enables controlled inflation/deflation\n\n**Weak Bending Constraints**: Prevent excessive folding in surface meshes\n- Applied to adjacent triangle pairs sharing an edge\n- Maintains surface curvature characteristics\n\n**Substep Integration**: Configurable substep count enables trade-offs between accuracy and performance based on application requirements.\n\n## File Format Support\n\n- **TetGen ASCII**: Standard `.node`, `.ele`, `.edge`, `.face` format compatibility\n- **Binary Serialization**: Optimized `.bin` format using serde/bincode for reduced I/O overhead\n- **Mesh Conversion**: Bidirectional conversion between ASCII and binary representations\n\n## Usage\n\n```rust\nuse xpbdrs::{\n    mesh::Tetrahedral,\n    xpbd::{XpbdParams, XpbdState, step_basic}\n};\n\n// Load tetrahedral mesh from TetGen files\nlet mut mesh = Tetrahedral::from_files(\"mesh_prefix\")?;\nlet initial_values = mesh.constraints.evaluate(\u0026mesh.vertices);\n\n// Configure simulation parameters\nlet params = XpbdParams {\n    length_compliance: 0.001,      // Material stiffness\n    volume_compliance: 0.001,      // Volume preservation\n    n_substeps: 10,                // Stability vs performance\n    time_substep: 0.016 / 10.0,    // 60 FPS with 10 substeps\n    ..Default::default()\n};\n\n// Initialize simulation state\nlet mut state = XpbdState::new(\n    mesh.vertices.len(), \n    mesh.constraints.size()\n);\n\n// Simulation loop with ground collision\nloop {\n    state = step_basic(\n        \u0026params, \n        state, \n        \u0026mut mesh, \n        \u0026initial_values,\n        |v| v.position.y = v.position.y.max(0.0) // Ground plane at y=0\n    );\n}\n```\n\n### Command Line Interface\n\n```bash\n# Convert TetGen mesh to optimized binary format\ncargo run -- export -i mesh_prefix -o output.bin\n\n# Launch demo softbody viwer (requires raylib feature)\ncargo run --features raylib -- demo mesh.bin\n\n# Run example simulations (require raylib feature for visualization)\ncargo run --features raylib --example cloth_draping\ncargo run --features raylib --example inflation_demo  \ncargo run --features raylib --example spot_in_box\n```\n\n## Examples\n\nThe `examples/` directory contains comprehensive demonstrations of library capabilities:\n\n- **Cloth Draping**: Realistic cloth simulation with sphere collision detection\n- **Surface Deformation**: Interactive plane mesh with localized force application  \n- **Inflation Demo**: Soft body volume scaling using tetrahedral constraints\n- **Spot in Box**: Constrained dynamics with periodic force impulses\n\nEach example includes parameter customization, interactive controls, and visual output modes. All examples require the `raylib` feature to be enabled for 3D visualization.\n\n**Note**: The core XPBD simulation library can be used without raylib for headless physics computation. Only the examples, demos, and visualization components require the raylib feature.\n\n## Dependencies\n\n- **glam**: Vector and matrix mathematics with serde support\n- **serde/bincode**: Mesh serialization  \n- **tracing**: Structured logging\n- **clap**: Command-line argument parsing (dev dependency)\n\n### Optional Features\n\n- **raylib** (optional): 3D rendering and user interaction for examples and demos\n  - Enable with `cargo run --features raylib` or `default-features = false` in Cargo.toml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikhilr612%2Fxpbdrs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikhilr612%2Fxpbdrs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikhilr612%2Fxpbdrs/lists"}