Allow GameObjects without physics
This commit is contained in:
parent
777628d7e1
commit
4026a09928
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "internal/physics.h"
|
#include "internal/physics.h"
|
||||||
|
#include "object.h"
|
||||||
|
|
||||||
namespace kek {
|
namespace kek {
|
||||||
|
|
||||||
@ -44,18 +45,36 @@ void GameObject::addPhysics(btCollisionShape *shape, float mass, int collisionFl
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameObject::rotateTo(glm::quat rotation) {
|
void GameObject::rotateTo(glm::quat rotation) {
|
||||||
|
if(!this->physics) {
|
||||||
|
DefaultRotateableObject::rotateTo(rotation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this->physics->body->getWorldTransform().setRotation(Physics::fromGLM(rotation));
|
this->physics->body->getWorldTransform().setRotation(Physics::fromGLM(rotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat GameObject::getRotation() {
|
glm::quat GameObject::getRotation() {
|
||||||
|
if(!this->physics) {
|
||||||
|
return DefaultRotateableObject::getRotation();
|
||||||
|
}
|
||||||
|
|
||||||
return Physics::toGLM(this->physics->body->getWorldTransform().getRotation());
|
return Physics::toGLM(this->physics->body->getWorldTransform().getRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameObject::moveTo(glm::vec3 position) {
|
void GameObject::moveTo(glm::vec3 position) {
|
||||||
|
if(!this->physics) {
|
||||||
|
DefaultRotateableObject::moveTo(position);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this->physics->body->getWorldTransform().setOrigin(Physics::fromGLM(position));
|
this->physics->body->getWorldTransform().setOrigin(Physics::fromGLM(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 GameObject::getPosition() {
|
glm::vec3 GameObject::getPosition() {
|
||||||
|
if(!this->physics) {
|
||||||
|
return DefaultRotateableObject::getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
return Physics::toGLM(this->physics->body->getWorldTransform().getOrigin());
|
return Physics::toGLM(this->physics->body->getWorldTransform().getOrigin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
namespace kek {
|
namespace kek {
|
||||||
|
|
||||||
class GameObject: public RotateableObject {
|
class GameObject: public DefaultRotateableObject {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<Mesh *> meshes;
|
std::vector<Mesh *> meshes;
|
||||||
|
Loading…
Reference in New Issue
Block a user