From 2b2e05f00946dba44cf0235c0307dcb68b9eadc7 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Tue, 24 Mar 2015 19:12:33 +0100 Subject: [PATCH] Protecting all member functions of entity class with the mutex. --- game/entity.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/game/entity.cc b/game/entity.cc index 9a42fa0..72d759e 100644 --- a/game/entity.cc +++ b/game/entity.cc @@ -47,23 +47,28 @@ Entity::~Entity(){ } glm::vec3 Entity::getPosition() { + std::lock_guard lock(mutex); return position; } glm::mat4 Entity::getRotation() { + std::lock_guard lock(mutex); return rotation; } void Entity::setPosition(glm::vec3 position) { + std::lock_guard lock(mutex); this->position = position; } void Entity::setRotation(glm::vec3 rotation) { + std::lock_guard lock(mutex); this->rotation = glm::rotate(rotation.x, glm::vec3(1.0f, 0.0f, 0.0f)) * glm::rotate(rotation.y, glm::vec3(0.0f, 1.0f, 0.0f)) * glm::rotate(rotation.z, glm::vec3(0.0f, 0.0f, 1.0f)); } void Entity::setRotation(glm::mat4 rotation) { + std::lock_guard lock(mutex); this->rotation = rotation; }