本文整理汇总了C++中TInlineComponentArray::Num方法的典型用法代码示例。如果您正苦于以下问题:C++ TInlineComponentArray::Num方法的具体用法?C++ TInlineComponentArray::Num怎么用?C++ TInlineComponentArray::Num使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TInlineComponentArray
的用法示例。
在下文中一共展示了TInlineComponentArray::Num方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetActorSelectionFlags
void UUnrealEdEngine::SetActorSelectionFlags (AActor* InActor)
{
TInlineComponentArray<UActorComponent*> Components;
InActor->GetComponents(Components);
//for every component in the actor
for(int32 ComponentIndex = 0; ComponentIndex < Components.Num(); ComponentIndex++)
{
UActorComponent* Component = Components[ComponentIndex];
if (Component->IsRegistered())
{
// If we have a 'child actor' component, want to update its visible selection state
UChildActorComponent* ChildActorComponent = Cast<UChildActorComponent>(Component);
if(ChildActorComponent != NULL && ChildActorComponent->ChildActor != NULL)
{
SetActorSelectionFlags(ChildActorComponent->ChildActor);
}
UPrimitiveComponent* PrimComponent = Cast<UPrimitiveComponent>(Component);
if(PrimComponent != NULL && PrimComponent->IsRegistered())
{
PrimComponent->PushSelectionToProxy();
}
UDecalComponent* DecalComponent = Cast<UDecalComponent>(Component);
if(DecalComponent != NULL)// && DecalComponent->IsRegistered())
{
DecalComponent->PushSelectionToProxy();
}
}
}
}
示例2: DrawComponentVisualizersHUD
void UUnrealEdEngine::DrawComponentVisualizersHUD(const FViewport* Viewport, const FSceneView* View, FCanvas* Canvas)
{
// Iterate over all selected actors
for (FSelectionIterator It(GetSelectedActorIterator()); It; ++It)
{
AActor* Actor = Cast<AActor>(*It);
if (Actor != NULL)
{
// Then iterate over components of that actor
TInlineComponentArray<UActorComponent*> Components;
Actor->GetComponents(Components);
for (int32 CompIdx = 0; CompIdx<Components.Num(); CompIdx++)
{
UActorComponent* Comp = Components[CompIdx];
if (Comp->IsRegistered())
{
// Try and find a visualizer
TSharedPtr<FComponentVisualizer> Visualizer = FindComponentVisualizer(Comp->GetClass());
if (Visualizer.IsValid())
{
Visualizer->DrawVisualizationHUD(Comp, Viewport, View, Canvas);
}
}
}
}
}
}
示例3: AcquireSkeletonFromObjectGuid
USkeleton* FAnimationTrackEditor::AcquireSkeletonFromObjectGuid(const FGuid& Guid)
{
TArray<UObject*> OutObjects;
GetSequencer()->GetRuntimeObjects(GetSequencer()->GetFocusedMovieSceneInstance(), Guid, OutObjects);
USkeleton* Skeleton = NULL;
for (int32 i = 0; i < OutObjects.Num(); ++i)
{
AActor* Actor = Cast<AActor>(OutObjects[i]);
if (Actor != NULL)
{
TInlineComponentArray<USkeletalMeshComponent*> SkeletalMeshComponents;
Actor->GetComponents(SkeletalMeshComponents);
for (int32 j = 0; j <SkeletalMeshComponents.Num(); ++j)
{
USkeletalMeshComponent* SkeletalMeshComp = SkeletalMeshComponents[j];
if (SkeletalMeshComp->SkeletalMesh && SkeletalMeshComp->SkeletalMesh->Skeleton)
{
// @todo Multiple actors, multiple components
check(!Skeleton);
Skeleton = SkeletalMeshComp->SkeletalMesh->Skeleton;
}
}
}
}
return Skeleton;
}
示例4: CheckForErrors
void AActor::CheckForErrors()
{
if ( GetClass()->HasAnyClassFlags(CLASS_Deprecated) )
{
FFormatNamedArguments Arguments;
Arguments.Add(TEXT("ActorName"), FText::FromString(GetName()));
FMessageLog("MapCheck").Warning()
->AddToken(FUObjectToken::Create(this))
->AddToken(FTextToken::Create(FText::Format(LOCTEXT( "MapCheck_Message_ActorIsObselete_Deprecated", "{ActorName} : Obsolete and must be removed! (Class is deprecated)" ), Arguments) ))
->AddToken(FMapErrorToken::Create(FMapErrors::ActorIsObselete));
return;
}
if ( GetClass()->HasAnyClassFlags(CLASS_Abstract) )
{
FFormatNamedArguments Arguments;
Arguments.Add(TEXT("ActorName"), FText::FromString(GetName()));
FMessageLog("MapCheck").Warning()
->AddToken(FUObjectToken::Create(this))
->AddToken(FTextToken::Create(FText::Format(LOCTEXT( "MapCheck_Message_ActorIsObselete_Abstract", "{ActorName} : Obsolete and must be removed! (Class is abstract)" ), Arguments) ))
->AddToken(FMapErrorToken::Create(FMapErrors::ActorIsObselete));
return;
}
UPrimitiveComponent* PrimComp = Cast<UPrimitiveComponent>(RootComponent);
if( PrimComp && (PrimComp->Mobility != EComponentMobility::Movable) && PrimComp->BodyInstance.bSimulatePhysics)
{
FFormatNamedArguments Arguments;
Arguments.Add(TEXT("ActorName"), FText::FromString(GetName()));
FMessageLog("MapCheck").Warning()
->AddToken(FUObjectToken::Create(this))
->AddToken(FTextToken::Create(FText::Format(LOCTEXT( "MapCheck_Message_StaticPhysNone", "{ActorName} : Static object with bSimulatePhysics set to true" ), Arguments) ))
->AddToken(FMapErrorToken::Create(FMapErrors::StaticPhysNone));
}
if( RootComponent && FMath::IsNearlyZero( GetRootComponent()->RelativeScale3D.X * GetRootComponent()->RelativeScale3D.Y * GetRootComponent()->RelativeScale3D.Z ) )
{
FFormatNamedArguments Arguments;
Arguments.Add(TEXT("ActorName"), FText::FromString(GetName()));
FMessageLog("MapCheck").Error()
->AddToken(FUObjectToken::Create(this))
->AddToken(FTextToken::Create(FText::Format(LOCTEXT( "MapCheck_Message_InvalidDrawscale", "{ActorName} : Invalid DrawScale/DrawScale3D" ), Arguments) ))
->AddToken(FMapErrorToken::Create(FMapErrors::InvalidDrawscale));
}
// Route error checking to components.
TInlineComponentArray<UActorComponent*> Components;
GetComponents(Components);
for ( int32 ComponentIndex = 0 ; ComponentIndex < Components.Num() ; ++ComponentIndex )
{
UActorComponent* ActorComponent = Components[ ComponentIndex ];
if (ActorComponent->IsRegistered())
{
ActorComponent->CheckForErrors();
}
}
}
示例5: RemoveViewFromActorViewVisibility
void FLayers::RemoveViewFromActorViewVisibility( FLevelEditorViewportClient* ViewportClient )
{
const int32 ViewIndex = ViewportClient->ViewIndex;
// get the bit for the view index
uint64 ViewBit = ((uint64)1 << ViewIndex);
// get all bits under that that we want to keep
uint64 KeepBits = ViewBit - 1;
// Iterate over all actors, looking for actors in the specified layers.
for( FActorIterator It(ViewportClient->GetWorld()) ; It ; ++It )
{
const TWeakObjectPtr< AActor > Actor = *It;
if( !IsActorValidForLayer( Actor ) )
{
continue;
}
// remember original bits
uint64 OriginalHiddenViews = Actor->HiddenEditorViews;
uint64 Was = Actor->HiddenEditorViews;
// slide all bits higher than ViewIndex down one since the view is being removed from Editor
uint64 LowBits = Actor->HiddenEditorViews & KeepBits;
// now slide the top bits down by ViewIndex + 1 (chopping off ViewBit)
uint64 HighBits = Actor->HiddenEditorViews >> (ViewIndex + 1);
// then slide back up by ViewIndex, which will now have erased ViewBit, as well as leaving 0 in the low bits
HighBits = HighBits << ViewIndex;
// put it all back together
Actor->HiddenEditorViews = LowBits | HighBits;
// reregister if we changed the visibility bits, as the rendering thread needs them
if (OriginalHiddenViews == Actor->HiddenEditorViews)
{
continue;
}
// Find all registered primitive components and update the scene proxy with the actors updated visibility map
TInlineComponentArray<UPrimitiveComponent*> Components;
Actor->GetComponents(Components);
for( int32 ComponentIdx = 0; ComponentIdx < Components.Num(); ++ComponentIdx )
{
UPrimitiveComponent* PrimitiveComponent = Components[ComponentIdx];
if (PrimitiveComponent->IsRegistered())
{
// Push visibility to the render thread
PrimitiveComponent->PushEditorVisibilityToProxy( Actor->HiddenEditorViews );
}
}
}
}
示例6: Tick
void FSCSEditorViewportClient::Tick(float DeltaSeconds)
{
FEditorViewportClient::Tick(DeltaSeconds);
// Register the selection override delegate for the preview actor's components
TSharedPtr<SSCSEditor> SCSEditor = BlueprintEditorPtr.Pin()->GetSCSEditor();
AActor* PreviewActor = GetPreviewActor();
if (PreviewActor != nullptr)
{
TInlineComponentArray<UPrimitiveComponent*> PrimitiveComponents;
PreviewActor->GetComponents(PrimitiveComponents);
for (int32 CompIdx = 0; CompIdx < PrimitiveComponents.Num(); ++CompIdx)
{
UPrimitiveComponent* PrimComponent = PrimitiveComponents[CompIdx];
if (!PrimComponent->SelectionOverrideDelegate.IsBound())
{
SCSEditor->SetSelectionOverride(PrimComponent);
}
}
}
else
{
InvalidatePreview(false);
}
if ( PreviewActor != LastPreviewActor.Get() || PreviewActor == nullptr || IsRealtime() )
{
LastPreviewActor = PreviewActor;
Invalidate();
RefreshPreviewBounds();
}
// Tick the preview scene world.
if (!GIntraFrameDebuggingGameThread)
{
// Ensure that the preview actor instance is up-to-date for component editing (e.g. after compiling the Blueprint, the actor may be reinstanced outside of this class)
if(PreviewActor != BlueprintEditorPtr.Pin()->GetBlueprintObj()->SimpleConstructionScript->GetComponentEditorActorInstance())
{
BlueprintEditorPtr.Pin()->GetBlueprintObj()->SimpleConstructionScript->SetComponentEditorActorInstance(PreviewActor);
}
// Allow full tick only if preview simulation is enabled and we're not currently in an active SIE or PIE session
if(bIsSimulateEnabled && GEditor->PlayWorld == NULL && !GEditor->bIsSimulatingInEditor)
{
PreviewScene->GetWorld()->Tick(IsRealtime() ? LEVELTICK_All : LEVELTICK_TimeOnly, DeltaSeconds);
}
else
{
PreviewScene->GetWorld()->Tick(IsRealtime() ? LEVELTICK_ViewportsOnly : LEVELTICK_TimeOnly, DeltaSeconds);
}
}
}
示例7: HideActorComponents
void USceneCaptureComponent::HideActorComponents(AActor* InActor)
{
if (InActor)
{
TInlineComponentArray<UPrimitiveComponent*> PrimitiveComponents;
InActor->GetComponents(PrimitiveComponents);
for (int32 ComponentIndex = 0, NumComponents = PrimitiveComponents.Num(); ComponentIndex < NumComponents; ++ComponentIndex)
{
HiddenComponents.AddUnique(PrimitiveComponents[ComponentIndex]);
}
}
}
示例8: IsActorValidForMaterialApplication
/**
* Determines if the provided actor is capable of having a material applied to it.
*
* @param TargetActor Actor to check for the validity of material application
*
* @return true if the actor is valid for material application; false otherwise
*/
bool FActorFactoryAssetProxy::IsActorValidForMaterialApplication( AActor* TargetActor )
{
bool bIsValid = false;
//@TODO: PAPER2D: Extend this to support non mesh components (or make sprites a mesh component)
// Check if the actor has a mesh or fog volume density. If so, it can likely have
// a material applied to it. Otherwise, it cannot.
if ( TargetActor )
{
TInlineComponentArray<UMeshComponent*> MeshComponents;
TargetActor->GetComponents(MeshComponents);
bIsValid = (MeshComponents.Num() > 0);
}
return bIsValid;
}
示例9: SelectComponent
void UUnrealEdEngine::SelectComponent(UActorComponent* Component, bool bInSelected, bool bNotify, bool bSelectEvenIfHidden)
{
// Don't do any work if the component's selection state matches the target selection state
const bool bComponentSelected = GetSelectedComponents()->IsSelected(Component);
if (( bComponentSelected && !bInSelected ) || ( !bComponentSelected && bInSelected ))
{
if (bInSelected)
{
UE_LOG(LogEditorSelectUtils, Verbose, TEXT("Selected Component: %s"), *Component->GetClass()->GetName());
}
else
{
UE_LOG(LogEditorSelectUtils, Verbose, TEXT("Deselected Component: %s"), *Component->GetClass()->GetName());
}
GetSelectedComponents()->Select(Component, bInSelected);
// Make sure the override delegate is bound properly
auto SceneComponent = Cast<USceneComponent>(Component);
if (SceneComponent)
{
FComponentEditorUtils::BindComponentSelectionOverride(SceneComponent, true);
}
// Update the selection visualization
AActor* ComponentOwner = Component->GetOwner();
if (ComponentOwner != nullptr)
{
TInlineComponentArray<UPrimitiveComponent*> PrimitiveComponents;
ComponentOwner->GetComponents(PrimitiveComponents);
for (int32 Idx = 0; Idx < PrimitiveComponents.Num(); ++Idx)
{
PrimitiveComponents[Idx]->PushSelectionToProxy();
}
}
if (bNotify)
{
NoteSelectionChange();
}
}
}
示例10: ProcessNewComponentArray
void UActorRecording::ProcessNewComponentArray(TInlineComponentArray<USceneComponent*>& ProspectiveComponents) const
{
// Only iterate as far as the current size of the array (it may grow inside the loop)
int32 LastIndex = ProspectiveComponents.Num();
for(int32 Index = 0; Index < LastIndex; ++Index)
{
USceneComponent* NewComponent = ProspectiveComponents[Index];
USceneComponent* Parent = ProspectiveComponents[Index]->GetAttachParent();
while (Parent)
{
TWeakObjectPtr<USceneComponent> WeakParent(Parent);
if (TrackedComponents.Contains(WeakParent) || ProspectiveComponents.Contains(Parent) || Parent->GetOwner() != NewComponent->GetOwner())
{
break;
}
else
{
ProspectiveComponents.Add(Parent);
}
Parent = Parent->GetAttachParent();
}
}
// Sort parent first, to ensure that attachments get added properly
TMap<USceneComponent*, int32> AttachmentDepths;
for (USceneComponent* Component : ProspectiveComponents)
{
AttachmentDepths.Add(Component, GetAttachmentDepth(Component));
}
ProspectiveComponents.Sort(
[&](USceneComponent& A, USceneComponent& B)
{
return *AttachmentDepths.Find(&A) < *AttachmentDepths.Find(&B);
}
);
}
示例11: DrawSnapVertices
static void DrawSnapVertices( AActor* Actor, float PointSize, FPrimitiveDrawInterface* PDI )
{
TInlineComponentArray<UActorComponent*> Components;
Actor->GetComponents(Components);
// Get the closest vertex on each component
for( int32 ComponentIndex = 0; ComponentIndex < Components.Num(); ++ComponentIndex )
{
TSharedPtr<FVertexIterator> VertexGetter = MakeVertexIterator( Cast<UPrimitiveComponent>( Components[ComponentIndex] ) );
if( VertexGetter.IsValid() )
{
FVertexIterator& VertexGetterRef = *VertexGetter;
for( ; VertexGetterRef; ++VertexGetterRef )
{
PDI->DrawPoint( VertexGetterRef.Position(), VertexSnappingConstants::VertexHelperColor, PointSize, SDPG_World );
}
}
else
{
PDI->DrawPoint( Actor->GetActorLocation(), VertexSnappingConstants::VertexHelperColor, PointSize, SDPG_World );
}
}
}
示例12: PreCreateKeyframe
bool UMatineeTrackAnimControlHelper::PreCreateKeyframe( UInterpTrack *Track, float fTime ) const
{
KeyframeAddAnimSequence = NULL;
UInterpTrackAnimControl *AnimTrack = CastChecked<UInterpTrackAnimControl>(Track);
UInterpGroup* Group = CastChecked<UInterpGroup>(Track->GetOuter());
AActor* Actor = GetGroupActor(Track);
if (!Actor)
{
// error message
UE_LOG(LogSlateMatinee, Warning, TEXT("No Actor is selected. Select actor first."));
return false;
}
USkeletalMeshComponent * SkelMeshComp = NULL;
TInlineComponentArray<USkeletalMeshComponent*> SkeletalMeshComponents;
Actor->GetComponents(SkeletalMeshComponents);
for (int32 I=0; I<SkeletalMeshComponents.Num(); ++I)
{
USkeletalMeshComponent * CurSkelMeshComp = SkeletalMeshComponents[I];
// if qualified to play animation, break
if (CurSkelMeshComp->SkeletalMesh && CurSkelMeshComp->SkeletalMesh->Skeleton)
{
SkelMeshComp = CurSkelMeshComp;
break;
}
}
if (!SkelMeshComp)
{
UE_LOG(LogSlateMatinee, Warning, TEXT("SkeletalMeshComponent isn't found in the selected actor or it does not have Mesh/Skeleton set up in order to play animation"));
return false;
}
USkeleton* Skeleton = SkelMeshComp->SkeletalMesh->Skeleton;
if ( Skeleton )
{
// Show the dialog.
FEdModeInterpEdit* Mode = (FEdModeInterpEdit*)GLevelEditorModeTools().GetActiveMode( FBuiltinEditorModes::EM_InterpEdit );
check(Mode != NULL);
check(Mode->InterpEd != NULL);
TSharedPtr< SWindow > Parent = FSlateApplication::Get().GetActiveTopLevelWindow();
if ( Parent.IsValid() )
{
FAssetPickerConfig AssetPickerConfig;
AssetPickerConfig.OnAssetSelected = FOnAssetSelected::CreateUObject( this, &UMatineeTrackAnimControlHelper::OnAddKeyTextEntry, Mode->InterpEd, Track );
AssetPickerConfig.bAllowNullSelection = false;
AssetPickerConfig.InitialAssetViewType = EAssetViewType::List;
// Filter config
AssetPickerConfig.Filter.ClassNames.Add(UAnimSequence::StaticClass()->GetFName());
AssetPickerConfig.Filter.TagsAndValues.Add(TEXT("Skeleton"), FAssetData(Skeleton).GetExportTextName());
FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>(TEXT("ContentBrowser"));
FMenuBuilder MenuBuilder(true, NULL);
MenuBuilder.BeginSection(NAME_None, LOCTEXT("MatineeAnimPicker", "Browse"));
{
TSharedPtr<SBox> MenuEntry = SNew(SBox)
.WidthOverride(300.0f)
.HeightOverride(300.f)
[
ContentBrowserModule.Get().CreateAssetPicker(AssetPickerConfig)
];
MenuBuilder.AddWidget(MenuEntry.ToSharedRef(), FText::GetEmpty(), true);
}
MenuBuilder.EndSection();
EntryMenu = FSlateApplication::Get().PushMenu(
Parent.ToSharedRef(),
FWidgetPath(),
MenuBuilder.MakeWidget(),
FSlateApplication::Get().GetCursorPos(),
FPopupTransitionEffect(FPopupTransitionEffect::TypeInPopup)
);
}
}
else
{
FMessageDialog::Open( EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "NoAnimSeqsFound", "No AnimSequences Found. Make sure to load AnimSequences.") );
}
return false;
}
示例13: UpdateVolumeActorVisibility
void UUnrealEdEngine::UpdateVolumeActorVisibility( UClass* InVolumeActorClass, FLevelEditorViewportClient* InViewport )
{
TSubclassOf<AActor> VolumeClassToCheck = InVolumeActorClass ? InVolumeActorClass : AVolume::StaticClass();
// Build a list of actors that need to be updated. Only take actors of the passed in volume class.
UWorld* World = InViewport ? InViewport->GetWorld() : GWorld;
TArray< AActor *> ActorsToUpdate;
for( TActorIterator<AActor> It( World, VolumeClassToCheck ); It; ++It)
{
ActorsToUpdate.Add(*It);
}
if( ActorsToUpdate.Num() > 0 )
{
TArray< AActor* > ActorsThatChanged;
if( !InViewport )
{
// Update the visibility state of each actor for each viewport
for( int32 ViewportIdx = 0; ViewportIdx < LevelViewportClients.Num(); ++ViewportIdx )
{
FLevelEditorViewportClient& ViewClient = *LevelViewportClients[ViewportIdx];
{
// Only update the editor frame clients as those are the only viewports right now that show volumes.
InternalUpdateVolumeActorVisibility( ActorsToUpdate, ViewClient, ActorsThatChanged );
if( ActorsThatChanged.Num() )
{
// If actor visibility changed in the viewport, it needs to be redrawn
ViewClient.Invalidate();
}
}
}
}
else
{
// Only update the editor frame clients as those are the only viewports right now that show volumes.
InternalUpdateVolumeActorVisibility( ActorsToUpdate, *InViewport, ActorsThatChanged );
if( ActorsThatChanged.Num() )
{
// If actor visibility changed in the viewport, it needs to be redrawn
InViewport->Invalidate();
}
}
// Push all changes in the actors to the scene proxy so the render thread correctly updates visibility
for( int32 ActorIdx = 0; ActorIdx < ActorsThatChanged.Num(); ++ActorIdx )
{
AActor* ActorToUpdate = ActorsThatChanged[ ActorIdx ];
// Find all registered primitive components and update the scene proxy with the actors updated visibility map
TInlineComponentArray<UPrimitiveComponent*> PrimitiveComponents;
ActorToUpdate->GetComponents(PrimitiveComponents);
for( int32 ComponentIdx = 0; ComponentIdx < PrimitiveComponents.Num(); ++ComponentIdx )
{
UPrimitiveComponent* PrimitiveComponent = PrimitiveComponents[ComponentIdx];
if (PrimitiveComponent->IsRegistered())
{
// Push visibility to the render thread
PrimitiveComponent->PushEditorVisibilityToProxy( ActorToUpdate->HiddenEditorViews );
}
}
}
}
}
示例14: PostRender
void ADebugCameraHUD::PostRender()
{
Super::PostRender();
if (bShowHUD)
{
ADebugCameraController* DCC = Cast<ADebugCameraController>( PlayerOwner );
UFont* RenderFont = GEngine->GetSmallFont();
if( DCC != NULL )
{
FFontRenderInfo FontRenderInfo = Canvas->CreateFontRenderInfo(false, true);
Canvas->SetDrawColor(64, 64, 255, 255);
FString MyText = TEXT("Debug Camera");
float xl, yl;
Canvas->StrLen(RenderFont, MyText, xl, yl);
float X = Canvas->SizeX * 0.05f;
float Y = yl;//*1.67;
yl += 2*Y;
Canvas->DrawText(RenderFont, MyText, X, yl, 1.f, 1.f, FontRenderInfo);
Canvas->SetDrawColor(200, 200, 128, 255);
FVector const CamLoc = DCC->PlayerCameraManager->GetCameraLocation();
FRotator const CamRot = DCC->PlayerCameraManager->GetCameraRotation();
float const CamFOV = DCC->PlayerCameraManager->GetFOVAngle();
yl += Y;
FString const LocRotString = FString::Printf(TEXT("Loc=(%.1f, %.1f, %.1f) Rot=(%.1f, %.1f, %.1f)"), CamLoc.X, CamLoc.Y, CamLoc.Z, CamRot.Pitch, CamRot.Yaw, CamRot.Roll);
Canvas->DrawText(RenderFont, LocRotString, X, yl, 1.f, 1.f, FontRenderInfo);
yl += Y;
FString const FOVString = FString::Printf(TEXT("HFOV=%.1f"), CamFOV);
Canvas->DrawText(RenderFont, FOVString, X, yl, 1.f, 1.f, FontRenderInfo);
yl += Y;
FString const SpeedScaleString = FString::Printf(TEXT("SpeedScale=%.2fx"), DCC->SpeedScale);
Canvas->DrawText(RenderFont, SpeedScaleString, X, yl, 1.f, 1.f, FontRenderInfo);
yl += Y;
FString const SpeedString = FString::Printf(TEXT("MaxSpeed=%.1f"), DCC->GetSpectatorPawn() && DCC->GetSpectatorPawn()->GetMovementComponent() ? DCC->GetSpectatorPawn()->GetMovementComponent()->GetMaxSpeed() : 0.f);
Canvas->DrawText(RenderFont, SpeedString, X, yl, 1.f, 1.f, FontRenderInfo);
yl += Y;
//Canvas->DrawText(FString::Printf(TEXT("CamLoc:%s CamRot:%s"), *CamLoc.ToString(), *CamRot.ToString() ));
const TCHAR* CVarComplexName = TEXT("g.DebugCameraTraceComplex");
bool bTraceComplex = true;
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
bTraceComplex = CVarDebugCameraTraceComplex.GetValueOnGameThread() != 0;
#endif
FCollisionQueryParams TraceParams(NAME_None, bTraceComplex, this);
FHitResult Hit;
bool bHit = GetWorld()->LineTraceSingleByChannel(Hit, CamLoc, CamRot.Vector() * 100000.f + CamLoc, ECC_Pawn, TraceParams);
yl += Y;
Canvas->DrawText(RenderFont, FString::Printf(TEXT("Trace info (%s = %d):"), CVarComplexName, bTraceComplex ? 1 : 0), X, yl, 1.f, 1.f, FontRenderInfo);
if( bHit )
{
AActor* HitActor = Hit.GetActor();
yl += Y;
Canvas->DrawText(RenderFont, FString::Printf(TEXT("HitLoc:%s HitNorm:%s"), *Hit.Location.ToString(), *Hit.Normal.ToString() ), X, yl, 1.f, 1.f, FontRenderInfo);
yl += Y;
Canvas->DrawText(RenderFont, FString::Printf(TEXT("HitDist: %f"), Hit.Distance), X, yl, 1.f, 1.f, FontRenderInfo);
yl += Y;
Canvas->DrawText(RenderFont, FString::Printf(TEXT("HitActor: '%s'"), HitActor ? *HitActor->GetFName().ToString() : TEXT("<NULL>")), X, yl, 1.f, 1.f, FontRenderInfo);
yl += Y;
Canvas->DrawText(RenderFont, FString::Printf(TEXT("HitComponent: '%s'"), Hit.Component.Get() ? *Hit.Component.Get()->GetFName().ToString() : TEXT("<NULL>")), X, yl, 1.f, 1.f, FontRenderInfo);
yl += Y;
Canvas->DrawText(RenderFont, FString::Printf(TEXT("HitActor Class: '%s'"), HitActor && HitActor->GetClass() ? *HitActor->GetClass()->GetName() : TEXT("<Not Found>") ), X, yl, 1.f, 1.f, FontRenderInfo);
yl += Y;
Canvas->DrawText(RenderFont, FString::Printf(TEXT("HitActorPath: '%s'"), HitActor ? *HitActor->GetPathName() : TEXT("<Not Found>")), X, yl, 1.f, 1.f, FontRenderInfo);
yl += Y;
bool bFoundMaterial = false;
if ( Hit.Component != NULL )
{
bFoundMaterial = DisplayMaterials( X, yl, Y, Cast<UMeshComponent>(Hit.Component.Get()) );
}
else
{
TInlineComponentArray<UMeshComponent*> Components;
GetComponents(Components);
for ( int32 i=0; i<Components.Num(); i++ )
{
UMeshComponent* MeshComp = Components[i];
if ( MeshComp->IsRegistered() )
{
bFoundMaterial = bFoundMaterial || DisplayMaterials( X, yl, Y, MeshComp );
}
}
}
if ( bFoundMaterial == false )
{
yl += Y;
//.........这里部分代码省略.........
示例15: GetClosestVertex
FSnappingVertex FVertexSnappingImpl::GetClosestVertex( const TArray<FSnapActor>& Actors, const FVertexSnappingArgs& InArgs )
{
// The current closest distance
float ClosestDistance = FLT_MAX;
const FPlane& ActorPlane = InArgs.ActorPlane;
EAxisList::Type CurrentAxis = InArgs.CurrentAxis;
const FSceneView* View = InArgs.SceneView;
const FVector& CurrentLocation = InArgs.CurrentLocation;
const FVector2D& MousePosition = InArgs.MousePosition;
FSnappingVertex ClosestLocation( CurrentLocation );
AActor* ClosestActor = NULL;
// Find the closest vertex on each actor and then from that list find the closest vertex
for( int32 ActorIndex = 0; ActorIndex < Actors.Num(); ++ActorIndex )
{
const FSnapActor& SnapActor = Actors[ActorIndex];
AActor* Actor = SnapActor.Actor;
// Get the closest vertex on each component
TInlineComponentArray<UPrimitiveComponent*> PrimitiveComponents;
Actor->GetComponents(PrimitiveComponents);
for( int32 ComponentIndex = 0; ComponentIndex < PrimitiveComponents.Num(); ++ComponentIndex )
{
FSnappingVertex ClosestLocationOnComponent( CurrentLocation );
if( !GetClosestVertexOnComponent( SnapActor, PrimitiveComponents[ComponentIndex], InArgs, ClosestLocationOnComponent ) )
{
ClosestLocationOnComponent.Position = Actor->GetActorLocation();
ClosestLocationOnComponent.Normal = FVector::ZeroVector;
}
float Distance = 0;
if( CurrentAxis != EAxisList::Screen )
{
// Compute the distance from the point being snapped. When not in screen space we snap to the plane created by the current closest vertex
Distance = ActorPlane.PlaneDot( ClosestLocationOnComponent.Position );
}
else
{
// Favor the vertex closest to the mouse in screen space
FVector2D ComponentLocPixel;
if( View->WorldToPixel( ClosestLocationOnComponent.Position, ComponentLocPixel ) )
{
Distance = FVector::DistSquared( FVector( MousePosition, 0 ), FVector( ComponentLocPixel, 0 ) );
}
}
if(
// A close vertex must have been found
ClosestLocationOnComponent.Position != CurrentLocation
// we must have made some movement
&& !FMath::IsNearlyZero(Distance)
// If not in screen space the vertex cannot be behind the point being snapped
&& ( CurrentAxis == EAxisList::Screen || !FMath::IsNegativeFloat( Distance ) )
// The vertex must be closer than the current closest vertex
&& Distance < ClosestDistance )
{
ClosestActor = Actor;
ClosestDistance = Distance;
ClosestLocation = ClosestLocationOnComponent;
}
}
}
if( InArgs.bDrawVertexHelpers )
{
if(ActorVertsToDraw.IsValid())
{
ActorVertsToFade.Add(ActorVertsToDraw, FApp::GetCurrentTime());
}
ActorVertsToFade.Remove(ClosestActor);
ActorVertsToDraw = ClosestActor;
}
else
{
ActorVertsToDraw = nullptr;
ActorVertsToFade.Empty();
}
return ClosestLocation;
}