2014-10-22 22:51:41 +00:00
|
|
|
#include "entity.hh"
|
|
|
|
|
|
|
|
Entity::Entity(glm::vec3 position, glm::vec3 rotation) {
|
2014-11-14 23:03:52 +00:00
|
|
|
this->position = position;
|
|
|
|
setRotation(rotation);
|
|
|
|
}
|
|
|
|
|
|
|
|
Entity::Entity(glm::vec3 position, glm::mat4 rotation) {
|
2014-10-30 22:30:56 +00:00
|
|
|
this->position = position;
|
|
|
|
this->rotation = rotation;
|
2014-10-22 22:51:41 +00:00
|
|
|
}
|
|
|
|
|
2015-03-24 18:09:39 +00:00
|
|
|
Entity::Entity(const Entity &other) {
|
|
|
|
std::lock_guard<std::mutex> lock(other.mutex);
|
|
|
|
position = other.position;
|
|
|
|
rotation = other.rotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
Entity::Entity(Entity &&other) {
|
|
|
|
std::lock_guard<std::mutex> lock(other.mutex);
|
|
|
|
position = std::move(other.position);
|
|
|
|
rotation = std::move(other.rotation);
|
|
|
|
}
|
|
|
|
|
|
|
|
Entity& Entity::operator= (const Entity &other) {
|
|
|
|
std::lock(mutex, other.mutex);
|
|
|
|
std::lock_guard<std::mutex> self_lock(mutex, std::adopt_lock);
|
|
|
|
std::lock_guard<std::mutex> other_lock(other.mutex, std::adopt_lock);
|
|
|
|
position = other.position;
|
|
|
|
rotation = other.rotation;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
Entity& Entity::operator= (Entity &&other) {
|
|
|
|
std::lock(mutex, other.mutex);
|
|
|
|
std::lock_guard<std::mutex> self_lock(mutex, std::adopt_lock);
|
|
|
|
std::lock_guard<std::mutex> other_lock(other.mutex, std::adopt_lock);
|
|
|
|
position = std::move(other.position);
|
|
|
|
rotation = std::move(other.rotation);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2014-10-24 08:48:45 +00:00
|
|
|
Entity::Entity(){
|
|
|
|
}
|
|
|
|
|
2014-10-22 22:51:41 +00:00
|
|
|
Entity::~Entity(){
|
|
|
|
}
|
2014-10-31 09:36:23 +00:00
|
|
|
|
|
|
|
glm::vec3 Entity::getPosition() {
|
|
|
|
return position;
|
|
|
|
}
|
2014-11-12 23:37:27 +00:00
|
|
|
|
2014-11-14 23:03:52 +00:00
|
|
|
glm::mat4 Entity::getRotation() {
|
2014-11-12 23:37:27 +00:00
|
|
|
return rotation;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Entity::setPosition(glm::vec3 position) {
|
|
|
|
this->position = position;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Entity::setRotation(glm::vec3 rotation) {
|
2014-11-14 23:03:52 +00:00
|
|
|
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) {
|
2014-11-12 23:37:27 +00:00
|
|
|
this->rotation = rotation;
|
|
|
|
}
|