diff options
author | maximius <none@none> | 2009-10-17 15:51:44 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-10-17 15:51:44 -0700 |
commit | e585187b248f48b3c6e9247b49fa07c6565d65e5 (patch) | |
tree | 637c5b7ddacf41040bef4ea4f75a97da64c6a9bc /src/shared/vmap/BaseModel.cpp | |
parent | 26b5e033ffde3d161382fc9addbfa99738379641 (diff) |
*Backed out changeset 3be01fb200a5
--HG--
branch : trunk
Diffstat (limited to 'src/shared/vmap/BaseModel.cpp')
-rw-r--r-- | src/shared/vmap/BaseModel.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/shared/vmap/BaseModel.cpp b/src/shared/vmap/BaseModel.cpp index 335a9a128e0..2ffd5672218 100644 --- a/src/shared/vmap/BaseModel.cpp +++ b/src/shared/vmap/BaseModel.cpp @@ -17,12 +17,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "BaseModel.h" #include "VMapTools.h" + using namespace G3D; + namespace VMAP { //========================================================== + void BaseModel::getMember(Array<TriangleBox>& pMembers) { for(unsigned int i=0; i<iNTriangles; i++) @@ -30,12 +34,15 @@ namespace VMAP pMembers.append(iTriangles[i]); } } + //========================================================== BaseModel::BaseModel(unsigned int pNNodes, unsigned int pNTriangles) { init(pNNodes, pNTriangles); }; + //========================================================== + void BaseModel::init(unsigned int pNNodes, unsigned int pNTriangles) { iNNodes = pNNodes; @@ -45,16 +52,21 @@ namespace VMAP if(iNNodes >0) iTreeNodes = new TreeNode[iNNodes]; if(iNTriangles >0) iTriangles = new TriangleBox[iNTriangles]; } + //========================================================== + void BaseModel::free() { if(getTriangles() != 0) delete [] getTriangles(); setNTriangles(0); if(getTreeNodes() != 0) delete [] getTreeNodes(); setNNodes(0); } + //========================================================== + void BaseModel::intersect(const G3D::AABox& pBox, const G3D::Ray& pRay, float& pMaxDist, G3D::Vector3& pOutLocation, G3D::Vector3& /*pOutNormal*/) const { bool isInside = false; + float d = MyCollisionDetection::collisionLocationForMovingPointFixedAABox( pRay.origin, pRay.direction, pBox, @@ -64,7 +76,9 @@ namespace VMAP pMaxDist = d; } } + //========================================================== + bool BaseModel::intersect(const G3D::AABox& pBox, const G3D::Ray& pRay, float& pMaxDist) const { // See if the ray will ever hit this node or its children @@ -73,9 +87,12 @@ namespace VMAP bool rayWillHitBounds = MyCollisionDetection::collisionLocationForMovingPointFixedAABox( pRay.origin, pRay.direction, pBox, location, alreadyInsideBounds); + bool canHitThisNode = (alreadyInsideBounds || (rayWillHitBounds && ((location - pRay.origin).squaredLength() < (pMaxDist * pMaxDist)))); + return canHitThisNode; } + } // VMAP |