本文整理汇总了C++中TArray::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::Add方法的具体用法?C++ TArray::Add怎么用?C++ TArray::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Construct
void SAnimSegmentsPanel::Construct(const FArguments& InArgs)
{
bDragging = false;
const int32 NumTracks = 2;
AnimTrack = InArgs._AnimTrack;
ViewInputMin = InArgs._ViewInputMin;
ViewInputMax = InArgs._ViewInputMax;
OnAnimSegmentNodeClickedDelegate = InArgs._OnAnimSegmentNodeClicked;
OnPreAnimUpdateDelegate = InArgs._OnPreAnimUpdate;
OnPostAnimUpdateDelegate = InArgs._OnPostAnimUpdate;
// Animation Segment tracks
TArray<TSharedPtr<STrack>> AnimSTracks;
TArray<TSharedPtr<STrackNode>> AnimNodes;
FLinearColor SelectedColor = FLinearColor(1.0f,0.65,0.0f);
TSharedPtr<SVerticalBox> AnimSegmentTracks;
ChildSlot
[
SAssignNew(AnimSegmentTracks, SVerticalBox)
];
for (int32 TrackIdx=0; TrackIdx < NumTracks; TrackIdx++)
{
TSharedPtr<STrack> AnimSegmentTrack;
AnimSegmentTracks->AddSlot()
.AutoHeight()
.VAlign(VAlign_Center)
.Padding( FMargin(0.5f, 0.5f) )
[
SAssignNew(AnimSegmentTrack, STrack)
.TrackColor( InArgs._ColorTracker->GetNextColor() )
.ViewInputMin(ViewInputMin)
.ViewInputMax(ViewInputMax)
.TrackMaxValue( InArgs._TrackMaxValue)
//section stuff
.OnBarDrag(InArgs._OnBarDrag)
.OnBarDrop(InArgs._OnBarDrop)
.OnBarClicked(InArgs._OnBarClicked)
.DraggableBars(InArgs._DraggableBars)
.DraggableBarSnapPositions(InArgs._DraggableBarSnapPositions)
.TrackNumDiscreteValues(InArgs._TrackNumDiscreteValues)
.OnTrackRightClickContextMenu( InArgs._OnTrackRightClickContextMenu )
.ScrubPosition( InArgs._ScrubPosition )
.OnTrackDragDrop( this, &SAnimSegmentsPanel::OnTrackDragDrop )
];
AnimSTracks.Add(AnimSegmentTrack);
}
// Generate Nodes and map them to tracks
for ( int32 SegmentIdx=0; SegmentIdx < AnimTrack->AnimSegments.Num(); SegmentIdx++ )
{
AnimSTracks[ SegmentIdx % AnimSTracks.Num() ]->AddTrackNode(
SNew(STrackNode)
.ViewInputMax(this->ViewInputMax)
.ViewInputMin(this->ViewInputMin)
.NodeColor(InArgs._NodeColor)
.SelectedNodeColor(SelectedColor)
.DataLength(this, &SAnimSegmentsPanel::GetSegmentLength, SegmentIdx)
.DataStartPos(this, &SAnimSegmentsPanel::GetSegmentStartPos, SegmentIdx)
.NodeName(this, &SAnimSegmentsPanel::GetAnimSegmentName, SegmentIdx)
.ToolTipText(this, &SAnimSegmentsPanel::GetAnimSegmentDetailedInfo, SegmentIdx)
.OnTrackNodeDragged( this, &SAnimSegmentsPanel::SetSegmentStartPos, SegmentIdx )
.OnTrackNodeDropped( this, &SAnimSegmentsPanel::OnSegmentDropped, SegmentIdx)
.OnNodeRightClickContextMenu( this, &SAnimSegmentsPanel::SummonSegmentNodeContextMenu, SegmentIdx)
.OnTrackNodeClicked( this, &SAnimSegmentsPanel::OnAnimSegmentNodeClicked, SegmentIdx )
.NodeSelectionSet(InArgs._NodeSelectionSet)
);
}
}
示例2: EvaluateBoneTransforms
//.........这里部分代码省略.........
const float CosAngle = (TwoAB != 0.f) ? ((UpperLimbLength*UpperLimbLength) + (DesiredLength*DesiredLength) - (LowerLimbLength*LowerLimbLength)) / TwoAB : 0.f;
// If CosAngle is less than 0, the upper arm actually points the opposite way to DesiredDir, so we handle that.
const bool bReverseUpperBone = (CosAngle < 0.f);
// If CosAngle is greater than 1.f, the triangle could not be made - we cannot reach the target.
// We just have the two limbs double back on themselves, and EndPos will not equal the desired EffectorLocation.
if ((CosAngle > 1.f) || (CosAngle < -1.f))
{
// Because we want the effector to be a positive distance down DesiredDir, we go back by the smaller section.
if (UpperLimbLength > LowerLimbLength)
{
OutJointPos = RootPos + (UpperLimbLength * DesiredDir);
OutEndPos = OutJointPos - (LowerLimbLength * DesiredDir);
}
else
{
OutJointPos = RootPos - (UpperLimbLength * DesiredDir);
OutEndPos = OutJointPos + (LowerLimbLength * DesiredDir);
}
}
else
{
// Angle between upper limb and DesiredDir
const float Angle = FMath::Acos(CosAngle);
// Now we calculate the distance of the joint from the root -> effector line.
// This forms a right-angle triangle, with the upper limb as the hypotenuse.
const float JointLineDist = UpperLimbLength * FMath::Sin(Angle);
// And the final side of that triangle - distance along DesiredDir of perpendicular.
// ProjJointDistSqr can't be neg, because JointLineDist must be <= UpperLimbLength because appSin(Angle) is <= 1.
const float ProjJointDistSqr = (UpperLimbLength*UpperLimbLength) - (JointLineDist*JointLineDist);
// although this shouldn't be ever negative, sometimes Xbox release produces -0.f, causing ProjJointDist to be NaN
// so now I branch it.
float ProjJointDist = (ProjJointDistSqr>0.f)? FMath::Sqrt(ProjJointDistSqr) : 0.f;
if( bReverseUpperBone )
{
ProjJointDist *= -1.f;
}
// So now we can work out where to put the joint!
OutJointPos = RootPos + (ProjJointDist * DesiredDir) + (JointLineDist * JointBendDir);
}
}
// Update transform for upper bone.
{
// Get difference in direction for old and new joint orientations
FVector const OldDir = (InitialJointPos - RootPos).GetSafeNormal();
FVector const NewDir = (OutJointPos - RootPos).GetSafeNormal();
// Find Delta Rotation take takes us from Old to New dir
FQuat const DeltaRotation = FQuat::FindBetween(OldDir, NewDir);
// Rotate our Joint quaternion by this delta rotation
UpperLimbCSTransform.SetRotation( DeltaRotation * UpperLimbCSTransform.GetRotation() );
// And put joint where it should be.
UpperLimbCSTransform.SetTranslation( RootPos );
// Order important. First bone is upper limb.
OutBoneTransforms.Add( FBoneTransform(UpperLimbIndex, UpperLimbCSTransform) );
}
// Update transform for lower bone.
{
// Get difference in direction for old and new joint orientations
FVector const OldDir = (InitialEndPos - InitialJointPos).GetSafeNormal();
FVector const NewDir = (OutEndPos - OutJointPos).GetSafeNormal();
// Find Delta Rotation take takes us from Old to New dir
FQuat const DeltaRotation = FQuat::FindBetween(OldDir, NewDir);
// Rotate our Joint quaternion by this delta rotation
LowerLimbCSTransform.SetRotation( DeltaRotation * LowerLimbCSTransform.GetRotation() );
// And put joint where it should be.
LowerLimbCSTransform.SetTranslation( OutJointPos );
// Order important. Second bone is lower limb.
OutBoneTransforms.Add( FBoneTransform(LowerLimbIndex, LowerLimbCSTransform) );
}
// Update transform for end bone.
{
if( bTakeRotationFromEffectorSpace )
{
EndBoneCSTransform.SetRotation( EffectorTransform.GetRotation() );
}
else if( bMaintainEffectorRelRot )
{
EndBoneCSTransform = EndBoneLocalTransform * LowerLimbCSTransform;
}
// Set correct location for end bone.
EndBoneCSTransform.SetTranslation(OutEndPos);
// Order important. Third bone is End Bone.
OutBoneTransforms.Add( FBoneTransform(IKBone.BoneIndex, EndBoneCSTransform) );
}
// Make sure we have correct number of bones
check(OutBoneTransforms.Num() == 3);
}
示例3: DumpSharedMemoryUsage
void FPhysxSharedData::DumpSharedMemoryUsage(FOutputDevice* Ar)
{
struct FSharedResourceEntry
{
uint64 MemorySize;
uint64 Count;
};
struct FSortBySize
{
FORCEINLINE bool operator()( const FSharedResourceEntry& A, const FSharedResourceEntry& B ) const
{
// Sort descending
return B.MemorySize < A.MemorySize;
}
};
TMap<FString, FSharedResourceEntry> AllocationsByType;
uint64 OverallSize = 0;
int32 OverallCount = 0;
TMap<FString, TArray<PxBase*> > ObjectsByType;
for (int32 i=0; i < (int32)SharedObjects->getNbObjects(); ++i)
{
PxBase& Obj = SharedObjects->getObject(i);
FString TypeName = ANSI_TO_TCHAR(Obj.getConcreteTypeName());
TArray<PxBase*>* ObjectsArray = ObjectsByType.Find(TypeName);
if (ObjectsArray == NULL)
{
ObjectsByType.Add(TypeName, TArray<PxBase*>());
ObjectsArray = ObjectsByType.Find(TypeName);
}
check(ObjectsArray);
ObjectsArray->Add(&Obj);
}
TArray<FString> TypeNames;
ObjectsByType.GetKeys(TypeNames);
for (int32 TypeIdx=0; TypeIdx < TypeNames.Num(); ++TypeIdx)
{
const FString& TypeName = TypeNames[TypeIdx];
TArray<PxBase*>* ObjectsArray = ObjectsByType.Find(TypeName);
check(ObjectsArray);
PxSerializationRegistry* Sr = PxSerialization::createSerializationRegistry(*GPhysXSDK);
PxCollection* Collection = PxCreateCollection();
for (int32 i=0; i < ObjectsArray->Num(); ++i)
{
Collection->add(*((*ObjectsArray)[i]));;
}
PxSerialization::complete(*Collection, *Sr); // chase all other stuff (shared shaps, materials, etc) needed to serialize this collection
FPhysXCountMemoryStream Out;
PxSerialization::serializeCollectionToBinary(Out, *Collection, *Sr);
Collection->release();
Sr->release();
OverallSize += Out.UsedMemory;
OverallCount += ObjectsArray->Num();
FSharedResourceEntry NewEntry;
NewEntry.Count = ObjectsArray->Num();
NewEntry.MemorySize = Out.UsedMemory;
AllocationsByType.Add(TypeName, NewEntry);
}
Ar->Logf(TEXT(""));
Ar->Logf(TEXT("Shared Resources:"));
Ar->Logf(TEXT(""));
AllocationsByType.ValueSort(FSortBySize());
Ar->Logf(TEXT("%-10d %s (%d)"), OverallSize, TEXT("Overall"), OverallCount );
for( auto It=AllocationsByType.CreateConstIterator(); It; ++It )
{
Ar->Logf(TEXT("%-10d %s (%d)"), It.Value().MemorySize, *It.Key(), It.Value().Count );
}
}
示例4: Update
void FMovieSceneSkeletalAnimationTrackInstance::Update( EMovieSceneUpdateData& UpdateData, const TArray<TWeakObjectPtr<UObject>>& RuntimeObjects, class IMovieScenePlayer& Player, FMovieSceneSequenceInstance& SequenceInstance )
{
if (UpdateData.UpdatePass == MSUP_PreUpdate)
{
UpdateRefreshBones(RuntimeObjects);
return;
}
// @todo Sequencer gameplay update has a different code path than editor update for animation
for ( TWeakObjectPtr<UObject> RuntimeObjectPtr : RuntimeObjects )
{
USkeletalMeshComponent* SkeletalMeshComponent = GetSkeletalMeshComponentFromRuntimeObjectPtr( RuntimeObjectPtr );
if ( SkeletalMeshComponent )
{
TArray<UMovieSceneSection*> AnimSections = AnimationTrack->GetAnimSectionsAtTime( UpdateData.Position );
// cbb: If there is no overlapping section, evaluate the closest section only if the current time is before it.
if (AnimSections.Num() == 0)
{
UMovieSceneSection* NearestSection = MovieSceneHelpers::FindNearestSectionAtTime( AnimationTrack->GetAllSections(), UpdateData.Position );
if (NearestSection)
{
AnimSections.Add(NearestSection);
}
}
for (int32 AnimSectionIndex = 0; AnimSectionIndex < AnimSections.Num(); ++AnimSectionIndex)
{
UMovieSceneSkeletalAnimationSection* AnimSection = Cast<UMovieSceneSkeletalAnimationSection>( AnimSections[AnimSectionIndex] );
if ( AnimSection && AnimSection->IsActive() )
{
UAnimSequenceBase* AnimSequence = AnimSection->GetAnimSequence();
if ( AnimSequence )
{
float EvalTime = MapTimeToAnimation( UpdateData.Position, AnimSection );
int32 ChannelIndex = 0;
const bool bLooping = false;
if ( ShouldUsePreviewPlayback( Player, SkeletalMeshComponent ) )
{
// If the playback status is jumping, ie. one such occurrence is setting the time for thumbnail generation, disable anim notifies updates because it could fire audio
const bool bFireNotifies = Player.GetPlaybackStatus() == EMovieScenePlayerStatus::Jumping || Player.GetPlaybackStatus() == EMovieScenePlayerStatus::Stopped ? false : true;
float DeltaTime = UpdateData.Position > UpdateData.LastPosition ? UpdateData.Position - UpdateData.LastPosition : 0.f;
// When jumping from one cut to another cut, the delta time should be 0 so that anim notifies before the current position are not evaluated. Note, anim notifies at the current time should still be evaluated.
if ( UpdateData.bJumpCut )
{
DeltaTime = 0.f;
}
const bool bResetDynamics = Player.GetPlaybackStatus() == EMovieScenePlayerStatus::Stepping ||
Player.GetPlaybackStatus() == EMovieScenePlayerStatus::Jumping ||
Player.GetPlaybackStatus() == EMovieScenePlayerStatus::Scrubbing ||
( DeltaTime == 0.0f && Player.GetPlaybackStatus() != EMovieScenePlayerStatus::Stopped );
PreviewSetAnimPosition( SkeletalMeshComponent, AnimSection->GetSlotName(), ChannelIndex, AnimSequence, EvalTime, bLooping, bFireNotifies, DeltaTime, Player.GetPlaybackStatus() == EMovieScenePlayerStatus::Playing, bResetDynamics );
}
else
{
// Don't fire notifies at runtime since they will be fired through the standard animation tick path.
const bool bFireNotifies = false;
SetAnimPosition( SkeletalMeshComponent, AnimSection->GetSlotName(), ChannelIndex, AnimSequence, EvalTime, bLooping, bFireNotifies );
}
}
}
}
}
}
}
示例5: Update
void FogWorker::Update(float time)
{
// Debug stuff
static const FName TraceTag(TEXT("FOWTrace"));
const UWorld* world = Manager.GetWorld();
if(!world)
{
return;
}
UpdateRenderOrigin();
FVector origin, SurfaceExtent;
Manager.GetActorBounds(false, origin, SurfaceExtent);
if(FMath::IsNearlyZero(SurfaceExtent.Size2D()))
{
return;
}
ForgetOldLocations(time);
// Cache observers location
TArray<FVector> observers;
observers.Reserve(Manager.Observers.Num());
for(const auto& o : Manager.Observers)
{
if(o->IsValidLowLevel())
{
observers.Add(o->GetActorLocation());
}
}
// iterate through observers to unveil fog
for(auto& observerLocation : observers)
{
FVector2D observerTexLoc(observerLocation - Manager.CameraPosition);
TArray<FVector2D> sightShape;
observerTexLoc /= FVector2D(SurfaceExtent);
observerTexLoc *= TextureSize / 2.0f;
observerTexLoc += FVector2D(TextureSize / 2.0f, TextureSize / 2.0f);
FCollisionQueryParams queryParams(TraceTag, true);
for(float i = 0; i < 2 * PI; i += HALF_PI / 100.0f)
{
auto x = Manager.SightRange * FMath::Cos(i);
auto y = Manager.SightRange * FMath::Sin(i);
FVector sightLoc = observerLocation + FVector(x, y, 0);
FHitResult hit;
if(world->LineTraceSingleByChannel(hit, observerLocation, sightLoc, ECC_GameTraceChannel2, queryParams))
{
sightLoc = hit.Location;
}
FVector2D hitTexLoc;
if(FSceneView::ProjectWorldToScreen(sightLoc, FIntRect(0, 0, 1024, 768), FMatrix::Identity, hitTexLoc))
{
// hitTexLoc = FVector2D(sightLoc - Manager.CameraPosition);
hitTexLoc /= FVector2D(SurfaceExtent);
hitTexLoc *= TextureSize / 2.0f;
hitTexLoc += FVector2D(TextureSize / 2.0f, TextureSize / 2.0f);
sightShape.AddUnique(hitTexLoc);
}
}
// draw a unveil shape
DrawUnveilShape(observerTexLoc, sightShape);
// flood fill area
// FloodFill(observerTexLoc.X, observerTexLoc.Y);
}
UpdateTextureData();
}
示例6: InitMaterialExpressionClasses
void MaterialExpressionClasses::InitMaterialExpressionClasses()
{
if( !bInitialized )
{
UMaterialEditorOptions* TempEditorOptions = ConstructObject<UMaterialEditorOptions>( UMaterialEditorOptions::StaticClass() );
UClass* BaseType = UMaterialExpression::StaticClass();
if( BaseType )
{
TArray<UStructProperty*> ExpressionInputs;
const UStruct* ExpressionInputStruct = GetExpressionInputStruct();
for( TObjectIterator<UClass> It ; It ; ++It )
{
UClass* Class = *It;
if( !Class->HasAnyClassFlags(CLASS_Abstract | CLASS_Deprecated) )
{
if( Class->IsChildOf(UMaterialExpression::StaticClass()) )
{
ExpressionInputs.Empty();
// Exclude comments from the expression list, as well as the base parameter expression, as it should not be used directly
if ( Class != UMaterialExpressionComment::StaticClass()
&& Class != UMaterialExpressionParameter::StaticClass() )
{
FMaterialExpression MaterialExpression;
// Trim the material expression name and add it to the list used for filtering.
MaterialExpression.Name = FString(*Class->GetName()).Mid(FCString::Strlen(TEXT("MaterialExpression")));
MaterialExpression.MaterialClass = Class;
AllExpressionClasses.Add(MaterialExpression);
// Initialize the expression class input map.
for( TFieldIterator<UStructProperty> InputIt(Class) ; InputIt ; ++InputIt )
{
UStructProperty* StructProp = *InputIt;
if( StructProp->Struct == ExpressionInputStruct )
{
ExpressionInputs.Add( StructProp );
}
}
// See if it is in the favorites array...
for (int32 FavoriteIndex = 0; FavoriteIndex < TempEditorOptions->FavoriteExpressions.Num(); FavoriteIndex++)
{
if (Class->GetName() == TempEditorOptions->FavoriteExpressions[FavoriteIndex])
{
FavoriteExpressionClasses.AddUnique(MaterialExpression);
}
}
// Category fill...
UMaterialExpression* TempObject = Cast<UMaterialExpression>(Class->GetDefaultObject());
if (TempObject)
{
if (TempObject->MenuCategories.Num() == 0)
{
UnassignedExpressionClasses.Add(MaterialExpression);
}
else
{
for (int32 CategoryIndex = 0; CategoryIndex < TempObject->MenuCategories.Num(); CategoryIndex++)
{
FCategorizedMaterialExpressionNode* CategoryNode = GetCategoryNode(TempObject->MenuCategories[CategoryIndex], true);
check(CategoryNode);
CategoryNode->MaterialExpressions.AddUnique(MaterialExpression);
}
}
}
}
}
}
}
}
struct FCompareFMaterialExpression
{
FORCEINLINE bool operator()( const FMaterialExpression& A, const FMaterialExpression& B ) const
{
return A.Name < B.Name;
}
};
AllExpressionClasses.Sort(FCompareFMaterialExpression());
struct FCompareFCategorizedMaterialExpressionNode
{
FORCEINLINE bool operator()( const FCategorizedMaterialExpressionNode& A, const FCategorizedMaterialExpressionNode& B ) const
{
return A.CategoryName < B.CategoryName;
}
};
CategorizedExpressionClasses.Sort( FCompareFCategorizedMaterialExpressionNode() );
bInitialized = true;
}
}
示例7: while
void D3DObjectImage::EndCache(D3DDevice *d3d)
{
if (!_cache_enabled || _cache.Length() == 0)
return;
D3DShaderPack::Current()->SetVDecl(d3d, D3DShaderPack::VDECL_XYUVC);
D3DShaderPack::Current()->SetVS(d3d, D3DShaderPack::VS_COPY_UV_COLOR);
D3DShaderPack::Current()->SetPS(d3d, D3DShaderPack::PS_TEX_COLOR_FILTER);
static TArray<Vertex> sorted;
static TArray<GroupDesc> groups;
sorted.Allocate(0);
groups.Allocate(0);
bool found = true;
while (found)
{
found = false;
int cur_id = -1;
int num = 0;
for (int i = 0; i < _cache.Length(); i++)
{
// We have processed this
if (_cache[i]->_image_id < 0)
continue;
found = true;
if (cur_id < 0)
cur_id = _cache[i]->_image_id;
if (_cache[i]->_image_id == cur_id)
{
if (!_cache[i]->_with_border)
{
Vertex *data = _cache[i]->MakeData();
sorted.Add(data[0]);
sorted.Add(data[1]);
sorted.Add(data[2]);
sorted.Add(data[3]);
sorted.Add(data[4]);
sorted.Add(data[5]);
_cache[i]->_image_id = -_cache[i]->_image_id - 1;
num++;
}
else
{
Vertex *data = _cache[i]->MakeDataBorder();
int last_len = sorted.Length();
sorted.Allocate(last_len + 6 * 9);
CopyMemory(&sorted[last_len], data, sizeof(Vertex) * 6 * 9);
_cache[i]->_image_id = -_cache[i]->_image_id - 1;
num += 9;
}
}
}
if (num > 0)
{
GroupDesc gd = {num, cur_id};
groups.Add(gd);
}
}
// Restore ids
for (int i = 0; i < _cache.Length(); i++)
_cache[i]->_image_id = -_cache[i]->_image_id - 1;
D3DVertexBufferCache::CacheEntryInfo ce_info;
if (!D3DVertexBufferCache::Current()->InitBuffer(d3d, (BYTE *)sorted.Data(),
sorted.Length() * sizeof(Vertex), ce_info))
{
return;
}
D3DVertexBufferCache::Current()->SelectBufferToDevice(d3d, ce_info.id, sizeof(Vertex));
HRESULT hr;
for (int i = 0, cur = 0; i < groups.Length(); i++)
{
if (FAILED(hr = D3DImageCache::Current()->SelectImageToDevice(d3d, groups[i].id)))
{
Log("Failed to select texture: %X", (DWORD)hr);
}
// d3d->GetDevice()->DrawPrimitiveUP(D3DPT_TRIANGLELIST, groups[i].num * 2,
// &sorted[cur], sizeof(Vertex));
d3d->GetDevice()->DrawPrimitive(D3DPT_TRIANGLELIST, cur, groups[i].num * 2);
cur += groups[i].num * 6;
}
DBG("Image cache drawn: %d items, %d groups", _cache.Length(), groups.Length());
_cache_enabled = false;
}
示例8: RegisterCommands
/** UI_COMMAND takes long for the compile to optimize */
PRAGMA_DISABLE_OPTIMIZATION
void FLevelViewportCommands::RegisterCommands()
{
UI_COMMAND( ToggleMaximize, "Maximize Viewport", "Toggles the Maximize state of the current viewport", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ToggleGameView, "Game View", "Toggles game view. Game view shows the scene as it appears in game", EUserInterfaceActionType::ToggleButton, FInputChord( EKeys::G ) );
UI_COMMAND( ToggleImmersive, "Immersive Mode", "Switches this viewport between immersive mode and regular mode", EUserInterfaceActionType::ToggleButton, FInputChord( EKeys::F11 ) );
UI_COMMAND( CreateCamera, "Create Camera Here", "Creates a new camera actor at the current location of this viewport's camera", EUserInterfaceActionType::Button, FInputChord() );
UI_COMMAND( HighResScreenshot, "High Resolution Screenshot...", "Opens the control panel for high resolution screenshots", EUserInterfaceActionType::Button, FInputChord() );
UI_COMMAND( UseDefaultShowFlags, "Use Defaults", "Resets all show flags to default", EUserInterfaceActionType::Button, FInputChord() );
UI_COMMAND( PilotSelectedActor, "Pilot Selected Actor", "Move the selected actor around using the viewport controls, and bind the viewport to the actor's location and orientation.", EUserInterfaceActionType::Button, FInputChord( EModifierKey::Control | EModifierKey::Shift, EKeys::P ) );
UI_COMMAND( EjectActorPilot, "Eject from Actor Pilot", "Stop piloting an actor with the current viewport. Unlocks the viewport's position and orientation from the actor the viewport is currently piloting.", EUserInterfaceActionType::Button, FInputChord() );
UI_COMMAND( ToggleActorPilotCameraView, "Actor Pilot Camera View", "Toggles showing the exact camera view when using the viewport to pilot a camera", EUserInterfaceActionType::ToggleButton, FInputChord( EModifierKey::Control | EModifierKey::Shift, EKeys::C ) );
UI_COMMAND( ViewportConfig_OnePane, "Layout One Pane", "Changes the viewport arrangement to one pane", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ViewportConfig_TwoPanesH, "Layout Two Panes (horizontal)", "Changes the viewport arrangement to two panes, side-by-side", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ViewportConfig_TwoPanesV, "Layout Two Panes (vertical)", "Changes the viewport arrangement to two panes, one above the other", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ViewportConfig_ThreePanesLeft, "Layout Three Panes (one left, two right)", "Changes the viewport arrangement to three panes, one on the left, two on the right", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ViewportConfig_ThreePanesRight, "Layout Three Panes (one right, two left)", "Changes the viewport arrangement to three panes, one on the right, two on the left", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ViewportConfig_ThreePanesTop, "Layout Three Panes (one top, two bottom)", "Changes the viewport arrangement to three panes, one on the top, two on the bottom", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ViewportConfig_ThreePanesBottom, "Layout Three Panes (one bottom, two top)", "Changes the viewport arrangement to three panes, one on the bottom, two on the top", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ViewportConfig_FourPanesLeft, "Layout Four Panes (one left, three right)", "Changes the viewport arrangement to four panes, one on the left, three on the right", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ViewportConfig_FourPanesRight, "Layout Four Panes (one right, three left)", "Changes the viewport arrangement to four panes, one on the right, three on the left", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ViewportConfig_FourPanesTop, "Layout Four Panes (one top, three bottom)", "Changes the viewport arrangement to four panes, one on the top, three on the bottom", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ViewportConfig_FourPanesBottom, "Layout Four Panes (one bottom, three top)", "Changes the viewport arrangement to four panes, one on the bottom, three on the top", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ViewportConfig_FourPanes2x2, "Layout Four Panes (2x2)", "Changes the viewport arrangement to four panes, in a 2x2 grid", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( ApplyMaterialToActor, "Apply Material", "Attempts to apply a dropped material to this object", EUserInterfaceActionType::Button, FInputChord() );
UI_COMMAND( ToggleCinematicPreview, "Toggles Cinematic Preview", "If enabled, allows Matinee or Sequencer previews to play in this viewport", EUserInterfaceActionType::ToggleButton, FInputChord() );
UI_COMMAND( FindInLevelScriptBlueprint, "Find In Level Script", "Finds references of a selected actor in the level script blueprint", EUserInterfaceActionType::Button, FInputChord(EModifierKey::Control, EKeys::K) );
UI_COMMAND( AdvancedSettings, "Advanced Settings...", "Opens the advanced viewport settings", EUserInterfaceActionType::Button, FInputChord());
// Generate a command for each buffer visualization mode
{
struct FMaterialIterator
{
const TSharedRef<class FBindingContext> Parent;
FLevelViewportCommands::TBufferVisualizationModeCommandMap& CommandMap;
FMaterialIterator(const TSharedRef<class FBindingContext> InParent, FLevelViewportCommands::TBufferVisualizationModeCommandMap& InCommandMap)
: Parent(InParent)
, CommandMap(InCommandMap)
{
}
void ProcessValue(const FString& InMaterialName, const UMaterial* InMaterial, const FText& InDisplayName)
{
FName ViewportCommandName = *(FString(TEXT("BufferVisualizationMenu")) + InMaterialName);
FBufferVisualizationRecord& Record = CommandMap.Add(ViewportCommandName, FBufferVisualizationRecord());
Record.Name = *InMaterialName;
const FText MaterialNameText = FText::FromString( InMaterialName );
Record.Command = FUICommandInfoDecl( Parent, ViewportCommandName, MaterialNameText, MaterialNameText )
.UserInterfaceType( EUserInterfaceActionType::RadioButton )
.DefaultChord( FInputChord() );
}
};
BufferVisualizationModeCommands.Empty();
FName ViewportCommandName = *(FString(TEXT("BufferVisualizationOverview")));
FBufferVisualizationRecord& OverviewRecord = BufferVisualizationModeCommands.Add(ViewportCommandName, FBufferVisualizationRecord());
OverviewRecord.Name = NAME_None;
OverviewRecord.Command = FUICommandInfoDecl( this->AsShared(), ViewportCommandName, LOCTEXT("BufferVisualization", "Overview"), LOCTEXT("BufferVisualization", "Overview") )
.UserInterfaceType( EUserInterfaceActionType::RadioButton )
.DefaultChord( FInputChord() );
FMaterialIterator It(this->AsShared(), BufferVisualizationModeCommands);
GetBufferVisualizationData().IterateOverAvailableMaterials(It);
}
const TArray<FShowFlagData>& ShowFlagData = GetShowFlagMenuItems();
// Generate a command for each show flag
for( int32 ShowFlag = 0; ShowFlag < ShowFlagData.Num(); ++ShowFlag )
{
const FShowFlagData& SFData = ShowFlagData[ShowFlag];
FFormatNamedArguments Args;
Args.Add( TEXT("ShowFlagName"), SFData.DisplayName );
FText LocalizedName;
switch( SFData.Group )
{
case SFG_Visualize:
LocalizedName = FText::Format( LOCTEXT("VisualizeFlagLabel", "Visualize {ShowFlagName}"), Args );
break;
default:
LocalizedName = FText::Format( LOCTEXT("ShowFlagLabel", "Show {ShowFlagName}"), Args );
break;
}
//@todo Slate: The show flags system does not support descriptions currently
const FText ShowFlagDesc;
TSharedPtr<FUICommandInfo> ShowFlagCommand
//.........这里部分代码省略.........
示例9: RerunConstructionScripts
void AActor::RerunConstructionScripts()
{
// don't allow (re)running construction scripts on dying actors
bool bAllowReconstruction = !IsPendingKill() && !HasAnyFlags(RF_BeginDestroyed|RF_FinishDestroyed);
#if WITH_EDITOR
if(bAllowReconstruction && GIsEditor)
{
// Generate the blueprint hierarchy for this actor
TArray<UBlueprint*> ParentBPStack;
bAllowReconstruction = UBlueprint::GetBlueprintHierarchyFromClass(GetClass(), ParentBPStack);
if(bAllowReconstruction)
{
for(int i = ParentBPStack.Num() - 1; i > 0 && bAllowReconstruction; --i)
{
const UBlueprint* ParentBP = ParentBPStack[i];
if(ParentBP && ParentBP->bBeingCompiled)
{
// don't allow (re)running construction scripts if a parent BP is being compiled
bAllowReconstruction = false;
}
}
}
}
#endif
if(bAllowReconstruction)
{
// Temporarily suspend the undo buffer; we don't need to record reconstructed component objects into the current transaction
ITransaction* CurrentTransaction = GUndo;
GUndo = NULL;
// Create cache to store component data across rerunning construction scripts
FComponentInstanceDataCache InstanceDataCache(this);
// If there are attached objects detach them and store the socket names
TArray<AActor*> AttachedActors;
GetAttachedActors(AttachedActors);
// Struct to store info about attached actors
struct FAttachedActorInfo
{
AActor* AttachedActor;
FName AttachedToSocket;
};
// Save info about attached actors
TArray<FAttachedActorInfo> AttachedActorInfos;
for( AActor* AttachedActor : AttachedActors)
{
USceneComponent* EachRoot = AttachedActor->GetRootComponent();
// If the component we are attached to is about to go away...
if( EachRoot && EachRoot->AttachParent && EachRoot->AttachParent->bCreatedByConstructionScript )
{
// Save info about actor to reattach
FAttachedActorInfo Info;
Info.AttachedActor = AttachedActor;
Info.AttachedToSocket = EachRoot->AttachSocketName;
AttachedActorInfos.Add(Info);
// Now detach it
AttachedActor->Modify();
EachRoot->DetachFromParent(true);
}
}
// Save off original pose of the actor
FTransform OldTransform = FTransform::Identity;
FName SocketName;
AActor* Parent = NULL;
if (RootComponent != NULL)
{
// Do not need to detach if root component is not going away
if(RootComponent->AttachParent != NULL && RootComponent->bCreatedByConstructionScript)
{
Parent = RootComponent->AttachParent->GetOwner();
// Root component should never be attached to another component in the same actor!
if(Parent == this)
{
UE_LOG(LogActor, Warning, TEXT("RerunConstructionScripts: RootComponent (%s) attached to another component in this Actor (%s)."), *RootComponent->GetPathName(), *Parent->GetPathName());
Parent = NULL;
}
SocketName = RootComponent->AttachSocketName;
//detach it to remove any scaling
RootComponent->DetachFromParent(true);
}
OldTransform = RootComponent->ComponentToWorld;
}
// Destroy existing components
DestroyConstructedComponents();
// Reset random streams
ResetPropertiesForConstruction();
// Run the construction scripts
OnConstruction(OldTransform);
if(Parent)
{
USceneComponent* ChildRoot = GetRootComponent();
//.........这里部分代码省略.........
示例10: OnDrag
void FMoveSection::OnDrag( const FPointerEvent& MouseEvent, const FVector2D& LocalMousePos, const FTimeToPixel& TimeToPixelConverter, TSharedPtr<FTrackNode> SequencerNode )
{
if( Section.IsValid() )
{
auto Sections = SequencerNode->GetSections();
TArray<UMovieSceneSection*> MovieSceneSections;
for (int32 i = 0; i < Sections.Num(); ++i)
{
MovieSceneSections.Add(Sections[i]->GetSectionObject());
}
FVector2D TotalDelta = LocalMousePos - DragOffset;
float DistanceMoved = TotalDelta.X / TimeToPixelConverter.GetPixelsPerInput();
float DeltaTime = DistanceMoved;
if ( Settings->GetIsSnapEnabled() )
{
bool bSnappedToSection = false;
if ( Settings->GetSnapSectionTimesToSections() )
{
TArray<float> TimesToSnapTo;
GetSectionSnapTimes(TimesToSnapTo, Section.Get(), SequencerNode, true);
TArray<float> TimesToSnap;
TimesToSnap.Add(DistanceMoved + Section->GetStartTime());
TimesToSnap.Add(DistanceMoved + Section->GetEndTime());
float OutSnappedTime = 0.f;
float OutNewTime = 0.f;
if (SnapToTimes(TimesToSnap, TimesToSnapTo, TimeToPixelConverter, OutSnappedTime, OutNewTime))
{
DeltaTime = OutNewTime - (OutSnappedTime - DistanceMoved);
bSnappedToSection = true;
}
}
if ( bSnappedToSection == false && Settings->GetSnapSectionTimesToInterval() )
{
float NewStartTime = DistanceMoved + Section->GetStartTime();
DeltaTime = Settings->SnapTimeToInterval( NewStartTime ) - Section->GetStartTime();
}
}
int32 TargetRowIndex = Section->GetRowIndex();
// vertical dragging - master tracks only
if (SequencerNode->GetTrack()->SupportsMultipleRows() && Sections.Num() > 1)
{
float TrackHeight = Sections[0]->GetSectionHeight();
if (LocalMousePos.Y < 0.f || LocalMousePos.Y > TrackHeight)
{
int32 MaxRowIndex = 0;
for (int32 i = 0; i < Sections.Num(); ++i)
{
if (Sections[i]->GetSectionObject() != Section.Get())
{
MaxRowIndex = FMath::Max(MaxRowIndex, Sections[i]->GetSectionObject()->GetRowIndex());
}
}
TargetRowIndex = FMath::Clamp(Section->GetRowIndex() + FMath::FloorToInt(LocalMousePos.Y / TrackHeight),
0, MaxRowIndex + 1);
}
}
bool bDeltaX = !FMath::IsNearlyZero(TotalDelta.X);
bool bDeltaY = TargetRowIndex != Section->GetRowIndex();
if (bDeltaX && bDeltaY &&
!Section->OverlapsWithSections(MovieSceneSections, TargetRowIndex - Section->GetRowIndex(), DeltaTime))
{
Section->MoveSection(DeltaTime, DraggedKeyHandles);
Section->SetRowIndex(TargetRowIndex);
}
else
{
if (bDeltaY &&
!Section->OverlapsWithSections(MovieSceneSections, TargetRowIndex - Section->GetRowIndex(), 0.f))
{
Section->SetRowIndex(TargetRowIndex);
}
if (bDeltaX)
{
if (!Section->OverlapsWithSections(MovieSceneSections, 0, DeltaTime))
{
Section->MoveSection(DeltaTime, DraggedKeyHandles);
}
else
{
// Find the borders of where you can move to
TRange<float> SectionBoundaries = GetSectionBoundaries(Section.Get(), SequencerNode);
float LeftMovementMaximum = SectionBoundaries.GetLowerBoundValue() - Section->GetStartTime();
float RightMovementMaximum = SectionBoundaries.GetUpperBoundValue() - Section->GetEndTime();
// Tell the section to move itself and any data it has
//.........这里部分代码省略.........
示例11: MenuBuilder
TSharedRef< SWidget > FLevelEditorToolBar::GenerateQuickSettingsMenu( TSharedRef<FUICommandList> InCommandList )
{
#define LOCTEXT_NAMESPACE "LevelToolBarViewMenu"
// Get all menu extenders for this context menu from the level editor module
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>( TEXT("LevelEditor") );
TArray<FLevelEditorModule::FLevelEditorMenuExtender> MenuExtenderDelegates = LevelEditorModule.GetAllLevelEditorToolbarViewMenuExtenders();
TArray<TSharedPtr<FExtender>> Extenders;
for (int32 i = 0; i < MenuExtenderDelegates.Num(); ++i)
{
if (MenuExtenderDelegates[i].IsBound())
{
Extenders.Add(MenuExtenderDelegates[i].Execute(InCommandList));
}
}
TSharedPtr<FExtender> MenuExtender = FExtender::Combine(Extenders);
const bool bShouldCloseWindowAfterMenuSelection = true;
FMenuBuilder MenuBuilder( bShouldCloseWindowAfterMenuSelection, InCommandList, MenuExtender );
MenuBuilder.BeginSection("LevelEditorSelection", LOCTEXT("SelectionHeading","Selection") );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().AllowTranslucentSelection );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().AllowGroupSelection );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().StrictBoxSelect );
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorEditing", LOCTEXT("EditingHeading", "Editing") );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().ShowTransformWidget );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().DrawBrushMarkerPolys );
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorPreview", LOCTEXT("PreviewHeading", "Previewing") );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().OnlyLoadVisibleInPIE );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().ToggleParticleSystemLOD );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().ToggleParticleSystemHelpers );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().ToggleFreezeParticleSimulation );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().ToggleLODViewLocking );
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().LevelStreamingVolumePrevis );
MenuBuilder.AddSubMenu(
LOCTEXT( "ScalabilitySubMenu", "Engine Scalability Settings" ),
LOCTEXT( "ScalabilitySubMenu_ToolTip", "Open the engine scalability settings" ),
FNewMenuDelegate::CreateStatic( &MakeScalabilityMenu ) );
MenuBuilder.AddSubMenu(
LOCTEXT( "MaterialQualityLevelSubMenu", "Material Quality Level" ),
LOCTEXT( "MaterialQualityLevelSubMenu_ToolTip", "Sets the value of the CVar \"r.MaterialQualityLevel\" (low=0, high=1). This affects materials via the QualitySwitch material expression." ),
FNewMenuDelegate::CreateStatic( &MakeMaterialQualityLevelMenu ) );
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorAudio", LOCTEXT("AudioHeading", "Real Time Audio") );
{
TSharedRef<SWidget> VolumeItem = SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.FillWidth(0.9f)
.Padding( FMargin(2.0f, 0.0f, 0.0f, 0.0f) )
[
SNew(SVolumeControl)
.ToolTipText_Static(&FLevelEditorActionCallbacks::GetAudioVolumeToolTip)
.Volume_Static(&FLevelEditorActionCallbacks::GetAudioVolume)
.OnVolumeChanged_Static(&FLevelEditorActionCallbacks::OnAudioVolumeChanged)
.Muted_Static(&FLevelEditorActionCallbacks::GetAudioMuted)
.OnMuteChanged_Static(&FLevelEditorActionCallbacks::OnAudioMutedChanged)
]
+SHorizontalBox::Slot()
.FillWidth(0.1f);
MenuBuilder.AddWidget(VolumeItem, LOCTEXT("VolumeControlLabel","Volume"));
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection("LevelEditorActorSnap", LOCTEXT("ActorSnapHeading","Actor Snap") );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().EnableActorSnap );
TSharedRef<SWidget> SnapItem =
SNew(SHorizontalBox)
+SHorizontalBox::Slot()
.FillWidth(0.9f)
[
SNew(SSlider)
.ToolTipText_Static(&FLevelEditorActionCallbacks::GetActorSnapTooltip)
.Value_Static(&FLevelEditorActionCallbacks::GetActorSnapSetting)
.OnValueChanged_Static(&FLevelEditorActionCallbacks::SetActorSnapSetting)
]
+SHorizontalBox::Slot()
.FillWidth(0.1f);
MenuBuilder.AddWidget(SnapItem, LOCTEXT("ActorSnapLabel","Distance"));
}
MenuBuilder.EndSection();
MenuBuilder.BeginSection( "Snapping", LOCTEXT("SnappingHeading","Snapping") );
{
MenuBuilder.AddMenuEntry( FLevelEditorCommands::Get().ToggleSocketSnapping );
//.........这里部分代码省略.........
示例12: GetSupportedFormats
virtual void GetSupportedFormats(TArray<FName>& OutFormats) const
{
OutFormats.Add(NAME_SF_METAL);
OutFormats.Add(NAME_SF_METAL_MRT);
OutFormats.Add(NAME_SF_METAL_SM5);
}
示例13: OnPaintSection
int32 FAnimationSection::OnPaintSection( const FGeometry& AllottedGeometry, const FSlateRect& SectionClippingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, bool bParentEnabled ) const
{
UMovieSceneAnimationSection* AnimSection = Cast<UMovieSceneAnimationSection>(&Section);
FTimeToPixel TimeToPixelConverter( AllottedGeometry, TRange<float>( Section.GetStartTime(), Section.GetEndTime() ) );
// Add a box for the section
FSlateDrawElement::MakeBox(
OutDrawElements,
LayerId,
AllottedGeometry.ToPaintGeometry(),
FEditorStyle::GetBrush("Sequencer.GenericSection.Background"),
SectionClippingRect,
ESlateDrawEffect::None,
FLinearColor(0.7f, 0.4f, 0.7f, 1.f)
);
// Darken the part that doesn't have animation
if (AnimSection->GetAnimationStartTime() > AnimSection->GetStartTime())
{
float StartDarkening = AnimSection->GetStartTime();
float EndDarkening = FMath::Min(AnimSection->GetAnimationStartTime(), AnimSection->GetEndTime());
float StartPixels = TimeToPixelConverter.TimeToPixel(StartDarkening);
float EndPixels = TimeToPixelConverter.TimeToPixel(EndDarkening);
FSlateDrawElement::MakeBox(
OutDrawElements,
LayerId + 1,
AllottedGeometry.ToPaintGeometry(FVector2D(StartPixels, 0), FVector2D(EndPixels - StartPixels, AllottedGeometry.Size.Y)),
FEditorStyle::GetBrush("WhiteTexture"),
SectionClippingRect,
ESlateDrawEffect::None,
FLinearColor(0.f, 0.f, 0.f, 0.3f)
);
}
// Add lines where the animation starts and ends/loops
float CurrentTime = AnimSection->GetAnimationStartTime();
while (CurrentTime < AnimSection->GetEndTime())
{
if (CurrentTime > AnimSection->GetStartTime())
{
float CurrentPixels = TimeToPixelConverter.TimeToPixel(CurrentTime);
TArray<FVector2D> Points;
Points.Add(FVector2D(CurrentPixels, 0));
Points.Add(FVector2D(CurrentPixels, AllottedGeometry.Size.Y));
FSlateDrawElement::MakeLines(
OutDrawElements,
LayerId + 2,
AllottedGeometry.ToPaintGeometry(),
Points,
SectionClippingRect
);
}
CurrentTime += AnimSection->GetAnimationDuration();
}
return LayerId+3;
}
示例14: BuildAudioFlowRoadmap
void FSoundCueGraphConnectionDrawingPolicy::BuildAudioFlowRoadmap()
{
UAudioComponent* PreviewAudioComponent = GEditor->GetPreviewAudioComponent();
FAudioDevice* AudioDevice = PreviewAudioComponent ? PreviewAudioComponent->GetAudioDevice() : nullptr;
if (AudioDevice)
{
USoundCueGraph* SoundCueGraph = CastChecked<USoundCueGraph>(GraphObj);
USoundCue* SoundCue = SoundCueGraph->GetSoundCue();
if (PreviewAudioComponent && PreviewAudioComponent->IsPlaying() && PreviewAudioComponent->Sound == SoundCue)
{
TArray<FWaveInstance*> WaveInstances;
const int32 FirstActiveIndex = AudioDevice->GetSortedActiveWaveInstances(WaveInstances, ESortedActiveWaveGetType::QueryOnly);
// Run through the active instances and cull out anything that isn't related to this graph
if (FirstActiveIndex > 0)
{
WaveInstances.RemoveAt(0, FirstActiveIndex + 1);
}
for (int32 WaveIndex = WaveInstances.Num() - 1; WaveIndex >= 0 ; --WaveIndex)
{
UAudioComponent* WaveInstanceAudioComponent = UAudioComponent::GetAudioComponentFromID(WaveInstances[WaveIndex]->ActiveSound->GetAudioComponentID());
if (WaveInstanceAudioComponent != PreviewAudioComponent)
{
WaveInstances.RemoveAtSwap(WaveIndex);
}
}
for (int32 WaveIndex = 0; WaveIndex < WaveInstances.Num(); ++WaveIndex)
{
TArray<USoundNode*> PathToWaveInstance;
if (SoundCue->FindPathToNode(WaveInstances[WaveIndex]->WaveInstanceHash, PathToWaveInstance))
{
TArray<USoundCueGraphNode_Root*> RootNode;
TArray<UEdGraphNode*> GraphNodes;
SoundCueGraph->GetNodesOfClass<USoundCueGraphNode_Root>(RootNode);
check(RootNode.Num() == 1);
GraphNodes.Add(RootNode[0]);
TArray<double> NodeTimes;
NodeTimes.Add(FApp::GetCurrentTime()); // Time for the root node
for (int32 i = 0; i < PathToWaveInstance.Num(); ++i)
{
const double ObservationTime = FApp::GetCurrentTime() + 1.f;
NodeTimes.Add(ObservationTime);
GraphNodes.Add(PathToWaveInstance[i]->GraphNode);
}
// Record the unique node->node pairings, keeping only the most recent times for each pairing
for (int32 i = GraphNodes.Num() - 1; i >= 1; --i)
{
UEdGraphNode* CurNode = GraphNodes[i];
double CurNodeTime = NodeTimes[i];
UEdGraphNode* NextNode = GraphNodes[i-1];
double NextNodeTime = NodeTimes[i-1];
FExecPairingMap& Predecessors = PredecessorNodes.FindOrAdd(NextNode);
// Update the timings if this is a more recent pairing
FTimePair& Timings = Predecessors.FindOrAdd(CurNode);
if (Timings.ThisExecTime < NextNodeTime)
{
Timings.PredExecTime = CurNodeTime;
Timings.ThisExecTime = NextNodeTime;
}
}
}
}
}
}
}
示例15: GetTextureFormats
void FIOSTargetPlatform::GetTextureFormats( const UTexture* Texture, TArray<FName>& OutFormats ) const
{
check(Texture);
// we remap some of the defaults (with PVRTC and ASTC formats)
static FName FormatRemap[] =
{
// original PVRTC ASTC
FName(TEXT("DXT1")), FName(TEXT("PVRTC2")), FName(TEXT("ASTC_RGB")),
FName(TEXT("DXT5")), FName(TEXT("PVRTC4")), FName(TEXT("ASTC_RGBA")),
FName(TEXT("DXT5n")), FName(TEXT("PVRTCN")), FName(TEXT("ASTC_NormalAG")),
FName(TEXT("BC5")), FName(TEXT("PVRTCN")), FName(TEXT("ASTC_NormalRG")),
FName(TEXT("AutoDXT")), FName(TEXT("AutoPVRTC")), FName(TEXT("ASTC_RGBAuto")),
};
static FName NameBGRA8(TEXT("BGRA8"));
static FName NamePOTERROR(TEXT("POTERROR"));
FName TextureFormatName = NAME_None;
// forward rendering only needs one channel for shadow maps
if (Texture->LODGroup == TEXTUREGROUP_Shadowmap && !SupportsMetalMRT())
{
TextureFormatName = FName(TEXT("G8"));
}
// if we didn't assign anything specially, then use the defaults
if (TextureFormatName == NAME_None)
{
TextureFormatName = GetDefaultTextureFormatName(Texture, EngineSettings, false);
}
// perform any remapping away from defaults
bool bFoundRemap = false;
bool bIncludePVRTC = CookPVRTC();
bool bIncludeASTC = CookASTC();
for (int32 RemapIndex = 0; RemapIndex < ARRAY_COUNT(FormatRemap); RemapIndex += 3)
{
if (TextureFormatName == FormatRemap[RemapIndex])
{
// we found a remapping
bFoundRemap = true;
// include the formats we want (use ASTC first so that it is preferred at runtime if they both exist and it's supported)
if (bIncludeASTC)
{
OutFormats.AddUnique(FormatRemap[RemapIndex + 2]);
}
if (bIncludePVRTC)
{
// handle non-power of 2 textures
if (!Texture->Source.IsPowerOfTwo())
{
// option 1: Uncompress, but users will get very large textures unknowningly
// OutFormats.AddUnique(NameBGRA8);
// option 2: Use an "error message" texture so they see it in game
OutFormats.AddUnique(NamePOTERROR);
}
else
{
OutFormats.AddUnique(FormatRemap[RemapIndex + 1]);
}
}
}
}
// if we didn't already remap above, add it now
if (!bFoundRemap)
{
OutFormats.Add(TextureFormatName);
}
}