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


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

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


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

示例1:

TArray<QuestTask*> QuestTask::getSubTasks() {
	TArray<QuestTask*> result;

	result.Init(0);

	return result;
}
开发者ID:JustInToCoding,项目名称:UnionGame,代码行数:7,代码来源:QuestTask.cpp

示例2: ExtractDDSInRGBE

void FHDRLoadHelper::ExtractDDSInRGBE(TArray<uint8>& OutDDSFile) const
{
	// header, one uint32 per texel, no mips
	OutDDSFile.Init(4 + sizeof(FDDSFileHeader) + GetWidth() * GetHeight() * sizeof(uint32));

	// create the dds header
	{
		uint32* DDSMagicNumber = (uint32*)OutDDSFile.GetData();

		// to identify DDS file format
		*DDSMagicNumber = 0x20534444;

		FDDSFileHeader* header = (FDDSFileHeader*)(OutDDSFile.GetData() + 4);

		FMemory::MemZero(*header);

		header->dwSize = sizeof(FDDSFileHeader);
		header->dwFlags = DDSF_Caps | DDSF_Height | DDSF_Width | DDSF_PixelFormat;
		header->dwWidth = GetWidth();
		header->dwHeight = GetHeight();
		header->dwCaps2 = 0;
		header->dwMipMapCount = 1;
		header->ddpf.dwSize = sizeof(FDDSPixelFormatHeader);
		header->ddpf.dwFlags = DDSPF_RGB;
		header->ddpf.dwRGBBitCount = 32;
		header->ddpf.dwRBitMask = 0x00ff0000;
		header->ddpf.dwGBitMask = 0x0000ff00;
		header->ddpf.dwBBitMask = 0x000000ff;
	}

	uint32 *DDSData = (uint32*)(OutDDSFile.GetData() + 4 + sizeof(FDDSFileHeader));

	// Get the raw input data as 2d image
	DecompressWholeImage(DDSData);
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:35,代码来源:HDRLoader.cpp

示例3: ReadToArray

bool FPipeHandle::ReadToArray(TArray<uint8> & Output)
{
	int BytesAvailable = 0;
	if (ioctl(PipeDesc, FIONREAD, &BytesAvailable) == 0)
	{
		if (BytesAvailable > 0)
		{
			Output.Init(BytesAvailable);
			int BytesRead = read(PipeDesc, Output.GetData(), BytesAvailable);
			if (BytesRead > 0)
			{
				if (BytesRead < BytesAvailable)
				{
					Output.SetNum(BytesRead);
				}

				return true;
			}
			else
			{
				Output.Empty();
			}
		}
	}

	return false;
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:27,代码来源:LinuxPlatformProcess.cpp

示例4: PrepareContext

bool FEnvQueryInstance::PrepareContext(UClass* Context, TArray<FVector>& Data)
{
	if (Context == NULL)
	{
		return false;
	}

	FEnvQueryContextData ContextData;
	const bool bSuccess = PrepareContext(Context, ContextData);

	if (bSuccess && ContextData.ValueType && ContextData.ValueType->IsChildOf(UEnvQueryItemType_LocationBase::StaticClass()))
	{
		UEnvQueryItemType_LocationBase* DefTypeOb = (UEnvQueryItemType_LocationBase*)ContextData.ValueType->GetDefaultObject();
		const uint16 DefTypeValueSize = DefTypeOb->GetValueSize();
		uint8* RawData = (uint8*)ContextData.RawData.GetTypedData();

		Data.Init(ContextData.NumValues);
		for (int32 i = 0; i < ContextData.NumValues; i++)
		{
			Data[i] = DefTypeOb->GetLocation(RawData);
			RawData += DefTypeValueSize;
		}
	}

	return bSuccess;
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:26,代码来源:EnvQueryInstance.cpp

示例5: Float

void ABalloonGrid::Float()
{
	SP_Grid NullGrid;
	TArray<SP_Grid> Highest;
	Highest.Init(NullGrid, GridSizeX);
	for (auto G : SearchResult)
	{
		if (Highest[G->X] == NullGrid || Highest[G->X]->Y > G->Y)
		{
			Highest[G->X] = G;
		}
	}
	ABalloon* SignalBalloon = NULL;
	int32 OffsetMax = 0;
	for (auto G : Highest)
	{
		int32 FloatOffset = 1;
		if (G == NullGrid) continue;
		//UE_LOG(YLog, Warning, TEXT("Float, X:%d,Y:%d"), G->X, G->Y);
		for (int32 y = G->Y+1; y < GridSizeY; ++y)
		{
			SP_Grid GTemp = Grids[y*GridSizeX + G->X];
			if (GTemp->Object != NULL)
			{
				int32 TargetGridY = GTemp->Y - FloatOffset;
				if (FloatOffset > OffsetMax)
				{
					OffsetMax = FloatOffset;
					SignalBalloon = GTemp->Object;
				}
				GTemp->Object->SetTargetGrid(G->X, TargetGridY);
				Grids[TargetGridY*GridSizeX + G->X]->Object = GTemp->Object;
				GTemp->Object = NULL;
			}
			else
			{
				++FloatOffset;
			}
		}
		UE_LOG(YLog, Warning, TEXT("FloatOffset:%d"), FloatOffset);
		if (FloatOffset == GridSizeY)
		{
			--MaxBalloonX;
			UE_LOG(YLog, Warning, TEXT("MaxBalloonX:%d"), MaxBalloonX);
		}
	}
	Join();
	if (SignalBalloon)
	{
		UE_LOG(YLog, Warning, TEXT("SignalBalloon MaxBalloonX:%d"), MaxBalloonX);
		SignalBalloon->bIsSignal = true;
		SignalBalloon->NewBalloonX = MaxBalloonX;
	}
	else
	{
		SignalBalloon->gBalloonX = MaxBalloonX;
	}
	SearchResult.Empty();
}
开发者ID:Physwf,项目名称:physwf-unreal-lab,代码行数:59,代码来源:BalloonGrid.cpp

示例6: rebuildBaseMeshFromGrid

void UGridMesher::rebuildBaseMeshFromGrid()
{
	ClearAllMeshSections();
	numMeshes = 0;

	if (myGrid != nullptr)
	{
		TArray<float> vertexRadii;
		vertexRadii.Init(baseMeshRadius, myGrid->numNodes);
		TArray<FColor> vertexColors;
		vertexColors.Init(FColor::Blue, myGrid->numNodes);
		
		if (renderBaseMesh)
		{
			buildNewMesh(vertexRadii, vertexColors,TArray<FVector>(), baseMeshMaterial);
		}
	}
}
开发者ID:Lightheart54,项目名称:HexPlanet,代码行数:18,代码来源:GridMesher.cpp

示例7: UpdateUITexture

void UVaQuoleUIComponent::UpdateUITexture()
{
	// Ignore texture update
	if (!bEnabled || WebUI == NULL)
	{
		return;
	}

	// Don't update when WebView resizes or changes texture format
	if (WebUI->IsPendingVisualEvents())
	{
		return;
	}

	if (Texture && Texture->Resource)
	{
		// Check that texture is prepared
		auto rhiRef = static_cast<FTexture2DResource*>(Texture->Resource)->GetTexture2DRHI();
		if (!rhiRef)
			return;

		// Load data from view
		const UCHAR* my_data = WebUI->GrabView();
		const size_t size = Width * Height * sizeof(uint32);

		// @TODO This is a bit heavy to keep reallocating/deallocating, but not a big deal. Maybe we can ping pong between buffers instead.
		TArray<uint32> ViewBuffer;
		ViewBuffer.Init(Width * Height);
		FMemory::Memcpy(ViewBuffer.GetData(), my_data, size);

		// This will be passed off to the render thread, which will delete it when it has finished with it
		FVaQuoleTextureDataPtr DataPtr = MakeShareable(new FVaQuoleTextureData);
		DataPtr->SetRawData(Width, Height, sizeof(uint32), ViewBuffer);

		// Cleanup
		ViewBuffer.Empty();
		my_data = 0;

		ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER(
			UpdateVaQuoleTexture,
			FVaQuoleTextureDataPtr, ImageData, DataPtr,
			FTexture2DRHIRef, TargetTexture, rhiRef,
			const size_t, DataSize, size,
		{
			uint32 stride = 0;
			void* MipData = GDynamicRHI->RHILockTexture2D(TargetTexture, 0, RLM_WriteOnly, stride, false);

			if (MipData)
			{
				FMemory::Memcpy(MipData, ImageData->GetRawBytesPtr(), ImageData->GetDataSize());
				GDynamicRHI->RHIUnlockTexture2D(TargetTexture, 0, false);
			}

			ImageData.Reset();
		});
开发者ID:Aboutdept,项目名称:VaQuoleUI,代码行数:55,代码来源:VaQuoleUIComponent.cpp

示例8: FirstFreeID

int8 APlayerConnectionHandler::FirstFreeID()
{
    TArray<bool> Available;
    Available.Init(true, Clients.Num());
    for (auto Client : Clients){
        if(Client.Status != EPlayerStatus::Disconnected) Available[Client.ID] = false;
    }
    for (int8 Result = 0; Result < Clients.Num(); Result++){
        if (Available[Result]) return Result;
    }
	return -1;
}
开发者ID:mcseyyy,项目名称:ParallaxTD,代码行数:12,代码来源:PlayerConnectionHandler.cpp

示例9: Reload

void AMagazineItem::Reload(APlayerCharacter* player) {
    TArray<AAmmoItem*> toReadd;
    toReadd.Init(NULL, 0);
    
    for (unsigned int i = 0; i < Ammunition.Num(); i++) {
        if (!Ammunition[i]) {
            // Stop if the magazine is filled
            if (GetStoredAmmo() >= Ammunition.Num()) break;
            
            ItemSlot slot = player->Inventory->FindItemByType(AAmmoItem::StaticClass());
            if (slot.IsValid()) {
                AAmmoItem* item = Cast<AAmmoItem>(slot.Get());
                if(item) {
                    if (item->Calibre == Calibre) {
                        slot.Delete();
                        Ammunition.Add(item);
                        Ammunition.Swap(i, Ammunition.Num() - 1);
                        Ammunition.RemoveAt(Ammunition.Num() - 1);
                        
                        item->SetState(None);
                        item->AttachRootComponentTo(StaticMesh);
                        item->SetActorRelativeLocation(FVector::ZeroVector);
                        item->SetActorRelativeRotation(FRotator::ZeroRotator);
                    } else {
                        toReadd.Add(item);
                        
                        slot.Delete();
                    }
                } else break;
            } else break;
        }
    }
    
    for (auto& item: toReadd) {
        if (item) {
            if (player->Inventory->EquipItem(item)) {
                // Nothing changed! (possibly state, but that is dealt for us)
                
                // Stop pickup text
                player->Inventory->RecentlyEquiped = NULL;
            } else {
                item->SetState(ItemState::World);
                item->Unwear(player);
                
                item->DetachRootComponentFromParent();
                Drop(player);
            }
        }
    }
}
开发者ID:AidoP,项目名称:OncomingPreAlpha,代码行数:50,代码来源:MagazineItem.cpp

示例10: BuildDestructibleMeshFromFractureSettings

UNREALED_API bool BuildDestructibleMeshFromFractureSettings(UDestructibleMesh& DestructibleMesh, FSkeletalMeshImportData* OutData)
{
	bool Success = false;

#if WITH_APEX
	physx::NxDestructibleAsset* NewApexDestructibleAsset = NULL;

#if WITH_EDITORONLY_DATA
	if (DestructibleMesh.FractureSettings != NULL)
	{
		TArray<UMaterialInterface*> OverrideMaterials;
		OverrideMaterials.Init(DestructibleMesh.Materials.Num());	//save old materials
		for (int32 MaterialIndex = 0; MaterialIndex < DestructibleMesh.Materials.Num(); ++MaterialIndex)
		{
			OverrideMaterials[MaterialIndex] = DestructibleMesh.Materials[MaterialIndex].MaterialInterface;
		}

		DestructibleMesh.Materials.Init(DestructibleMesh.FractureSettings->Materials.Num());

		for (int32 MaterialIndex = 0; MaterialIndex < DestructibleMesh.Materials.Num(); ++MaterialIndex)
		{
			if (MaterialIndex < OverrideMaterials.Num())	//if user has overriden materials use it
			{
				DestructibleMesh.Materials[MaterialIndex].MaterialInterface = OverrideMaterials[MaterialIndex];
			}
			else
			{
				DestructibleMesh.Materials[MaterialIndex].MaterialInterface = DestructibleMesh.FractureSettings->Materials[MaterialIndex];
			}

		}

		NxDestructibleAssetCookingDesc DestructibleAssetCookingDesc;
		DestructibleMesh.FractureSettings->BuildDestructibleAssetCookingDesc(DestructibleAssetCookingDesc);
		NewApexDestructibleAsset = DestructibleMesh.FractureSettings->CreateApexDestructibleAsset(DestructibleAssetCookingDesc);
	}
#endif	// WITH_EDITORONLY_DATA

	if (NewApexDestructibleAsset != NULL)
	{
		Success = SetApexDestructibleAsset(DestructibleMesh, *NewApexDestructibleAsset, OutData, EDestructibleImportOptions::PreserveSettings);
	}
#endif // WITH_APEX

	return Success;
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:46,代码来源:ApexDestructibleAssetImport.cpp

示例11: StringFromBinaryArray

FString	UMySocket::receiveMessage()
{
	if (!mySocket)
		return "";
	TArray<uint8> ReceivedData;
	if (pendingDateSize)
	{
		ReceivedData.Init('\0', FMath::Min(pendingDateSize, 65507u));

		int32 Read = 0;
		mySocket->Recv(ReceivedData.GetData(), ReceivedData.Num(), Read);
	}
	if (ReceivedData.Num() <= 0)
		return "";
	const FString ReceivedUE4String = StringFromBinaryArray(ReceivedData);
	return ReceivedUE4String;
}
开发者ID:Witrix,项目名称:EIP-Sowaj-ClientMobile,代码行数:17,代码来源:MySocket.cpp

示例12:

TArray<uint8> UMySocket::receiveDataWithPending()
{
	TArray<uint8> ReceivedData;

	if (!mySocket)
		return ReceivedData;

	uint32 Size;
	while (mySocket->HasPendingData(Size))
	{
		ReceivedData.Init('\0', FMath::Min(Size, 65507u));

		int32 Read = 0;
		mySocket->Recv(ReceivedData.GetData(), ReceivedData.Num(), Read);
	}
	return (ReceivedData);
}
开发者ID:Witrix,项目名称:EIP-Sowaj-ClientMobile,代码行数:17,代码来源:MySocket.cpp

示例13: TCPSocketListener

void ATitanBotsPlayerController::TCPSocketListener()
{

	///////////////
	if (!ConnectionSocket) return;
	///////////////

		//Binary Array
		TArray<uint8> ReceivedData;

		uint32 Size;
		while (ConnectionSocket->HasPendingData(Size))
		{
			ReceivedData.Init(FMath::Min(Size, 65507u), 0);

			int32 Read = 0;
			ConnectionSocket->Recv(ReceivedData.GetData(), ReceivedData.Num(), Read);

			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Data Read! %d"), ReceivedData.Num()));
		}

		if (ReceivedData.Num() <= 0)
		{
			//No Data Received
			return;
		}

		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("Data Bytes Read ~> %d"), ReceivedData.Num()));


		/////////////////////
		//						String From Binary Array
		const FString ReceivedUE4String = StringFromBinaryArray(ReceivedData);
		////////////////////

		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("As String Data ~> %s"), *ReceivedUE4String));

	if (bIsInGarage)
	{

		NFCIDCheck(ReceivedUE4String);
	}
}
开发者ID:CHADALAK1,项目名称:Game,代码行数:43,代码来源:TitanBotsPlayerController.cpp

示例14: DoWork

	void FAsyncSoundFileExportTask::DoWork()
	{
		// Create a new sound file object which we will pass our data to so we can read from it
		FSoundFile SoundFileInput;

		ESoundFileError::Type Error = SoundFileInput.Initialize(SoundFileData);
		SOUND_EXPORT_CHECK(Error);

		// Create a new sound file object which will be written to disk
		FSoundFile SoundFileOutput;

		FSoundFileDescription OriginalDescription = SoundFileData->GetOriginalDescription();
		const TArray<ESoundFileChannelMap::Type>& ChannelMap = SoundFileData->GetChannelMap();

		Error = SoundFileOutput.OpenEmptyFileForExport(ExportPath, OriginalDescription, ChannelMap);
		SOUND_EXPORT_CHECK(Error);

		// Create a buffer to do the processing 
		SoundFileCount ProcessBufferSamples = 1024 * OriginalDescription.NumChannels;
		TArray<double> ProcessBuffer;
		ProcessBuffer.Init(0.0, ProcessBufferSamples);

		// Now perform the encoding to the target file
		SoundFileCount SamplesRead = 0;
		Error = SoundFileInput.ReadSamples(ProcessBuffer.GetData(), ProcessBufferSamples, SamplesRead);
		SOUND_EXPORT_CHECK(Error);
		
		while (SamplesRead)
		{
			SOUND_EXPORT_CHECK(SoundFileInput.GetError());
			SoundFileCount SamplesWritten;

			Error = SoundFileOutput.WriteSamples(ProcessBuffer.GetData(), SamplesRead, SamplesWritten);
			SOUND_EXPORT_CHECK(Error);

			Error = SoundFileInput.ReadSamples(ProcessBuffer.GetData(), ProcessBufferSamples, SamplesRead);
			SOUND_EXPORT_CHECK(Error);
		}

		SoundFileInput.ReleaseSoundFileHandle();
		SoundFileOutput.ReleaseSoundFileHandle();
	}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:42,代码来源:UnrealAudioSoundFileExport.cpp

示例15:

TArray<uint16> UWALandscapeNode_Multiply::GenerateHeightmap()
{
	TArray<uint16> OutputA;
	TArray<uint16> OutputB;
	TArray<uint16> RetVal;

	if (InputA && InputB)
	{
		OutputA = InputA->GenerateHeightmap();
	
		OutputB = InputB->GenerateHeightmap();
	
		
		RetVal.Init(0, OutputA.Num());
		for (int32 Idx = 0; Idx < OutputA.Num(); Idx++)
		{
			RetVal[Idx] = OutputA[Idx] * OutputB[Idx];
		}

	}
	return RetVal;
}
开发者ID:iniside,项目名称:ActionRPGGame,代码行数:22,代码来源:WALandscapeNode_Multiply.cpp


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