2014-08-04 20:46:58 +00:00
|
|
|
|
|
|
|
// Libraries
|
|
|
|
#include "ProxyShape.h"
|
|
|
|
|
|
|
|
using namespace reactphysics3d;
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
ProxyShape::ProxyShape(CollisionBody* body, CollisionShape* shape, const Transform& transform,
|
|
|
|
decimal mass)
|
|
|
|
:mBody(body), mCollisionShape(shape), mLocalToBodyTransform(transform), mMass(mass),
|
2014-08-04 20:57:24 +00:00
|
|
|
mNext(NULL), mBroadPhaseID(-1), mCachedCollisionData(NULL), mUserData(NULL) {
|
2014-08-04 20:46:58 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
ProxyShape::~ProxyShape() {
|
|
|
|
|
|
|
|
// Release the cached collision data memory
|
|
|
|
if (mCachedCollisionData != NULL) {
|
|
|
|
free(mCachedCollisionData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return true if a point is inside the collision shape
|
|
|
|
bool ProxyShape::testPointInside(const Vector3& worldPoint) {
|
|
|
|
const Transform localToWorld = mBody->getTransform() * mLocalToBodyTransform;
|
|
|
|
const Vector3 localPoint = localToWorld.getInverse() * worldPoint;
|
2014-08-09 08:28:37 +00:00
|
|
|
return mCollisionShape->testPointInside(localPoint, this);
|
2014-08-04 20:46:58 +00:00
|
|
|
}
|
|
|
|
|