Revision 9cb381ec server/src/Animation.cpp
| server/src/Animation.cpp | ||
|---|---|---|
| 27 | 27 |
*/ |
| 28 | 28 |
|
| 29 | 29 |
#include "Animation.h" |
| 30 |
#include <stdexcept> |
|
| 31 |
|
|
| 30 | 32 |
using namespace std; |
| 31 |
using namespace boost; |
|
| 32 | 33 |
|
| 33 | 34 |
Animation::Animation(){
|
| 34 | 35 |
active = false; |
| ... | ... | |
| 51 | 52 |
|
| 52 | 53 |
//Set up end time |
| 53 | 54 |
int duration = duration_each * repetitions; |
| 54 |
start_time = get_system_time(); //posix_time::microsec_clock::local_time();
|
|
| 55 |
end_time = start_time + boost::posix_time::milliseconds(duration);
|
|
| 55 |
start_time = std::chrono::steady_clock::now();
|
|
| 56 |
end_time = start_time + std::chrono::milliseconds(duration);
|
|
| 56 | 57 |
} |
| 57 | 58 |
|
| 58 | 59 |
bool Animation::is_active(){
|
| ... | ... | |
| 141 | 142 |
} |
| 142 | 143 |
|
| 143 | 144 |
//now check if this animation ended: |
| 144 |
system_time now = get_system_time(); //posix_time::microsec_clock::local_time();
|
|
| 145 |
std::chrono::time_point<std::chrono::steady_clock> now = std::chrono::steady_clock::now();
|
|
| 145 | 146 |
if (now > end_time){
|
| 146 | 147 |
active = false; |
| 147 | 148 |
return; |
| 148 | 149 |
} |
| 149 | 150 |
|
| 150 | 151 |
//milliseconds from the beginning of this ani: |
| 151 |
posix_time::time_duration diff = now - start_time; |
|
| 152 |
float elapsed_ms = diff.total_milliseconds(); |
|
| 153 |
//printf("mili %f\n",elapsed_ms);
|
|
| 152 |
float elapsed_ms = std::chrono::duration<float, milli>(now - start_time).count(); |
|
| 153 |
//printf("milli %f\n",elapsed_ms);
|
|
| 154 | 154 |
|
| 155 | 155 |
float max_elongation = 0.0; |
| 156 | 156 |
float profile = 0.0; |
Also available in: Unified diff