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
4 changes: 4 additions & 0 deletions build/nphysics2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ nalgebra = "0.16"
approx = "0.3"
downcast = "0.9"
ncollide2d = "0.17"
serde = { version = "1.0", optional = true, features = ["derive"]}

[target.'cfg(feature = "serde")'.dependencies]
nalgebra = { version = "0.16", features = ["serde-serialize"] }

[target.wasm32-unknown-unknown.dependencies]
stdweb = {version = "0.4", optional = true}
Expand Down
18 changes: 11 additions & 7 deletions build/nphysics3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ name = "nphysics3d"
path = "../../src/lib.rs"

[dependencies]
num-traits = "0.2"
slab = "0.4"
alga = "0.7"
nalgebra = "0.16"
approx = "0.3"
downcast = "0.9"
ncollide3d = "0.17"
num-traits = "0.2"
slab = "0.4"
alga = "0.7"
nalgebra = "0.16"
approx = "0.3"
downcast = "0.9"
ncollide3d = "0.17"
serde = { version = "1.0", optional = true, features = ["derive"] }

[target.'cfg(feature = "serde")'.dependencies]
nalgebra = { version = "0.16", features = ["serde-serialize"] }

[target.wasm32-unknown-unknown.dependencies]
stdweb = {version = "0.4", optional = true}
Expand Down
1 change: 1 addition & 0 deletions src/algebra/force2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::ops::{Add, AddAssign, Mul, Neg, Sub, SubAssign};
/// A force with a linear and angular (torque) component.
#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Force2<N: Real> {
/// The linear force.
pub linear: Vector2<N>,
Expand Down
1 change: 1 addition & 0 deletions src/algebra/force3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::ops::{Add, AddAssign, Mul, Neg, Sub, SubAssign};
/// A force with a linear and angular (torque) component.
#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Force3<N: Real> {
/// The linear force.
pub linear: Vector3<N>,
Expand Down
1 change: 1 addition & 0 deletions src/algebra/inertia2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use algebra::{Force2, Velocity2};

/// The inertia of a rigid body grouping both its mass and its angular inertia.
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Inertia2<N: Real> {
/// The linear part (mass) of the inertia.
pub linear: N,
Expand Down
1 change: 1 addition & 0 deletions src/algebra/inertia3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use na::{self, Isometry3, Matrix3, Matrix6, Real, U3};

/// The inertia of a rigid body grouping both its mass and its angular inertia.
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Inertia3<N: Real> {
/// The linear part (mass) of the inertia.
pub linear: N,
Expand Down
1 change: 1 addition & 0 deletions src/algebra/velocity2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::ops::{Add, AddAssign, Mul, Sub, SubAssign};
/// A velocity structure combining both the linear angular velocities of a point.
#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Velocity2<N: Real> {
/// The linear velocity.
pub linear: Vector2<N>,
Expand Down
1 change: 1 addition & 0 deletions src/algebra/velocity3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::ops::{Add, AddAssign, Mul, Sub, SubAssign};
/// A velocity structure combining both the linear angular velocities of a point.
#[repr(C)]
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Velocity3<N: Real> {
/// The linear velocity.
pub linear: Vector3<N>,
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ extern crate ncollide2d as ncollide;
#[cfg(feature = "dim3")]
extern crate ncollide3d as ncollide;
extern crate num_traits as num;

#[cfg(feature = "serde")]
#[macro_use]
extern crate serde;

extern crate slab;

/*
Expand Down
6 changes: 6 additions & 0 deletions src/object/collider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ impl<N: Real> ColliderData<N> {
&self.material
}

/// Set the material of this collider.
#[inline]
pub fn set_material(&mut self, material: Material<N>) {
self.material = material;
}

#[inline]
pub(crate) fn body_status_dependent_ndofs(&self) -> usize {
self.body_status_dependent_ndofs
Expand Down
1 change: 1 addition & 0 deletions src/object/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use na::{self, Real};
/// will average the coefficient of the two surfaces in contact in order
/// to deduce the restitution/friction coefficient.
#[derive(Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Material<N: Real> {
/// Restitution coefficient of the surface.
pub restitution: N,
Expand Down
5 changes: 5 additions & 0 deletions src/world/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ impl<N: Real> World<N> {
self.prediction
}

/// Angular prediction used internally for collision detection.
pub fn angular_prediction(&self) -> N {
self.angular_prediction
}

/// Disable the perfomance counters that measure various times and statistics during a timestep.
pub fn disable_performance_counters(&mut self) {
self.counters.disable();
Expand Down