Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Partial Serialization support + Missing Default & Debug derives #184

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion build/nphysics2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ either = "1.0"
num-traits = "0.2"
slab = "0.4"
alga = "0.8"
nalgebra = { version = "0.17", features = [ "sparse" ] }
approx = "0.3"
downcast-rs = "1.0"
bitflags = "1.0"
ncollide2d = "0.18"
serde = { version = "1.0", optional = true, features = ["derive"]}

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

[target.wasm32-unknown-unknown.dependencies]
stdweb = {version = "0.4", optional = true}
Expand Down
7 changes: 6 additions & 1 deletion build/nphysics3d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ either = "1.0"
num-traits = "0.2"
slab = "0.4"
alga = "0.8"
nalgebra = { version = "0.17", features = [ "sparse" ] }
approx = "0.3"
downcast-rs = "1.0"
bitflags = "1.0"
ncollide3d = "0.18"
serde = { version = "1.0", optional = true, features = ["derive"]}

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

[target.wasm32-unknown-unknown.dependencies]
stdweb = {version = "0.4", optional = true}
Expand Down
10 changes: 5 additions & 5 deletions nphysics_testbed3d/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ extern crate time;
#[macro_use]
extern crate log;

pub use crate::engine::GraphicsManager;
pub use crate::testbed::Testbed;
pub use world_owner::WorldOwner;

mod engine;
pub mod objects;
mod testbed;
mod world_owner;
mod world_owner;

pub use crate::engine::GraphicsManager;
pub use crate::testbed::Testbed;
pub use crate::world_owner::WorldOwner;
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/inertia3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::algebra::{Force3, Velocity3};

/// 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
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ extern crate num_traits as num;
extern crate slab;
extern crate either;

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

/*
* The two following crates are pulled-in for
* measuring time.
Expand Down
6 changes: 6 additions & 0 deletions src/object/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ pub enum BodyStatus {
Kinematic,
}

impl Default for BodyStatus {
fn default() -> Self {
BodyStatus::Dynamic
}
}

/// The activation status of a body.
///
/// This controls whether a body is sleeping or not.
Expand Down
7 changes: 6 additions & 1 deletion src/world/collider_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ impl<N: Real> ColliderWorld<N> {
pub fn as_collider_world(&self) -> &CollisionWorld<N, ColliderData<N>> {
&self.cworld
}

/// The underlying collision world from the ncollide crate.
pub fn as_collider_world_mut(&mut self) -> &mut CollisionWorld<N, ColliderData<N>> {
&mut self.cworld
}

/// Unwraps the underlying collision world from the ncollide crate.
pub fn into_inner(self) -> CollisionWorld<N, ColliderData<N>> {
Expand Down Expand Up @@ -567,4 +572,4 @@ impl<'a, N: Real> Iterator for ColliderChain<'a, N> {
self.curr = coll.next();
Some(coll)
}
}
}