bool UWorld::SweepTest(const FVector& Start, const FVector& End, const FQuat& Rot, ECollisionChannel TraceChannel, const struct FCollisionShape & CollisionShape, const struct FCollisionQueryParams& Params, const struct FCollisionResponseParams& ResponseParam) const { if(CollisionShape.IsNearlyZero()) { // if extent is 0, we'll just do linetrace instead return LineTraceTest(Start, End, TraceChannel, Params); } #if WITH_PHYSX switch (CollisionShape.ShapeType) { case ECollisionShape::Box: { const PxBoxGeometry PBoxGeom( U2PVector(CollisionShape.GetBox()) ); const PxQuat PGeomRot = U2PQuat(Rot); return GeomSweepTest(this, PBoxGeom, PGeomRot, Start, End, TraceChannel, Params, ResponseParam, FCollisionObjectQueryParams::DefaultObjectQueryParam); } case ECollisionShape::Sphere: { PxSphereGeometry PSphereGeom( CollisionShape.GetSphereRadius()); PxQuat PGeomRot = PxQuat::createIdentity(); return GeomSweepTest(this, PSphereGeom, PGeomRot, Start, End, TraceChannel, Params, ResponseParam, FCollisionObjectQueryParams::DefaultObjectQueryParam); } case ECollisionShape::Capsule: { PxCapsuleGeometry PCapsuleGeom( CollisionShape.GetCapsuleRadius(), CollisionShape.GetCapsuleAxisHalfLength() ); const PxQuat PGeomRot = ConvertToPhysXCapsuleRot(Rot); return GeomSweepTest(this, PCapsuleGeom, PGeomRot, Start, End, TraceChannel, Params, ResponseParam, FCollisionObjectQueryParams::DefaultObjectQueryParam); } default: // invalid point ensure(false); } #endif //WITH_PHYSX return false; }
bool UWorld::SweepTestByChannel(const FVector& Start, const FVector& End, const FQuat& Rot, ECollisionChannel TraceChannel, const FCollisionShape& CollisionShape, const FCollisionQueryParams& Params /* = FCollisionQueryParams::DefaultQueryParam */, const FCollisionResponseParams& ResponseParam /* = FCollisionResponseParams::DefaultResponseParam */) const { if (CollisionShape.IsNearlyZero()) { // if extent is 0, we'll just do linetrace instead return LineTraceTestByChannel(Start, End, TraceChannel, Params, ResponseParam); } else { #if UE_WITH_PHYSICS return GeomSweepTest(this, CollisionShape, Rot, Start, End, TraceChannel, Params, ResponseParam, FCollisionObjectQueryParams::DefaultObjectQueryParam); #else return false; #endif } }