From 4bb12d6859a1877f848db413075b4abadd4c7fc4 Mon Sep 17 00:00:00 2001 From: Colin Sherratt Date: Fri, 26 Dec 2014 16:18:29 -0500 Subject: [PATCH] Switch to rustc_serialize --- Cargo.toml | 4 +++- src/aabb.rs | 4 ++-- src/angle.rs | 4 ++-- src/cgmath.rs | 2 +- src/cylinder.rs | 2 +- src/frustum.rs | 4 ++-- src/line.rs | 2 +- src/matrix.rs | 6 +++--- src/obb.rs | 4 ++-- src/plane.rs | 2 +- src/point.rs | 4 ++-- src/projection.rs | 6 +++--- src/quaternion.rs | 2 +- src/ray.rs | 2 +- src/rotation.rs | 4 ++-- src/sphere.rs | 2 +- src/transform.rs | 4 ++-- src/vector.rs | 2 +- 18 files changed, 31 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 76249ab..53bf6ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,5 +14,7 @@ authors = ["Brendan Zabarauskas ", ] [lib] - name = "cgmath" + +[dependencies] +rustc-serialize="*" \ No newline at end of file diff --git a/src/aabb.rs b/src/aabb.rs index b8df9ba..f07b7c1 100644 --- a/src/aabb.rs +++ b/src/aabb.rs @@ -84,7 +84,7 @@ pub trait Aabb, P: Point> { } /// A two-dimensional AABB, aka a rectangle. -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Aabb2 { pub min: Point2, pub max: Point2, @@ -129,7 +129,7 @@ impl fmt::Show for Aabb2 { } /// A three-dimensional AABB, aka a rectangular prism. -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Aabb3 { pub min: Point3, pub max: Point3, diff --git a/src/angle.rs b/src/angle.rs index b73baf1..a372fe9 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -23,10 +23,10 @@ use approx::ApproxEq; use num::{BaseFloat, One, one, Zero, zero}; /// An angle, in radians -#[deriving(Copy, Clone, PartialEq, PartialOrd, Hash, Encodable, Decodable, Rand)] +#[deriving(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable, Rand)] pub struct Rad { pub s: S } /// An angle, in degrees -#[deriving(Copy, Clone, PartialEq, PartialOrd, Hash, Encodable, Decodable, Rand)] +#[deriving(Copy, Clone, PartialEq, PartialOrd, Hash, RustcEncodable, RustcDecodable, Rand)] pub struct Deg { pub s: S } /// Create a new angle, in radians diff --git a/src/cgmath.rs b/src/cgmath.rs index 072b24e..021d02f 100644 --- a/src/cgmath.rs +++ b/src/cgmath.rs @@ -33,7 +33,7 @@ //! `look_at`, `from_angle`, `from_euler`, and `from_axis_angle` methods. //! These are provided for convenience. -extern crate serialize; +extern crate "rustc-serialize" as rustc_serialize; // Re-exports diff --git a/src/cylinder.rs b/src/cylinder.rs index d13b0b8..6876710 100644 --- a/src/cylinder.rs +++ b/src/cylinder.rs @@ -18,7 +18,7 @@ use point::Point3; use vector::Vector3; -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Cylinder { pub center: Point3, pub axis: Vector3, diff --git a/src/frustum.rs b/src/frustum.rs index 8ebe229..9ca83ff 100644 --- a/src/frustum.rs +++ b/src/frustum.rs @@ -22,7 +22,7 @@ use plane::Plane; use point::Point3; use vector::{Vector, EuclideanVector}; -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Frustum { pub left: Plane, pub right: Plane, @@ -59,7 +59,7 @@ Frustum { } } -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct FrustumPoints { pub near_top_left: Point3, pub near_top_right: Point3, diff --git a/src/line.rs b/src/line.rs index a0e3153..bb7b63c 100644 --- a/src/line.rs +++ b/src/line.rs @@ -22,7 +22,7 @@ use ray::{Ray2}; use intersect::Intersect; /// A generic directed line segment from `origin` to `dest`. -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Line

