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.

484 lines
24 KiB

  1. //====== Copyright � 1996-2009, Valve Corporation, All rights reserved. =======
  2. //
  3. // Declaration of CDmeGraphEditorState, a data model element which stores
  4. // the active state data for the graph editor.
  5. //
  6. //=============================================================================
  7. #ifndef DMEGRAPHEDITORCURVE_H
  8. #define DMEGRAPHEDITORCURVE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "movieobjects/dmechannel.h"
  13. #include "datamodel/dmelement.h"
  14. #include "checksum_crc.h"
  15. enum SelectionMode_t
  16. {
  17. SELECT_SET,
  18. SELECT_ADD,
  19. SELECT_REMOVE,
  20. SELECT_TOGGLE,
  21. };
  22. enum AddKeyMode_t
  23. {
  24. ADD_KEYS_AUTO,
  25. ADD_KEYS_INTERPOLATE,
  26. ADD_KEYS_STEPPED,
  27. };
  28. enum TangentOperation_t
  29. {
  30. TANGENTS_FLAT, // Tangents are modified so the value of the end points are equal to the key value
  31. TANGENTS_LINEAR, // Tangents are modified so the endpoints are on the line between the key values
  32. TANGENTS_SPLINE, // Tangents are modified so the that they are parallel to the line from the proceeding key to the next key
  33. TANGENTS_UNIFIED, // Tangents are modified so both sides of the tangent lie on the same line
  34. TANGENTS_ISOMETRIC, // Tangents are modified so both sides of the tangent are of equal length
  35. TANGENTS_STEP, // Set the key to step mode, out tangent is ignored and all values between the key and the next key are equal to the key value
  36. TANGENTS_WEIGHTED, // Set the key to perform tangent calculations using the time of of the tangents
  37. TANGENTS_UNWEIGHTED, // Set the key to perform tangent calculations such that the delta time of the tangents is ignored ( always 1/3 time to next key ).
  38. };
  39. enum KeyTangentMode_t
  40. {
  41. TANGENT_MODE_DEFAULT,
  42. TANGENT_MODE_LINEAR,
  43. TANGENT_MODE_SPLINE,
  44. TANGENT_MODE_STEPPED
  45. };
  46. class CDmeGraphEditorCurve;
  47. //-----------------------------------------------------------------------------
  48. // The CDmeCurveKey class represents a single key on a curve an hold
  49. // information about the position of the key and its tangents. The tangent
  50. // values are stored as delta so they do not have to be updated when the value
  51. // of the key changes.
  52. //-----------------------------------------------------------------------------
  53. class CDmeCurveKey : public CDmElement
  54. {
  55. DEFINE_ELEMENT( CDmeCurveKey, CDmElement );
  56. enum KeyDirtyFlags_t
  57. {
  58. KEY_CLEAN = 0,
  59. KEY_IN_DIRTY = 1,
  60. KEY_OUT_DIRTY = 2
  61. };
  62. static const int UNWEIGHTED_DISPLAY_LENGTH = 60;
  63. public:
  64. // Initialize the key with the specified time and value
  65. void Initialize( DmeTime_t time, float flValue, int nComponent );
  66. // Get a pointer to the curve to which the key belongs
  67. CDmeGraphEditorCurve *GetCurve() const;
  68. // Return the sort value for the two keys based on their times
  69. static int SortFunc( CDmeCurveKey * const *pKeyA, CDmeCurveKey * const *pKeyB );
  70. // Clear the selection state of the key and its tangents
  71. void ClearSelection();
  72. // Set the key tangents to be flat
  73. void SetTangentsFlat( const CDmeCurveKey *pPrevKey, const CDmeCurveKey *pNextKey, bool bSetIn, bool bSetOut );
  74. // Set the key tangents to be linear
  75. void SetTangentsLinear( const CDmeCurveKey *pPrevKey, const CDmeCurveKey *pNextKey, bool bSetIn, bool bSetOut );
  76. // Set the key tangents using a spline method
  77. void SetTangentsSpline( const CDmeCurveKey *pPrevKey, const CDmeCurveKey *pNextKey, bool bSetIn, bool bSetOut );
  78. // Make both of the tangents of the key lie one the same line
  79. void SetTangentsUnified( float flUnitsPerSecond, bool bSetIn, bool bSetOut );
  80. // Make both of the tangents of the key be the same length
  81. void SetTangentsIsometric( float flUnitsPerSecond, bool bSetIn, bool bSetOut );
  82. // Set the key tangents as being broken (not unified)
  83. void SetTangentsBroken();
  84. // Set the key as being in stepped mode
  85. void SetStepped( bool bStepped );
  86. // Enable or disable weighted tangents
  87. void SetWeighted( bool bWeighted, const CDmeCurveKey *pPrevKey, const CDmeCurveKey *pNextKey );
  88. // Make the specified key match the unweighted form
  89. void ConformUnweighted( const CDmeCurveKey *pPrevKey, const CDmeCurveKey *pNextKey );
  90. void SetSelected( bool bSelect ) { m_Selected = bSelect; }
  91. void SetInSelected( bool bSelect ) { m_InSelected = bSelect; }
  92. void SetOutSelected( bool bSelect ) { m_OutSelected = bSelect; }
  93. void SetKeyClean() { m_KeyDirtyFlags = KEY_CLEAN; }
  94. void SetKeyInClean() { m_KeyDirtyFlags &= ~KEY_IN_DIRTY; }
  95. void SetKeyOutClean() { m_KeyDirtyFlags &= ~KEY_OUT_DIRTY;}
  96. void SetKeyInDirty() { m_KeyDirtyFlags |= KEY_IN_DIRTY; }
  97. void SetKeyOutDirty() { m_KeyDirtyFlags |= KEY_OUT_DIRTY; }
  98. // Tangent manipulation
  99. void SetInTime( DmeTime_t dt ) { m_InTime = dt; }
  100. void SetInDelta( float flDelta ) { m_InDelta = flDelta; }
  101. void SetOutTime( DmeTime_t dt ) { m_OutTime = dt; }
  102. void SetOutDelta( float flDelta ) { m_OutDelta = flDelta; }
  103. // Accessors
  104. bool IsSelected() const { return m_Selected; }
  105. bool InTangentSelected() const { return m_InSelected; }
  106. bool OutTangentSelected() const { return m_OutSelected; }
  107. bool IsKeyWeighted() const { return m_Weighted; }
  108. bool IsKeyUnified() const { return m_Unified; }
  109. int GetComponent() const { return m_Component; }
  110. DmeTime_t GetTime() const { return m_Time; }
  111. float GetValue() const { return m_Value; }
  112. DmeTime_t GetInTime() const { return m_InTime; }
  113. float GetInDelta() const { return m_InDelta; }
  114. DmeTime_t GetOutTime() const { return m_OutTime; }
  115. float GetOutDelta() const { return m_OutDelta; }
  116. bool IsKeyStepped() const { return m_OutMode == TANGENT_MODE_STEPPED; }
  117. KeyTangentMode_t GetInMode() const { return ( KeyTangentMode_t )m_InMode.Get(); }
  118. KeyTangentMode_t GetOutMode() const { return ( KeyTangentMode_t )m_OutMode.Get(); }
  119. bool IsInTangentValid() const { return ( m_InTime != DMETIME_ZERO ); }
  120. bool IsOutTangentValid() const { return ( m_OutTime != DMETIME_ZERO ); }
  121. bool IsKeyDirty() const { return ( m_KeyDirtyFlags != KEY_CLEAN ); }
  122. bool IsKeyInDirty() const { return ( m_KeyDirtyFlags & KEY_IN_DIRTY ) != 0; }
  123. bool IsKeyOutDirty() const { return ( m_KeyDirtyFlags & KEY_OUT_DIRTY ) != 0; }
  124. static int GetUnweightedDisplayLength() { return UNWEIGHTED_DISPLAY_LENGTH; }
  125. private:
  126. friend class CDmeGraphEditorCurve; // GraphEditorCurve is a friend so that it may manipulate the key values
  127. friend class CUndoGraphEditorModifyKeys; // The modify keys undo element is also allowed to touch keys directly to restore state
  128. // Key time and value manipulation, these functions are private as they are intended to be used
  129. // only by the CDmeGraphEditorCurve to which the key belongs. This is because the curve needs
  130. // to know when these values change, in particular the keys are stored ordered by time in the
  131. // curve, so the change of key time may require re-ordering of the key list in the curve.
  132. void SetTime( DmeTime_t time ) { m_Time = time; }
  133. void SetValue( float value ) { m_Value = value; }
  134. void SetInMode( KeyTangentMode_t mode ) { m_InMode = mode; }
  135. void SetOutMode( KeyTangentMode_t mode ) { m_OutMode = mode; }
  136. // Save all of the current values of the key internally.
  137. void StoreCurrentValues();
  138. // Mark the previous values as being invalid
  139. void ClearPreviousValues() { m_bOldValuesValid = false; }
  140. // The old values are copied from the current values of the key by calling StoreCurrentValues(). These
  141. // are temporary values that are used to determine the delta values of operations. The following functions
  142. // return the old values if they have been stored or the current values if the old values have not been stored.
  143. bool GetPreviousStepped() const { return m_bOldValuesValid ? ( m_OldOutMode == TANGENT_MODE_STEPPED ) : ( m_OutMode == TANGENT_MODE_STEPPED ); }
  144. DmeTime_t GetPreviousTime() const { return m_bOldValuesValid ? m_OldTime : m_Time; }
  145. float GetPreviousValue() const { return m_bOldValuesValid ? m_OldValue : m_Value; }
  146. DmeTime_t GetPreviousInTime() const { return m_bOldValuesValid ? m_OldInTime : m_InTime; }
  147. float GetPreviousInDelta() const { return m_bOldValuesValid ? m_OldInDelta : m_InDelta; }
  148. DmeTime_t GetPreviousOutTime() const { return m_bOldValuesValid ? m_OldOutTime : m_OutTime; }
  149. float GetPreviousOutDelta() const { return m_bOldValuesValid ? m_OldOutDelta : m_OutDelta; }
  150. // Multi-selected tangent state, these will return true if the specified tangent is selected or just the key is selected
  151. bool InMultiSelected() const { return m_InSelected || ( m_Selected && !m_OutSelected ); }
  152. bool OutMultiSelected() const { return m_OutSelected || ( m_Selected && !m_InSelected ); }
  153. int m_Component; // Index of the component of the curve the key is associated with
  154. int m_KeyDirtyFlags; // Flags indicating if the key has been changed and on which side
  155. CDmaVar< bool > m_Selected; // "selected" : flag indicating if the key is currently selected
  156. CDmaVar< bool > m_InSelected; // "inSelected" : flag indicating if the in tangent of the key is selected
  157. CDmaVar< bool > m_OutSelected; // "outSelected" : flag indicating if the out tangent of the key is selected
  158. CDmaVar< bool > m_Weighted; // "weighted" : flag indicating if the tangents of the keys are operating in weighted mode
  159. CDmaVar< bool > m_Unified; // "unified" : flag indicating if the tangents of the key are to be manipulated together
  160. CDmaVar< int > m_InMode; // "inMode" : mode in which the in tangent is currently operating
  161. CDmaVar< int > m_OutMode; // "outMode" : mode in which the out tangent is currently operating
  162. CDmaVar< DmeTime_t > m_Time; // "time" : The time the key is located at
  163. CDmaVar< float > m_Value; // "value" : The value of the curve at the point of the key
  164. CDmaVar< DmeTime_t > m_InTime; // "inTime" : The time length of the left tangent of the key
  165. CDmaVar< float > m_InDelta; // "inDelta" : The delta value of the left tangent of the key
  166. CDmaVar< DmeTime_t > m_OutTime; // "outTime" : The time length of the right tangent of the key
  167. CDmaVar< float > m_OutDelta; // "outDelta" : The delta value of the right tangent of the key
  168. bool m_bOldValuesValid; // Flag indicating if the set of old values have been stored and are valid
  169. int m_OldInMode; // Previous in tangent operation mode
  170. int m_OldOutMode; // Previous out tangent operation mode
  171. DmeTime_t m_OldTime; // Previous time of the key
  172. float m_OldValue; // Previous value of the key
  173. DmeTime_t m_OldInTime; // Previous time length of the in tangent
  174. float m_OldInDelta; // Previous delta value of the in tangent
  175. DmeTime_t m_OldOutTime; // Previous time length of the out tangent
  176. float m_OldOutDelta; // Previous delta value of the out tangent
  177. };
  178. //-----------------------------------------------------------------------------
  179. // The CDmeEditCurve represents a channel which is being displayed for editing
  180. // int the graph editor.
  181. //-----------------------------------------------------------------------------
  182. class CDmeGraphEditorCurve : public CDmElement
  183. {
  184. DEFINE_ELEMENT( CDmeGraphEditorCurve, CDmElement );
  185. static const int MAX_COMPONENTS = LOG_MAX_COMPONENTS;
  186. struct SamplePoint_t
  187. {
  188. DmeTime_t time;
  189. float value;
  190. };
  191. public:
  192. // Set the channel and components assigned to the curve and initialize the curve data.
  193. void Initialize( CDmeChannel *pChannel, DmeFramerate_t framerate, bool bFrameSnap, const DmeClipStack_t &clipstack );
  194. // Initialize the edit log.
  195. void InitializeEditLog( DmeFramerate_t framerate, const DmeClipStack_t &clipstack );
  196. // Make sure all results of curve editing are applied to the log
  197. void Finalize();
  198. // Determine if the CRC of the log is the same as the last time finalize was called on the curve
  199. bool VerifyLogCRC() const;
  200. // Compute the tangents of the specified key
  201. void ComputeTangentsForKey( CDmeCurveKey *pKey, bool bStepped ) const;
  202. // Set the tangents for the key to be the specified type
  203. void SetKeyTangents( CDmeCurveKey *pKey, TangentOperation_t tangentType, bool bRespectSelection, float flUnitsPerSecond ) const;
  204. // Add keys to the curve at the specified time for the specified components
  205. void AddKeysAtTime( DmeTime_t time, LogComponents_t nComponentFlags, bool bComputeTangents, AddKeyMode_t addMode, bool bVisibleOnly );
  206. // Remove all of keys at the specified time
  207. bool RemoveKeysAtTime( DmeTime_t time );
  208. // Add a key to the curve at the specified time on the specified component
  209. void AddKeyAtTime( DmeTime_t time, int nComponent, bool bRecomputeNeigbors );
  210. // Set the value of the key at the specified time or create a new key at the time with the specified value
  211. CDmeCurveKey *SetKeyAtTime( DmeTime_t time, int nComponent, float flValue );
  212. // Set the position value of the key at the specified time or create a new key at the time with the specified value
  213. void SetKeyAtTime( DmeTime_t time, LogComponents_t nComponentFlags, const Vector &position );
  214. // Set the position value of the key at the specified time or create a new key at the time with the specified value
  215. void SetKeyAtTime( DmeTime_t time, LogComponents_t nComponentFlags, const Quaternion &orientation );
  216. // Set the position value of the key at the specified time or create a new key at the time with the specified value
  217. void SetKeyAtTime( DmeTime_t time, LogComponents_t nComponentFlags, const CDmAttribute *pAttr );
  218. // Remove a key from the specified component of the curve at the specified time
  219. bool RemoveKeyAtTime( DmeTime_t time, int nComponent );
  220. // Find the keys within the specified time range
  221. void FindKeysInTimeRange( CUtlVector< CDmeCurveKey * > &keyList, DmeTime_t startTime, DmeTime_t endTime, int nComponent );
  222. // Offset the specified keys by the specified about of time
  223. void OffsetKeyTimes( const CUtlVector< CDmeCurveKey * > &keyList, DmeTime_t timeDelta );
  224. // Move the specified key by the specified amount
  225. void MoveKeys( const CUtlVector< CDmeCurveKey * > &moveKeyList, DmeTime_t timeDelta, float flValueDelta,
  226. const DmeClipStack_t &localTimeClipStack, DmeFramerate_t framerate, float flValueScale,
  227. float timeScale, DmeTime_t cursorTime, bool bFrameSnap, bool bUnifiedTangents );
  228. // Scale the specified keys about the specified
  229. void ScaleKeys( const CUtlVector< CDmeCurveKey * > &keyList, float flTimeScaleFactor, float flValueScaleFactor,
  230. DmeTime_t originTime, float flOriginValue, const DmeClipStack_t &localTimeClipStack, DmeFramerate_t framerate );
  231. // Blend the specified keys toward the provided value using the specified blend factor
  232. void BlendKeys( const CUtlVector< CDmeCurveKey * > &keyList, Vector4D targetValue, DmAttributeType_t targetValueType, float flBlendFactor );
  233. // Blend the specified keys toward the value at the specified time using the specified blend factor
  234. void BlendKeys( const CUtlVector< CDmeCurveKey * > &keyList, DmeTime_t targetValueTime, float flBlendFactor );
  235. // Delete the specified keys from the curve
  236. void DeleteKeys( const CUtlVector< CDmeCurveKey * > &keyList );
  237. // Build the keys from the log bookmarks
  238. void BuildKeysFromLog( DmeFramerate_t framerate, bool bFrameSnap, const DmeClipStack_t &graphClipStack );
  239. // Update the edit layer for changes to the specified keys
  240. void UpdateEditLayer( DmeFramerate_t framerate, const DmeClipStack_t &graphClipStack, bool bEditLayerUndoable, bool bOffsetMode );
  241. // Flatten the layers of the edit log, overwriting the base log layer with the active edit layer
  242. void FlattenEditLog();
  243. // Get the range of values within the specified time range
  244. bool GetValueRangeForTime( DmeTime_t minTime, DmeTime_t maxTime, float &minValue, float &maxValue ) const;
  245. // Get the shot relative time of the specified key
  246. DmeTime_t GetKeyShotTime( int nKeyIndex, int nComponent ) const;
  247. // Get the shot relative time of the specified key
  248. DmeTime_t GetKeyShotTime( CDmeCurveKey *pKey ) const;
  249. // Get the shot relative time of the key and its tangents
  250. void GetKeyShotTimes( CDmeCurveKey *pKey, DmeTime_t &keyTime, DmeTime_t &inTime, DmeTime_t &outTime ) const;
  251. // Find the neighboring keys of the specified key
  252. int FindKeyNeighbors( const CDmeCurveKey *pKey, CDmeCurveKey *&pPreviousKey, CDmeCurveKey *&pNextKey ) const;
  253. // Build the clip stack for channel used by the the curve
  254. bool BuildClipStack( DmeClipStack_t *pClipStack, CDmeClip *pRoot, CDmeClip *pShot ) const;
  255. // Get the channels clip to which the channel of the curve belongs
  256. CDmeChannelsClip *GetChannelsClip() const;
  257. // Mark all components as not being visible
  258. void ClearComponents();
  259. // Add the specified components to the current set of components
  260. void UpdateComponents( LogComponents_t nComponentFlags );
  261. // Get the flag specifying which components of the log are to be displayed.
  262. LogComponents_t GetComponentFlags() const;
  263. // Get the number of components in the curve
  264. int GetNumComponents() const;
  265. // Determine if the component specified by index is visible
  266. bool IsComponentVisible( int nComponentIndex ) const;
  267. // Determine if the specified component is selected
  268. bool IsComponentSelected( int nComponentIndex ) const;
  269. // Set the selected state of the component
  270. void SetComponentSelection( LogComponents_t nComponentIndex, SelectionMode_t selectionMode );
  271. // Clear the component selection of the curve
  272. void ClearComponentSelection();
  273. // Get all of the keys for the components specified by the provided flags
  274. void GetKeysForComponents( CUtlVector< CDmeCurveKey * > &keyList, LogComponents_t nComponentFlags ) const;
  275. // Get the value of the specified component of the edit log at the specified time
  276. float GetEditValue( DmeTime_t time, int nComponentIndex ) const;
  277. // Return true if the specified channel is the one in use by the curve
  278. bool IsCurveUsingChannel( const CDmeChannel *pChannel ) { return m_Channel == pChannel; }
  279. // Accessors
  280. CDmeChannel *GetChannel() const { return m_Channel; }
  281. const CDmeLog *GetEditLog() const { return m_EditLog; }
  282. const CDmeCurveKey *GetKey( int nIndex, int nComponent ) const { return m_KeyList[ nComponent ][ nIndex ]; }
  283. CDmeCurveKey *GetKey( int nIndex, int nComponent ) { return m_KeyList[ nComponent ][ nIndex ]; }
  284. int GetNumKeys( int nComponent ) const { return m_KeyList[ nComponent ].Count(); }
  285. bool IsVisibleX() const { return GetValue< bool >( "xVisible", false ); }
  286. bool IsVisibleY() const { return GetValue< bool >( "yVisible", false ); }
  287. bool IsVisibleZ() const { return GetValue< bool >( "zVisible", false ); }
  288. private:
  289. // Find the key on the specified component at the specified time
  290. int FindKeyAtLocalTime( DmeTime_t localTime, int nComponent ) const;
  291. // Find the index of the specified key
  292. int FindKeyIndex( const CDmeCurveKey *pKey ) const;
  293. // Find the neighboring keys of the key with the specified index
  294. void FindKeyNeighbors( int nKeyIndex, int nComponent, CDmeCurveKey *&pPreviousKey, CDmeCurveKey *&pNextKey ) const;
  295. // Find the previous neighbors of the key using the stored key ordering list
  296. bool FindOldKeyNeighbors( const CDmeCurveKey *pKey, CDmeCurveKey *&pPreviousKey, CDmeCurveKey *&pNextKey ) const;
  297. // Find the key which was previously at the first key of the curve segment containing the specified time.
  298. const CDmeCurveKey *FindOldSegmentForTime( DmeTime_t time, int nComponent ) const;
  299. // Create a key at the specified time, with the specified value.
  300. CDmeCurveKey *CreateKey( DmeTime_t time, float flValue, int nComponent, bool bRecomputeNeighbors );
  301. // Remove the specified key from the curve
  302. void RemoveKey( int nKeyIndex, int nComponent );
  303. // Compute the tangents for the curve segment between the two keys
  304. void ComputeKeyTangentsForSegment( CDmeCurveKey *pStartKey, CDmeCurveKey *pEndKey, bool bAllowStepped ) const;
  305. // Update the tangent handles of keys based on the current mode
  306. void UpdateTangentHandles();
  307. // Update the key list so that all keys are valid and in order
  308. void FixupKeyList( const CUtlVector< CDmeCurveKey * > &editKeyList );
  309. // Make sure all of the keys are in order, but make no other changes to the keys
  310. void SortKeyList();
  311. // Make a copy of the current key list so that it may be used to compare the key ordering after changes have been made
  312. void StoreCurrentKeyList();
  313. // Clear the copy of the stored key list
  314. void ClearCachedKeyList();
  315. // Update the base log from the edit log.
  316. void UpdateBaseLog( bool bUseEditLayer );
  317. // Update the edit layer for changes to the specified keys
  318. template < typename T >
  319. void UpdateEditLayer( CDmeTypedLog< T > *pEditLog, DmeFramerate_t framerate, const DmeClipStack_t &graphClipstack, bool bEditLayerUndoable, bool bOffsetMode );
  320. // Generate samples for the curve between two keys and write them into the edit layer
  321. template < typename T >
  322. void GenerateCurveSamples( const CDmeCurveKey *pKeyA, const CDmeCurveKey *pKeyB, CUtlVector< DmeTime_t > &sampleTimes, CUtlVector< T > &sampleValues, int nComponent,
  323. const CDmeTypedLogLayer< T > *pBaseLayer, int &nLayerKeyIndex, DmeFramerate_t sampleRate, const DmeClipStack_t &clipstack, bool bOffsetMode ) const;
  324. // Generate sample values for the specified component using the provided sample points
  325. template < typename T >
  326. void GenerateSampleValues( const CUtlVector< Vector2D > &points, const CUtlVector< DmeTime_t > &pointTimes, CUtlVector< DmeTime_t > &sampleTimes, CUtlVector< T > &sampleValues,
  327. int nComponent, const CDmeTypedLogLayer< T > *pBaseLayer, int &nLayerKeyIndex, DmeFramerate_t sampleRate, const DmeClipStack_t &clipstack ) const;
  328. // Generate sample values for the specified component using the provided previous curve points and the new curve points
  329. template < typename T >
  330. void GenerateOffsetSampleValues( const CUtlVector< Vector2D > &points, const CUtlVector< DmeTime_t > &pointTimes, const CUtlVector< Vector2D > &prevPoints,
  331. const CUtlVector< DmeTime_t > &prevPointTimes, CUtlVector< DmeTime_t > &sampleTimes, CUtlVector< T > &sampleValues, int nComponent,
  332. const CDmeTypedLogLayer< T > *pBaseLayer, int nLayerKeyIndex, DmeFramerate_t sampleRate, const DmeClipStack_t &clipstack, bool bRescaleTime ) const;
  333. // Get the range of values within the specified time range for the specified log
  334. template < typename T >
  335. bool GetValueRangeForTime( CDmeTypedLog< T > *pEditLog, DmeTime_t minTime, DmeTime_t maxTime, float &minValue, float &maxValue ) const;
  336. // Update the log bookmarks to match the keys
  337. void UpdateLogBookmarks() const;
  338. // Compute the crc of the log associated with channel
  339. CRC32_t ComputeLogCRC() const;
  340. // Re-scale the provided list of times from one time frame to another.
  341. static void RescaleTimes( DmeTime_t prevStart, DmeTime_t prevEnd, DmeTime_t newStart, DmeTime_t newEnd, const CUtlVector< DmeTime_t > &oldTimes, CUtlVector< DmeTime_t > &newTimes );
  342. // Interleave a set of times with times occurring at a regular global interval between the provided start and end time.
  343. static void InterleaveGlobalSampleTimes( DmeTime_t startTime, DmeTime_t endTime, const CUtlVector< DmeTime_t > &existingSampleTimes, CUtlVector< DmeTime_t > &sampleTimes, DmeFramerate_t sampleRate, const DmeClipStack_t &clipstack );
  344. private:
  345. CDmaElement< CDmeChannel > m_Channel; // "channel" : The channel associated with the curve
  346. CDmaElement< CDmeLog > m_EditLog; // "editLog" : Log that will be used for editing, for quaternions this is the log of Euler angles.
  347. CDmaElementArray< CDmeCurveKey > m_KeyList[ MAX_COMPONENTS ]; // "keyList" : List of keys on the curve
  348. CDmaVar< int > m_ComponentSelection; // "componentSelection" : Flags specifying which components are selected
  349. CRC32_t m_logCRC; // CRC value of the log the last time Finalize() was called
  350. CDmeLogLayer *m_pEditLayer; // Pointer to the log layer used to store the results of the curve manipulation
  351. CUtlVector< CDmeCurveKey * > m_OldKeyList[ MAX_COMPONENTS ]; // A list of the ordering of keys before the current modification
  352. friend class CUndoGraphEditorModifyKeys;
  353. };
  354. // Quaternion <==> Euler conversion utilities.
  355. void QuaternionToEuler( const Quaternion &q, Vector &rotation, Vector &absRotation );
  356. void EulerToQuaternion( const Vector &euler, Quaternion &quat );
  357. bool ConvertLogEulerToQuaternion( const CDmeVector3LogLayer *pEulerLayer, CDmeQuaternionLogLayer *pQuatLayer );
  358. bool ConvertLogQuaterionToEuler( const CDmeQuaternionLogLayer *pQuatLayer, CDmeVector3LogLayer *pEulerLayer, DmeFramerate_t sampleRate, const DmeClipStack_t &clipstack );
  359. #endif // DMEGRAPHEDITORCURVE_H