Convert more getRealTime to getRealTimeMs

This commit is contained in:
Benau 2018-11-08 01:37:21 +08:00
parent 866df61527
commit 189b90b2c5
4 changed files with 16 additions and 14 deletions

View File

@ -88,7 +88,7 @@ SFXManager::SFXManager()
// The sound manager initialises OpenAL
m_initialized = music_manager->initialized();
m_master_gain = UserConfigParams::m_sfx_volume;
m_last_update_time = -1.0f;
m_last_update_time = -1;
// Init position, since it can be used before positionListener is called.
// No need to use lock here, since the thread will be created later.
m_listener_position.getData() = Vec3(0, 0, 0);
@ -477,10 +477,10 @@ void* SFXManager::mainLoop(void *obj)
{
// Wait some time to let other threads run, then queue an
// update event to keep music playing.
double t = StkTime::getRealTime();
uint64_t t = StkTime::getRealTimeMs();
StkTime::sleep(1);
t = StkTime::getRealTime() - t;
me->queue(SFX_UPDATE, (SFXBase*)NULL, float(t));
t = StkTime::getRealTimeMs() - t;
me->queue(SFX_UPDATE, (SFXBase*)NULL, float(t / 1000.0));
}
me->m_sfx_commands.lock();
PROFILER_POP_CPU_MARKER();
@ -834,15 +834,15 @@ void SFXManager::reallyUpdateNow(SFXCommand *current)
if (!UserConfigParams::m_enable_sound)
return;
if (m_last_update_time < 0.0)
if (m_last_update_time < 0)
{
// first time
m_last_update_time = StkTime::getRealTime();
m_last_update_time = StkTime::getRealTimeMs();
}
double previous_update_time = m_last_update_time;
m_last_update_time = StkTime::getRealTime();
float dt = float(m_last_update_time - previous_update_time);
uint64_t previous_update_time = m_last_update_time;
m_last_update_time = StkTime::getRealTimeMs();
float dt = float(m_last_update_time - previous_update_time) / 1000.0f;
assert(current->m_command==SFX_UPDATE);
if (music_manager->getCurrentMusic())

View File

@ -218,7 +218,7 @@ private:
/** Thread id of the thread running in this object. */
Synchronised<pthread_t *> m_thread_id;
double m_last_update_time;
uint64_t m_last_update_time;
/** A conditional variable to wake up the main loop. */
pthread_cond_t m_cond_request;

View File

@ -173,7 +173,7 @@ void MultitouchDevice::reset()
}
m_orientation = 0.0f;
m_gyro_time = 0.0;
m_gyro_time = 0;
} // reset
// ----------------------------------------------------------------------------
@ -498,9 +498,10 @@ void MultitouchDevice::updateOrientationFromGyroscope(float z)
{
const float GYRO_SPEED_THRESHOLD = 0.005f;
double now = StkTime::getRealTime();
float timedelta = now - m_gyro_time;
uint64_t now = StkTime::getRealTimeMs();
uint64_t delta = now - m_gyro_time;
m_gyro_time = now;
float timedelta = (float)delta / 1000.f;
if (timedelta > 0.5f)
{
timedelta = 0.1f;

View File

@ -23,6 +23,7 @@
#include <vector>
#include "input/input_device.hpp"
#include "utils/types.hpp"
#include "IEventReceiver.h"
#ifdef ANDROID
@ -90,7 +91,7 @@ private:
float m_sensitivity_y;
float m_orientation;
double m_gyro_time;
uint64_t m_gyro_time;
#ifdef ANDROID
/** Pointer to the Android irrlicht device */