feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -29,7 +29,7 @@ bool NarrowPhaseQuery::CastRay(const RRayCast &inRay, RayCastResult &ioHit, cons
|
|||
mBodyLockInterface(inBodyLockInterface),
|
||||
mBodyFilter(inBodyFilter)
|
||||
{
|
||||
UpdateEarlyOutFraction(ioHit.mFraction);
|
||||
ResetEarlyOutFraction(ioHit.mFraction);
|
||||
}
|
||||
|
||||
virtual void AddHit(const ResultType &inResult) override
|
||||
|
|
@ -126,6 +126,10 @@ void NarrowPhaseQuery::CastRay(const RRayCast &inRay, const RayCastSettings &inR
|
|||
// Do narrow phase collision check
|
||||
ts.CastRay(mRay, mRayCastSettings, mCollector, mShapeFilter);
|
||||
|
||||
// Notify collector of the end of this body
|
||||
// We do this before updating the early out fraction so that the collector can still modify it
|
||||
mCollector.OnBodyEnd();
|
||||
|
||||
// Update early out fraction based on narrow phase collector
|
||||
UpdateEarlyOutFraction(mCollector.GetEarlyOutFraction());
|
||||
}
|
||||
|
|
@ -189,6 +193,10 @@ void NarrowPhaseQuery::CollidePoint(RVec3Arg inPoint, CollidePointCollector &ioC
|
|||
// Do narrow phase collision check
|
||||
ts.CollidePoint(mPoint, mCollector, mShapeFilter);
|
||||
|
||||
// Notify collector of the end of this body
|
||||
// We do this before updating the early out fraction so that the collector can still modify it
|
||||
mCollector.OnBodyEnd();
|
||||
|
||||
// Update early out fraction based on narrow phase collector
|
||||
UpdateEarlyOutFraction(mCollector.GetEarlyOutFraction());
|
||||
}
|
||||
|
|
@ -255,6 +263,10 @@ void NarrowPhaseQuery::CollideShape(const Shape *inShape, Vec3Arg inShapeScale,
|
|||
// Do narrow phase collision check
|
||||
ts.CollideShape(mShape, mShapeScale, mCenterOfMassTransform, mCollideShapeSettings, mBaseOffset, mCollector, mShapeFilter);
|
||||
|
||||
// Notify collector of the end of this body
|
||||
// We do this before updating the early out fraction so that the collector can still modify it
|
||||
mCollector.OnBodyEnd();
|
||||
|
||||
// Update early out fraction based on narrow phase collector
|
||||
UpdateEarlyOutFraction(mCollector.GetEarlyOutFraction());
|
||||
}
|
||||
|
|
@ -284,82 +296,13 @@ void NarrowPhaseQuery::CollideShape(const Shape *inShape, Vec3Arg inShapeScale,
|
|||
|
||||
void NarrowPhaseQuery::CollideShapeWithInternalEdgeRemoval(const Shape *inShape, Vec3Arg inShapeScale, RMat44Arg inCenterOfMassTransform, const CollideShapeSettings &inCollideShapeSettings, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const
|
||||
{
|
||||
JPH_PROFILE_FUNCTION();
|
||||
// We require these settings for internal edge removal to work
|
||||
CollideShapeSettings settings = inCollideShapeSettings;
|
||||
settings.mActiveEdgeMode = EActiveEdgeMode::CollideWithAll;
|
||||
settings.mCollectFacesMode = ECollectFacesMode::CollectFaces;
|
||||
|
||||
class MyCollector : public CollideShapeBodyCollector
|
||||
{
|
||||
public:
|
||||
MyCollector(const Shape *inShape, Vec3Arg inShapeScale, RMat44Arg inCenterOfMassTransform, const CollideShapeSettings &inCollideShapeSettings, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, const BodyLockInterface &inBodyLockInterface, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) :
|
||||
CollideShapeBodyCollector(ioCollector),
|
||||
mShape(inShape),
|
||||
mShapeScale(inShapeScale),
|
||||
mCenterOfMassTransform(inCenterOfMassTransform),
|
||||
mBaseOffset(inBaseOffset),
|
||||
mBodyLockInterface(inBodyLockInterface),
|
||||
mBodyFilter(inBodyFilter),
|
||||
mShapeFilter(inShapeFilter),
|
||||
mCollideShapeSettings(inCollideShapeSettings),
|
||||
mCollector(ioCollector)
|
||||
{
|
||||
// We require these settings for internal edge removal to work
|
||||
mCollideShapeSettings.mActiveEdgeMode = EActiveEdgeMode::CollideWithAll;
|
||||
mCollideShapeSettings.mCollectFacesMode = ECollectFacesMode::CollectFaces;
|
||||
}
|
||||
|
||||
virtual void AddHit(const ResultType &inResult) override
|
||||
{
|
||||
// Only test shape if it passes the body filter
|
||||
if (mBodyFilter.ShouldCollide(inResult))
|
||||
{
|
||||
// Lock the body
|
||||
BodyLockRead lock(mBodyLockInterface, inResult);
|
||||
if (lock.SucceededAndIsInBroadPhase()) // Race condition: body could have been removed since it has been found in the broadphase, ensures body is in the broadphase while we call the callbacks
|
||||
{
|
||||
const Body &body = lock.GetBody();
|
||||
|
||||
// Check body filter again now that we've locked the body
|
||||
if (mBodyFilter.ShouldCollideLocked(body))
|
||||
{
|
||||
// Collect the transformed shape
|
||||
TransformedShape ts = body.GetTransformedShape();
|
||||
|
||||
// Notify collector of new body
|
||||
mCollector.OnBody(body);
|
||||
|
||||
// Release the lock now, we have all the info we need in the transformed shape
|
||||
lock.ReleaseLock();
|
||||
|
||||
// Do narrow phase collision check
|
||||
ts.CollideShape(mShape, mShapeScale, mCenterOfMassTransform, mCollideShapeSettings, mBaseOffset, mCollector, mShapeFilter);
|
||||
|
||||
// After each body, we need to flush the InternalEdgeRemovingCollector because it uses 'ts' as context and it will go out of scope at the end of this block
|
||||
mCollector.Flush();
|
||||
|
||||
// Update early out fraction based on narrow phase collector
|
||||
UpdateEarlyOutFraction(mCollector.GetEarlyOutFraction());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Shape * mShape;
|
||||
Vec3 mShapeScale;
|
||||
RMat44 mCenterOfMassTransform;
|
||||
RVec3 mBaseOffset;
|
||||
const BodyLockInterface & mBodyLockInterface;
|
||||
const BodyFilter & mBodyFilter;
|
||||
const ShapeFilter & mShapeFilter;
|
||||
CollideShapeSettings mCollideShapeSettings;
|
||||
InternalEdgeRemovingCollector mCollector;
|
||||
};
|
||||
|
||||
// Calculate bounds for shape and expand by max separation distance
|
||||
AABox bounds = inShape->GetWorldSpaceBounds(inCenterOfMassTransform, inShapeScale);
|
||||
bounds.ExpandBy(Vec3::sReplicate(inCollideShapeSettings.mMaxSeparationDistance));
|
||||
|
||||
// Do broadphase test
|
||||
MyCollector collector(inShape, inShapeScale, inCenterOfMassTransform, inCollideShapeSettings, inBaseOffset, ioCollector, *mBodyLockInterface, inBodyFilter, inShapeFilter);
|
||||
mBroadPhaseQuery->CollideAABox(bounds, collector, inBroadPhaseLayerFilter, inObjectLayerFilter);
|
||||
InternalEdgeRemovingCollector wrapper(ioCollector);
|
||||
CollideShape(inShape, inShapeScale, inCenterOfMassTransform, settings, inBaseOffset, wrapper, inBroadPhaseLayerFilter, inObjectLayerFilter, inBodyFilter, inShapeFilter);
|
||||
}
|
||||
|
||||
void NarrowPhaseQuery::CastShape(const RShapeCast &inShapeCast, const ShapeCastSettings &inShapeCastSettings, RVec3Arg inBaseOffset, CastShapeCollector &ioCollector, const BroadPhaseLayerFilter &inBroadPhaseLayerFilter, const ObjectLayerFilter &inObjectLayerFilter, const BodyFilter &inBodyFilter, const ShapeFilter &inShapeFilter) const
|
||||
|
|
@ -409,6 +352,10 @@ void NarrowPhaseQuery::CastShape(const RShapeCast &inShapeCast, const ShapeCastS
|
|||
// Do narrow phase collision check
|
||||
ts.CastShape(mShapeCast, mShapeCastSettings, mBaseOffset, mCollector, mShapeFilter);
|
||||
|
||||
// Notify collector of the end of this body
|
||||
// We do this before updating the early out fraction so that the collector can still modify it
|
||||
mCollector.OnBodyEnd();
|
||||
|
||||
// Update early out fraction based on narrow phase collector
|
||||
UpdateEarlyOutFraction(mCollector.GetEarlyOutFraction());
|
||||
}
|
||||
|
|
@ -471,6 +418,10 @@ void NarrowPhaseQuery::CollectTransformedShapes(const AABox &inBox, TransformedS
|
|||
// Do narrow phase collision check
|
||||
ts.CollectTransformedShapes(mBox, mCollector, mShapeFilter);
|
||||
|
||||
// Notify collector of the end of this body
|
||||
// We do this before updating the early out fraction so that the collector can still modify it
|
||||
mCollector.OnBodyEnd();
|
||||
|
||||
// Update early out fraction based on narrow phase collector
|
||||
UpdateEarlyOutFraction(mCollector.GetEarlyOutFraction());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue