Skip to content

Commit

Permalink
Documentation and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ManevilleF committed Oct 15, 2021
1 parent a0b7bc2 commit 2c6dfd9
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CHANGELOG

## 0.1.0

First version
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<!-- cargo-sync-readme start -->

# bevy_verlet

[![workflow](https://github.com/ManevilleF/bevy_verlet/actions/workflows/rust.yml/badge.svg)](https://github.com/ManevilleF/bevy_verlet/actions/workflows/rust.yml)

[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/)
[![Crates.io](https://img.shields.io/crates/v/bevy_verlet.svg)](https://crates.io/crates/bevy_verlet)
[![Docs.rs](https://docs.rs/bevy_verlet/badge.svg)](https://docs.rs/bevy_verlet)
[![dependency status](https://deps.rs/crate/bevy_verlet/0.1.0/status.svg)](https://deps.rs/crate/bevy_verlet)

Simple Verlet points and sticks implementation for bevy.

## Features
Expand All @@ -20,11 +28,10 @@ Customize *friction* and *gravity* with the `VerletConfig` resource.

1. `debug`

This feature will add a *system* drawing debug lines for every stick using [bevy_prototype_debug_lines](https://crates.io/crates/bevy_prototype_debug_lines)
This feature will add a *system* drawing debug lines for every stick using [bevy_prototype_debug_lines](https://crates.io/crates/bevy_prototype_debug_lines)

2. `shuffle`

This feature will randomize the `VerletStick` computation, can be costly and make the processing jittery.
<!-- cargo-sync-readme end -->

## Examples

Expand Down
3 changes: 3 additions & 0 deletions src/components/locked.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/// Component preventing application of [`VerletPoint`][VerletPoint] physics.
///
/// [VerletPoint]: struct.VerletPoint.html
#[derive(Debug, Copy, Clone)]
pub struct VerletLocked {}
2 changes: 2 additions & 0 deletions src/components/point.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use bevy::math::Vec3;

/// Main verlet physics component.
/// Any entity with this component will have physics applied to it
#[derive(Debug, Clone)]
pub struct VerletPoint {
pub(crate) old_position: Option<Vec3>,
Expand Down
6 changes: 6 additions & 0 deletions src/components/stick.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
use bevy::prelude::Entity;

/// Constraint component between two [`VerletPoint`][VerletPoint].
///
/// [VerletPoint]: struct.VerletPoint.html
#[derive(Debug, Clone)]
pub struct VerletStick {
/// Start `VerletPoint` entity
pub point_a_entity: Entity,
/// End `VerletPoint` entity
pub point_b_entity: Entity,
/// Target stick length
pub length: f32,
}
4 changes: 4 additions & 0 deletions src/components/stick_max_tension.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/// Component adding a maximum tension to a [`VerletStick`][VerletStick]
///
/// The stick will break when its size becomes bigger than its `length` multiplied by this factor
///
/// If you set it to `1.0` the stick will break almost instantly
/// If you set it to `2.0` the stick will break when stretched to twice its `length`
///
/// [VerletStick]: struct.VerletStick.html
#[derive(Debug, Clone)]
pub struct VerletStickMaxTension(pub f32);
35 changes: 35 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
//! # bevy_verlet
//!
//! [![workflow](https://github.com/ManevilleF/bevy_verlet/actions/workflows/rust.yml/badge.svg)](https://github.com/ManevilleF/bevy_verlet/actions/workflows/rust.yml)
//!
//! [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
//! [![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/)
//! [![Crates.io](https://img.shields.io/crates/v/bevy_verlet.svg)](https://crates.io/crates/bevy_verlet)
//! [![Docs.rs](https://docs.rs/bevy_verlet/badge.svg)](https://docs.rs/bevy_verlet)
//! [![dependency status](https://deps.rs/crate/bevy_verlet/0.1.0/status.svg)](https://deps.rs/crate/bevy_verlet)
//!
//! Simple Verlet points and sticks implementation for bevy.
//!
//! ## Features
//!
//! You can simply add a `VerletPoint` component on any entity with a `Transform` and the verlet physics will apply.
//!
//! Connect points using `VerletStick` to constrain movement (see [examples](./examples)).
//!
//! Lock some points by adding the `VerletLocked` component on a `VerletPoint` entity.
//!
//! Customize *friction* and *gravity* with the `VerletConfig` resource.
//!
//! > Works in 2D and 3D.
//!
//! ## Cargo features
//!
//! 1. `debug`
//!
//! This feature will add a *system* drawing debug lines for every stick using [bevy_prototype_debug_lines](https://crates.io/crates/bevy_prototype_debug_lines)
//!
#![deny(warnings)]
#![forbid(missing_docs)]
#![forbid(unsafe_code)]

pub use {components::*, resources::*};

mod components;
Expand Down Expand Up @@ -56,6 +90,7 @@ impl Default for BevyVerletPlugin {
}

impl BevyVerletPlugin {
/// Instantiates a new plugin with a custom time step
pub fn new(time_step: f64) -> Self {
Self {
time_step: Some(time_step),
Expand Down
1 change: 1 addition & 0 deletions src/resources/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ impl VerletConfig {
1.0 - self.friction
}

/// Retrieves the `gravity` field without the `z` axis
pub fn gravity_2d(&self) -> Vec2 {
Vec2::new(self.gravity.x, self.gravity.y)
}
Expand Down

0 comments on commit 2c6dfd9

Please sign in to comment.