当前位置: 首页>>代码示例>>C++>>正文


C++ TArray::Empty方法代码示例

本文整理汇总了C++中TArray::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::Empty方法的具体用法?C++ TArray::Empty怎么用?C++ TArray::Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TArray的用法示例。


在下文中一共展示了TArray::Empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PopValueImpl

static inline
void PopValueImpl(const TArray<FOscDataElemStruct> & input, TArray<FOscDataElemStruct> & output, T & Value)
{
    if(input.Num() > 0)
    {
        output.Reserve(input.Num() - 1);
        for(int32 i=1, n=input.Num(); i!=n; ++i)
        {
            output.Add(input[i]);
        }
        Value = input[0].GetValue<T>();
    }
    else
    {
        output.Empty();
        Value = FOscDataElemStruct().GetValue<T>();
    }
}
开发者ID:Potion,项目名称:ampm,代码行数:18,代码来源:OscFunctionLibrary.cpp

示例2: CreateMaskWeights

void FAnimationRuntime::CreateMaskWeights(TArray<FPerBoneBlendWeight> & BoneBlendWeights, const TArray<FInputBlendPose>	&BlendFilters, const FBoneContainer& RequiredBones, const USkeleton* Skeleton)
{
	if ( Skeleton )
	{
		const TArray<FBoneIndexType> & RequiredBoneIndices = RequiredBones.GetBoneIndicesArray();
		
		BoneBlendWeights.Empty(RequiredBoneIndices.Num());
		BoneBlendWeights.AddZeroed(RequiredBoneIndices.Num());

		// base mask bone
		for (int32 PoseIndex=0; PoseIndex<BlendFilters.Num(); ++PoseIndex)
		{
			const FInputBlendPose& BlendPose = BlendFilters[PoseIndex];

			for (int32 BranchIndex=0; BranchIndex<BlendPose.BranchFilters.Num(); ++BranchIndex)
			{
				const FBranchFilter& BranchFilter = BlendPose.BranchFilters[BranchIndex];
				int32 MaskBoneIndex = RequiredBones.GetPoseBoneIndexForBoneName(BranchFilter.BoneName);

				// how much weight increase Per depth
				float MaxWeight = (BranchFilter.BlendDepth > 0) ? 1.f : -1.f;
				float IncreaseWeightPerDepth = (BranchFilter.BlendDepth != 0) ? (1.f/((float)BranchFilter.BlendDepth)) : 1.f;
	
				// go through skeleton tree requiredboneindices
				for (int32 BoneIndex = 0; BoneIndex<RequiredBoneIndices.Num(); ++BoneIndex)
				{
					int32 MeshBoneIndex = RequiredBoneIndices[BoneIndex];
					int32 Depth = RequiredBones.GetDepthBetweenBones(MeshBoneIndex, MaskBoneIndex);

					// if Depth == -1, it's not a child
					if( Depth != -1 )
					{
						// when you write to buffer, you'll need to match with BasePoses BoneIndex
						FPerBoneBlendWeight& BoneBlendWeight = BoneBlendWeights[BoneIndex];

						BoneBlendWeight.SourceIndex = PoseIndex;
						float BlendIncrease = IncreaseWeightPerDepth * (float)(Depth + 1);
						BoneBlendWeight.BlendWeight = FMath::Clamp<float>(BoneBlendWeight.BlendWeight + BlendIncrease, 0.f, 1.f);
					}
				}
			}
		}
	}
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:44,代码来源:AnimationRuntime.cpp

示例3: VerifyAgainstDirectory

bool FBuildPatchVerificationImpl::VerifyAgainstDirectory(TArray<FString>& OutDatedFiles, double& TimeSpentPaused)
{
	bool bAllCorrect = true;
	OutDatedFiles.Empty();
	TimeSpentPaused = 0;
	if (VerifyMode == EVerifyMode::FileSizeCheckAllFiles || VerifyMode == EVerifyMode::ShaVerifyAllFiles)
	{
		Manifest->GetTaggedFileList(InstallTags, RequiredFiles);
	}

	// Setup progress tracking
	double TotalBuildSizeDouble = Manifest->GetFileSize(RequiredFiles);
	double ProcessedBytes = 0;
	CurrentBuildPercentage = 0;

	// Select verify function
	bool bVerifySha = VerifyMode == EVerifyMode::ShaVerifyAllFiles || VerifyMode == EVerifyMode::ShaVerifyTouchedFiles;

	// For all files in the manifest, check that they produce the correct SHA1 hash, adding any that don't to the list
	for (const FString& BuildFile : RequiredFiles)
	{
		// Break if quitting
		if (FBuildPatchInstallError::HasFatalError())
		{
			break;
		}

		// Get file details
		int64 BuildFileSize = Manifest->GetFileSize(BuildFile);

		// Verify the file
		CurrentFileWeight = BuildFileSize / TotalBuildSizeDouble;
		bool bFileOk = bVerifySha ? VerfiyFileSha(BuildFile, TimeSpentPaused) : VerfiyFileSize(BuildFile, TimeSpentPaused);
		if (bFileOk == false)
		{
			bAllCorrect = false;
			OutDatedFiles.Add(BuildFile);
		}
		ProcessedBytes += BuildFileSize;
		CurrentBuildPercentage = ProcessedBytes / TotalBuildSizeDouble;
	}

	return bAllCorrect && !FBuildPatchInstallError::HasFatalError();
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:44,代码来源:BuildPatchVerification.cpp

示例4: RemoveActionBinding

void UInputComponent::RemoveActionBinding( const int32 BindingIndex )
{
	if (BindingIndex >= 0 && BindingIndex < ActionBindings.Num())
	{
		const FInputActionBinding& BindingToRemove = ActionBindings[BindingIndex];

		// Potentially need to clear some pairings
		if (BindingToRemove.bPaired)
		{
			TArray<int32> IndicesToClear;
			const EInputEvent PairedEvent = (BindingToRemove.KeyEvent == IE_Pressed ? IE_Released : IE_Pressed);

			for (int32 ActionIndex = 0; ActionIndex < ActionBindings.Num(); ++ActionIndex)
			{
				if (ActionIndex != BindingIndex)
				{
					const FInputActionBinding& ActionBinding = ActionBindings[ActionIndex];
					if (ActionBinding.ActionName == BindingToRemove.ActionName)
					{
						// If we find another of the same key event then the pairing is intact so we're done
						if (ActionBinding.KeyEvent == BindingToRemove.KeyEvent)
						{
							IndicesToClear.Empty();
							break;
						}
						// Otherwise we may need to clear the pairing so track the index
						else if (ActionBinding.KeyEvent == PairedEvent)
						{
							IndicesToClear.Add(ActionIndex);
						}
					}
				}
			}

			for (int32 ClearIndex = 0; ClearIndex < IndicesToClear.Num(); ++ClearIndex)
			{
				ActionBindings[IndicesToClear[ClearIndex]].bPaired = false;
			}
		}

		ActionBindings.RemoveAt(BindingIndex);
	}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:43,代码来源:InputComponent.cpp

示例5: Decrypt

void FPIELoginSettingsInternal::Decrypt()
{
	if (TokenBytes.Num() > 0)
	{
		const int64 PaddedEncryptedFileSize = Align(TokenBytes.Num(), FAES::AESBlockSize);
		if (PaddedEncryptedFileSize > 0 && PaddedEncryptedFileSize == TokenBytes.Num())
		{
			TArray<uint8> TempArray;
			TempArray.Empty(PaddedEncryptedFileSize);
			TempArray.AddUninitialized(PaddedEncryptedFileSize);
			FMemory::Memcpy(TempArray.GetData(), TokenBytes.GetData(), PaddedEncryptedFileSize);
			
			// XOR Cipher
			int32 NumXors = PaddedEncryptedFileSize / sizeof(int32);
			int32* TempArrayPtr = (int32*)(TempArray.GetData());
			for (int32 i = 0; i < NumXors; i++)
			{
				TempArrayPtr[i] = TempArrayPtr[i] ^ ONLINEPIE_XOR_KEY;
			}

			//FAES::DecryptData(TempArray.GetData(), PaddedEncryptedFileSize);

			// Validate the unencrypted data (stored size less than total data, null terminated character where it should be)
			int32 PasswordDataSize = TempArray[0];
			int32 PasswordLength = PasswordDataSize / sizeof(TCHAR);
			TCHAR* Password = (TCHAR*)(TempArray.GetData() + 1);
			if (PasswordDataSize < TempArray.Num() &&
				Password[PasswordLength - 1] == '\0')
			{
				Token = FString(Password);
			}
			else
			{
				Token.Empty();
				TokenBytes.Empty();
			}
		}
	}
	else
	{
		Token.Empty();
	}
}
开发者ID:WasPedro,项目名称:UnrealEngine4.11-HairWorks,代码行数:43,代码来源:OnlinePIESettings.cpp

示例6: Evaluate

void FAnimNode_BlendListBase::Evaluate(FPoseContext& Output)
{
	SCOPE_CYCLE_COUNTER(STAT_AnimNativeBlendPoses);

	const int32 MaxNumPoses = BlendPose.Num();

	//@TODO: This is currently using O(NumPoses) memory but doesn't need to
	if ((MaxNumPoses > 0) && (BlendPose.Num() == BlendWeights.Num()))
	{
		TArray<FPoseContext> FilteredPoseContexts;
		FilteredPoseContexts.Empty(MaxNumPoses);

		FTransformArrayA2** FilteredPoses = new FTransformArrayA2*[MaxNumPoses];
		float* FilteredWeights = new float[MaxNumPoses];

		int32 NumActivePoses = 0;
		for (int32 i = 0; i < BlendPose.Num(); ++i)
		{
			const float BlendWeight = BlendWeights[i];
			if (BlendWeight > ZERO_ANIMWEIGHT_THRESH)
			{
				FPoseContext& CurrentPoseContext = *(new (FilteredPoseContexts) FPoseContext(Output));

				FPoseLink& CurrentPose = BlendPose[i];
				CurrentPose.Evaluate(CurrentPoseContext);

				FilteredPoses[NumActivePoses] = &(CurrentPoseContext.Pose.Bones);
				FilteredWeights[NumActivePoses] = BlendWeight;
				NumActivePoses++;
			}
		}

		FAnimationRuntime::BlendPosesTogether(NumActivePoses, (const FTransformArrayA2**)FilteredPoses, (const float*)FilteredWeights, Output.AnimInstance->RequiredBones, Output.Pose.Bones);

		delete[] FilteredPoses;
		delete[] FilteredWeights;
	}
	else
	{
		Output.ResetToRefPose();
	}
}
开发者ID:johndpope,项目名称:UE4,代码行数:42,代码来源:AnimNode_BlendListBase.cpp

示例7: Create

	virtual bool Create(uint32 InNumQueuedThreads,uint32 StackSize = (32 * 1024),EThreadPriority ThreadPriority=TPri_Normal) override
	{
		// Make sure we have synch objects
		bool bWasSuccessful = true;
		check(SynchQueue == nullptr);
		SynchQueue = new FCriticalSection();
		FScopeLock Lock(SynchQueue);
		// Presize the array so there is no extra memory allocated
		check(QueuedThreads.Num() == 0);
		QueuedThreads.Empty(InNumQueuedThreads);

		// Check for stack size override.
		if( OverrideStackSize > StackSize )
		{
			StackSize = OverrideStackSize;
		}

		// Now create each thread and add it to the array
		for (uint32 Count = 0; Count < InNumQueuedThreads && bWasSuccessful == true; Count++)
		{
			// Create a new queued thread
			FQueuedThread* pThread = new FQueuedThread();
			// Now create the thread and add it if ok
			if (pThread->Create(this,StackSize,ThreadPriority) == true)
			{
				QueuedThreads.Add(pThread);
				AllThreads.Add(pThread);
			}
			else
			{
				// Failed to fully create so clean up
				bWasSuccessful = false;
				delete pThread;
			}
		}
		// Destroy any created threads if the full set was not successful
		if (bWasSuccessful == false)
		{
			Destroy();
		}
		return bWasSuccessful;
	}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:42,代码来源:ThreadingBase.cpp

示例8: CoefficientTotal

TArray<FLayoutGeometry> SSplitter2x2::ArrangeChildrenForLayout( const FGeometry& AllottedGeometry ) const
{
	check( Children.Num() == 4 );

	TArray<FLayoutGeometry> Result;
	Result.Empty(Children.Num());

	int32 NumNonCollapsedChildren = 0;
	FVector2D CoefficientTotal(0,0);

	// The allotted space for our children is our geometry minus a little space to show splitter handles
	const FVector2D SpaceAllottedForChildren = AllottedGeometry.Size - FVector2D(SplitterHandleSize,SplitterHandleSize);

	// The current offset that the next child should be positioned at.
	FVector2D Offset(0,0);

	for (int32 ChildIndex=0; ChildIndex < Children.Num(); ++ChildIndex)
	{
		const FSlot& CurSlot = Children[ChildIndex];

		// Calculate the amount of space that this child should take up.  
		// It is based on the current percentage of space it should take up which is defined by a user moving the splitters
		const FVector2D ChildSpace = SpaceAllottedForChildren * CurSlot.PercentageAttribute.Get();

		// put them in their spot
		Result.Emplace(FSlateLayoutTransform(Offset), ChildSpace);

		// Advance to the next slot. If the child is collapsed, it takes up no room and does not need a splitter
		if( ChildIndex == 1 )
		{
			// ChildIndex of 1 means we are starting the next column so reset the Y offset.
			Offset.Y = 0.0f;
			Offset += FVector2D( ChildSpace.X + SplitterHandleSize, 0);
		}
		else
		{
			Offset += FVector2D( 0, ChildSpace.Y + SplitterHandleSize );
		}
	}
	return Result;
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:41,代码来源:SSplitter.cpp

示例9: OnSCSEditorUpdateSelectionFromNodes

void FSCSDiff::OnSCSEditorUpdateSelectionFromNodes(const TArray<FSCSEditorTreeNodePtrType>& SelectedNodes)
{
	FText InspectorTitle = FText::GetEmpty();
	TArray<UObject*> InspectorObjects;
	InspectorObjects.Empty(SelectedNodes.Num());
	for (auto NodeIt = SelectedNodes.CreateConstIterator(); NodeIt; ++NodeIt)
	{
		auto NodePtr = *NodeIt;
		if(NodePtr.IsValid() && NodePtr->CanEditDefaults())
		{
			InspectorTitle = FText::FromString(NodePtr->GetDisplayString());
			InspectorObjects.Add(NodePtr->GetComponentTemplate());
		}
	}

	if( Inspector.IsValid() )
	{
		SKismetInspector::FShowDetailsOptions Options(InspectorTitle, true);
		Inspector->ShowDetailsForObjects(InspectorObjects, Options);
	}
}
开发者ID:JustDo1989,项目名称:UnrealEngine4.11-HairWorks,代码行数:21,代码来源:SCSDiff.cpp

示例10: GetTargetFunction

void UK2Node_CallArrayFunction::GetArrayTypeDependentPins(TArray<UEdGraphPin*>& OutPins) const
{
	OutPins.Empty();

	UFunction* TargetFunction = GetTargetFunction();
	check(TargetFunction);

	const FString DependentPinMetaData = TargetFunction->GetMetaData(FBlueprintMetadata::MD_ArrayDependentParam);
	TArray<FString> TypeDependentPinNames;
	DependentPinMetaData.ParseIntoArray(TypeDependentPinNames, TEXT(","), true);

	for(TArray<UEdGraphPin*>::TConstIterator it(Pins); it; ++it)
	{
		UEdGraphPin* CurrentPin = *it;
		int32 ItemIndex = 0;
		if( CurrentPin && TypeDependentPinNames.Find(CurrentPin->PinName, ItemIndex) )
		{
			OutPins.Add(CurrentPin);
		}
	}
}
开发者ID:PickUpSU,项目名称:UnrealEngine4,代码行数:21,代码来源:K2Node_CallArrayFunction.cpp

示例11: SortTriangles_Random

void SortTriangles_Random( int32 NumTriangles, const FSoftSkinVertex* Vertices, uint32* Indices )
{
	TArray<int32> Triangles;
	for( int32 i=0;i<NumTriangles;i++ )
	{
		Triangles.Insert(i, i > 0 ? FMath::Rand() % i : 0);
	}

	// export new draw order
	TArray<uint32> NewIndices;
	NewIndices.Empty(NumTriangles*3);
	for( int TriIndex=0;TriIndex<NumTriangles;TriIndex++ )
	{
		int32 tri = Triangles[TriIndex];
		NewIndices.Add(Indices[tri*3+0]);
		NewIndices.Add(Indices[tri*3+1]);
		NewIndices.Add(Indices[tri*3+2]);	
	}

	FMemory::Memcpy( Indices, NewIndices.GetData(), NewIndices.Num() * sizeof(uint32) );
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:21,代码来源:SkeletalMeshSorting.cpp

示例12: CalculateStep1dCDF

/** Calculates the step 1D cumulative distribution function for the given unnormalized probability distribution function. */
void CalculateStep1dCDF(const TArray<float>& PDF, TArray<float>& CDF, float& UnnormalizedIntegral)
{
	CDF.Empty(PDF.Num());
	float RunningUnnormalizedIntegral = 0;
	CDF.Add(0.0f);
	for (int32 i = 1; i < PDF.Num(); i++)
	{
		RunningUnnormalizedIntegral += PDF[i - 1];
		CDF.Add(RunningUnnormalizedIntegral);
	}
	UnnormalizedIntegral = RunningUnnormalizedIntegral + PDF.Last();
	if (UnnormalizedIntegral > 0.0f)
	{
		// Normalize the CDF
		for (int32 i = 1; i < CDF.Num(); i++)
		{
			CDF[i] /= UnnormalizedIntegral;
		}
	}
	check(CDF.Num() == PDF.Num());
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:22,代码来源:MonteCarlo.cpp

示例13: BeginPlay

// Called when the game starts or when spawned
void AWorldSpawn::BeginPlay() {
    Super::BeginPlay();

	UE_LOG(LogTemp, Warning, TEXT("BEGIN PLAY"));

	hex_list.clear();
	chunk_triangles.Empty();

	AActor* new_hex_obj = GetWorld()->SpawnActor<AActor>(hex_asset, FVector::ZeroVector, FRotator(0, -90, 0));
	UStaticMeshComponent* mesh_component = Cast<UStaticMeshComponent>(new_hex_obj->GetComponentByClass(UStaticMeshComponent::StaticClass()));
	vertex_buffer = &mesh_component->StaticMesh->RenderData->LODResources[0].PositionVertexBuffer;
	index_buffer = mesh_component->StaticMesh->RenderData->LODResources[0].IndexBuffer.GetArrayView();
	new_hex_obj->Destroy();

	SetActorRotation(FRotator(0, -90, 0));

	UE_LOG(LogTemp, Warning, TEXT("num_vertices: %d"), vertex_buffer->GetNumVertices());

    fnoise.init();
	gen_chunk();
}
开发者ID:fordream,项目名称:unreal-voxel-terrain,代码行数:22,代码来源:WorldSpawn.cpp

示例14: UpdateChunkSelection

void FDestructibleMeshEditorViewportClient::UpdateChunkSelection( TArray<int32> InSelectedChunkIndices )
{
	// Store the proxies in the ppol
	UnusedProxies.Append(SelectedChunks);

	// Clear selected chunks
	SelectedChunks.Empty(InSelectedChunkIndices.Num());

	// make sure we have enough proxies to fill the selection array */
	while(UnusedProxies.Num() < InSelectedChunkIndices.Num())
	{
		UnusedProxies.Add(NewObject<UDestructibleChunkParamsProxy>());
	}

	UDestructibleMesh* DestructibleMesh = DestructibleMeshEditorPtr.Pin()->GetDestructibleMesh();
	UDestructibleFractureSettings* FractureSettings = DestructibleMesh->FractureSettings;

	TArray<UObject*> SelectedObjects;
	// Setup the selection array
	for (int32 i=0; i < InSelectedChunkIndices.Num(); ++i)
	{
		UDestructibleChunkParamsProxy* Proxy = UnusedProxies.Pop();

		Proxy->DestructibleMesh = DestructibleMesh;
		Proxy->ChunkIndex = InSelectedChunkIndices[i];
		Proxy->DestructibleMeshEditorPtr = DestructibleMeshEditorPtr;

		if (FractureSettings != NULL && FractureSettings->ChunkParameters.Num() > Proxy->ChunkIndex)
		{
			Proxy->ChunkParams = Proxy->DestructibleMesh->FractureSettings->ChunkParameters[Proxy->ChunkIndex];
		}

		SelectedChunks.Add(Proxy);
		SelectedObjects.Add(Proxy);
	}


	FDestructibleMeshEditor* MeshEd = (FDestructibleMeshEditor*)DestructibleMeshEditorPtr.Pin().Get();
	MeshEd->SetSelectedChunks(SelectedObjects);
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:40,代码来源:SDestructibleMeshEditorViewport.cpp

示例15: OnColorPickerCancelled

void FColorStructCustomization::OnColorPickerCancelled( FLinearColor OriginalColor )
{
	TArray<FString> PerObjectColors;

	for( int32 ColorIndex = 0; ColorIndex < SavedPreColorPickerColors.Num(); ++ColorIndex )
	{
		if( bIsLinearColor )
		{
			PerObjectColors.Add( SavedPreColorPickerColors[ColorIndex].ToString() );
		}
		else
		{
			const bool bSRGB = false;
			FColor Color = SavedPreColorPickerColors[ColorIndex].ToFColor( bSRGB );
			PerObjectColors.Add( Color.ToString() );
		}
	}

	StructPropertyHandle->SetPerObjectValues( PerObjectColors );

	PerObjectColors.Empty();
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:22,代码来源:MathStructCustomizations.cpp


注:本文中的TArray::Empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。