Raycast query now returns false if the body is not active

This commit is contained in:
Daniel Chappuis 2014-11-29 17:05:53 +01:00
parent f598e0c1e9
commit 2ab1aace7c
2 changed files with 7 additions and 2 deletions

View File

@ -287,14 +287,15 @@ bool CollisionBody::testPointInside(const Vector3& worldPoint) const {
/// The method returns the closest hit among all the collision shapes of the body
bool CollisionBody::raycast(const Ray& ray, RaycastInfo& raycastInfo) {
// If the body is not active, it cannot be hit by rays
if (!mIsActive) return false;
bool isHit = false;
Ray rayTemp(ray);
// For each collision shape of the body
for (ProxyShape* shape = mProxyCollisionShapes; shape != NULL; shape = shape->mNext) {
// TODO : Test for broad-phase hit for each shape before testing actual shape raycast
// Test if the ray hits the collision shape
if (shape->raycast(rayTemp, raycastInfo)) {
rayTemp.maxFraction = raycastInfo.hitFraction;

View File

@ -167,6 +167,10 @@ inline decimal ProxyShape::getMargin() const {
// Raycast method with feedback information
inline bool ProxyShape::raycast(const Ray& ray, RaycastInfo& raycastInfo) {
// If the corresponding body is not active, it cannot be hit by rays
if (!mBody->isActive()) return false;
return mCollisionShape->raycast(ray, raycastInfo, this);
}