{ pub origin: P, pub dest: P, diff --git a/src/matrix.rs b/src/matrix.rs index 57d5187..d82010d 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -29,15 +29,15 @@ use vector::{Vector, EuclideanVector}; use vector::{Vector2, Vector3, Vector4}; /// A 2 x 2, column major matrix -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable, Rand)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)] pub struct Matrix2 { pub x: Vector2, pub y: Vector2 } /// A 3 x 3, column major matrix -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable, Rand)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)] pub struct Matrix3 { pub x: Vector3, pub y: Vector3, pub z: Vector3 } /// A 4 x 4, column major matrix -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable, Rand)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)] pub struct Matrix4 { pub x: Vector4, pub y: Vector4, pub z: Vector4, pub w: Vector4 } diff --git a/src/obb.rs b/src/obb.rs index 15ad539..4c3302e 100644 --- a/src/obb.rs +++ b/src/obb.rs @@ -18,14 +18,14 @@ use point::{Point2, Point3}; use vector::{Vector2, Vector3}; -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Obb2 { pub center: Point2, pub axis: Vector2, pub extents: Vector2, } -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Obb3 { pub center: Point3, pub axis: Vector3, diff --git a/src/plane.rs b/src/plane.rs index 1c36b19..0127153 100644 --- a/src/plane.rs +++ b/src/plane.rs @@ -39,7 +39,7 @@ use vector::{Vector, EuclideanVector}; /// The `A*x + B*y + C*z - D = 0` form is preferred over the other common /// alternative, `A*x + B*y + C*z + D = 0`, because it tends to avoid /// superfluous negations (see _Real Time Collision Detection_, p. 55). -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Plane { pub n: Vector3, pub d: S, diff --git a/src/point.rs b/src/point.rs index be87393..6d65f71 100644 --- a/src/point.rs +++ b/src/point.rs @@ -26,11 +26,11 @@ use num::{BaseNum, BaseFloat, one, zero}; use vector::*; /// A point in 2-dimensional space. -#[deriving(PartialEq, Copy, Clone, Hash, Encodable, Decodable)] +#[deriving(PartialEq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)] pub struct Point2 { pub x: S, pub y: S } /// A point in 3-dimensional space. -#[deriving(PartialEq, Copy, Clone, Hash, Encodable, Decodable)] +#[deriving(PartialEq, Copy, Clone, Hash, RustcEncodable, RustcDecodable)] pub struct Point3 { pub x: S, pub y: S, pub z: S } diff --git a/src/projection.rs b/src/projection.rs index e574767..1d97850 100644 --- a/src/projection.rs +++ b/src/projection.rs @@ -69,7 +69,7 @@ pub trait Projection: ToMatrix4 { } /// A perspective projection based on a vertical field-of-view angle. -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct PerspectiveFov { pub fovy: A, pub aspect: S, @@ -143,7 +143,7 @@ impl> ToMatrix4 for PerspectiveFov { } /// A perspective projection with arbitrary left/right/bottom/top distances -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Perspective { pub left: S, right: S, pub bottom: S, top: S, @@ -193,7 +193,7 @@ impl ToMatrix4 for Perspective { } /// An orthographic projection with arbitrary left/right/bottom/top distances -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Ortho { pub left: S, right: S, pub bottom: S, top: S, diff --git a/src/quaternion.rs b/src/quaternion.rs index ffa29c6..715899a 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -29,7 +29,7 @@ use vector::{Vector3, Vector, EuclideanVector}; /// A [quaternion](https://en.wikipedia.org/wiki/Quaternion) in scalar/vector /// form. -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable, Rand)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Rand)] pub struct Quaternion { pub s: S, pub v: Vector3 } /// Represents types which can be expressed as a quaternion. diff --git a/src/ray.rs b/src/ray.rs index 879a2c4..46ad081 100644 --- a/src/ray.rs +++ b/src/ray.rs @@ -19,7 +19,7 @@ use vector::{Vector, Vector2, Vector3}; /// A generic ray starting at `origin` and extending infinitely in /// `direction`. -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Ray { pub origin: P, pub direction: V, diff --git a/src/rotation.rs b/src/rotation.rs index 547108f..881071a 100644 --- a/src/rotation.rs +++ b/src/rotation.rs @@ -161,7 +161,7 @@ pub trait Rotation3: Rotation, Point3> /// let unit_y3 = rot_half.concat(&rot_half).rotate_vector(&unit_x); /// assert!(unit_y3.approx_eq(&unit_y2)); /// ``` -#[deriving(PartialEq, Copy, Clone, Encodable, Decodable)] +#[deriving(PartialEq, Copy, Clone, RustcEncodable, RustcDecodable)] pub struct Basis2 { mat: Matrix2 } @@ -239,7 +239,7 @@ impl Rotation2 for Basis2 { /// inversion, can be implemented more efficiently than the implementations for /// `math::Matrix3`. To ensure orthogonality is maintained, the operations have /// been restricted to a subeset of those implemented on `Matrix3`. -#[deriving(PartialEq, Copy, Clone, Encodable, Decodable)] +#[deriving(PartialEq, Copy, Clone, RustcEncodable, RustcDecodable)] pub struct Basis3 { mat: Matrix3 } diff --git a/src/sphere.rs b/src/sphere.rs index a1f6b83..b376722 100644 --- a/src/sphere.rs +++ b/src/sphere.rs @@ -21,7 +21,7 @@ use point::{Point, Point3}; use ray::Ray3; use vector::Vector; -#[deriving(Copy, Clone, PartialEq, Encodable, Decodable)] +#[deriving(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub struct Sphere { pub center: Point3, pub radius: S, diff --git a/src/transform.rs b/src/transform.rs index ea29f70..d6a6a2d 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -76,7 +76,7 @@ pub trait Transform, P: Point> { /// A generic transformation consisting of a rotation, /// displacement vector and scale amount. -#[deriving(Copy, Clone, Encodable, Decodable)] +#[deriving(Copy, Clone, RustcEncodable, RustcDecodable)] pub struct Decomposed { pub scale: S, pub rot: R, @@ -159,7 +159,7 @@ impl> fmt::Show for Decomposed { pub mat: Matrix4, } diff --git a/src/vector.rs b/src/vector.rs index 0e6757d..d40c9cf 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -177,7 +177,7 @@ pub trait Vector: Array1 + Zero + One + Neg { // Utility macro for generating associated functions for the vectors macro_rules! vec( ($Self:ident <$S:ident> { $($field:ident),+ }, $n:expr) => ( - #[deriving(PartialEq, Eq, Copy, Clone, Hash, Encodable, Decodable, Rand)] + #[deriving(PartialEq, Eq, Copy, Clone, Hash, RustcEncodable, RustcDecodable, Rand)] pub struct $Self { $(pub $field: S),+ } impl<$S> $Self<$S> {