forked from dimforge/rapier
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
313 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[package] | ||
name = "rapier_testbed2d-f64" | ||
version = "0.12.0-alpha.1" | ||
authors = [ "Sébastien Crozet <[email protected]>" ] | ||
description = "Testbed for the Rapier 2-dimensional physics engine in Rust." | ||
homepage = "http://rapier.org" | ||
repository = "https://github.com/dimforge/rapier" | ||
categories = [ "science", "game-development", "mathematics", "simulation", "wasm"] | ||
keywords = [ "physics", "dynamics", "rigid", "real-time", "impulse_joints" ] | ||
license = "Apache-2.0" | ||
edition = "2021" | ||
|
||
[badges] | ||
maintenance = { status = "actively-developed" } | ||
|
||
[lib] | ||
name = "rapier_testbed2d" | ||
path = "../../src_testbed/lib.rs" | ||
required-features = [ "dim2" ] | ||
|
||
[features] | ||
default = [ "dim2" ] | ||
dim2 = [ ] | ||
parallel = [ "rapier/parallel", "num_cpus" ] | ||
other-backends = [ "wrapped2d" ] | ||
|
||
|
||
[dependencies] | ||
nalgebra = { version = "0.30", features = [ "rand" ] } | ||
rand = "0.8" | ||
rand_pcg = "0.3" | ||
instant = { version = "0.1", features = [ "web-sys", "now" ]} | ||
bitflags = "1" | ||
num_cpus = { version = "1", optional = true } | ||
wrapped2d = { version = "0.4", optional = true } | ||
crossbeam = "0.8" | ||
bincode = "1" | ||
Inflector = "0.11" | ||
md5 = "0.7" | ||
|
||
bevy_egui = "0.10" | ||
bevy_ecs = "0.6" | ||
|
||
# Dependencies for native only. | ||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] | ||
bevy = {version = "0.6", default-features = false, features = ["bevy_winit", "render", "x11"]} | ||
|
||
# Dependencies for WASM only. | ||
[target.'cfg(target_arch = "wasm32")'.dependencies] | ||
bevy = {version = "0.6", default-features = false, features = ["bevy_winit", "render"]} | ||
#bevy_webgl2 = "0.5" | ||
|
||
[dependencies.rapier] | ||
package = "rapier2d-f64" | ||
path = "../rapier2d-f64" | ||
version = "0.12.0-alpha.1" | ||
features = [ "serde-serialize" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
[package] | ||
name = "rapier_testbed3d-f64" | ||
version = "0.12.0-alpha.1" | ||
authors = [ "Sébastien Crozet <[email protected]>" ] | ||
description = "Testbed for the Rapier 3-dimensional physics engine in Rust." | ||
homepage = "http://rapier.org" | ||
repository = "https://github.com/dimforge/rapier" | ||
categories = [ "science", "game-development", "mathematics", "simulation", "wasm"] | ||
keywords = [ "physics", "dynamics", "rigid", "real-time", "impulse_joints" ] | ||
license = "Apache-2.0" | ||
edition = "2021" | ||
|
||
[badges] | ||
maintenance = { status = "actively-developed" } | ||
|
||
[lib] | ||
name = "rapier_testbed3d" | ||
path = "../../src_testbed/lib.rs" | ||
required-features = [ "dim3" ] | ||
|
||
[features] | ||
default = [ "dim3" ] | ||
dim3 = [ ] | ||
parallel = [ "rapier/parallel", "num_cpus" ] | ||
|
||
[dependencies] | ||
nalgebra = { version = "0.30", features = [ "rand" ] } | ||
rand = "0.8" | ||
rand_pcg = "0.3" | ||
instant = { version = "0.1", features = [ "web-sys", "now" ]} | ||
bitflags = "1" | ||
num_cpus = { version = "1", optional = true } | ||
crossbeam = "0.8" | ||
bincode = "1" | ||
md5 = "0.7" | ||
Inflector = "0.11" | ||
serde = { version = "1", features = [ "derive" ] } | ||
|
||
bevy_egui = "0.10" | ||
bevy_ecs = "0.6" | ||
|
||
# Dependencies for native only. | ||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] | ||
bevy = {version = "0.6", default-features = false, features = ["bevy_winit", "render", "x11"]} | ||
|
||
# Dependencies for WASM only. | ||
[target.'cfg(target_arch = "wasm32")'.dependencies] | ||
bevy = {version = "0.6", default-features = false, features = ["bevy_winit", "render"]} | ||
#bevy_webgl2 = "0.5" | ||
|
||
[dependencies.rapier] | ||
package = "rapier3d-f64" | ||
path = "../rapier3d-f64" | ||
version = "0.12.0-alpha.1" | ||
features = [ "serde-serialize" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[package] | ||
name = "rapier-examples-3d-f64" | ||
version = "0.1.0" | ||
authors = [ "Sébastien Crozet <[email protected]>" ] | ||
edition = "2021" | ||
default-run = "all_examples3-f64" | ||
|
||
[features] | ||
parallel = [ "rapier3d-f64/parallel", "rapier_testbed3d-f64/parallel" ] | ||
simd-stable = [ "rapier3d-f64/simd-stable" ] | ||
simd-nightly = [ "rapier3d-f64/simd-nightly" ] | ||
enhanced-determinism = [ "rapier3d-f64/enhanced-determinism" ] | ||
|
||
[dependencies] | ||
rand = "0.8" | ||
getrandom = { version = "0.2", features = [ "js" ] } | ||
Inflector = "0.11" | ||
wasm-bindgen = "0.2" | ||
obj-rs = { version = "0.6", default-features = false } | ||
bincode = "1" | ||
serde = "1" | ||
|
||
[dependencies.rapier_testbed3d-f64] | ||
path = "../crates/rapier_testbed3d-f64" | ||
|
||
[dependencies.rapier3d-f64] | ||
path = "../crates/rapier3d-f64" | ||
|
||
[[bin]] | ||
name = "all_examples3-f64" | ||
path = "./all_examples3-f64.rs" | ||
|
||
#[lib] | ||
#crate-type = ["cdylib", "rlib"] | ||
#path = "./all_examples3_wasm.rs" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#![allow(dead_code)] | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
use wasm_bindgen::prelude::*; | ||
extern crate rapier3d_f64 as rapier3d; | ||
|
||
use inflector::Inflector; | ||
|
||
use rapier_testbed3d::{Testbed, TestbedApp}; | ||
use std::cmp::Ordering; | ||
|
||
mod debug_serialized3; | ||
|
||
fn demo_name_from_command_line() -> Option<String> { | ||
let mut args = std::env::args(); | ||
|
||
while let Some(arg) = args.next() { | ||
if &arg[..] == "--example" { | ||
return args.next(); | ||
} | ||
} | ||
|
||
None | ||
} | ||
|
||
#[cfg(any(target_arch = "wasm32", target_arch = "asmjs"))] | ||
fn demo_name_from_url() -> Option<String> { | ||
None | ||
// let window = stdweb::web::window(); | ||
// let hash = window.location()?.search().ok()?; | ||
// if hash.len() > 0 { | ||
// Some(hash[1..].to_string()) | ||
// } else { | ||
// None | ||
// } | ||
} | ||
|
||
#[cfg(not(any(target_arch = "wasm32", target_arch = "asmjs")))] | ||
fn demo_name_from_url() -> Option<String> { | ||
None | ||
} | ||
|
||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))] | ||
pub fn main() { | ||
let demo = demo_name_from_command_line() | ||
.or_else(|| demo_name_from_url()) | ||
.unwrap_or(String::new()) | ||
.to_camel_case(); | ||
|
||
let mut builders: Vec<(_, fn(&mut Testbed))> = | ||
vec![("(Debug) serialized", debug_serialized3::init_world)]; | ||
|
||
// Lexicographic sort, with stress tests moved at the end of the list. | ||
builders.sort_by(|a, b| match (a.0.starts_with("("), b.0.starts_with("(")) { | ||
(true, true) | (false, false) => a.0.cmp(b.0), | ||
(true, false) => Ordering::Greater, | ||
(false, true) => Ordering::Less, | ||
}); | ||
|
||
let i = builders | ||
.iter() | ||
.position(|builder| builder.0.to_camel_case().as_str() == demo.as_str()) | ||
.unwrap_or(0); | ||
|
||
let testbed = TestbedApp::from_builders(i, builders); | ||
testbed.run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
use rapier3d::prelude::*; | ||
use rapier_testbed3d::Testbed; | ||
|
||
#[derive(serde::Deserialize)] | ||
struct State { | ||
pub islands: IslandManager, | ||
pub broad_phase: BroadPhase, | ||
pub narrow_phase: NarrowPhase, | ||
pub bodies: RigidBodySet, | ||
pub colliders: ColliderSet, | ||
pub impulse_joints: ImpulseJointSet, | ||
pub multibody_joints: MultibodyJointSet, | ||
pub ccd_solver: CCDSolver, | ||
} | ||
|
||
pub fn init_world(testbed: &mut Testbed) { | ||
/* | ||
* Set up the testbed. | ||
*/ | ||
let bytes = std::fs::read("state.bin").unwrap(); | ||
let mut state: State = bincode::deserialize(&bytes).unwrap(); | ||
|
||
for body in state.bodies.iter_mut() { | ||
dbg!(body.1.position()); | ||
dbg!(body.1.is_ccd_enabled()); | ||
dbg!(body.1.is_sleeping()); | ||
// dbg!(body.1); | ||
body.1.clear_forces(false); | ||
} | ||
|
||
let mut to_remove = vec![]; | ||
for (_, co) in state.colliders.iter() { | ||
if co.shape().as_ball().is_none() { | ||
if let Some(parent) = co.parent() { | ||
let body = &state.bodies[parent]; | ||
if body.is_dynamic() { | ||
to_remove.push(parent); | ||
} | ||
} | ||
} | ||
} | ||
|
||
// for h in to_remove { | ||
// state.bodies.remove( | ||
// h, | ||
// &mut state.islands, | ||
// &mut state.colliders, | ||
// &mut state.impulse_joints, | ||
// &mut state.multibody_joints, | ||
// ); | ||
// } | ||
|
||
testbed.set_world( | ||
state.bodies, | ||
state.colliders, | ||
state.impulse_joints, | ||
state.multibody_joints, | ||
); | ||
testbed.harness_mut().physics.islands = state.islands; | ||
testbed.harness_mut().physics.broad_phase = state.broad_phase; | ||
testbed.harness_mut().physics.narrow_phase = state.narrow_phase; | ||
testbed.harness_mut().physics.ccd_solver = state.ccd_solver; | ||
// testbed.harness_mut().physics.integration_parameters.erp = 0.0; | ||
// testbed | ||
// .harness_mut() | ||
// .physics | ||
// .integration_parameters | ||
// .delassus_inv_factor = 1.0; | ||
|
||
testbed.set_graphics_shift(vector![-541.0, -6377257.0, -61.0]); | ||
testbed.look_at(point![10.0, 10.0, 10.0], point![0.0, 0.0, 0.0]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.