Added proper synchronization for mouse controller and camera.

Camera class now contains three instances of synched variables. a local copy changed on master. a shared copy only used for sharing in serialize/deserialize. and finally a synched copy never written to except in post sync
This commit is contained in:
Joakim Kilby
2015-02-10 11:34:12 +01:00
parent 47ed14b8d6
commit a8abfa74bd
5 changed files with 94 additions and 54 deletions
@@ -118,9 +118,9 @@ public:
void orbitDelta(const glm::quat& rotation);
void orbit(const float &dx, const float &dy, const float &dz);
void orbit(const float &dx, const float &dy, const float &dz, const float &dist);
void distance(const float &d);
//void distance(const float &d);
void rotateDelta(const glm::quat& rotation);
+17 -6
View File
@@ -136,30 +136,41 @@ public:
const glm::vec3& lookUpVector() const;
void postSynchronizationPreDraw();
void preSynchronization();
void serialize(SyncBuffer* syncBuffer);
void deserialize(SyncBuffer* syncBuffer);
private:
float _maxFov;
float _sinMaxFov;
psc _position;
glm::mat4 _viewProjectionMatrix;
glm::mat4 _modelMatrix;
glm::mat4 _viewMatrix;
glm::mat4 _projectionMatrix;
glm::vec3 _viewDirection;
glm::vec3 _cameraDirection;
glm::vec2 _scaling;
// glm::quat _viewRotation;
glm::mat4 _viewRotationMatrix; // compiled from the quaternion
// glm::quat _viewRotation;
glm::vec3 _lookUp;
//cluster variables
std::mutex _syncMutex;
//local variables
glm::mat4 _localViewRotationMatrix;
glm::vec2 _localScaling;
psc _localPosition;
//shared copies of local variables
glm::vec2 _sharedScaling;
psc _sharedPosition;
glm::mat4 _sharedViewRotationMatrix;
std::mutex _syncMutex;
//cluster synced variables
glm::vec2 _syncedScaling;
psc _syncedPosition;
glm::mat4 _syncedViewRotationMatrix;
};
} // namespace openspace