CastResult.h 912 B

1234567891011121314151617181920212223242526272829
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Physics/Body/BodyID.h>
  5. #include <Physics/Collision/Shape/SubShapeID.h>
  6. namespace JPH {
  7. /// Structure that holds a ray cast or other object cast hit
  8. class BroadPhaseCastResult
  9. {
  10. public:
  11. /// 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.
  12. inline float GetEarlyOutFraction() const { return mFraction; }
  13. BodyID mBodyID; ///< Body that was hit
  14. float mFraction = 1.0f + FLT_EPSILON; ///< Hit fraction of the ray/object [0, 1], HitPoint = Start + mFraction * (End - Start)
  15. };
  16. /// Specialization of cast result against a shape
  17. class RayCastResult : public BroadPhaseCastResult
  18. {
  19. public:
  20. SubShapeID mSubShapeID2; ///< Sub shape ID of shape that we collided against
  21. };
  22. } // JPH