earlyOutPolyList.h
Engine/source/collision/earlyOutPolyList.h
Classes:
class
Early out check PolyList.
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 _EARLYOUTPOLYLIST_H_ 25#define _EARLYOUTPOLYLIST_H_ 26 27#ifndef _ABSTRACTPOLYLIST_H_ 28#include "collision/abstractPolyList.h" 29#endif 30 31 32/// Early out check PolyList 33/// 34/// This class is used primarily for triggers and similar checks. It checks to see 35/// if any of the geometry you feed it is inside its area, and if it is, it stops 36/// checking for any more data and returns a true value. This is good if you want 37/// to know if anything is in your "trigger" area, for instance. 38/// 39/// @see AbstractPolyList 40class EarlyOutPolyList : public AbstractPolyList 41{ 42 void memcpy(U32* d, U32* s,U32 size); 43 44 // Internal data 45 struct Vertex { 46 Point3F point; 47 U32 mask; 48 }; 49 50 struct Poly { 51 PlaneF plane; 52 SceneObject* object; 53 BaseMatInstance* material; 54 U32 vertexStart; 55 U32 vertexCount; 56 U32 surfaceKey; 57 }; 58 59 public: 60 typedef Vector<PlaneF> PlaneList; 61 private: 62 typedef Vector<Vertex> VertexList; 63 typedef Vector<Poly> PolyList; 64 typedef Vector<U32> IndexList; 65 66 PolyList mPolyList; 67 VertexList mVertexList; 68 IndexList mIndexList; 69 bool mEarlyOut; 70 71 PlaneList mPolyPlaneList; 72 73 public: 74 // Data set by caller 75 PlaneList mPlaneList; 76 VectorF mNormal; 77 78 public: 79 EarlyOutPolyList(); 80 ~EarlyOutPolyList(); 81 void clear(); 82 83 // Virtual methods 84 bool isEmpty() const; 85 U32 addPoint(const Point3F& p); 86 U32 addPlane(const PlaneF& plane); 87 void begin(BaseMatInstance* material,U32 surfaceKey); 88 void plane(U32 v1,U32 v2,U32 v3); 89 void plane(const PlaneF& p); 90 void plane(const U32 index); 91 void vertex(U32 vi); 92 void end(); 93 94 protected: 95 const PlaneF& getIndexedPlane(const U32 index); 96}; 97 98#endif // _H_EARLYOUTPOLYLIST_ 99