mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 03:42:48 +01:00
Expose GameObjectMotionState
This commit is contained in:
parent
e55688e21c
commit
5d6e3598ca
@ -21,30 +21,21 @@
|
||||
#include "objects/GameObject.hpp"
|
||||
#include "objects/VehicleInfo.hpp"
|
||||
|
||||
class GameObjectMotionState : public btMotionState {
|
||||
public:
|
||||
GameObjectMotionState(GameObject* object) : m_object(object) {
|
||||
}
|
||||
void GameObjectMotionState::getWorldTransform(btTransform& tform) const {
|
||||
auto& position = m_object->getPosition();
|
||||
auto& rotation = m_object->getRotation();
|
||||
tform.setOrigin(btVector3(position.x, position.y, position.z));
|
||||
tform.setRotation(
|
||||
btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w));
|
||||
}
|
||||
|
||||
void getWorldTransform(btTransform& tform) const override {
|
||||
auto& position = m_object->getPosition();
|
||||
auto& rotation = m_object->getRotation();
|
||||
tform.setOrigin(btVector3(position.x, position.y, position.z));
|
||||
tform.setRotation(
|
||||
btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w));
|
||||
}
|
||||
|
||||
void setWorldTransform(const btTransform& tform) override {
|
||||
auto& o = tform.getOrigin();
|
||||
auto r = tform.getRotation();
|
||||
glm::vec3 position(o.x(), o.y(), o.z());
|
||||
glm::quat rotation(r.w(), r.x(), r.y(), r.z());
|
||||
m_object->updateTransform(position, rotation);
|
||||
}
|
||||
|
||||
private:
|
||||
GameObject* m_object;
|
||||
};
|
||||
void GameObjectMotionState::setWorldTransform(const btTransform& tform) {
|
||||
auto& o = tform.getOrigin();
|
||||
auto r = tform.getRotation();
|
||||
glm::vec3 position(o.x(), o.y(), o.z());
|
||||
glm::quat rotation(r.w(), r.x(), r.y(), r.z());
|
||||
m_object->updateTransform(position, rotation);
|
||||
}
|
||||
|
||||
CollisionInstance::~CollisionInstance() {
|
||||
if (m_body) {
|
||||
|
@ -4,10 +4,10 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <btBulletDynamicsCommon.h>
|
||||
|
||||
class btCollisionShape;
|
||||
class btCompoundShape;
|
||||
class btMotionState;
|
||||
class btRigidBody;
|
||||
class btTriangleIndexVertexArray;
|
||||
struct CollisionModel;
|
||||
|
||||
@ -15,6 +15,19 @@ class GameObject;
|
||||
struct DynamicObjectData;
|
||||
struct VehicleHandlingInfo;
|
||||
|
||||
class GameObjectMotionState : public btMotionState {
|
||||
public:
|
||||
explicit GameObjectMotionState(GameObject* object) : m_object(object) {
|
||||
}
|
||||
|
||||
void getWorldTransform(btTransform& tform) const override;
|
||||
|
||||
void setWorldTransform(const btTransform& tform) override;
|
||||
|
||||
private:
|
||||
GameObject* m_object;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief CollisionInstance stores bullet body information
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user