Torque3D Documentation / _generateds / extrudedPolyList.h

extrudedPolyList.h

Engine/source/collision/extrudedPolyList.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _EXTRUDEDPOLYLIST_H_
 25#define _EXTRUDEDPOLYLIST_H_
 26
 27#ifndef _MMATH_H_
 28#include "math/mMath.h"
 29#endif
 30
 31#ifndef _MPOLYHEDRON_H_
 32#include "math/mPolyhedron.h"
 33#endif
 34
 35#ifndef _TVECTOR_H_
 36#include "core/util/tVector.h"
 37#endif
 38
 39#ifndef _ABSTRACTPOLYLIST_H_
 40#include "collision/abstractPolyList.h"
 41#endif
 42
 43
 44class CollisionList;
 45
 46
 47//----------------------------------------------------------------------------
 48/// Extruded Polytope PolyList
 49///
 50/// This class is used primarily for collision detection, by objects which need
 51/// to check for obstructions along their path. You feed it a polytope to
 52/// extrude along the direction of movement, and it gives you a list of collisions.
 53/// 
 54/// @see AbstractPolyList
 55class ExtrudedPolyList: public AbstractPolyList
 56{
 57public:
 58   struct Vertex {
 59      Point3F point;
 60      U32 mask;
 61   };
 62
 63   struct Poly {
 64      PlaneF plane;
 65      SceneObject* object;
 66      BaseMatInstance* material;
 67   };
 68
 69   struct ExtrudedFace {
 70      bool active;
 71      PlaneF plane;
 72      F32 maxDistance;
 73      U32 planeMask;
 74      F32 faceDot;
 75      F32 faceShift;
 76      F32 time;
 77      Point3F point;
 78      F32 height;
 79   };
 80
 81   typedef Vector<ExtrudedFace> ExtrudedList;
 82   typedef Vector<PlaneF> PlaneList;
 83   typedef Vector<Vertex> VertexList;
 84   typedef Vector<U32> IndexList;
 85
 86   static F32 EqualEpsilon;
 87   static F32 FaceEpsilon;
 88
 89   // Internal data
 90   VertexList   mVertexList;
 91   IndexList    mIndexList;
 92   ExtrudedList mExtrudedList;
 93   PlaneList    mPlaneList;
 94   VectorF      mVelocity;
 95   VectorF      mNormalVelocity;
 96   F32          mFaceShift;
 97   Poly         mPoly;
 98
 99   // Returned info
100   CollisionList* mCollisionList;
101
102   PlaneList mPolyPlaneList;
103   
104   //
105private:
106   bool testPoly(ExtrudedFace&);
107
108public:
109   ExtrudedPolyList();
110   ~ExtrudedPolyList();
111   void extrude(const Polyhedron&, const VectorF& vec);
112   void setVelocity(const VectorF& velocity);
113   void setCollisionList(CollisionList*);
114   void adjustCollisionTime();
115
116   // Virtual methods
117   bool isEmpty() const;
118   U32  addPoint(const Point3F& p);
119   U32  addPlane(const PlaneF& plane);
120   void begin(BaseMatInstance* material, U32 surfaceKey);
121   void plane(U32 v1,U32 v2,U32 v3);
122   void plane(const PlaneF& p);
123   void plane(const U32 index);
124   void vertex(U32 vi);
125   void end();
126
127  protected:
128   const PlaneF& getIndexedPlane(const U32 index);
129};
130
131#endif
132