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.

191 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef CL_DEMOSMOOTHING_H
  8. #define CL_DEMOSMOOTHING_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "mathlib/vector.h"
  13. #include "quakedef.h"
  14. #include "tier0/platform.h"
  15. #define FDEMO_NORMAL 0
  16. #define FDEMO_USE_ORIGIN2 (1<<0)
  17. #define FDEMO_USE_ANGLES2 (1<<1)
  18. #define FDEMO_NOINTERP (1<<2) // don't interpolate between this an last view
  19. struct democmdinfo_t
  20. {
  21. // Default constructor
  22. democmdinfo_t()
  23. {
  24. flags = FDEMO_NORMAL;
  25. viewOrigin.Init();
  26. viewAngles.Init();
  27. localViewAngles.Init();
  28. // Resampled origin/angles
  29. viewOrigin2.Init();
  30. viewAngles2.Init();
  31. localViewAngles2.Init();
  32. }
  33. // Copy constructor
  34. // Assignment
  35. democmdinfo_t& operator=(const democmdinfo_t& src )
  36. {
  37. if ( this == &src )
  38. return *this;
  39. flags = src.flags;
  40. viewOrigin = src.viewOrigin;
  41. viewAngles = src.viewAngles;
  42. localViewAngles = src.localViewAngles;
  43. viewOrigin2 = src.viewOrigin2;
  44. viewAngles2 = src.viewAngles2;
  45. localViewAngles2 = src.localViewAngles2;
  46. return *this;
  47. }
  48. const Vector& GetViewOrigin()
  49. {
  50. if ( flags & FDEMO_USE_ORIGIN2 )
  51. {
  52. return viewOrigin2;
  53. }
  54. return viewOrigin;
  55. }
  56. const QAngle& GetViewAngles()
  57. {
  58. if ( flags & FDEMO_USE_ANGLES2 )
  59. {
  60. return viewAngles2;
  61. }
  62. return viewAngles;
  63. }
  64. const QAngle& GetLocalViewAngles()
  65. {
  66. if ( flags & FDEMO_USE_ANGLES2 )
  67. {
  68. return localViewAngles2;
  69. }
  70. return localViewAngles;
  71. }
  72. void Reset( void )
  73. {
  74. flags = 0;
  75. viewOrigin2 = viewOrigin;
  76. viewAngles2 = viewAngles;
  77. localViewAngles2 = localViewAngles;
  78. }
  79. int flags;
  80. // original origin/viewangles
  81. Vector viewOrigin;
  82. QAngle viewAngles;
  83. QAngle localViewAngles;
  84. // Resampled origin/viewangles
  85. Vector viewOrigin2;
  86. QAngle viewAngles2;
  87. QAngle localViewAngles2;
  88. };
  89. struct demosmoothing_t
  90. {
  91. demosmoothing_t()
  92. {
  93. file_offset = 0;
  94. frametick = 0;
  95. selected = false;
  96. samplepoint = false;
  97. vecmoved.Init();
  98. angmoved.Init();
  99. targetpoint = false;
  100. vectarget.Init();
  101. }
  102. demosmoothing_t& operator=(const demosmoothing_t& src )
  103. {
  104. if ( this == &src )
  105. return *this;
  106. file_offset = src.file_offset;
  107. frametick = src.frametick;
  108. selected = src.selected;
  109. samplepoint = src.samplepoint;
  110. vecmoved = src.vecmoved;
  111. angmoved = src.angmoved;
  112. targetpoint = src.targetpoint;
  113. vectarget = src.vectarget;
  114. info = src.info;
  115. return *this;
  116. }
  117. int file_offset;
  118. int frametick;
  119. bool selected;
  120. // For moved sample points
  121. bool samplepoint;
  122. Vector vecmoved;
  123. QAngle angmoved;
  124. bool targetpoint;
  125. Vector vectarget;
  126. democmdinfo_t info;
  127. };
  128. struct CSmoothingContext
  129. {
  130. CSmoothingContext()
  131. {
  132. active = false;
  133. filename[ 0 ] = 0;
  134. }
  135. CSmoothingContext& operator=(const CSmoothingContext& src )
  136. {
  137. if ( this == &src )
  138. return *this;
  139. active = src.active;
  140. Q_strncpy( filename, src.filename, sizeof( filename ) );
  141. smooth.RemoveAll();
  142. int c = src.smooth.Count();
  143. int i;
  144. for ( i = 0; i < c; i++ )
  145. {
  146. demosmoothing_t newitem;
  147. newitem = src.smooth[ i ];
  148. smooth.AddToTail( newitem );
  149. }
  150. return *this;
  151. }
  152. bool active;
  153. char filename[ MAX_OSPATH ];
  154. CUtlVector< demosmoothing_t > smooth;
  155. };
  156. #endif // CL_DEMOSMOOTHING_H