earlyOutPolyList.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _EARLYOUTPOLYLIST_H_
  23. #define _EARLYOUTPOLYLIST_H_
  24. #ifndef _ABSTRACTPOLYLIST_H_
  25. #include "collision/abstractPolyList.h"
  26. #endif
  27. /// Early out check PolyList
  28. ///
  29. /// This class is used primarily for triggers and similar checks. It checks to see
  30. /// if any of the geometry you feed it is inside its area, and if it is, it stops
  31. /// checking for any more data and returns a true value. This is good if you want
  32. /// to know if anything is in your "trigger" area, for instance.
  33. ///
  34. /// @see AbstractPolyList
  35. class EarlyOutPolyList : public AbstractPolyList
  36. {
  37. void memcpy(U32* d, U32* s,U32 size);
  38. // Internal data
  39. struct Vertex {
  40. Point3F point;
  41. U32 mask;
  42. };
  43. struct Poly {
  44. PlaneF plane;
  45. SceneObject* object;
  46. BaseMatInstance* material;
  47. U32 vertexStart;
  48. U32 vertexCount;
  49. U32 surfaceKey;
  50. };
  51. public:
  52. typedef Vector<PlaneF> PlaneList;
  53. private:
  54. typedef Vector<Vertex> VertexList;
  55. typedef Vector<Poly> PolyList;
  56. typedef Vector<U32> IndexList;
  57. PolyList mPolyList;
  58. VertexList mVertexList;
  59. IndexList mIndexList;
  60. bool mEarlyOut;
  61. PlaneList mPolyPlaneList;
  62. public:
  63. // Data set by caller
  64. PlaneList mPlaneList;
  65. VectorF mNormal;
  66. public:
  67. EarlyOutPolyList();
  68. ~EarlyOutPolyList();
  69. void clear();
  70. // Virtual methods
  71. bool isEmpty() const;
  72. U32 addPoint(const Point3F& p);
  73. U32 addPlane(const PlaneF& plane);
  74. void begin(BaseMatInstance* material,U32 surfaceKey);
  75. void plane(U32 v1,U32 v2,U32 v3);
  76. void plane(const PlaneF& p);
  77. void plane(const U32 index);
  78. void vertex(U32 vi);
  79. void end();
  80. protected:
  81. const PlaneF& getIndexedPlane(const U32 index);
  82. };
  83. #endif // _H_EARLYOUTPOLYLIST_