Create transform module, move frustum module, add a little documentation
This commit is contained in:
parent
8ae7f3dbad
commit
f5d96ab398
11 changed files with 35 additions and 12 deletions
2
Makefile
2
Makefile
|
@ -22,7 +22,7 @@ SRC_CRATE = $(TARGET).rs
|
||||||
EXTERN_DIR = $(ROOT_DIR)/extern
|
EXTERN_DIR = $(ROOT_DIR)/extern
|
||||||
BUILD_DIR = $(ROOT_DIR)/lib
|
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 = $(TARGET)
|
||||||
TEST_BUILD_DIR = $(ROOT_DIR)/test
|
TEST_BUILD_DIR = $(ROOT_DIR)/test
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//! Color channel conversions and utility methods
|
||||||
|
|
||||||
pub trait Channel: Primitive + Orderable {
|
pub trait Channel: Primitive + Orderable {
|
||||||
priv fn from<T:Channel>(chan: T) -> Self;
|
priv fn from<T:Channel>(chan: T) -> Self;
|
||||||
pub fn to_channel<T:Channel>(&self) -> T;
|
pub fn to_channel<T:Channel>(&self) -> T;
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//! Color types, functions and conversions
|
||||||
|
|
||||||
pub use self::channel::{Channel, FloatChannel};
|
pub use self::channel::{Channel, FloatChannel};
|
||||||
pub use self::hsv::{HSV, ToHSV, HSVA, ToHSVA};
|
pub use self::hsv::{HSV, ToHSV, HSVA, ToHSVA};
|
||||||
pub use self::rgb::{RGB, ToRGB, RGBA, ToRGBA};
|
pub use self::rgb::{RGB, ToRGB, RGBA, ToRGBA};
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
// Core datatypes and conversion traits for 3D mathematics
|
||||||
|
|
||||||
pub use self::dim::Dimensional;
|
pub use self::dim::Dimensional;
|
||||||
pub use self::mat::{Mat2, ToMat2, Mat3, ToMat3, Mat4, ToMat4};
|
pub use self::mat::{Mat2, ToMat2, Mat3, ToMat3, Mat4, ToMat4};
|
||||||
pub use self::quat::{Quat, ToQuat};
|
pub use self::quat::{Quat, ToQuat};
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// 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::plane::Plane3;
|
||||||
pub use self::point::{Point, Point2, Point3};
|
pub use self::point::{Point, Point2, Point3};
|
||||||
pub use self::ray::Ray3;
|
pub use self::ray::Ray3;
|
||||||
|
@ -21,5 +24,7 @@ pub mod plane;
|
||||||
pub mod point;
|
pub mod point;
|
||||||
pub mod ray;
|
pub mod ray;
|
||||||
|
|
||||||
|
pub mod frustum;
|
||||||
|
|
||||||
pub mod octree;
|
pub mod octree;
|
||||||
pub mod quadtree;
|
pub mod quadtree;
|
||||||
|
|
|
@ -16,3 +16,4 @@
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
// http://gameprogrammingpatterns.com/spatial-partition.html
|
// http://gameprogrammingpatterns.com/spatial-partition.html
|
||||||
|
// http://github.com/mozilla/servo/blob/master/src/components/main/compositing/quadtree.rs
|
||||||
|
|
14
src/lmath.rs
14
src/lmath.rs
|
@ -26,6 +26,10 @@
|
||||||
#[path = "core/core.rs"]
|
#[path = "core/core.rs"]
|
||||||
pub mod core;
|
pub mod core;
|
||||||
|
|
||||||
|
#[cfg(color)]
|
||||||
|
#[path = "color/color.rs"]
|
||||||
|
pub mod color;
|
||||||
|
|
||||||
#[cfg(geom)]
|
#[cfg(geom)]
|
||||||
#[path = "geom/geom.rs"]
|
#[path = "geom/geom.rs"]
|
||||||
pub mod geom;
|
pub mod geom;
|
||||||
|
@ -34,10 +38,6 @@ pub mod geom;
|
||||||
#[path = "noise/noise.rs"]
|
#[path = "noise/noise.rs"]
|
||||||
pub mod noise;
|
pub mod noise;
|
||||||
|
|
||||||
#[cfg(world)]
|
#[cfg(transform)]
|
||||||
#[path = "world/world.rs"]
|
#[path = "transform/transform.rs"]
|
||||||
pub mod world;
|
pub mod transform;
|
||||||
|
|
||||||
#[cfg(color)]
|
|
||||||
#[path = "color/color.rs"]
|
|
||||||
pub mod color;
|
|
||||||
|
|
|
@ -13,5 +13,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//! Procedural noise generation utility types
|
||||||
|
|
||||||
pub mod perlin;
|
pub mod perlin;
|
||||||
pub mod simplex;
|
pub mod simplex;
|
||||||
|
|
|
@ -14,8 +14,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use core::Mat4;
|
use core::Mat4;
|
||||||
use geom::Plane3;
|
use geom::{Plane3, Frustum};
|
||||||
use world::Frustum;
|
|
||||||
|
|
||||||
#[path = "../num_macros.rs"]
|
#[path = "../num_macros.rs"]
|
||||||
mod num_macros;
|
mod num_macros;
|
|
@ -13,8 +13,18 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
pub use self::frustum::{Frustum, FrustumPoints};
|
|
||||||
pub use self::projection::{Projection, Perspective, PerspectiveFOV, Ortho};
|
pub use self::projection::{Projection, Perspective, PerspectiveFOV, Ortho};
|
||||||
|
|
||||||
pub mod frustum;
|
use core::{Vec3, Quat};
|
||||||
|
|
||||||
pub mod projection;
|
pub mod projection;
|
||||||
|
|
||||||
|
pub trait Transform<T> {}
|
||||||
|
|
||||||
|
pub struct QuatTransform<T> {
|
||||||
|
scale: T,
|
||||||
|
translation: Vec3<T>,
|
||||||
|
rotation: Quat<T>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Transform<T> for QuatTransform<T> {}
|
Loading…
Reference in a new issue