Return true if a point is inside the collision shape
| 68 | |
| 69 | // Return true if a point is inside the collision shape |
| 70 | bool CapsuleShape::testPointInside(const Vector3& localPoint, Collider* /*collider*/) const { |
| 71 | |
| 72 | const decimal diffYCenterSphere1 = localPoint.y - mHalfHeight; |
| 73 | const decimal diffYCenterSphere2 = localPoint.y + mHalfHeight; |
| 74 | const decimal xSquare = localPoint.x * localPoint.x; |
| 75 | const decimal zSquare = localPoint.z * localPoint.z; |
| 76 | const decimal squareRadius = mMargin * mMargin; |
| 77 | |
| 78 | // Return true if the point is inside the cylinder or one of the two spheres of the capsule |
| 79 | return ((xSquare + zSquare) < squareRadius && |
| 80 | localPoint.y < mHalfHeight && localPoint.y > -mHalfHeight) || |
| 81 | (xSquare + zSquare + diffYCenterSphere1 * diffYCenterSphere1) < squareRadius || |
| 82 | (xSquare + zSquare + diffYCenterSphere2 * diffYCenterSphere2) < squareRadius; |
| 83 | } |
| 84 | |
| 85 | // Return the local bounds of the shape in x, y and z directions |
| 86 | // This method is used to compute the AABB of the box |
nothing calls this directly
no outgoing calls
no test coverage detected