Counter Strike : Global Offensive Source Code
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.

99 lines
4.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef COORDSIZE_H
  9. #define COORDSIZE_H
  10. #pragma once
  11. #include "worldsize.h"
  12. // OVERALL Coordinate Size Limits used in COMMON.C MSG_*BitCoord() Routines (and someday the HUD)
  13. #define COORD_INTEGER_BITS 14
  14. #define COORD_FRACTIONAL_BITS 5
  15. #define COORD_DENOMINATOR (1<<(COORD_FRACTIONAL_BITS))
  16. #define COORD_RESOLUTION (1.0/(COORD_DENOMINATOR))
  17. // Special threshold for networking multiplayer origins
  18. #define COORD_INTEGER_BITS_MP 11
  19. #define COORD_FRACTIONAL_BITS_MP_LOWPRECISION 3
  20. #define COORD_DENOMINATOR_LOWPRECISION (1<<(COORD_FRACTIONAL_BITS_MP_LOWPRECISION))
  21. #define COORD_RESOLUTION_LOWPRECISION (1.0/(COORD_DENOMINATOR_LOWPRECISION))
  22. #define NORMAL_FRACTIONAL_BITS 11
  23. #define NORMAL_DENOMINATOR ( (1<<(NORMAL_FRACTIONAL_BITS)) - 1 )
  24. #define NORMAL_RESOLUTION (1.0/(NORMAL_DENOMINATOR))
  25. // this is limited by the network fractional bits used for coords
  26. // because net coords will be only be accurate to 5 bits fractional
  27. // Standard collision test epsilon
  28. // 1/32nd inch collision epsilon
  29. #define DIST_EPSILON (0.03125)
  30. // Verify that coordsize.h and worldsize.h are consistently defined
  31. #if (MAX_COORD_INTEGER != (1<<COORD_INTEGER_BITS) )
  32. #error MAX_COORD_INTEGER does not match COORD_INTEGER_BITS
  33. #endif
  34. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  35. // The following are Bit Packing Diagrams for client/server Coordinate BitField Messages
  36. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  37. //
  38. // "Coordinates" = +/-16384.9375 (21 Bits Max)
  39. //
  40. // | IntegerFlagBit:1 | FractionFlagBit:1 | SignBit:1 | IntegerField:14 | FractionPart:4 | Total
  41. // --------------------------------------------------------------------------------------------------
  42. // 0 0 - - - 2
  43. // 0 1 x - xxxx 7
  44. // 1 0 x xxxxxxxxxxxxx - 17
  45. // 1 1 x xxxxxxxxxxxxx xxxx 21
  46. //
  47. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  48. //
  49. // "Vec3Coordinate" = Up to 3 Coordinates (66 Bits Max)
  50. //
  51. // | NonZeroX:1 | NonZeroY:1 | NonZeroZ:1 | 0..3 "Coordinates" | BitField Total
  52. // -------------------------------------------------------------------------------
  53. // 0 0 0 - 3
  54. // 0 0 1 7..21 Bits 10..24
  55. // 0 1 0 7..21 Bits 10..24
  56. // 1 0 0 7..21 Bits 10..24
  57. // 0 1 1 14..42 Bits 17..45
  58. // 1 1 0 14..42 Bits 17..45
  59. // 1 0 1 14..42 Bits 17..45
  60. // 1 1 1 21..63 Bits 24..66
  61. //
  62. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  63. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  64. // The following are Bit Packing Diagrams for client/server Normal BitField Messages
  65. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  66. //
  67. // "Normals" = +/-1.0 (12 Bits Total)
  68. //
  69. // The only gotcha here is that normalization occurs so that
  70. // 011111111111 = +1.0 and 1111111111111 = -1.0
  71. //
  72. // | SignBit:1 | FractionPart:11 | Total
  73. // --------------------------------------------------------------------------------------------------
  74. // 1 xxxxxxxxxxx 12
  75. //
  76. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  77. //
  78. // "Vec3Normal" = Up to 3 Coordinates (27 Bits Max)
  79. //
  80. // | NonZeroX:1 | NonZeroY:1 | 0..2 "Coordinates" | Z Sign Bit | BitField Total
  81. // -------------------------------------------------------------------------------
  82. // 0 0 - x 3
  83. // 0 1 12 Bits x 14
  84. // 1 0 12 Bits x 14
  85. // 1 1 24 Bits x 27
  86. //
  87. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  88. #endif // COORDSIZE_H