Exemplo n.º 1
0
bool UWorld::OverlapMulti(TArray<struct FOverlapResult>& OutOverlaps, const FVector& Pos, const FQuat& Rot,ECollisionChannel TraceChannel, const struct FCollisionShape & CollisionShape, const struct FCollisionQueryParams& Params, const struct FCollisionResponseParams& ResponseParam ) const
{
#if WITH_PHYSX
	switch (CollisionShape.ShapeType)
	{
	case ECollisionShape::Box:
		{
			PxBoxGeometry PBoxGeom( U2PVector(CollisionShape.GetBox()) );
			PxTransform PGeomPose = U2PTransform(FTransform(Rot, Pos));

			return GeomOverlapMulti(this, PBoxGeom, PGeomPose, OutOverlaps, TraceChannel, Params, ResponseParam, FCollisionObjectQueryParams::DefaultObjectQueryParam);
		}
	case ECollisionShape::Sphere:
		{
			PxSphereGeometry PSphereGeom( CollisionShape.GetSphereRadius() );
			PxTransform PGeomPose(U2PVector(Pos), PxQuat::createIdentity());
			return GeomOverlapMulti(this, PSphereGeom, PGeomPose, OutOverlaps, TraceChannel, Params, ResponseParam, FCollisionObjectQueryParams::DefaultObjectQueryParam);
		}

	case ECollisionShape::Capsule:
		{
			PxCapsuleGeometry PCapsuleGeom( CollisionShape.GetCapsuleRadius(), CollisionShape.GetCapsuleAxisHalfLength() );
			PxTransform PGeomPose = ConvertToPhysXCapsulePose( FTransform(Rot,Pos) );

			return GeomOverlapMulti(this, PCapsuleGeom, PGeomPose, OutOverlaps, TraceChannel, Params, ResponseParam, FCollisionObjectQueryParams::DefaultObjectQueryParam);
		}
	default:
		// invalid point
		ensure(false);
	}
#endif //WITH_PHYSX
	return false;
}
bool UWorld::OverlapMultiByChannel(TArray<struct FOverlapResult>& OutOverlaps, const FVector& Pos, const FQuat& Rot, ECollisionChannel TraceChannel, const FCollisionShape& CollisionShape, const FCollisionQueryParams& Params /* = FCollisionQueryParams::DefaultQueryParam */, const FCollisionResponseParams& ResponseParam /* = FCollisionResponseParams::DefaultResponseParam */) const
{
#if UE_WITH_PHYSICS
	return GeomOverlapMulti(this, CollisionShape, Pos, Rot, OutOverlaps, TraceChannel, Params, ResponseParam, FCollisionObjectQueryParams::DefaultObjectQueryParam);
#else
	return false;
#endif
}
bool UWorld::OverlapMultiByObjectType(TArray<struct FOverlapResult>& OutOverlaps, const FVector& Pos, const FQuat& Rot, const FCollisionObjectQueryParams& ObjectQueryParams, const FCollisionShape& CollisionShape, const FCollisionQueryParams& Params /* = FCollisionQueryParams::DefaultQueryParam */) const
{
#if UE_WITH_PHYSICS
	GeomOverlapMulti(this, CollisionShape, Pos, Rot, OutOverlaps, DefaultCollisionChannel, Params, FCollisionResponseParams::DefaultResponseParam, ObjectQueryParams);

	// object query returns true if any hit is found, not only blocking hit
	return (OutOverlaps.Num() > 0);
#else
	return false;
#endif
}
Exemplo n.º 4
0
bool UWorld::OverlapSingle(struct FOverlapResult& OutOverlap, const FVector& Pos, const FQuat& Rot, const struct FCollisionShape& CollisionShape, const struct FCollisionQueryParams& Params, const struct FCollisionObjectQueryParams& ObjectQueryParams) const
{
	bool bBlocking = false;
#if UE_WITH_PHYSICS
	TArray<FOverlapResult> Overlaps;
	GeomOverlapMulti(this, CollisionShape, Pos, Rot, Overlaps, DefaultCollisionChannel, Params, FCollisionResponseParams::DefaultResponseParam, ObjectQueryParams);
	if (Overlaps.Num() > 0)
	{
		OutOverlap = Overlaps[0];
		bBlocking = true;
	}
#endif

	return bBlocking;
}
Exemplo n.º 5
0
bool UWorld::OverlapMulti(TArray<struct FOverlapResult>& OutOverlaps,const FVector& Pos, const FQuat& Rot, const struct FCollisionShape & CollisionShape, const struct FCollisionQueryParams& Params, const struct FCollisionObjectQueryParams& ObjectQueryParams) const
{
	// object query returns true if any hit is found, not only blocking hit
#if WITH_PHYSX
	switch (CollisionShape.ShapeType)
	{
	case ECollisionShape::Box:
		{
			PxBoxGeometry PBoxGeom( U2PVector(CollisionShape.GetBox()) );
			PxTransform PGeomPose = U2PTransform(FTransform(Rot, Pos));

			GeomOverlapMulti(this, PBoxGeom, PGeomPose, OutOverlaps, DefaultCollisionChannel, Params, FCollisionResponseParams::DefaultResponseParam, ObjectQueryParams);
		}
		break;
	case ECollisionShape::Sphere:
		{
			PxSphereGeometry PSphereGeom( CollisionShape.GetSphereRadius() );
			PxTransform PGeomPose(U2PVector(Pos), PxQuat::createIdentity());
			GeomOverlapMulti(this, PSphereGeom, PGeomPose, OutOverlaps, DefaultCollisionChannel, Params, FCollisionResponseParams::DefaultResponseParam, ObjectQueryParams);
		}
		break;
	case ECollisionShape::Capsule:
		{
			PxCapsuleGeometry PCapsuleGeom( CollisionShape.GetCapsuleRadius(), CollisionShape.GetCapsuleAxisHalfLength() );
			PxTransform PGeomPose = ConvertToPhysXCapsulePose( FTransform(Rot,Pos) );

			GeomOverlapMulti(this, PCapsuleGeom, PGeomPose, OutOverlaps, DefaultCollisionChannel, Params, FCollisionResponseParams::DefaultResponseParam, ObjectQueryParams);
		}
		break;
	default:
		// invalid point
		ensure(false);
	}
#endif //WITH_PHYSX
	return (OutOverlaps.Num() > 0);
}