43template <
class ResultTypeArg,
class TraitsType>
54 template <
class ResultTypeArg2>
62 virtual void Reset() { mEarlyOutFraction = TraitsType::InitialEarlyOutFraction; }
67 virtual void OnBody([[maybe_unused]]
const Body &inBody) { }
80 inline void ResetEarlyOutFraction(
float inFraction = TraitsType::InitialEarlyOutFraction) { mEarlyOutFraction = inFraction; }
83 inline void ForceEarlyOut() { mEarlyOutFraction = TraitsType::ShouldEarlyOutFraction; }
86 inline bool ShouldEarlyOut()
const {
return mEarlyOutFraction <= TraitsType::ShouldEarlyOutFraction; }
96 float mEarlyOutFraction = TraitsType::InitialEarlyOutFraction;
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
Virtual interface that allows collecting multiple collision results.
Definition: CollisionCollector.h:45
void ForceEarlyOut()
Force the collision detection algorithm to terminate as soon as possible. Call this from the AddHit f...
Definition: CollisionCollector.h:83
void ResetEarlyOutFraction(float inFraction=TraitsType::InitialEarlyOutFraction)
Reset the early out fraction to a specific value.
Definition: CollisionCollector.h:80
CollisionCollector()=default
Default constructor.
virtual ~CollisionCollector()=default
Destructor.
bool ShouldEarlyOut() const
When true, the collector will no longer accept any additional hits and the collision detection routin...
Definition: CollisionCollector.h:86
virtual void AddHit(const ResultType &inResult)=0
This function will be called for every hit found, it's up to the application to decide how to store t...
virtual void Reset()
If you want to reuse this collector, call Reset()
Definition: CollisionCollector.h:62
CollisionCollector(const CollisionCollector< ResultTypeArg2, TraitsType > &inRHS)
Constructor to initialize from another collector.
Definition: CollisionCollector.h:55
CollisionCollector(const CollisionCollector< ResultTypeArg, TraitsType > &inRHS)=default
float GetEarlyOutFraction() const
Get the current early out value.
Definition: CollisionCollector.h:89
const TransformedShape * GetContext() const
Definition: CollisionCollector.h:71
virtual void OnBody(const Body &inBody)
Definition: CollisionCollector.h:67
void UpdateEarlyOutFraction(float inFraction)
Update the early out fraction (should be lower than before)
Definition: CollisionCollector.h:77
ResultTypeArg ResultType
Declare ResultType so that derived classes can use it.
Definition: CollisionCollector.h:48
void SetContext(const TransformedShape *inContext)
Set by the collision detection functions to the current TransformedShape that we're colliding against...
Definition: CollisionCollector.h:70
float GetPositiveEarlyOutFraction() const
Get the current early out value but make sure it's bigger than zero, this is used for shape casting a...
Definition: CollisionCollector.h:92
Traits to use for CastRay.
Definition: CollisionCollector.h:14
static constexpr float InitialEarlyOutFraction
For rays the early out fraction is the fraction along the line to order hits.
Definition: CollisionCollector.h:17
static constexpr float ShouldEarlyOutFraction
Closest hit: Fraction is 0.
Definition: CollisionCollector.h:18
Traits to use for CastShape.
Definition: CollisionCollector.h:23
static constexpr float InitialEarlyOutFraction
For rays the early out fraction is the fraction along the line to order hits.
Definition: CollisionCollector.h:26
static constexpr float ShouldEarlyOutFraction
Deepest hit: Penetration is infinite.
Definition: CollisionCollector.h:27
Traits to use for CollideShape.
Definition: CollisionCollector.h:32
static constexpr float InitialEarlyOutFraction
For shape collisions we use -penetration depth to order hits.
Definition: CollisionCollector.h:35
static constexpr float ShouldEarlyOutFraction
Deepest hit: Penetration is infinite.
Definition: CollisionCollector.h:36