From 2c6dfd9262749ecdc6021a737dbbf727d4b538d4 Mon Sep 17 00:00:00 2001 From: Felix de Maneville Date: Fri, 15 Oct 2021 13:37:09 +0200 Subject: [PATCH] Documentation and changelog --- CHANGELOG.md | 5 +++++ README.md | 13 ++++++++--- src/components/locked.rs | 3 +++ src/components/point.rs | 2 ++ src/components/stick.rs | 6 +++++ src/components/stick_max_tension.rs | 4 ++++ src/lib.rs | 35 +++++++++++++++++++++++++++++ src/resources/config.rs | 1 + 8 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5a14389 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# CHANGELOG + +## 0.1.0 + +First version \ No newline at end of file diff --git a/README.md b/README.md index 5b72a5d..496973a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,15 @@ + + # 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 @@ -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. + ## Examples diff --git a/src/components/locked.rs b/src/components/locked.rs index 196e895..fa7b1e1 100644 --- a/src/components/locked.rs +++ b/src/components/locked.rs @@ -1,2 +1,5 @@ +/// Component preventing application of [`VerletPoint`][VerletPoint] physics. +/// +/// [VerletPoint]: struct.VerletPoint.html #[derive(Debug, Copy, Clone)] pub struct VerletLocked {} diff --git a/src/components/point.rs b/src/components/point.rs index 15ffe8a..bf181cc 100644 --- a/src/components/point.rs +++ b/src/components/point.rs @@ -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, diff --git a/src/components/stick.rs b/src/components/stick.rs index 6ff866d..2584a2c 100644 --- a/src/components/stick.rs +++ b/src/components/stick.rs @@ -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, } diff --git a/src/components/stick_max_tension.rs b/src/components/stick_max_tension.rs index 8fa9f15..c666131 100644 --- a/src/components/stick_max_tension.rs +++ b/src/components/stick_max_tension.rs @@ -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); diff --git a/src/lib.rs b/src/lib.rs index c2ae996..6cec9e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; @@ -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), diff --git a/src/resources/config.rs b/src/resources/config.rs index 48aa46d..5bdd2fb 100644 --- a/src/resources/config.rs +++ b/src/resources/config.rs @@ -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) }