Move types related to bounding volumes to bounds module
This commit is contained in:
parent
8973179b0d
commit
e1e6b90c1b
10 changed files with 40 additions and 14 deletions
2
Makefile
2
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=transform --cfg=space
|
||||
CFG = --cfg=bounds --cfg=color --cfg=geom --cfg=noise --cfg=transform --cfg=space
|
||||
|
||||
TEST = $(TARGET)
|
||||
TEST_BUILD_DIR = $(ROOT_DIR)/test
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
use core::{Vec2, AsVec2, Vec3, AsVec3};
|
||||
use geom::{Point2, Point3};
|
||||
|
||||
#[deriving(Clone, Eq)]
|
||||
pub struct AABB2<T> {
|
||||
center: Point2<T>,
|
||||
size: Vec2<T>,
|
||||
|
@ -33,15 +34,17 @@ impl<T> AABB2<T> {
|
|||
}
|
||||
|
||||
impl<T:Clone + Float> AABB2<T> {
|
||||
#[inline]
|
||||
pub fn from_bounds(mn: Point2<T>, mx: Point2<T>) -> AABB2<T> {
|
||||
AABB2 {
|
||||
center: Point2::from_vec2(mn.as_vec2().add_v(mx.as_vec2()).div_t(two!(T))),
|
||||
center: Point2::from_vec2(
|
||||
mn.as_vec2().add_v(mx.as_vec2()).div_t(two!(T))
|
||||
),
|
||||
size: mx - mn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[deriving(Clone, Eq)]
|
||||
pub struct AABB3<T> {
|
||||
center: Point3<T>,
|
||||
size: Vec3<T>,
|
||||
|
@ -57,10 +60,11 @@ impl<T> AABB3<T> {
|
|||
}
|
||||
|
||||
impl<T:Clone + Float> AABB3<T> {
|
||||
#[inline]
|
||||
pub fn from_bounds(mn: Point3<T>, mx: Point3<T>) -> AABB3<T> {
|
||||
AABB3 {
|
||||
center: Point3::from_vec3(mn.as_vec3().add_v(mx.as_vec3()).div_t(two!(T))),
|
||||
center: Point3::from_vec3(
|
||||
mn.as_vec3().add_v(mx.as_vec3()).div_t(two!(T))
|
||||
),
|
||||
size: mx - mn,
|
||||
}
|
||||
}
|
24
src/bounds/bounds.rs
Normal file
24
src/bounds/bounds.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2013 The Lmath Developers. For a full listing of the authors,
|
||||
// refer to the AUTHORS file at the top-level directory of this distribution.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub use self::aabb::{AABB2, AABB3};
|
||||
pub use self::frustum::{Frustum, FrustumPoints};
|
||||
pub use self::sphere::Sphere;
|
||||
|
||||
pub mod aabb;
|
||||
pub mod box;
|
||||
pub mod cylinder;
|
||||
pub mod frustum;
|
||||
pub mod sphere;
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
use geom::Point3;
|
||||
|
||||
#[deriving(Clone, Eq)]
|
||||
pub struct Sphere<T> {
|
||||
center: Point3<T>,
|
||||
radius: T,
|
|
@ -13,20 +13,12 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
pub use self::aabb::{AABB2, AABB3};
|
||||
pub use self::frustum::{Frustum, FrustumPoints};
|
||||
pub use self::plane::Plane3;
|
||||
pub use self::point::Point;
|
||||
pub use self::point::{Point2, AsPoint2};
|
||||
pub use self::point::{Point3, AsPoint3};
|
||||
pub use self::ray::{Ray2, Ray3};
|
||||
pub use self::sphere::Sphere;
|
||||
|
||||
pub mod aabb;
|
||||
pub mod box;
|
||||
pub mod cylinder;
|
||||
pub mod frustum;
|
||||
pub mod plane;
|
||||
pub mod point;
|
||||
pub mod ray;
|
||||
pub mod sphere;
|
||||
|
|
|
@ -32,6 +32,10 @@ mod core_macros;
|
|||
#[path = "core/core.rs"]
|
||||
pub mod core;
|
||||
|
||||
#[cfg(bounds)]
|
||||
#[path = "bounds/bounds.rs"]
|
||||
pub mod bounds;
|
||||
|
||||
#[cfg(color)]
|
||||
#[path = "color/color.rs"]
|
||||
pub mod color;
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use bounds::Frustum;
|
||||
use core::Mat4;
|
||||
use geom::{Plane3, Frustum};
|
||||
use geom::Plane3;
|
||||
|
||||
///
|
||||
/// Create a perspective projection matrix
|
||||
|
|
Loading…
Reference in a new issue