Raycast query now returns false if the body is not active
This commit is contained in:
parent
f598e0c1e9
commit
2ab1aace7c
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user