//------------------------------------------------------------------------------
// Lamp : Open source game middleware
// Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//------------------------------------------------------------------------------

/** @file
 * 軸沿いボックス実装
 * @author Junpee
 */

#include "LampBasic.h"
#include "Geometry/Primitive/AxisAlignedBox.h"
#include "Geometry/Distance/AxisAlignedBoxDistance.h"
#include "Geometry/Intersection/AxisAlignedBoxIntersection.h"

namespace Lamp{

//------------------------------------------------------------------------------
// 定数
//------------------------------------------------------------------------------
// ゼロボックス
const AxisAlignedBox AxisAlignedBox::zero(0.f, 0.f, 0.f, 0.f, 0.f, 0.f);

// 単位ボックス
const AxisAlignedBox AxisAlignedBox::unit(
	-0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f);

//------------------------------------------------------------------------------
// 距離
//------------------------------------------------------------------------------
// 点距離の二乗
float AxisAlignedBox::getSquaredDistance(const Vector3& point) const{
	return AxisAlignedBoxDistance::squaredDistance(*this, point);
}
//------------------------------------------------------------------------------
// 軸沿いボックス距離の二乗
float AxisAlignedBox::getSquaredDistance(
	const AxisAlignedBox& axisAlignedBox) const{
	return AxisAlignedBoxDistance::squaredDistance(*this, axisAlignedBox);
}
//------------------------------------------------------------------------------
// カプセル距離の二乗
float AxisAlignedBox::getSquaredDistance(const Capsule& capsule) const{
	return AxisAlignedBoxDistance::squaredDistance(*this, capsule);
}
//------------------------------------------------------------------------------
// コーン距離の二乗
float AxisAlignedBox::getSquaredDistance(const Cone& cone) const{
	return AxisAlignedBoxDistance::squaredDistance(*this, cone);
}
//------------------------------------------------------------------------------
// ライン距離の二乗
float AxisAlignedBox::getSquaredDistance(const Line& line) const{
	return AxisAlignedBoxDistance::squaredDistance(*this, line);
}
//------------------------------------------------------------------------------
// 指向性ボックス距離の二乗
float AxisAlignedBox::getSquaredDistance(const OrientedBox& orientedBox) const{
	return AxisAlignedBoxDistance::squaredDistance(*this, orientedBox);
}
//------------------------------------------------------------------------------
// 平面距離
float AxisAlignedBox::getDistance(const Plane& plane) const{
	return AxisAlignedBoxDistance::distance(*this, plane);
}
//------------------------------------------------------------------------------
// レイ距離の二乗
float AxisAlignedBox::getSquaredDistance(const Ray& ray) const{
	return AxisAlignedBoxDistance::squaredDistance(*this, ray);
}
//------------------------------------------------------------------------------
// セグメント距離の二乗
float AxisAlignedBox::getSquaredDistance(const Segment& segment) const{
	return AxisAlignedBoxDistance::squaredDistance(*this, segment);
}
//------------------------------------------------------------------------------
// 球距離の二乗
float AxisAlignedBox::getSquaredDistance(const Sphere& sphere) const{
	return AxisAlignedBoxDistance::squaredDistance(*this, sphere);
}
//------------------------------------------------------------------------------
// 三角距離の二乗
float AxisAlignedBox::getSquaredDistance(const Triangle& triangle) const{
	return AxisAlignedBoxDistance::squaredDistance(*this, triangle);
}
//------------------------------------------------------------------------------
// 交差
//------------------------------------------------------------------------------
// 点交差
bool AxisAlignedBox::intersect(const Vector3& point) const{
	return AxisAlignedBoxIntersection::intersect(*this, point);
}
//------------------------------------------------------------------------------
// 軸沿いボックス交差
bool AxisAlignedBox::intersect(const AxisAlignedBox& axisAlignedBox) const{
	return AxisAlignedBoxIntersection::intersect(*this, axisAlignedBox);
}
//------------------------------------------------------------------------------
// カプセル交差
bool AxisAlignedBox::intersect(const Capsule& capsule) const{
	return AxisAlignedBoxIntersection::intersect(*this, capsule);
}
//------------------------------------------------------------------------------
// コーン交差
bool AxisAlignedBox::intersect(const Cone& cone) const{
	return AxisAlignedBoxIntersection::intersect(*this, cone);
}
//------------------------------------------------------------------------------
// ライン交差
bool AxisAlignedBox::intersect(const Line& line) const{
	return AxisAlignedBoxIntersection::intersect(*this, line);
}
//------------------------------------------------------------------------------
// 指向性ボックス交差
bool AxisAlignedBox::intersect(const OrientedBox& orientedBox) const{
	return AxisAlignedBoxIntersection::intersect(*this, orientedBox);
}
//------------------------------------------------------------------------------
// 平面交差
bool AxisAlignedBox::intersect(const Plane& plane) const{
	return AxisAlignedBoxIntersection::intersect(*this, plane);
}
//------------------------------------------------------------------------------
// レイ交差
bool AxisAlignedBox::intersect(const Ray& ray) const{
	return AxisAlignedBoxIntersection::intersect(*this, ray);
}
//------------------------------------------------------------------------------
// セグメント交差
bool AxisAlignedBox::intersect(const Segment& segment) const{
	return AxisAlignedBoxIntersection::intersect(*this, segment);
}
//------------------------------------------------------------------------------
// 球交差
bool AxisAlignedBox::intersect(const Sphere& sphere) const{
	return AxisAlignedBoxIntersection::intersect(*this, sphere);
}
//------------------------------------------------------------------------------
// 三角交差
bool AxisAlignedBox::intersect(const Triangle& triangle) const{
	return AxisAlignedBoxIntersection::intersect(*this, triangle);
}
//------------------------------------------------------------------------------
} // End of namespace Lamp
//------------------------------------------------------------------------------
