Adding ViroKit. Needs AWSCore :(

This commit is contained in:
John Lyon-Smith
2018-03-27 17:46:15 -07:00
parent 2ab15e7dc1
commit 02e06dface
844 changed files with 86921 additions and 21 deletions

View File

@@ -0,0 +1,55 @@
//
// VROPhysicsMotionState.h
// ViroRenderer
//
// Copyright © 2017 Viro Media. All rights reserved.
//
#ifndef VROPhysicsMotionState_h
#define VROPhysicsMotionState_h
#include <btBulletDynamicsCommon.h>
/*
VROPhysicsMotionState, when attached to a Bullet body, notifies or grabs
transformation updates to/from a weakly referenced VROPhysicsBody.
*/
class VROPhysicsMotionState : public btMotionState {
public:
std::weak_ptr<VROPhysicsBody> _w_physicsBody;
VROPhysicsMotionState(std::shared_ptr<VROPhysicsBody> body, btTransform transformOffset) {
_w_physicsBody = body;
_physicsTransformOffset = transformOffset;
}
virtual ~VROPhysicsMotionState(){}
void getWorldTransform(btTransform& centerOfMassWorldTrans) const {
std::shared_ptr<VROPhysicsBody> body = _w_physicsBody.lock();
if (!body) {
return;
}
body->getWorldTransform(centerOfMassWorldTrans);
}
void setWorldTransform(const btTransform& centerOfMassWorldTrans) {
std::shared_ptr<VROPhysicsBody> body = _w_physicsBody.lock();
if (!body) {
return;
}
body->setWorldTransform(centerOfMassWorldTrans);
}
btTransform getPhysicsTransformOffset(){
return _physicsTransformOffset;
}
private:
/*
The offset from Viro's geometric transform to Bullet's physicsBody transform (center of mass).
*/
btTransform _physicsTransformOffset;
};
#endif