diff --git a/src/kekengine/cpp/object/gameobject.cpp b/src/kekengine/cpp/object/gameobject.cpp index 21e0f06..9fb6425 100644 --- a/src/kekengine/cpp/object/gameobject.cpp +++ b/src/kekengine/cpp/object/gameobject.cpp @@ -5,6 +5,7 @@ #include "internal.h" #include "internal/physics.h" +#include "object.h" namespace kek { @@ -44,18 +45,36 @@ void GameObject::addPhysics(btCollisionShape *shape, float mass, int collisionFl } void GameObject::rotateTo(glm::quat rotation) { + if(!this->physics) { + DefaultRotateableObject::rotateTo(rotation); + return; + } + this->physics->body->getWorldTransform().setRotation(Physics::fromGLM(rotation)); } glm::quat GameObject::getRotation() { + if(!this->physics) { + return DefaultRotateableObject::getRotation(); + } + return Physics::toGLM(this->physics->body->getWorldTransform().getRotation()); } void GameObject::moveTo(glm::vec3 position) { + if(!this->physics) { + DefaultRotateableObject::moveTo(position); + return; + } + this->physics->body->getWorldTransform().setOrigin(Physics::fromGLM(position)); } glm::vec3 GameObject::getPosition() { + if(!this->physics) { + return DefaultRotateableObject::getPosition(); + } + return Physics::toGLM(this->physics->body->getWorldTransform().getOrigin()); } diff --git a/src/kekengine/include/gameobject.h b/src/kekengine/include/gameobject.h index 67e7a2c..a557eee 100644 --- a/src/kekengine/include/gameobject.h +++ b/src/kekengine/include/gameobject.h @@ -8,7 +8,7 @@ namespace kek { -class GameObject: public RotateableObject { +class GameObject: public DefaultRotateableObject { protected: std::vector meshes;