-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3d91c8
commit 2f439df
Showing
10 changed files
with
219 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#include "Clock.h" | ||
|
||
namespace Arcane | ||
{ | ||
// Library Includes | ||
#include <chrono> | ||
|
||
// Local Includes | ||
|
||
// This Includes | ||
#include "clock.h" | ||
|
||
|
||
// Implementation | ||
//**************************************************** | ||
// CClock: CClock Class Constructor | ||
// @author: | ||
// @parameter: No parameters | ||
// | ||
// @return: none | ||
//***************************************************** | ||
CClock::CClock() | ||
: m_fTimeElapsed(0.0f) | ||
, m_fDeltaTime(0.0f) | ||
{ | ||
|
||
} | ||
|
||
//**************************************************** | ||
// ~CClock: CClock Class Destructor | ||
// @author: | ||
// @parameter: No parameters | ||
// | ||
// @return: none | ||
//***************************************************** | ||
CClock::~CClock() | ||
{ | ||
|
||
} | ||
|
||
//**************************************************** | ||
// Initialise: CClock Class Initialiser - sets the first time values | ||
// @author: | ||
// @parameter: No parameters | ||
// | ||
// @return: true if initialisation is successful, false if not | ||
//***************************************************** | ||
bool CClock::Initialise() | ||
{ | ||
m_fCurrentTime = std::chrono::high_resolution_clock::now(); | ||
return (true); | ||
} | ||
|
||
//**************************************************** | ||
// Process: processes the change in time since it was last called | ||
// @author: | ||
// @parameter: No parameters | ||
// | ||
// @return: void | ||
//***************************************************** | ||
void | ||
CClock::Process() | ||
{ | ||
m_fLastTime = m_fCurrentTime; | ||
|
||
m_fCurrentTime = std::chrono::high_resolution_clock::now(); | ||
|
||
|
||
m_fDeltaTime = static_cast<double>(std::chrono::duration_cast<std::chrono::milliseconds>(m_fCurrentTime - m_fLastTime).count()); | ||
|
||
m_fTimeElapsed += m_fDeltaTime; | ||
} | ||
|
||
//**************************************************** | ||
// GetDeltaTick: gets the current delta tick value | ||
// @author: | ||
// @parameter: No parameters | ||
// | ||
// @return: the current delta tick value | ||
//***************************************************** | ||
float CClock::GetDeltaTick() | ||
{ | ||
return (static_cast<float>(m_fDeltaTime)); | ||
} | ||
|
||
void CClock::Reset() | ||
{ | ||
m_fCurrentTime = std::chrono::high_resolution_clock::now(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef _CLOCK_H_ | ||
#define _CLOCK_H_ | ||
|
||
// Library Includes | ||
#include <chrono> | ||
#include <vector> | ||
|
||
namespace Arcane | ||
{ | ||
// Prototypes | ||
class CClock | ||
{ | ||
// Member Functions | ||
public: | ||
CClock(); | ||
~CClock(); | ||
bool Initialise(); | ||
void Process(); | ||
float GetDeltaTick(); | ||
void Reset(); | ||
|
||
protected: | ||
|
||
private: | ||
CClock(const CClock& _kr); | ||
CClock& operator= (const CClock& _kr); | ||
|
||
// Member Variables | ||
public: | ||
|
||
protected: | ||
double m_fTimeElapsed; | ||
double m_fDeltaTime; | ||
std::chrono::high_resolution_clock::time_point m_fLastTime; | ||
std::chrono::high_resolution_clock::time_point m_fCurrentTime; | ||
|
||
std::vector<double> m_vecTimeHistory; | ||
|
||
long long m_llNumCounts; | ||
|
||
private: | ||
|
||
}; | ||
} | ||
|
||
#endif // |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters