本文整理汇总了C++中UPrimitiveComponent::InitSweepCollisionParams方法的典型用法代码示例。如果您正苦于以下问题:C++ UPrimitiveComponent::InitSweepCollisionParams方法的具体用法?C++ UPrimitiveComponent::InitSweepCollisionParams怎么用?C++ UPrimitiveComponent::InitSweepCollisionParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UPrimitiveComponent
的用法示例。
在下文中一共展示了UPrimitiveComponent::InitSweepCollisionParams方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TickGrip
//.........这里部分代码省略.........
if (!actor->bReplicateMovement)
actor->SetReplicateMovement(true);
}
else
{
GrippedActors[i].bColliding = false;
if (actor->bReplicateMovement)
actor->SetReplicateMovement(false);
}
}
else
{
if (!GrippedActors[i].bColliding)
{
root->SetWorldTransform(WorldTransform, true);
}
}
}
else if (GrippedActors[i].GripCollisionType == EGripCollisionType::InteractiveHybridCollisionWithSweep)
{
// Need to use without teleport so that the physics velocity is updated for when the actor is released to throw
//if (bIsServer)
//{
FBPActorPhysicsHandleInformation * GripHandle = GetPhysicsGrip(GrippedActors[i]);
if (!GrippedActors[i].bColliding)
{
// Make sure that there is no collision on course before turning off collision and snapping to controller
if (bIsServer && actor && actor->bReplicateMovement)
{
FCollisionQueryParams QueryParams(NAME_None, false, this->GetOwner());
FCollisionResponseParams ResponseParam;
root->InitSweepCollisionParams(QueryParams, ResponseParam);
QueryParams.AddIgnoredActor(actor);
QueryParams.AddIgnoredActors(root->MoveIgnoreActors);
if (GetWorld()->SweepTestByChannel(root->GetComponentLocation(), WorldTransform.GetLocation(), root->GetComponentQuat(), ECollisionChannel::ECC_Visibility, root->GetCollisionShape(), QueryParams, ResponseParam))
{
GrippedActors[i].bColliding = true;
}
else
{
GrippedActors[i].bColliding = false;
}
}
// If still not colliding
if (!GrippedActors[i].bColliding)
{
if (bIsServer && actor->bReplicateMovement) // So we don't call on on change event over and over locally
actor->SetReplicateMovement(false);
if (bIsServer && GripHandle)
{
DestroyPhysicsHandle(GrippedActors[i]);
if(GrippedActors[i].Actor)
GrippedActors[i].Actor->DisableComponentsSimulatePhysics();
else
root->SetSimulatePhysics(false);
}
root->SetWorldTransform(WorldTransform, false);
}
else
示例2: CheckComponentWithSweep
bool UGripMotionControllerComponent::CheckComponentWithSweep(UPrimitiveComponent * ComponentToCheck, FVector Move, FRotator newOrientation, bool bSkipSimulatingComponents/*, bool &bHadBlockingHitOut*/)
{
TArray<FHitResult> Hits;
// WARNING: HitResult is only partially initialized in some paths. All data is valid only if bFilledHitResult is true.
FHitResult BlockingHit(NoInit);
BlockingHit.bBlockingHit = false;
BlockingHit.Time = 1.f;
bool bFilledHitResult = false;
bool bMoved = false;
bool bIncludesOverlapsAtEnd = false;
bool bRotationOnly = false;
UPrimitiveComponent *root = ComponentToCheck;
if (!root || !root->IsQueryCollisionEnabled())
return false;
FVector start(root->GetComponentLocation());
const bool bCollisionEnabled = root->IsQueryCollisionEnabled();
if (bCollisionEnabled)
{
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
if (!root->IsRegistered())
{
UE_LOG(LogTemp, Warning, TEXT("MovedComponent %s not initialized in grip motion controller"), *root->GetFullName());
}
#endif
UWorld* const MyWorld = GetWorld();
FComponentQueryParams Params(TEXT("sweep_params"), root->GetOwner());
FCollisionResponseParams ResponseParam;
root->InitSweepCollisionParams(Params, ResponseParam);
bool const bHadBlockingHit = MyWorld->ComponentSweepMulti(Hits, root, start, start + Move, newOrientation, Params);
if (bHadBlockingHit)
{
int32 BlockingHitIndex = INDEX_NONE;
float BlockingHitNormalDotDelta = BIG_NUMBER;
for (int32 HitIdx = 0; HitIdx < Hits.Num(); HitIdx++)
{
const FHitResult& TestHit = Hits[HitIdx];
// Ignore the owning actor to the motion controller
if (TestHit.Actor == this->GetOwner() || (bSkipSimulatingComponents && TestHit.Component->IsSimulatingPhysics()))
{
if (Hits.Num() == 1)
{
//bHadBlockingHitOut = false;
return false;
}
else
continue;
}
if (TestHit.bBlockingHit && TestHit.IsValidBlockingHit())
{
if (TestHit.Time == 0.f)
{
// We may have multiple initial hits, and want to choose the one with the normal most opposed to our movement.
const float NormalDotDelta = (TestHit.ImpactNormal | Move);
if (NormalDotDelta < BlockingHitNormalDotDelta)
{
BlockingHitNormalDotDelta = NormalDotDelta;
BlockingHitIndex = HitIdx;
}
}
else if (BlockingHitIndex == INDEX_NONE)
{
// First non-overlapping blocking hit should be used, if an overlapping hit was not.
// This should be the only non-overlapping blocking hit, and last in the results.
BlockingHitIndex = HitIdx;
break;
}
//}
}
}
// Update blocking hit, if there was a valid one.
if (BlockingHitIndex >= 0)
{
BlockingHit = Hits[BlockingHitIndex];
bFilledHitResult = true;
}
}
}
// Handle blocking hit notifications. Avoid if pending kill (which could happen after overlaps).
if (BlockingHit.bBlockingHit && !root->IsPendingKill())
{
check(bFilledHitResult);
if (root->IsDeferringMovementUpdates())
{
FScopedMovementUpdate* ScopedUpdate = root->GetCurrentScopedMovement();
ScopedUpdate->AppendBlockingHitAfterMove(BlockingHit);
}
else
//.........这里部分代码省略.........