diff --git a/Makefile b/Makefile index 9671953..5555260 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ SRC_CRATE = $(TARGET).rs EXTERN_DIR = $(ROOT_DIR)/extern BUILD_DIR = $(ROOT_DIR)/lib -CFG = --cfg=color --cfg=geom --cfg=noise --cfg=world +CFG = --cfg=color --cfg=geom --cfg=noise --cfg=transform TEST = $(TARGET) TEST_BUILD_DIR = $(ROOT_DIR)/test diff --git a/src/color/channel.rs b/src/color/channel.rs index c879795..dd64fdc 100644 --- a/src/color/channel.rs +++ b/src/color/channel.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +//! Color channel conversions and utility methods + pub trait Channel: Primitive + Orderable { priv fn from(chan: T) -> Self; pub fn to_channel(&self) -> T; diff --git a/src/color/color.rs b/src/color/color.rs index 2c3890f..09e6c57 100644 --- a/src/color/color.rs +++ b/src/color/color.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +//! Color types, functions and conversions + pub use self::channel::{Channel, FloatChannel}; pub use self::hsv::{HSV, ToHSV, HSVA, ToHSVA}; pub use self::rgb::{RGB, ToRGB, RGBA, ToRGBA}; diff --git a/src/core/core.rs b/src/core/core.rs index b5d8d1e..f98c178 100644 --- a/src/core/core.rs +++ b/src/core/core.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// Core datatypes and conversion traits for 3D mathematics + pub use self::dim::Dimensional; pub use self::mat::{Mat2, ToMat2, Mat3, ToMat3, Mat4, ToMat4}; pub use self::quat::{Quat, ToQuat}; diff --git a/src/world/frustum.rs b/src/geom/frustum.rs similarity index 100% rename from src/world/frustum.rs rename to src/geom/frustum.rs diff --git a/src/geom/geom.rs b/src/geom/geom.rs index 9e32c17..80dc00e 100644 --- a/src/geom/geom.rs +++ b/src/geom/geom.rs @@ -13,6 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//! Types and traits for geometric intersections and transformations + +pub use self::frustum::{Frustum, FrustumPoints}; pub use self::plane::Plane3; pub use self::point::{Point, Point2, Point3}; pub use self::ray::Ray3; @@ -21,5 +24,7 @@ pub mod plane; pub mod point; pub mod ray; +pub mod frustum; + pub mod octree; pub mod quadtree; diff --git a/src/geom/quadtree.rs b/src/geom/quadtree.rs index 31a0028..cc94c55 100644 --- a/src/geom/quadtree.rs +++ b/src/geom/quadtree.rs @@ -16,3 +16,4 @@ // TODO // http://gameprogrammingpatterns.com/spatial-partition.html +// http://github.com/mozilla/servo/blob/master/src/components/main/compositing/quadtree.rs diff --git a/src/lmath.rs b/src/lmath.rs index 8327d7d..ed95591 100644 --- a/src/lmath.rs +++ b/src/lmath.rs @@ -26,6 +26,10 @@ #[path = "core/core.rs"] pub mod core; +#[cfg(color)] +#[path = "color/color.rs"] +pub mod color; + #[cfg(geom)] #[path = "geom/geom.rs"] pub mod geom; @@ -34,10 +38,6 @@ pub mod geom; #[path = "noise/noise.rs"] pub mod noise; -#[cfg(world)] -#[path = "world/world.rs"] -pub mod world; - -#[cfg(color)] -#[path = "color/color.rs"] -pub mod color; +#[cfg(transform)] +#[path = "transform/transform.rs"] +pub mod transform; diff --git a/src/noise/noise.rs b/src/noise/noise.rs index 4defb06..1fb9c35 100644 --- a/src/noise/noise.rs +++ b/src/noise/noise.rs @@ -13,5 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//! Procedural noise generation utility types + pub mod perlin; pub mod simplex; diff --git a/src/world/projection.rs b/src/transform/projection.rs similarity index 99% rename from src/world/projection.rs rename to src/transform/projection.rs index effd90a..fb5b619 100644 --- a/src/world/projection.rs +++ b/src/transform/projection.rs @@ -14,8 +14,7 @@ // limitations under the License. use core::Mat4; -use geom::Plane3; -use world::Frustum; +use geom::{Plane3, Frustum}; #[path = "../num_macros.rs"] mod num_macros; diff --git a/src/world/world.rs b/src/transform/transform.rs similarity index 80% rename from src/world/world.rs rename to src/transform/transform.rs index 590ae68..aa3b2a5 100644 --- a/src/world/world.rs +++ b/src/transform/transform.rs @@ -13,8 +13,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -pub use self::frustum::{Frustum, FrustumPoints}; pub use self::projection::{Projection, Perspective, PerspectiveFOV, Ortho}; -pub mod frustum; +use core::{Vec3, Quat}; + pub mod projection; + +pub trait Transform {} + +pub struct QuatTransform { + scale: T, + translation: Vec3, + rotation: Quat, +} + +impl Transform for QuatTransform {}