MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / testPointInside

Method testPointInside

src/collision/shapes/CapsuleShape.cpp:70–83  ·  view source on GitHub ↗

Return true if a point is inside the collision shape

Source from the content-addressed store, hash-verified

68
69// Return true if a point is inside the collision shape
70bool 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected