Skip to content

Commit

Permalink
V0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ManevilleF committed Dec 2, 2023
1 parent c397174 commit 0ef2a3e
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 74 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

## 0.7.0

* Bump `bevy` to `0.12.x`
* Bump `bevy_rapier3d` to `0.23.x`
* Bump `bevy_inspector_egui` to `0.21.x`
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_silk"
version = "0.6.0"
version = "0.7.0"
edition = "2021"
authors = ["Felix de Maneville <felix.maneville@gmail.com>"]
repository = "https://github.com/ManevilleF/bevy_silk"
Expand Down
90 changes: 47 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Bevy Silk

[![workflow](https://github.com/ManevilleF/bevy_silk/actions/workflows/rust.yml/badge.svg)](https://github.com/ManevilleF/bevy_silk/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/)
Expand All @@ -7,19 +9,15 @@

<!-- cargo-sync-readme start -->

# Bevy Silk

CPU driven Cloth engine for Bevy using Verlet integration.

by [Félix Lescaudey de Maneville](https://linktree.com/ManevilleF)

## Get started

### Dependency

Add `bevy_silk` as a dependency in the `Cargo.toml`

`bevy_silk = "0.6"`
`bevy_silk = "0.7"`

Or follow the main git branch

Expand All @@ -35,6 +33,7 @@ Or follow the main git branch
| 0.4.0 | 0.9 |
| 0.5.0 | 0.10 |
| 0.6.0 | 0.11 |
| 0.7.0 | 0.12 |

### Plugin

Expand Down Expand Up @@ -127,16 +126,20 @@ fn spawn(mut commands: Commands) {
))
.id();
let anchor_to_a = VertexAnchor {
custom_target: Some(entity_a), // The anchor will pin the vertices to `entity_a`
custom_offset: Some(Vec3::new(1.0, 1.2, 0.0)), // Specify an extra offset from the target's `GlobalTransform`
// The anchor will pin the vertices to `entity_a`
custom_target: Some(entity_a),
// Specify an extra offset from the target's `GlobalTransform`
custom_offset: Some(Vec3::new(1.0, 1.2, 0.0)),
..Default::default()
};
let anchor_to_self = VertexAnchor {
custom_target: None, // The anchor will pin the cloth entity
custom_offset: Some(Vec3::new(-1.0, 0.0, -0.1)), // Specify an extra offset from the target's `GlobalTransform`
// The anchor will pin the cloth entity
custom_target: None,
// Specify an extra offset from the target's `GlobalTransform`
custom_offset: Some(Vec3::new(-1.0, 0.0, -0.1)),
..Default::default()
};

let cloth = ClothBuilder::new()
// Adds pinned vertices ids using an Iterator
.with_anchored_vertex_ids(0..9, anchor_to_a)
Expand All @@ -153,11 +156,11 @@ fn spawn(mut commands: Commands) {

Custom anchoring allows to :

- pin vertices to various entities, like skeletal mesh joints
- define custom offsets to customize the distance between the anchored
* pin vertices to various entities, like skeletal mesh joints
* define custom offsets to customize the distance between the anchored
vertices an the target
- use world space pinning and ignore the target's rotation for example
- override the vertex positions, using only the offset
* use world space pinning and ignore the target's rotation for example
* override the vertex positions, using only the offset

### Configuration

Expand Down Expand Up @@ -190,8 +193,8 @@ configuration.
You may add wind forces to the simulation for a more dynamic clothing
effect, for each force you may choose from:

- `Wind::Constant` for constant wind force
- `Wind::SinWave` for a sin wave following wind intensity with custom force
* `Wind::Constant` for constant wind force
* `Wind::SinWave` for a sin wave following wind intensity with custom force
and frequency.

`Wind` forces can be added as a resource to your app through the `Winds`
Expand Down Expand Up @@ -221,8 +224,9 @@ fn main() {
## Collisions

Both [`bevy_rapier`] and [`bevy_xpbd`] are supported for cloth interactions with colliders.
They can be enabled with the `rapier_collisions` and `xpbd_collisions` features respectively.
Both [`bevy_rapier`] and [`bevy_xpbd`] are supported for cloth interactions
with colliders. They can be enabled with the `rapier_collisions` and
`xpbd_collisions` features respectively.

> Note: Collision support is still experimental for now and is not suited
> for production use. Feedback is welcome!
Expand Down Expand Up @@ -250,14 +254,14 @@ fn spawn(mut commands: Commands) {

Three `bevy_rapier` components will be automatically inserted:

- a `RigidBody::KinematicPositionBased`
- a `Collider` which will be updated every frame to follow the cloth bounds
* a `RigidBody::KinematicPositionBased`
* a `Collider` which will be updated every frame to follow the cloth bounds
(AABB)
- a `SolverGroup` set to 0 (`Group::NONE`) in everything, avoiding default
collision solving.
* a `SolverGroup` set to 0 (`Group::NONE`) in everything, avoiding default
collision solving.

You can customize what collisions will be checked by specifying `CollisionGroups`.
(See the [`bevy_rapier` docs](https://rapier.rs/docs/user_guides/bevy_plugin/colliders#collision-groups-and-solver-groups)).
You can customize what collisions will be checked by specifying
`CollisionGroups`. (See the [`bevy_rapier` docs](https://rapier.rs/docs/user_guides/bevy_plugin/colliders#collision-groups-and-solver-groups)).

### `bevy_xpbd`

Expand All @@ -282,13 +286,13 @@ fn spawn(mut commands: Commands) {

Three `bevy_xpbd` components will be automatically inserted:

- a `RigidBody::Kinematic`
- a `Collider` which will be updated every frame to follow the cloth bounds
* a `RigidBody::Kinematic`
* a `Collider` which will be updated every frame to follow the cloth bounds
(AABB)
- a `Sensor` used for avoiding default collision solving.
* a `Sensor` used for avoiding default collision solving.

You can customize what collisions will be checked by specifying `CollisionLayers`.
(See the [`bevy_xpbd` docs](https://docs.rs/bevy_xpbd_3d/latest/bevy_xpbd_3d/components/struct.CollisionLayers.html)).
You can customize what collisions will be checked by specifying
`CollisionLayers`. (See the [`bevy_xpbd` docs](https://docs.rs/bevy_xpbd_3d/latest/bevy_xpbd_3d/components/struct.CollisionLayers.html)).

## Mesh utils

Expand All @@ -297,27 +301,30 @@ useful for classic cloth uses like flags or capes

## Q&A

- `My mesh falls immediately and infinitely when I add a Cloth component,
* `My mesh falls immediately and infinitely when I add a Cloth component,
how to fix it?`

You probably didn't specify any *pinned points*, meaning there are no
vertices anchored to your entity's `GlobalTransform`.
You probably didn't specify any *pinned points*, meaning there are no
vertices anchored to your entity's `GlobalTransform`.

- `My cloth jitters a lot/ suddenly falls down/ has strange sudden
* `My cloth jitters a lot/ suddenly falls down/ has strange sudden
behaviour`

Gravity and winds are by default smoothed out by the framerate, if the
framerate drops suddenly gravity and wind get much stronger.
If your simulation suffers from this you can specify a custom smooth value
in `ClothConfig::acceleration_smoothing`.
Gravity and winds are by default smoothed out by the framerate, if the
framerate drops suddenly gravity and wind get much stronger.
If your simulation suffers from this you can specify a custom smooth
value in `ClothConfig::acceleration_smoothing`.

[`bevy_rapier`]: https://github.com/dimforge/bevy_rapier
[`bevy_xpbd`]: https://github.com/Jondolf/bevy_xpbd

<!-- cargo-sync-readme end -->

## TODO list

- [ ] World and per cloth simulation pause/ filter out cloth update
- [ ] Cloth update batching
- [ ] Cloth cutting maybe?
* [ ] World and per cloth simulation pause/ filter out cloth update
* [ ] Cloth update batching
* [ ] Cloth cutting maybe?

## Examples

Expand Down Expand Up @@ -346,6 +353,3 @@ in `ClothConfig::acceleration_smoothing`.
6. Anchors example

run `cargo run --example anchors`

[`bevy_rapier`]: https://github.com/dimforge/bevy_rapier
[`bevy_xpbd`]: https://github.com/Jondolf/bevy_xpbd
64 changes: 34 additions & 30 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
//! # Bevy Silk
//!
//! CPU driven Cloth engine for Bevy using Verlet integration.
//!
//! by [Félix Lescaudey de Maneville](https://linktree.com/ManevilleF)
//!
//! ## Get started
//!
//! ### Dependency
//!
//! Add `bevy_silk` as a dependency in the `Cargo.toml`
//!
//! `bevy_silk = "0.6"`
//! `bevy_silk = "0.7"`
//!
//! Or follow the main git branch
//!
Expand All @@ -26,6 +22,7 @@
//! | 0.4.0 | 0.9 |
//! | 0.5.0 | 0.10 |
//! | 0.6.0 | 0.11 |
//! | 0.7.0 | 0.12 |
//!
//! ### Plugin
//!
Expand Down Expand Up @@ -118,16 +115,20 @@
//! ))
//! .id();
//! let anchor_to_a = VertexAnchor {
//! custom_target: Some(entity_a), // The anchor will pin the vertices to `entity_a`
//! custom_offset: Some(Vec3::new(1.0, 1.2, 0.0)), // Specify an extra offset from the target's `GlobalTransform`
//! // The anchor will pin the vertices to `entity_a`
//! custom_target: Some(entity_a),
//! // Specify an extra offset from the target's `GlobalTransform`
//! custom_offset: Some(Vec3::new(1.0, 1.2, 0.0)),
//! ..Default::default()
//! };
//! let anchor_to_self = VertexAnchor {
//! custom_target: None, // The anchor will pin the cloth entity
//! custom_offset: Some(Vec3::new(-1.0, 0.0, -0.1)), // Specify an extra offset from the target's `GlobalTransform`
//! // The anchor will pin the cloth entity
//! custom_target: None,
//! // Specify an extra offset from the target's `GlobalTransform`
//! custom_offset: Some(Vec3::new(-1.0, 0.0, -0.1)),
//! ..Default::default()
//! };
//!
//!
//! let cloth = ClothBuilder::new()
//! // Adds pinned vertices ids using an Iterator
//! .with_anchored_vertex_ids(0..9, anchor_to_a)
Expand All @@ -143,11 +144,12 @@
//! ```
//!
//! Custom anchoring allows to :
//! - pin vertices to various entities, like skeletal mesh joints
//! - define custom offsets to customize the distance between the anchored
//!
//! * pin vertices to various entities, like skeletal mesh joints
//! * define custom offsets to customize the distance between the anchored
//! vertices an the target
//! - use world space pinning and ignore the target's rotation for example
//! - override the vertex positions, using only the offset
//! * use world space pinning and ignore the target's rotation for example
//! * override the vertex positions, using only the offset
//!
//! ### Configuration
//!
Expand Down Expand Up @@ -179,8 +181,9 @@
//!
//! You may add wind forces to the simulation for a more dynamic clothing
//! effect, for each force you may choose from:
//! - `Wind::Constant` for constant wind force
//! - `Wind::SinWave` for a sin wave following wind intensity with custom force
//!
//! * `Wind::Constant` for constant wind force
//! * `Wind::SinWave` for a sin wave following wind intensity with custom force
//! and frequency.
//!
//! `Wind` forces can be added as a resource to your app through the `Winds`
Expand Down Expand Up @@ -240,10 +243,10 @@
//!
//! Three `bevy_rapier` components will be automatically inserted:
//!
//! - a `RigidBody::KinematicPositionBased`
//! - a `Collider` which will be updated every frame to follow the cloth bounds
//! * a `RigidBody::KinematicPositionBased`
//! * a `Collider` which will be updated every frame to follow the cloth bounds
//! (AABB)
//! - a `SolverGroup` set to 0 (`Group::NONE`) in everything, avoiding default
//! * a `SolverGroup` set to 0 (`Group::NONE`) in everything, avoiding default
//! collision solving.
//!
//! You can customize what collisions will be checked by specifying
Expand Down Expand Up @@ -271,10 +274,11 @@
//! ```
//!
//! Three `bevy_xpbd` components will be automatically inserted:
//! - a `RigidBody::Kinematic`
//! - a `Collider` which will be updated every frame to follow the cloth bounds
//!
//! * a `RigidBody::Kinematic`
//! * a `Collider` which will be updated every frame to follow the cloth bounds
//! (AABB)
//! - a `Sensor` used for avoiding default collision solving.
//! * a `Sensor` used for avoiding default collision solving.
//!
//! You can customize what collisions will be checked by specifying
//! `CollisionLayers`. (See the [`bevy_xpbd` docs](https://docs.rs/bevy_xpbd_3d/latest/bevy_xpbd_3d/components/struct.CollisionLayers.html)).
Expand All @@ -286,19 +290,19 @@
//!
//! ## Q&A
//!
//! - `My mesh falls immediately and infinitely when I add a Cloth component,
//! * `My mesh falls immediately and infinitely when I add a Cloth component,
//! how to fix it?`
//!
//! You probably didn't specify any *pinned points*, meaning there are no
//! vertices anchored to your entity's `GlobalTransform`.
//! You probably didn't specify any *pinned points*, meaning there are no
//! vertices anchored to your entity's `GlobalTransform`.
//!
//! - `My cloth jitters a lot/ suddenly falls down/ has strange sudden
//! * `My cloth jitters a lot/ suddenly falls down/ has strange sudden
//! behaviour`
//!
//! Gravity and winds are by default smoothed out by the framerate, if the
//! framerate drops suddenly gravity and wind get much stronger.
//! If your simulation suffers from this you can specify a custom smooth value
//! in `ClothConfig::acceleration_smoothing`.
//! Gravity and winds are by default smoothed out by the framerate, if the
//! framerate drops suddenly gravity and wind get much stronger.
//! If your simulation suffers from this you can specify a custom smooth
//! value in `ClothConfig::acceleration_smoothing`.
//!
//! [`bevy_rapier`]: https://github.com/dimforge/bevy_rapier
//! [`bevy_xpbd`]: https://github.com/Jondolf/bevy_xpbd
Expand Down

0 comments on commit 0ef2a3e

Please sign in to comment.