CastResult.h 988 B

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Jolt/Physics/Body/BodyID.h>
  5. #include <Jolt/Physics/Collision/Shape/SubShapeID.h>
  6. JPH_NAMESPACE_BEGIN
  7. /// Structure that holds a ray cast or other object cast hit
  8. class BroadPhaseCastResult
  9. {
  10. public:
  11. JPH_OVERRIDE_NEW_DELETE
  12. /// Function required by the CollisionCollector. A smaller fraction is considered to be a 'better hit'. For rays/cast shapes we can just use the collision fraction.
  13. inline float GetEarlyOutFraction() const { return mFraction; }
  14. BodyID mBodyID; ///< Body that was hit
  15. float mFraction = 1.0f + FLT_EPSILON; ///< Hit fraction of the ray/object [0, 1], HitPoint = Start + mFraction * (End - Start)
  16. };
  17. /// Specialization of cast result against a shape
  18. class RayCastResult : public BroadPhaseCastResult
  19. {
  20. public:
  21. JPH_OVERRIDE_NEW_DELETE
  22. SubShapeID mSubShapeID2; ///< Sub shape ID of shape that we collided against
  23. };
  24. JPH_NAMESPACE_END