mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-04 18:11:01 -05:00
added synced versions of shared variables and modified set/get methods to adress the right versions of variables
This commit is contained in:
@@ -169,6 +169,11 @@ private:
|
||||
glm::vec2 _sharedScaling;
|
||||
psc _sharedPosition;
|
||||
glm::mat4 _sharedViewRotationMatrix;
|
||||
|
||||
//synced copies of local variables
|
||||
glm::vec2 _syncedScaling;
|
||||
psc _syncedPosition;
|
||||
glm::mat4 _syncedViewRotationMatrix;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -197,6 +197,11 @@ private:
|
||||
double _sharedTime;
|
||||
double _sharedDt;
|
||||
bool _sharedTimeJumped;
|
||||
|
||||
//synced copies
|
||||
double _syncedTime;
|
||||
double _syncedDt;
|
||||
bool _syncedTimeJumped;
|
||||
|
||||
|
||||
std::mutex _syncMutex;
|
||||
|
||||
+13
-6
@@ -51,6 +51,9 @@ Camera::Camera()
|
||||
, _sharedPosition()
|
||||
, _sharedScaling(1.f, 0.f)
|
||||
, _sharedViewRotationMatrix(1.f)
|
||||
, _syncedPosition()
|
||||
, _syncedScaling(1.f, 0.f)
|
||||
, _syncedViewRotationMatrix(1.f)
|
||||
, _focusPosition()
|
||||
{
|
||||
}
|
||||
@@ -66,7 +69,8 @@ void Camera::setPosition(psc pos)
|
||||
|
||||
const psc& Camera::position() const
|
||||
{
|
||||
return _localPosition;
|
||||
//return _localPosition;
|
||||
return _syncedPosition;
|
||||
}
|
||||
|
||||
void Camera::setModelMatrix(glm::mat4 modelMatrix){
|
||||
@@ -119,7 +123,8 @@ void Camera::setViewRotationMatrix(glm::mat4 m) {
|
||||
|
||||
const glm::mat4& Camera::viewRotationMatrix() const
|
||||
{
|
||||
return _localViewRotationMatrix;
|
||||
//return _localViewRotationMatrix;
|
||||
return _syncedViewRotationMatrix;
|
||||
}
|
||||
|
||||
void Camera::compileViewRotationMatrix()
|
||||
@@ -129,6 +134,7 @@ void Camera::compileViewRotationMatrix()
|
||||
|
||||
// the camera matrix needs to be rotated inverse to the world
|
||||
// _viewDirection = glm::rotate(glm::inverse(_viewRotation), _cameraDirection);
|
||||
//_viewDirection = (glm::inverse(_localViewRotationMatrix) * glm::vec4(_cameraDirection, 0.f)).xyz;
|
||||
_viewDirection = (glm::inverse(_localViewRotationMatrix) * glm::vec4(_cameraDirection, 0.f)).xyz;
|
||||
_viewDirection = glm::normalize(_viewDirection);
|
||||
}
|
||||
@@ -194,7 +200,8 @@ void Camera::setScaling(glm::vec2 scaling)
|
||||
|
||||
const glm::vec2& Camera::scaling() const
|
||||
{
|
||||
return _localScaling;
|
||||
//return _localScaling;
|
||||
return _syncedScaling;
|
||||
}
|
||||
|
||||
void Camera::setLookUpVector(glm::vec3 lookUp)
|
||||
@@ -230,9 +237,9 @@ void Camera::deserialize(SyncBuffer* syncBuffer){
|
||||
void Camera::postSynchronizationPreDraw(){
|
||||
_syncMutex.lock();
|
||||
|
||||
_localViewRotationMatrix = _sharedViewRotationMatrix;
|
||||
_localPosition = _sharedPosition;
|
||||
_localScaling = _sharedScaling;
|
||||
_syncedViewRotationMatrix = _sharedViewRotationMatrix;
|
||||
_syncedPosition = _sharedPosition;
|
||||
_syncedScaling = _sharedScaling;
|
||||
|
||||
_syncMutex.unlock();
|
||||
}
|
||||
|
||||
+16
-9
@@ -148,10 +148,13 @@ Time* Time::_instance = nullptr;
|
||||
Time::Time()
|
||||
: _time(-1.0)
|
||||
, _dt(1.0)
|
||||
, _timeJumped(false)
|
||||
, _syncedTime(-1.0)
|
||||
, _syncedDt(1.0)
|
||||
, _syncedTimeJumped(false)
|
||||
, _deltaTimePerSecond(1.0)
|
||||
, _sharedTime(-1.0)
|
||||
, _sharedDt(1.0)
|
||||
, _deltaTimePerSecond(1.0)
|
||||
, _timeJumped(false)
|
||||
, _sharedTimeJumped(false)
|
||||
{
|
||||
}
|
||||
@@ -184,7 +187,8 @@ void Time::setTime(double value) {
|
||||
|
||||
double Time::currentTime() const {
|
||||
assert(_instance);
|
||||
return _time;
|
||||
//return _time;
|
||||
return _syncedTime;
|
||||
}
|
||||
|
||||
double Time::advanceTime(double tickTime) {
|
||||
@@ -200,7 +204,8 @@ void Time::setDeltaTime(double deltaT) {
|
||||
}
|
||||
|
||||
double Time::deltaTime() const {
|
||||
return _dt;
|
||||
//return _dt;
|
||||
return _syncedDt;
|
||||
}
|
||||
|
||||
void Time::setTime(std::string time) {
|
||||
@@ -212,7 +217,8 @@ void Time::setTime(std::string time) {
|
||||
|
||||
std::string Time::currentTimeUTC() const {
|
||||
std::string date;
|
||||
SpiceManager::ref().getDateFromET(_time, date);
|
||||
//SpiceManager::ref().getDateFromET(_time, date);
|
||||
SpiceManager::ref().getDateFromET(_syncedTime, date);
|
||||
return date;
|
||||
}
|
||||
|
||||
@@ -239,9 +245,9 @@ void Time::deserialize(SyncBuffer* syncBuffer){
|
||||
void Time::postSynchronizationPreDraw(){
|
||||
_syncMutex.lock();
|
||||
|
||||
_time = _sharedTime;
|
||||
_dt = _sharedDt;
|
||||
_timeJumped = _sharedTimeJumped;
|
||||
_syncedTime = _sharedTime;
|
||||
_syncedDt = _sharedDt;
|
||||
_syncedTimeJumped = _sharedTimeJumped;
|
||||
|
||||
_syncMutex.unlock();
|
||||
}
|
||||
@@ -257,7 +263,8 @@ void Time::preSynchronization(){
|
||||
}
|
||||
|
||||
bool Time::timeJumped(){
|
||||
return _timeJumped;
|
||||
//return _timeJumped;
|
||||
return _syncedTimeJumped;
|
||||
}
|
||||
|
||||
void Time::setTimeJumped(bool jumped){
|
||||
|
||||
Reference in New Issue
Block a user