00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "LampBasic.h"
00026 #include "Geometry/System/Intersection.h"
00027 #include "Geometry/Primitive/Triangle.h"
00028 #include "Geometry/Distance/AxisAlignedBoxDistance.h"
00029 #include "Geometry/Distance/CapsuleDistance.h"
00030 #include "Geometry/Distance/ConeDistance.h"
00031 #include "Geometry/Distance/LineDistance.h"
00032 #include "Geometry/Distance/OrientedBoxDistance.h"
00033 #include "Geometry/Distance/PlaneDistance.h"
00034 #include "Geometry/Distance/RayDistance.h"
00035 #include "Geometry/Distance/SegmentDistance.h"
00036 #include "Geometry/Distance/SphereDistance.h"
00037 #include "Geometry/Distance/TriangleDistance.h"
00038 #include "Geometry/Intersection/AxisAlignedBoxIntersection.h"
00039 #include "Geometry/Intersection/CapsuleIntersection.h"
00040 #include "Geometry/Intersection/ConeIntersection.h"
00041 #include "Geometry/Intersection/LineIntersection.h"
00042 #include "Geometry/Intersection/OrientedBoxIntersection.h"
00043 #include "Geometry/Intersection/PlaneIntersection.h"
00044 #include "Geometry/Intersection/RayIntersection.h"
00045 #include "Geometry/Intersection/SegmentIntersection.h"
00046 #include "Geometry/Intersection/SphereIntersection.h"
00047 #include "Geometry/Intersection/TriangleIntersection.h"
00048
00049 namespace Lamp{
00050
00051
00052
00053
00054
00055 const Triangle Triangle::zero(Vector3::zero, Vector3::zero, Vector3::zero);
00056
00057
00058
00059
00060
00061 float Triangle::getSquaredDistance(const Vector3& point) const{
00062 return TriangleDistance::squaredDistance(*this, point);
00063 }
00064
00065
00066 float Triangle::getSquaredDistance(const AxisAlignedBox& axisAlignedBox) const{
00067 return AxisAlignedBoxDistance::squaredDistance(axisAlignedBox, *this);
00068 }
00069
00070
00071 float Triangle::getSquaredDistance(const Capsule& capsule) const{
00072 return CapsuleDistance::squaredDistance(capsule, *this);
00073 }
00074
00075
00076 float Triangle::getSquaredDistance(const Cone& cone) const{
00077 return ConeDistance::squaredDistance(cone, *this);
00078 }
00079
00080
00081 float Triangle::getSquaredDistance(const Line& line) const{
00082 return LineDistance::squaredDistance(line, *this);
00083 }
00084
00085
00086 float Triangle::getSquaredDistance(const OrientedBox& orientedBox) const{
00087 return OrientedBoxDistance::squaredDistance(orientedBox, *this);
00088 }
00089
00090
00091 float Triangle::getDistance(const Plane& plane) const{
00092 return PlaneDistance::distance(plane, *this);
00093 }
00094
00095
00096 float Triangle::getSquaredDistance(const Ray& ray) const{
00097 return RayDistance::squaredDistance(ray, *this);
00098 }
00099
00100
00101 float Triangle::getSquaredDistance(const Segment& segment) const{
00102 return SegmentDistance::squaredDistance(segment, *this);
00103 }
00104
00105
00106 float Triangle::getSquaredDistance(const Sphere& sphere) const{
00107 return SphereDistance::squaredDistance(sphere, *this);
00108 }
00109
00110
00111 float Triangle::getSquaredDistance(const Triangle& triangle) const{
00112 return TriangleDistance::squaredDistance(*this, triangle);
00113 }
00114
00115
00116
00117
00118 bool Triangle::intersect(const Vector3& point, float range) const{
00119 return TriangleIntersection::intersect(*this, point, range);
00120 }
00121
00122
00123 bool Triangle::intersect(const AxisAlignedBox& axisAlignedBox) const{
00124 return AxisAlignedBoxIntersection::intersect(axisAlignedBox, *this);
00125 }
00126
00127
00128 bool Triangle::intersect(const Cone& cone) const{
00129 return ConeIntersection::intersect(cone, *this);
00130 }
00131
00132
00133 bool Triangle::intersect(const Capsule& capsule) const{
00134 return CapsuleIntersection::intersect(capsule, *this);
00135 }
00136
00137
00138 bool Triangle::intersect(const Line& line) const{
00139 return LineIntersection::intersect(line, *this);
00140 }
00141
00142
00143 bool Triangle::intersect(const OrientedBox& orientedBox) const{
00144 return OrientedBoxIntersection::intersect(orientedBox, *this);
00145 }
00146
00147
00148 bool Triangle::intersect(const Plane& plane) const{
00149 return PlaneIntersection::intersect(plane, *this);
00150 }
00151
00152
00153 bool Triangle::intersect(const Ray& ray) const{
00154 return RayIntersection::intersect(ray, *this);
00155 }
00156
00157
00158 bool Triangle::intersect(const Segment& segment) const{
00159 return SegmentIntersection::intersect(segment, *this);
00160 }
00161
00162
00163 bool Triangle::intersect(const Sphere& sphere) const{
00164 return SphereIntersection::intersect(sphere, *this);
00165 }
00166
00167
00168 bool Triangle::intersect(Intersection* intersection, const Sphere& sphere) const{
00169 bool result = SphereIntersection::intersect(intersection, sphere, *this);
00170 if(result){ intersection->reverse(); }
00171 return result;
00172 }
00173
00174
00175 bool Triangle::intersect(const Triangle& triangle) const{
00176 return TriangleIntersection::intersect(*this, triangle);
00177 }
00178
00179 }
00180