Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #ifndef POLYLIB_H
  14. #define POLYLIB_H
  15. #pragma once
  16. #ifndef MATHLIB_H
  17. #include "mathlib/mathlib.h"
  18. #endif
  19. struct winding_t
  20. {
  21. int numpoints;
  22. Vector *p; // variable sized
  23. int maxpoints;
  24. winding_t *next;
  25. };
  26. #define MAX_POINTS_ON_WINDING 64
  27. // you can define on_epsilon in the makefile as tighter
  28. // point on plane side epsilon
  29. // todo: need a world-space epsilon, a lightmap-space epsilon, and a texture space epsilon
  30. // or at least convert from a world-space epsilon to lightmap and texture space epsilons
  31. #ifndef ON_EPSILON
  32. #define ON_EPSILON 0.1
  33. #endif
  34. winding_t *AllocWinding (int points);
  35. vec_t WindingArea (winding_t *w);
  36. void WindingCenter (winding_t *w, Vector &center);
  37. vec_t WindingAreaAndBalancePoint( winding_t *w, Vector &center );
  38. void ClipWindingEpsilon (winding_t *in, const Vector &normal, vec_t dist,
  39. vec_t epsilon, winding_t **front, winding_t **back);
  40. // translates everything by offset, then does the clip, then translates back (to keep precision)
  41. void ClipWindingEpsilon_Offset( winding_t *in, const Vector &normal, vec_t dist, vec_t epsilon, winding_t **front, winding_t **back, const Vector &offset );
  42. void ClassifyWindingEpsilon( winding_t *in, const Vector &normal, vec_t dist,
  43. vec_t epsilon, winding_t **front, winding_t **back, winding_t **on);
  44. void ClassifyWindingEpsilon_Offset( winding_t *in, const Vector &normal, vec_t dist,
  45. vec_t epsilon, winding_t **front, winding_t **back, winding_t **on, const Vector &offset);
  46. winding_t *ChopWinding (winding_t *in, const Vector &normal, vec_t dist);
  47. winding_t *CopyWinding (winding_t *w);
  48. winding_t *ReverseWinding (winding_t *w);
  49. winding_t *BaseWindingForPlane (const Vector &normal, vec_t dist);
  50. void CheckWinding (winding_t *w);
  51. void WindingPlane (winding_t *w, Vector &normal, vec_t *dist);
  52. void RemoveColinearPoints (winding_t *w);
  53. int WindingOnPlaneSide (winding_t *w, const Vector &normal, vec_t dist);
  54. void FreeWinding (winding_t *w);
  55. void WindingBounds (winding_t *w, Vector &mins, Vector &maxs);
  56. void ChopWindingInPlace (winding_t **w, const Vector &normal, vec_t dist, vec_t epsilon);
  57. // frees the original if clipped
  58. bool PointInWinding( Vector const &pt, winding_t *pWinding );
  59. // translates a winding by offset
  60. void TranslateWinding( winding_t *pWinding, const Vector &offset );
  61. void pw(winding_t *w);
  62. #endif // POLYLIB_H