Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@ This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern

### Installation

```
```sh
$ yarn
```

### Build

```
```sh
$ ./generate_user_guides.sh
```

This command reads the templates directory and extracts specific instructions for bevy / rust / rapier integrations. It also injects code contained in rust files.
Above command reads the templates directory and extracts specific instructions for bevy / rust / rapier integrations.
It also injects code contained in the example files.

```
```sh
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.
Above command generates static content into the `build` directory and can be served using any static contents hosting service.

```
```sh
$ yarn start
```

This command builds and starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.
Above command builds and starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.

### Deployment

```
```sh
$ GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy
```

Expand Down
5 changes: 3 additions & 2 deletions docs-examples/2d/bevy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = "0.13.2"
bevy_rapier2d = "0.26.0"
bevy = "0.14"
# bevy_rapier2d = "0.28"
bevy_rapier2d = { path = "../../../../bevy_rapier/bevy_rapier2d" }
Comment on lines +9 to +11
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update to 0.15

14 changes: 9 additions & 5 deletions docs-examples/2d/bevy/examples/advanced_collision_detection2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ fn display_events(
// DOCUSAURUS: Events stop

// DOCUSAURUS: ContactGraph1 start
fn display_contact_info(rapier_context: Res<RapierContext>, custom_info: Res<CustomInfo>) {
fn display_contact_info(rapier_context: ReadRapierContext, custom_info: Res<CustomInfo>) {
let entity1 = custom_info.entity1; // A first entity with a collider attached.
let entity2 = custom_info.entity2; // A second entity with a collider attached.
let rapier_context = rapier_context.single();

/* Find the contact pair, if it exists, between two colliders. */
if let Some(contact_pair) = rapier_context.contact_pair(entity1, entity2) {
// The contact pair exists meaning that the broad-phase identified a potential contact.
if contact_pair.has_any_active_contacts() {
if contact_pair.has_any_active_contact() {
// The contact pair has active contacts, meaning that it
// contains contacts for which contact forces were computed.
}
Expand Down Expand Up @@ -121,10 +122,11 @@ fn display_contact_info(rapier_context: Res<RapierContext>, custom_info: Res<Cus

// DOCUSAURUS: ContactGraph2 start
fn display_contact_info_all_from_1_entity(
rapier_context: Res<RapierContext>,
rapier_context: ReadRapierContext,
custom_info: Res<CustomInfo>,
) {
let entity = custom_info.entity2; // An entity with a collider attached.
let rapier_context = rapier_context.single();

/* Iterate through all the contact pairs involving a specific collider. */
for contact_pair in rapier_context.contact_pairs_with(entity) {
Expand All @@ -141,9 +143,10 @@ fn display_contact_info_all_from_1_entity(
// DOCUSAURUS: ContactGraph2 stop

// DOCUSAURUS: IntersectionGraph1 start
fn display_intersection_info(rapier_context: Res<RapierContext>, custom_info: Res<CustomInfo>) {
fn display_intersection_info(rapier_context: ReadRapierContext, custom_info: Res<CustomInfo>) {
let entity1 = custom_info.entity1; // A first entity with a collider attached.
let entity2 = custom_info.entity2; // A second entity with a collider attached.
let rapier_context = rapier_context.single();

/* Find the intersection pair, if it exists, between two colliders. */
if rapier_context.intersection_pair(entity1, entity2) == Some(true) {
Expand All @@ -157,10 +160,11 @@ fn display_intersection_info(rapier_context: Res<RapierContext>, custom_info: Re

// DOCUSAURUS: IntersectionGraph2 start
fn display_intersection_info_all_from_1_entity(
rapier_context: Res<RapierContext>,
rapier_context: ReadRapierContext,
custom_info: Res<CustomInfo>,
) {
let entity = custom_info.entity2; // An entity with a collider attached.
let rapier_context = rapier_context.single();

/* Iterate through all the intersection pairs involving a specific collider. */
for (collider1, collider2, intersecting) in rapier_context.intersection_pairs_with(entity) {
Expand Down
19 changes: 13 additions & 6 deletions docs-examples/2d/bevy/examples/scene_queries2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::{prelude::*, render::primitives::Aabb};
use bevy_rapier2d::{parry::query::intersection_test, prelude::*};
use bevy_rapier2d::prelude::*;

#[derive(PartialEq, Eq, Clone, Copy, Component)]
struct CustomData {
Expand Down Expand Up @@ -46,13 +46,15 @@ fn setup_physics(mut commands: Commands) {

// DOCUSAURUS: Raycast start
/* Cast a ray inside of a system. */
fn cast_ray(rapier_context: Res<RapierContext>) {
fn cast_ray(rapier_context: ReadRapierContext) {
let ray_pos = Vec2::new(1.0, 2.0);
let ray_dir = Vec2::new(0.0, 1.0);
let max_toi = 4.0;
let solid = true;
let filter = QueryFilter::default();

let rapier_context = rapier_context.single();

if let Some((entity, toi)) = rapier_context.cast_ray(ray_pos, ray_dir, max_toi, solid, filter) {
// The first collider hit has the entity `entity` and it hit after
// the ray travelled a distance equal to `ray_dir * toi`.
Expand Down Expand Up @@ -95,7 +97,7 @@ fn cast_ray(rapier_context: Res<RapierContext>) {

// DOCUSAURUS: Shapecast start
/* Cast a shape inside of a system. */
fn cast_shape(rapier_context: Res<RapierContext>) {
fn cast_shape(rapier_context: ReadRapierContext) {
let shape = Collider::cuboid(1.0, 2.0);
let shape_pos = Vec2::new(1.0, 2.0);
let shape_rot = 0.8;
Expand All @@ -107,6 +109,7 @@ fn cast_shape(rapier_context: Res<RapierContext>) {
stop_at_penetration: false,
compute_impact_geometry_on_penetration: false,
};
let rapier_context = rapier_context.single();

if let Some((entity, hit)) =
rapier_context.cast_shape(shape_pos, shape_rot, shape_vel, &shape, options, filter)
Expand All @@ -123,11 +126,12 @@ fn cast_shape(rapier_context: Res<RapierContext>) {

// DOCUSAURUS: PointProjection start
/* Project a point inside of a system. */
fn project_point(rapier_context: Res<RapierContext>) {
fn project_point(rapier_context: ReadRapierContext) {
let point = Vec2::new(1.0, 2.0);
let solid = true;
let filter = QueryFilter::default();

let rapier_context = rapier_context.single();
if let Some((entity, projection)) = rapier_context.project_point(point, solid, filter) {
// The collider closest to the point has this `handle`.
println!(
Expand All @@ -151,12 +155,13 @@ fn project_point(rapier_context: Res<RapierContext>) {

// DOCUSAURUS: IntersectionTest start
/* Test intersections inside of a system. */
fn test_intersections(rapier_context: Res<RapierContext>) {
fn test_intersections(rapier_context: ReadRapierContext) {
let shape = Collider::cuboid(1.0, 2.0);
let shape_pos = Vec2::new(0.0, 1.0);
let shape_rot = 0.8;
let filter = QueryFilter::default();

let rapier_context = rapier_context.single();
rapier_context.intersections_with_shape(shape_pos, shape_rot, &shape, filter, |entity| {
println!("The entity {:?} intersects our shape.", entity);
true // Return `false` instead if we want to stop searching for other colliders that contain this point.
Expand All @@ -176,11 +181,13 @@ fn test_intersections(rapier_context: Res<RapierContext>) {
// DOCUSAURUS: QueryFilter start
/* Cast a ray inside of a system. */
fn cast_ray_filtered(
rapier_context: Res<RapierContext>,
rapier_context: ReadRapierContext,
player_query: Query<Entity, With<Player>>,
custom_data_query: Query<&CustomData>,
) {
let player_handle = player_query.single();
let rapier_context = rapier_context.single();

let ray_pos = Vec2::new(1.0, 2.0);
let ray_dir = Vec2::new(0.0, 1.0);
let max_toi = 4.0;
Expand Down
Loading