winding.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef WINDING_H__
  2. #define WINDING_H__
  3. #if _MSC_VER >= 1000
  4. #pragma once
  5. #endif
  6. #include "basictypes.h"
  7. #include "mathtypes.h"
  8. #include "win32fix.h"
  9. #include "mathlib.h"
  10. #include "bspfile.h"
  11. #include "boundingbox.h"
  12. #define MAX_POINTS_ON_WINDING 128
  13. // TODO: FIX THIS STUPID SHIT (MAX_POINTS_ON_WINDING)
  14. #define BASE_WINDING_DISTANCE 9000
  15. #define SIDE_FRONT 0
  16. #define SIDE_ON 2
  17. #define SIDE_BACK 1
  18. #define SIDE_CROSS -2
  19. class Winding
  20. {
  21. public:
  22. // General Functions
  23. void Print() const;
  24. void getPlane(dplane_t& plane) const;
  25. void getPlane(vec3_t& normal, vec_t& dist) const;
  26. vec_t getArea() const;
  27. void getBounds(BoundingBox& bounds) const;
  28. void getBounds(vec3_t& mins, vec3_t& maxs) const;
  29. void getCenter(vec3_t& center) const;
  30. Winding* Copy() const;
  31. void Check() const; // Developer check for validity
  32. bool Valid() const; // Runtime/user/normal check for validity
  33. void addPoint(const vec3_t newpoint);
  34. void insertPoint(const vec3_t newpoint, const unsigned int offset);
  35. // Specialized Functions
  36. void RemoveColinearPoints();
  37. bool Clip(const dplane_t& split, bool keepon); // For hlbsp
  38. void Clip(const dplane_t& split, Winding** front, Winding** back);
  39. void Clip(const vec3_t normal, const vec_t dist, Winding** front, Winding** back);
  40. bool Chop(const vec3_t normal, const vec_t dist);
  41. void Divide(const dplane_t& split, Winding** front, Winding** back);
  42. int WindingOnPlaneSide(const vec3_t normal, const vec_t dist);
  43. void CopyPoints(vec3_t *points, int &numpoints);
  44. void initFromPoints(vec3_t *points, UINT32 numpoints);
  45. void Reset(void); // Resets the structure
  46. protected:
  47. void resize(UINT32 newsize);
  48. public:
  49. // Construction
  50. Winding(); // Do nothing :)
  51. Winding(vec3_t *points, UINT32 numpoints); // Create from raw points
  52. Winding(const dface_t& face);
  53. Winding(const dplane_t& face);
  54. Winding(const vec3_t normal, const vec_t dist);
  55. Winding(UINT32 points);
  56. Winding(const Winding& other);
  57. virtual ~Winding();
  58. Winding& operator=(const Winding& other);
  59. // Misc
  60. private:
  61. void initFromPlane(const vec3_t normal, const vec_t dist);
  62. public:
  63. // Data
  64. UINT32 m_NumPoints;
  65. vec3_t* m_Points;
  66. protected:
  67. UINT32 m_MaxPoints;
  68. };
  69. #endif