2014-08-04 20:46:58 +00:00
|
|
|
|
|
|
|
// Libraries
|
|
|
|
#include "ProxyShape.h"
|
|
|
|
|
|
|
|
using namespace reactphysics3d;
|
|
|
|
|
|
|
|
// Constructor
|
2015-02-12 21:31:26 +00:00
|
|
|
/**
|
|
|
|
* @param body Pointer to the parent body
|
|
|
|
* @param shape Pointer to the collision shape
|
|
|
|
* @param transform Transformation from collision shape local-space to body local-space
|
|
|
|
* @param mass Mass of the collision shape (in kilograms)
|
|
|
|
*/
|
2014-08-04 20:46:58 +00:00
|
|
|
ProxyShape::ProxyShape(CollisionBody* body, CollisionShape* shape, const Transform& transform,
|
|
|
|
decimal mass)
|
|
|
|
:mBody(body), mCollisionShape(shape), mLocalToBodyTransform(transform), mMass(mass),
|
2014-12-31 00:19:14 +00:00
|
|
|
mNext(NULL), mBroadPhaseID(-1), mCachedCollisionData(NULL), mUserData(NULL),
|
|
|
|
mCollisionCategoryBits(0x0001), mCollideWithMaskBits(0xFFFF) {
|
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
|
2015-02-12 21:31:26 +00:00
|
|
|
/**
|
|
|
|
* @param worldPoint Point to test in world-space coordinates
|
|
|
|
* @return True if the point is inside the collision shape
|
|
|
|
*/
|
2014-08-04 20:46:58 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|