本文整理汇总了C++中TArray::AddUninitialized方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::AddUninitialized方法的具体用法?C++ TArray::AddUninitialized怎么用?C++ TArray::AddUninitialized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::AddUninitialized方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawDebugSolidPlane
/** Loc is an anchor point in the world to guide which part of the infinite plane to draw. */
void DrawDebugSolidPlane(const UWorld* InWorld, FPlane const& P, FVector const& Loc, float Size, FColor const& Color, bool bPersistent, float LifeTime, uint8 DepthPriority)
{
// no debug line drawing on dedicated server
if (GEngine->GetNetMode(InWorld) != NM_DedicatedServer)
{
FVector const ClosestPtOnPlane = Loc - P.PlaneDot(Loc) * P;
FVector U, V;
P.FindBestAxisVectors(U, V);
U *= Size;
V *= Size;
TArray<FVector> Verts;
Verts.AddUninitialized(4);
Verts[0] = ClosestPtOnPlane + U + V;
Verts[1] = ClosestPtOnPlane - U + V;
Verts[2] = ClosestPtOnPlane + U - V;
Verts[3] = ClosestPtOnPlane - U - V;
TArray<int32> Indices;
Indices.AddUninitialized(6);
Indices[0] = 0; Indices[1] = 2; Indices[2] = 1;
Indices[3] = 1; Indices[4] = 2; Indices[5] = 3;
// plane quad
DrawDebugMesh(InWorld, Verts, Indices, Color, bPersistent, LifeTime, DepthPriority);
// arrow indicating normal
DrawDebugDirectionalArrow(InWorld, ClosestPtOnPlane, ClosestPtOnPlane + P * 16.f, 8.f, FColor::White, bPersistent, LifeTime, DepthPriority);
}
}
示例2: BlendPosesTogetherPerBone
void FAnimationRuntime::BlendPosesTogetherPerBone(const TArray<FCompactPose>& SourcePoses, const TArray<FBlendedCurve>& SourceCurves, const UBlendSpaceBase* BlendSpace, const TArray<FBlendSampleData>& BlendSampleDataCache, /*out*/ FCompactPose& ResultPose, /*out*/ FBlendedCurve& ResultCurve)
{
check(SourcePoses.Num() > 0);
const TArray<FBoneIndexType> & RequiredBoneIndices = ResultPose.GetBoneContainer().GetBoneIndicesArray();
TArray<int32> PerBoneIndices;
PerBoneIndices.AddUninitialized(ResultPose.GetNumBones());
for (int32 BoneIndex = 0; BoneIndex < PerBoneIndices.Num(); ++BoneIndex)
{
PerBoneIndices[BoneIndex] = BlendSpace->GetPerBoneInterpolationIndex(RequiredBoneIndices[BoneIndex], ResultPose.GetBoneContainer());
}
BlendPosePerBone<ETransformBlendMode::Overwrite>(PerBoneIndices, BlendSampleDataCache[0], ResultPose, SourcePoses[0]);
for (int32 i = 1; i < SourcePoses.Num(); ++i)
{
BlendPosePerBone<ETransformBlendMode::Accumulate>(PerBoneIndices, BlendSampleDataCache[i], ResultPose, SourcePoses[i]);
}
// Ensure that all of the resulting rotations are normalized
ResultPose.NormalizeRotations();
if (SourceCurves.Num() > 0)
{
TArray<float> SourceWeights;
SourceWeights.AddUninitialized(BlendSampleDataCache.Num());
for (int32 CacheIndex=0; CacheIndex<BlendSampleDataCache.Num(); ++CacheIndex)
{
SourceWeights[CacheIndex] = BlendSampleDataCache[CacheIndex].TotalWeight;
}
BlendCurves(SourceCurves, SourceWeights, ResultCurve);
}
}
示例3: UncompressFileDataFile
bool FBuildPatchUtils::UncompressFileDataFile(TArray< uint8 >& DataFileArray, FChunkHeader* OutHeader/* = nullptr*/)
{
FChunkHeader Header;
if (OutHeader == nullptr)
{
OutHeader = &Header;
}
FMemoryReader FileArrayReader(DataFileArray);
// Read the header
FileArrayReader << *OutHeader;
// Check header
const bool bValidHeader = OutHeader->IsValidMagic();
const bool bSupportedFormat = !(OutHeader->StoredAs & FChunkHeader::STORED_ENCRYPTED);
if (bValidHeader && bSupportedFormat)
{
bool bSuccess = true;
// Uncompress if we need to
if (OutHeader->StoredAs == FChunkHeader::STORED_COMPRESSED)
{
// Load the compressed data
const int32 CompressedSize = DataFileArray.Num() - OutHeader->HeaderSize;
TArray< uint8 > CompressedData;
TArray< uint8 > UncompressedData;
CompressedData.Empty(CompressedSize);
CompressedData.AddUninitialized(CompressedSize);
UncompressedData.Empty(OutHeader->DataSize);
UncompressedData.AddUninitialized(OutHeader->DataSize);
FileArrayReader.Serialize(CompressedData.GetData(), CompressedSize);
FileArrayReader.Close();
// Uncompress
bSuccess = FCompression::UncompressMemory(
static_cast<ECompressionFlags>(COMPRESS_ZLIB | COMPRESS_BiasMemory),
UncompressedData.GetData(),
UncompressedData.Num(),
CompressedData.GetData(),
CompressedData.Num());
// If successful, write back over the original array
if (bSuccess)
{
DataFileArray.Empty();
FMemoryWriter FileArrayWriter(DataFileArray);
OutHeader->StoredAs = FChunkHeader::STORED_RAW;
FileArrayWriter << *OutHeader;
FileArrayWriter.Serialize(UncompressedData.GetData(), UncompressedData.Num());
FileArrayWriter.Close();
}
}
return bSuccess;
}
return false;
}
示例4: TEXT
TArray<uint8> UGTCaptureComponent::CaptureNpyFloat16(FString Mode, int32 Channels)
{
// Flush location and rotation
check(CaptureComponents.Num() != 0);
USceneCaptureComponent2D* CaptureComponent = CaptureComponents.FindRef(Mode);
TArray<uint8> NpyData;
if (CaptureComponent == nullptr) {
UE_LOG(LogUnrealCV, Error, TEXT("Component for mode %s not found. Returning empty array."), *Mode);
return NpyData;
}
// Attach this to something, for example, a real camera
const FRotator PawnViewRotation = Pawn->GetViewRotation();
if (!PawnViewRotation.Equals(CaptureComponent->GetComponentRotation()))
{
CaptureComponent->SetWorldRotation(PawnViewRotation);
}
UTextureRenderTarget2D* RenderTarget = CaptureComponent->TextureTarget;
int32 Width = RenderTarget->SizeX, Height = RenderTarget->SizeY;
TArray<FFloat16Color> ImageData;
FTextureRenderTargetResource* RenderTargetResource;
ImageData.AddUninitialized(Width * Height);
RenderTargetResource = RenderTarget->GameThread_GetRenderTargetResource();
RenderTargetResource->ReadFloat16Pixels(ImageData);
// Check the byte order of data
// Compress image data to npy array
// Generate a header for the numpy array
NpyData = NpySerialization(ImageData, Width, Height, Channels);
return NpyData;
}
示例5: ParseFileAttributes
bool FFileAttributesParserImpl::ParseFileAttributes(const FString& MetaFilename, TMap<FString, FFileAttributes>& FileAttributes)
{
TAutoPtr<IFileHandle> Handle(PlatformFile.OpenRead(*MetaFilename));
if (Handle.IsValid())
{
TArray<uint8> FileData;
FileData.AddUninitialized(Handle->Size());
if (Handle->Read(FileData.GetData(), FileData.Num()))
{
FString FileDataString;
FFileHelper::BufferToString(FileDataString, FileData.GetData(), FileData.Num());
return FileAttributesMetaToMap(FileDataString, FileAttributes);
}
else
{
UE_LOG(LogFileAttributesParser, Error, TEXT("Could not read meta file %s"), *MetaFilename);
}
}
else
{
UE_LOG(LogFileAttributesParser, Error, TEXT("Could not open meta file %s"), *MetaFilename);
}
return false;
}
示例6: ReadAndStoreSaveFileURL
/**
* This function parses the Json response after uploading the save file to obtain the
* URL of the save file.
*
* @param JsonString Json string to parse
* @param PlayerControllerId Player controller ID of the player who is saving the file
*
*/
void CloudyWebConnectorImpl::ReadAndStoreSaveFileURL(FString JsonString, int32 PlayerControllerId)
{
JsonString = JsonString.Replace(TEXT("["), TEXT(""));
JsonString = JsonString.Replace(TEXT("]"), TEXT(""));
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
TSharedRef<TJsonReader<TCHAR>> JsonReader = TJsonReaderFactory<TCHAR>::Create(JsonString);
FJsonSerializer::Deserialize(JsonReader, JsonObject);
// More player controllers than the TArray size
if (PlayerControllerId >= SaveFileUrls.Num())
{
SaveFileUrls.AddUninitialized(PlayerControllerId - SaveFileUrls.Num() + 1);
}
if (JsonObject->HasField("saved_file"))
{
UE_LOG(CloudyWebConnectorLog, Error, TEXT("Json saved_file field found."));
SaveFileUrls.Insert(JsonObject->GetStringField("saved_file"), PlayerControllerId);
}
else
{
UE_LOG(CloudyWebConnectorLog, Error, TEXT("Json saved_file field NOT found."));
SaveFileUrls.Insert("", PlayerControllerId);
}
}
示例7: InitializeFromUncompressedData
void FReflectionCaptureFullHDRDerivedData::InitializeFromUncompressedData(const TArray<uint8>& UncompressedData)
{
DEC_MEMORY_STAT_BY(STAT_ReflectionCaptureMemory, CompressedCapturedData.GetAllocatedSize());
int32 UncompressedSize = UncompressedData.Num() * UncompressedData.GetTypeSize();
TArray<uint8> TempCompressedMemory;
// Compressed can be slightly larger than uncompressed
TempCompressedMemory.Empty(UncompressedSize * 4 / 3);
TempCompressedMemory.AddUninitialized(UncompressedSize * 4 / 3);
int32 CompressedSize = TempCompressedMemory.Num() * TempCompressedMemory.GetTypeSize();
verify(FCompression::CompressMemory(
(ECompressionFlags)(COMPRESS_ZLIB | COMPRESS_BiasMemory),
TempCompressedMemory.GetData(),
CompressedSize,
UncompressedData.GetData(),
UncompressedSize));
// Note: change REFLECTIONCAPTURE_FULL_DERIVEDDATA_VER when modifying the serialization layout
FMemoryWriter FinalArchive(CompressedCapturedData, true);
FinalArchive << UncompressedSize;
FinalArchive << CompressedSize;
FinalArchive.Serialize(TempCompressedMemory.GetData(), CompressedSize);
INC_MEMORY_STAT_BY(STAT_ReflectionCaptureMemory, CompressedCapturedData.GetAllocatedSize());
}
示例8: FName
TSharedPtr< FSlateDynamicImageBrush > FEpicSurvey::LoadRawDataAsBrush( FName ResourceName, const TArray< uint8 >& RawData ) const
{
TSharedPtr< FSlateDynamicImageBrush > Brush;
uint32 BytesPerPixel = 4;
int32 Width = 0;
int32 Height = 0;
bool bSucceeded = false;
TArray<uint8> DecodedImage;
IImageWrapperModule& ImageWrapperModule = FModuleManager::LoadModuleChecked<IImageWrapperModule>( FName("ImageWrapper") );
IImageWrapperPtr ImageWrapper = ImageWrapperModule.CreateImageWrapper( EImageFormat::PNG );
if ( ImageWrapper.IsValid() && ImageWrapper->SetCompressed( RawData.GetData(), RawData.Num() ) )
{
Width = ImageWrapper->GetWidth();
Height = ImageWrapper->GetHeight();
const TArray<uint8>* RawImageData = NULL;
if (ImageWrapper->GetRaw(ERGBFormat::BGRA, 8, RawImageData))
{
DecodedImage.AddUninitialized( Width * Height * BytesPerPixel );
DecodedImage = *RawImageData;
bSucceeded = true;
}
}
if ( bSucceeded )
{
Brush = FSlateDynamicImageBrush::CreateWithImageData( ResourceName, FVector2D(ImageWrapper->GetWidth(), ImageWrapper->GetHeight()), DecodedImage );
}
return Brush;
}
示例9: FillUpSpaceBasesRetargetBasePose
void FAnimationRuntime::FillUpSpaceBasesRetargetBasePose(const USkeleton* Skeleton, TArray<FTransform> &SpaceBaseRefPose)
{
check(Skeleton);
// @Todo fixme: this has to get preview mesh instead of skeleton
const USkeletalMesh* PreviewMesh = Skeleton->GetPreviewMesh();
if (PreviewMesh)
{
const TArray<FTransform> & ReferencePose = PreviewMesh->RetargetBasePose;
SpaceBaseRefPose.Empty(ReferencePose.Num());
SpaceBaseRefPose.AddUninitialized(ReferencePose.Num());
// initialize to identity since some of them don't have tracks
for(int Index=0; Index <SpaceBaseRefPose.Num(); ++Index)
{
int32 ParentIndex = PreviewMesh->RefSkeleton.GetParentIndex(Index);
if(ParentIndex != INDEX_NONE)
{
SpaceBaseRefPose[Index] = ReferencePose[Index] * SpaceBaseRefPose[ParentIndex];
}
else
{
SpaceBaseRefPose[Index] = ReferencePose[Index];
}
}
}
else
{
FAnimationRuntime::FillUpSpaceBasesRefPose(Skeleton, SpaceBaseRefPose);
}
}
示例10: SetCollisionResponseForActor
void UDestructibleComponent::SetCollisionResponseForActor(const FCollisionResponse& ColResponse, PxRigidDynamic* Actor, int32 ChunkIdx)
{
// Get collision channel and response
PxFilterData PQueryFilterData, PSimFilterData;
uint8 MoveChannel = GetCollisionObjectType();
if(IsCollisionEnabled())
{
AActor* Owner = GetOwner();
CreateShapeFilterData(MoveChannel, (Owner ? Owner->GetUniqueID() : 0), ColResponse.GetResponseContainer(), 0, ChunkIdxToBoneIdx(ChunkIdx), PQueryFilterData, PSimFilterData, BodyInstance.bUseCCD, BodyInstance.bNotifyRigidBodyCollision, false);
PQueryFilterData.word3 |= EPDF_SimpleCollision | EPDF_ComplexCollision;
SCOPED_SCENE_WRITE_LOCK(Actor->getScene());
TArray<PxShape*> Shapes;
Shapes.AddUninitialized(Actor->getNbShapes());
int ShapeCount = Actor->getShapes(Shapes.GetTypedData(), Shapes.Num());
for (int32 i=0; i < ShapeCount; ++i)
{
PxShape* Shape = Shapes[i];
Shape->setQueryFilterData(PQueryFilterData);
Shape->setSimulationFilterData(PSimFilterData);
Shape->setFlag(PxShapeFlag::eSCENE_QUERY_SHAPE, true);
Shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true);
Shape->setFlag(PxShapeFlag::eVISUALIZATION, true);
}
}
}
示例11: DeserializeFromData
bool FBuildPatchAppManifest::DeserializeFromData(const TArray<uint8>& DataInput)
{
if (DataInput.Num())
{
if (BufferIsJsonManifest(DataInput))
{
FString JsonManifest;
FFileHelper::BufferToString(JsonManifest, DataInput.GetData(), DataInput.Num());
return DeserializeFromJSON(JsonManifest);
}
else
{
FMemoryReader ManifestFile(DataInput);
FManifestFileHeader Header;
ManifestFile << Header;
const int32 SignedHeaderSize = Header.HeaderSize;
if (Header.CheckMagic() && DataInput.Num() > SignedHeaderSize)
{
FSHAHashData DataHash;
FSHA1::HashBuffer(&DataInput[Header.HeaderSize], DataInput.Num() - Header.HeaderSize, DataHash.Hash);
if (DataHash == Header.SHAHash)
{
TArray<uint8> UncompressedData;
if (Header.StoredAs == FChunkHeader::STORED_COMPRESSED && (Header.CompressedSize + Header.HeaderSize) == DataInput.Num())
{
UncompressedData.AddUninitialized(Header.DataSize);
if (!FCompression::UncompressMemory(
static_cast<ECompressionFlags>(COMPRESS_ZLIB | COMPRESS_BiasMemory),
UncompressedData.GetData(),
Header.DataSize,
&DataInput[Header.HeaderSize],
DataInput.Num() - Header.HeaderSize))
{
return false;
}
}
else if ((Header.DataSize + Header.HeaderSize) == DataInput.Num())
{
UncompressedData.Append(&DataInput[Header.HeaderSize], Header.DataSize);
}
else
{
return false;
}
FManifestReader ManifestData(UncompressedData);
return Serialize(ManifestData);
}
else
{
return false;
}
}
else
{
return false;
}
}
}
return false;
}
示例12: MakeShareable
TSharedPtr<FSlateDynamicImageBrush> FNewsFeedCache::RawDataToBrush( FName ResourceName, const TArray< uint8 >& InRawData ) const
{
TSharedPtr<FSlateDynamicImageBrush> Brush;
uint32 BytesPerPixel = 4;
int32 Width = 0;
int32 Height = 0;
bool bSucceeded = false;
TArray<uint8> DecodedImage;
IImageWrapperModule& ImageWrapperModule = FModuleManager::LoadModuleChecked<IImageWrapperModule>(FName("ImageWrapper"));
IImageWrapperPtr ImageWrapper = ImageWrapperModule.CreateImageWrapper( EImageFormat::PNG );
if (ImageWrapper.IsValid() && ImageWrapper->SetCompressed(InRawData.GetData(), InRawData.Num()))
{
Width = ImageWrapper->GetWidth();
Height = ImageWrapper->GetHeight();
const TArray<uint8>* RawData = NULL;
if (ImageWrapper->GetRaw( ERGBFormat::BGRA, 8, RawData))
{
DecodedImage.AddUninitialized( Width * Height * BytesPerPixel );
DecodedImage = *RawData;
bSucceeded = true;
}
}
if (bSucceeded && FSlateApplication::Get().GetRenderer()->GenerateDynamicImageResource(ResourceName, ImageWrapper->GetWidth(), ImageWrapper->GetHeight(), DecodedImage))
{
Brush = MakeShareable(new FSlateDynamicImageBrush(ResourceName, FVector2D(ImageWrapper->GetWidth(), ImageWrapper->GetHeight())));
}
return Brush;
}
示例13: ProceduralWaveUnderflow
void UPhyaCollisionHandler::ProceduralWaveUnderflow(USoundWaveProcedural* InProceduralWave, int32 SamplesRequired)
{
check(ProceduralWave == InProceduralWave);
const int32 QueuedSamples = ProceduralWave->GetAvailableAudioByteCount()/sizeof(uint16);
const int32 SamplesNeeded = SamplesRequired - QueuedSamples;
const int32 BlocksNeeded = FMath::CeilToInt(SamplesNeeded/BlockSize);
UE_LOG(LogTemp, Log, TEXT("Creating %d blocks for %s"), BlocksNeeded, *GetWorld()->GetPathName());
TArray<int16> SampleData;
SampleData.AddUninitialized(BlocksNeeded * BlockSize);
int32 CurrSample = 0;
for(int32 BlockIdx=0; BlockIdx<BlocksNeeded; BlockIdx++)
{
paBlock* AudioBlock = paTick();
float* AudioData = AudioBlock->getStart();
for(int32 SampleIdx=0; SampleIdx<BlockSize; SampleIdx++)
{
SampleData[CurrSample] = (int16)AudioData[SampleIdx];
CurrSample++;
//UE_LOG(LogTemp, Log, TEXT("%d:%f"), CurrSample, SampleData[CurrSample]);
}
}
ProceduralWave->QueueAudio((uint8*)SampleData.GetData(), SampleData.Num() * sizeof(int16));
}
示例14: AllocateTransformData
bool UPoseableMeshComponent::AllocateTransformData()
{
// Allocate transforms if not present.
if ( Super::AllocateTransformData() )
{
if( LocalAtoms.Num() != SkeletalMesh->RefSkeleton.GetNum() )
{
LocalAtoms = SkeletalMesh->RefSkeleton.GetRefBonePose();
TArray<FBoneIndexType> RequiredBoneIndexArray;
RequiredBoneIndexArray.AddUninitialized(LocalAtoms.Num());
for(int32 BoneIndex = 0; BoneIndex < LocalAtoms.Num(); ++BoneIndex)
{
RequiredBoneIndexArray[BoneIndex] = BoneIndex;
}
RequiredBones.InitializeTo(RequiredBoneIndexArray, *SkeletalMesh);
}
FillSpaceBases();
FlipEditableSpaceBases();
return true;
}
LocalAtoms.Empty();
return false;
}
示例15: GetRawSamplesFromBlendInput
void UBlendSpace::GetRawSamplesFromBlendInput(const FVector &BlendInput, TArray<FGridBlendSample> & OutBlendSamples) const
{
OutBlendSamples.Empty(4);
OutBlendSamples.AddUninitialized(4);
GetGridSamplesFromBlendInput(BlendInput, OutBlendSamples[0], OutBlendSamples[1], OutBlendSamples[2], OutBlendSamples[3]);
}