2 Copyright (C) 2006, 2008 Sony Computer Entertainment Inc.
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
28 #include "../PlatformDefinitions.h"
33 enum FeatureType { F, E, V };
35 //----------------------------------------------------------------------------
37 //----------------------------------------------------------------------------
38 ///The Box is an internal class used by the boxBoxDistance calculation.
46 inline Box(PE_REF(vmVector3) half_);
47 inline Box(float hx, float hy, float hz);
49 inline void Set(PE_REF(vmVector3) half_);
50 inline void Set(float hx, float hy, float hz);
52 inline vmVector3 GetAABB(const vmMatrix3& rotation) const;
56 Box::Box(PE_REF(vmVector3) half_)
62 Box::Box(float hx, float hy, float hz)
69 Box::Set(PE_REF(vmVector3) half_)
76 Box::Set(float hx, float hy, float hz)
78 mHalf = vmVector3(hx, hy, hz);
83 Box::GetAABB(const vmMatrix3& rotation) const
85 return absPerElem(rotation) * mHalf;
88 //-------------------------------------------------------------------------------------------------
90 //-------------------------------------------------------------------------------------------------
92 ///The BoxPoint class is an internally used class to contain feature information for boxBoxDistance calculation.
96 BoxPoint() : localPoint(0.0f) {}
99 FeatureType featureType;
102 inline void setVertexFeature(int plusX, int plusY, int plusZ);
103 inline void setEdgeFeature(int dim0, int plus0, int dim1, int plus1);
104 inline void setFaceFeature(int dim, int plus);
106 inline void getVertexFeature(int & plusX, int & plusY, int & plusZ) const;
107 inline void getEdgeFeature(int & dim0, int & plus0, int & dim1, int & plus1) const;
108 inline void getFaceFeature(int & dim, int & plus) const;
113 BoxPoint::setVertexFeature(int plusX, int plusY, int plusZ)
116 featureIdx = plusX << 2 | plusY << 1 | plusZ;
121 BoxPoint::setEdgeFeature(int dim0, int plus0, int dim1, int plus1)
126 featureIdx = plus1 << 5 | dim1 << 3 | plus0 << 2 | dim0;
128 featureIdx = plus0 << 5 | dim0 << 3 | plus1 << 2 | dim1;
134 BoxPoint::setFaceFeature(int dim, int plus)
137 featureIdx = plus << 2 | dim;
142 BoxPoint::getVertexFeature(int & plusX, int & plusY, int & plusZ) const
144 plusX = featureIdx >> 2;
145 plusY = featureIdx >> 1 & 1;
146 plusZ = featureIdx & 1;
151 BoxPoint::getEdgeFeature(int & dim0, int & plus0, int & dim1, int & plus1) const
153 plus0 = featureIdx >> 5;
154 dim0 = featureIdx >> 3 & 3;
155 plus1 = featureIdx >> 2 & 1;
156 dim1 = featureIdx & 3;
161 BoxPoint::getFaceFeature(int & dim, int & plus) const
163 plus = featureIdx >> 2;
164 dim = featureIdx & 3;
167 #endif /* __BOX_H__ */