本文整理汇总了C++中TArray::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::GetData方法的具体用法?C++ TArray::GetData怎么用?C++ TArray::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::GetData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateDefaultProperties
void FHotReloadClassReinstancer::UpdateDefaultProperties()
{
struct FPropertyToUpdate
{
UProperty* Property;
FName SubobjectName;
uint8* OldSerializedValuePtr;
uint8* NewValuePtr;
int64 OldSerializedSize;
};
/** Memory writer archive that supports UObject values the same way as FCDOWriter. */
class FPropertyValueMemoryWriter : public FMemoryWriter
{
public:
FPropertyValueMemoryWriter(TArray<uint8>& OutData)
: FMemoryWriter(OutData)
{}
virtual FArchive& operator<<(class UObject*& InObj) override
{
FArchive& Ar = *this;
if (InObj)
{
FName ClassName = InObj->GetClass()->GetFName();
FName ObjectName = InObj->GetFName();
Ar << ClassName;
Ar << ObjectName;
}
else
{
FName UnusedName = NAME_None;
Ar << UnusedName;
Ar << UnusedName;
}
return *this;
}
virtual FArchive& operator<<(FName& InName) override
{
FArchive& Ar = *this;
NAME_INDEX ComparisonIndex = InName.GetComparisonIndex();
NAME_INDEX DisplayIndex = InName.GetDisplayIndex();
int32 Number = InName.GetNumber();
Ar << ComparisonIndex;
Ar << DisplayIndex;
Ar << Number;
return Ar;
}
virtual FArchive& operator<<(FLazyObjectPtr& LazyObjectPtr) override
{
FArchive& Ar = *this;
auto UniqueID = LazyObjectPtr.GetUniqueID();
Ar << UniqueID;
return *this;
}
virtual FArchive& operator<<(FAssetPtr& AssetPtr) override
{
FArchive& Ar = *this;
auto UniqueID = AssetPtr.GetUniqueID();
Ar << UniqueID;
return Ar;
}
virtual FArchive& operator<<(FStringAssetReference& Value) override
{
FArchive& Ar = *this;
FString Path = Value.ToString();
Ar << Path;
if (IsLoading())
{
Value.SetPath(MoveTemp(Path));
}
return Ar;
}
};
// Collect default subobjects to update their properties too
const int32 DefaultSubobjectArrayCapacity = 16;
TArray<UObject*> DefaultSubobjectArray;
DefaultSubobjectArray.Empty(DefaultSubobjectArrayCapacity);
NewClass->GetDefaultObject()->CollectDefaultSubobjects(DefaultSubobjectArray);
TArray<FPropertyToUpdate> PropertiesToUpdate;
// Collect all properties that have actually changed
for (auto& Pair : ReconstructedCDOProperties.Properties)
{
auto OldPropertyInfo = OriginalCDOProperties.Properties.Find(Pair.Key);
if (OldPropertyInfo)
{
auto& NewPropertyInfo = Pair.Value;
uint8* OldSerializedValuePtr = OriginalCDOProperties.Bytes.GetData() + OldPropertyInfo->SerializedValueOffset;
uint8* NewSerializedValuePtr = ReconstructedCDOProperties.Bytes.GetData() + NewPropertyInfo.SerializedValueOffset;
if (OldPropertyInfo->SerializedValueSize != NewPropertyInfo.SerializedValueSize ||
FMemory::Memcmp(OldSerializedValuePtr, NewSerializedValuePtr, OldPropertyInfo->SerializedValueSize) != 0)
{
// Property value has changed so add it to the list of properties that need updating on instances
FPropertyToUpdate PropertyToUpdate;
PropertyToUpdate.Property = NewPropertyInfo.Property;
//.........这里部分代码省略.........
示例2: DoWork
void FAsyncSoundFileImportTask::DoWork()
{
// Create a new sound file object
TScopedPointer<FSoundFile> SoundFileInput = TScopedPointer<FSoundFile>(new FSoundFile());
// Open the file
ESoundFileError::Type Error = SoundFileInput->OpenFileForReading(ImportSettings.SoundFilePath);
SOUND_IMPORT_CHECK(Error);
TSharedPtr<ISoundFileData> SoundFileData;
Error = SoundFileInput->GetSoundFileData(SoundFileData);
SOUND_IMPORT_CHECK(Error);
// Get the input file's description
const FSoundFileDescription& InputDescription = SoundFileData->GetDescription();
// Get the input file's channel map
const TArray<ESoundFileChannelMap::Type>& InputChannelMap = SoundFileData->GetChannelMap();
// Build a description for the new file
FSoundFileDescription NewSoundFileDescription;
NewSoundFileDescription.NumChannels = InputDescription.NumChannels;
NewSoundFileDescription.NumFrames = InputDescription.NumFrames;
NewSoundFileDescription.FormatFlags = ImportSettings.Format;
NewSoundFileDescription.SampleRate = ImportSettings.SampleRate;
NewSoundFileDescription.NumSections = 0;
NewSoundFileDescription.bIsSeekable = 1;
// Open it as an empty file for reading and writing
ISoundFileInternal* SoundFileInternal = (ISoundFileInternal*)SoundFile.Get();
Error = SoundFileInternal->OpenEmptyFileForImport(NewSoundFileDescription, InputChannelMap);
SOUND_IMPORT_CHECK(Error);
// Set the original description on the new sound file
Error = SoundFileInternal->SetImportFileInfo(InputDescription, ImportSettings.SoundFilePath);
SOUND_IMPORT_CHECK(Error);
// Set the encoding quality (will only do anything if import target is Ogg-Vorbis)
Error = SoundFileInternal->SetEncodingQuality(ImportSettings.EncodingQuality);
SOUND_IMPORT_CHECK(Error);
// Set the state of the sound file to be loading
Error = SoundFileInternal->BeginImport();
SOUND_IMPORT_CHECK(Error);
// Create a buffer to do the processing
SoundFileCount ProcessBufferSamples = 1024 * NewSoundFileDescription.NumChannels;
TArray<double> ProcessBuffer;
ProcessBuffer.Init(0.0, ProcessBufferSamples);
// Find the max value if we've been told to do peak normalization on import
double MaxValue = 0.0;
SoundFileCount SamplesRead = 0;
bool bPerformPeakNormalization = ImportSettings.bPerformPeakNormalization;
if (bPerformPeakNormalization)
{
Error = SoundFileInput->ReadSamples(ProcessBuffer.GetData(), ProcessBufferSamples, SamplesRead);
SOUND_IMPORT_CHECK(Error);
while (SamplesRead)
{
for (SoundFileCount Sample = 0; Sample < SamplesRead; ++Sample)
{
if (ProcessBuffer[Sample] > FMath::Abs(MaxValue))
{
MaxValue = ProcessBuffer[Sample];
}
}
Error = SoundFileInput->ReadSamples(ProcessBuffer.GetData(), ProcessBufferSamples, SamplesRead);
SOUND_IMPORT_CHECK(Error);
}
// If this happens, it means we have a totally silent file
if (MaxValue == 0.0)
{
bPerformPeakNormalization = false;
}
// Seek the file back to the beginning
SoundFileCount OutOffset;
SoundFileInput->SeekFrames(0, ESoundFileSeekMode::FROM_START, OutOffset);
}
// Now perform the encoding to the target file
Error = SoundFileInput->ReadSamples(ProcessBuffer.GetData(), ProcessBufferSamples, SamplesRead);
SOUND_IMPORT_CHECK(Error);
while (SamplesRead)
{
SOUND_IMPORT_CHECK(SoundFileInput->GetError());
// Normalize the samples if we're told to
if (bPerformPeakNormalization)
{
for (int32 Sample = 0; Sample < SamplesRead; ++Sample)
{
ProcessBuffer[Sample] /= MaxValue;
}
//.........这里部分代码省略.........
示例3: Init
void FSlateOpenGLTexture::Init( GLenum TexFormat, const TArray<uint8>& TextureData )
{
// Create a new OpenGL texture
glGenTextures(1, &ShaderResource);
CHECK_GL_ERRORS;
// Ensure texturing is enabled before setting texture properties
#if USE_DEPRECATED_OPENGL_FUNCTIONALITY
glEnable(GL_TEXTURE_2D);
#endif // USE_DEPRECATED_OPENGL_FUNCTIONALITY
glBindTexture(GL_TEXTURE_2D, ShaderResource);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
#if USE_DEPRECATED_OPENGL_FUNCTIONALITY
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
#endif // USE_DEPRECATED_OPENGL_FUNCTIONALITY
// the raw data is in bgra or bgr
const GLint Format = GL_BGRA;
// Upload the texture data
glTexImage2D( GL_TEXTURE_2D, 0, TexFormat, SizeX, SizeY, 0, Format, GL_UNSIGNED_INT_8_8_8_8_REV, TextureData.GetData() );
bHasPendingResize = false;
CHECK_GL_ERRORS;
}
示例4: DoCustomNavigableGeometryExport
bool UDestructibleComponent::DoCustomNavigableGeometryExport(FNavigableGeometryExport& GeomExport) const
{
#if WITH_APEX
if (ApexDestructibleActor == NULL)
{
return false;
}
NxDestructibleActor* DestrActor = const_cast<NxDestructibleActor*>(ApexDestructibleActor);
const FTransform ComponentToWorldNoScale(ComponentToWorld.GetRotation(), ComponentToWorld.GetTranslation(), FVector(1.f));
TArray<PxShape*> Shapes;
Shapes.AddUninitialized(8);
PxRigidDynamic** PActorBuffer = NULL;
PxU32 PActorCount = 0;
if (DestrActor->acquirePhysXActorBuffer(PActorBuffer, PActorCount
, NxDestructiblePhysXActorQueryFlags::Static
| NxDestructiblePhysXActorQueryFlags::Dormant
| NxDestructiblePhysXActorQueryFlags::Dynamic))
{
uint32 ShapesExportedCount = 0;
while (PActorCount--)
{
const PxRigidDynamic* PActor = *PActorBuffer++;
if (PActor != NULL)
{
const FTransform PActorGlobalPose = P2UTransform(PActor->getGlobalPose());
const PxU32 ShapesCount = PActor->getNbShapes();
if (ShapesCount > PxU32(Shapes.Num()))
{
Shapes.AddUninitialized(ShapesCount - Shapes.Num());
}
const PxU32 RetrievedShapesCount = PActor->getShapes(Shapes.GetData(), Shapes.Num());
PxShape* const* ShapePtr = Shapes.GetData();
for (PxU32 ShapeIndex = 0; ShapeIndex < RetrievedShapesCount; ++ShapeIndex, ++ShapePtr)
{
if (*ShapePtr != NULL)
{
const PxTransform LocalPose = (*ShapePtr)->getLocalPose();
FTransform LocalToWorld = P2UTransform(LocalPose);
LocalToWorld.Accumulate(PActorGlobalPose);
switch((*ShapePtr)->getGeometryType())
{
case PxGeometryType::eCONVEXMESH:
{
PxConvexMeshGeometry Geometry;
if ((*ShapePtr)->getConvexMeshGeometry(Geometry))
{
++ShapesExportedCount;
// @todo address Geometry.scale not being used here
GeomExport.ExportPxConvexMesh(Geometry.convexMesh, LocalToWorld);
}
}
break;
case PxGeometryType::eTRIANGLEMESH:
{
// @todo address Geometry.scale not being used here
PxTriangleMeshGeometry Geometry;
if ((*ShapePtr)->getTriangleMeshGeometry(Geometry))
{
++ShapesExportedCount;
if ((Geometry.triangleMesh->getTriangleMeshFlags()) & PxTriangleMeshFlag::eHAS_16BIT_TRIANGLE_INDICES)
{
GeomExport.ExportPxTriMesh16Bit(Geometry.triangleMesh, LocalToWorld);
}
else
{
GeomExport.ExportPxTriMesh32Bit(Geometry.triangleMesh, LocalToWorld);
}
}
}
default:
{
UE_LOG(LogPhysics, Log, TEXT("UDestructibleComponent::DoCustomNavigableGeometryExport(): unhandled PxGeometryType, %d.")
, int32((*ShapePtr)->getGeometryType()));
}
break;
}
}
}
}
}
ApexDestructibleActor->releasePhysXActorBuffer();
INC_DWORD_STAT_BY(STAT_Navigation_DestructiblesShapesExported, ShapesExportedCount);
}
#endif // WITH_APEX
// we don't want a regular geometry export
return false;
}
示例5: GenerateLongLatUnwrap
/**
* Helper function to create an unwrapped 2D image of the cube map ( longitude/latitude )
* This version takes explicitly passed properties of the source object, as the sources have different APIs.
* @param TextureResource Source FTextureResource object.
* @param AxisDimenion axis length of the cube.
* @param SourcePixelFormat pixel format of the source.
* @param BitsOUT Raw bits of the 2D image bitmap.
* @param SizeXOUT Filled with the X dimension of the output bitmap.
* @param SizeYOUT Filled with the Y dimension of the output bitmap.
* @return true on success.
* @param FormatOUT Filled with the pixel format of the output bitmap.
*/
bool GenerateLongLatUnwrap(const FTextureResource* TextureResource, const uint32 AxisDimenion, const EPixelFormat SourcePixelFormat, TArray<uint8>& BitsOUT, FIntPoint& SizeOUT, EPixelFormat& FormatOUT)
{
TRefCountPtr<FBatchedElementParameters> BatchedElementParameters;
BatchedElementParameters = new FMipLevelBatchedElementParameters((float)0, true);
const FIntPoint LongLatDimensions(AxisDimenion * 2, AxisDimenion);
// If the source format is 8 bit per channel or less then select a LDR target format.
const EPixelFormat TargetPixelFormat = CalculateImageBytes(1, 1, 0, SourcePixelFormat) <= 4 ? PF_B8G8R8A8 : PF_FloatRGBA;
UTextureRenderTarget2D* RenderTargetLongLat = NewObject<UTextureRenderTarget2D>();
check(RenderTargetLongLat);
RenderTargetLongLat->AddToRoot();
RenderTargetLongLat->ClearColor = FLinearColor(0.0f, 0.0f, 0.0f, 0.0f);
RenderTargetLongLat->InitCustomFormat(LongLatDimensions.X, LongLatDimensions.Y, TargetPixelFormat, false);
RenderTargetLongLat->TargetGamma = 0;
FRenderTarget* RenderTarget = RenderTargetLongLat->GameThread_GetRenderTargetResource();
FCanvas* Canvas = new FCanvas(RenderTarget, NULL, 0, 0, 0, GMaxRHIFeatureLevel);
Canvas->SetRenderTarget_GameThread(RenderTarget);
// Clear the render target to black
Canvas->Clear(FLinearColor(0, 0, 0, 0));
FCanvasTileItem TileItem(FVector2D(0.0f, 0.0f), TextureResource, FVector2D(LongLatDimensions.X, LongLatDimensions.Y), FLinearColor::White);
TileItem.BatchedElementParameters = BatchedElementParameters;
TileItem.BlendMode = SE_BLEND_Opaque;
Canvas->DrawItem(TileItem);
Canvas->Flush_GameThread();
FlushRenderingCommands();
Canvas->SetRenderTarget_GameThread(NULL);
FlushRenderingCommands();
int32 ImageBytes = CalculateImageBytes(LongLatDimensions.X, LongLatDimensions.Y, 0, TargetPixelFormat);
BitsOUT.AddUninitialized(ImageBytes);
bool bReadSuccess = false;
switch (TargetPixelFormat)
{
case PF_B8G8R8A8:
bReadSuccess = RenderTarget->ReadPixelsPtr((FColor*)BitsOUT.GetData());
break;
case PF_FloatRGBA:
{
TArray<FFloat16Color> FloatColors;
bReadSuccess = RenderTarget->ReadFloat16Pixels(FloatColors);
FMemory::Memcpy(BitsOUT.GetData(), FloatColors.GetData(), ImageBytes);
}
break;
}
// Clean up.
RenderTargetLongLat->RemoveFromRoot();
RenderTargetLongLat = NULL;
delete Canvas;
SizeOUT = LongLatDimensions;
FormatOUT = TargetPixelFormat;
if (bReadSuccess == false)
{
// Reading has failed clear output buffer.
BitsOUT.Empty();
}
return bReadSuccess;
}
示例6: StringFromBinaryArray
//This function requires
// #include <string>
FString ATitanBotsPlayerController::StringFromBinaryArray(const TArray<uint8>& BinaryArray)
{
//Create a string from a byte array!
std::string cstr(reinterpret_cast<const char*>(BinaryArray.GetData()), BinaryArray.Num());
return FString(cstr.c_str());
}
示例7: NewEntry
AssetPath = Blueprint.ObjectPath;
break;
}
}
FComponentTypeEntry Entry = { FixedString, AssetPath.ToString(), nullptr };
ComponentTypeList.Add(Entry);
FComponentClassComboEntryPtr NewEntry(new FComponentClassComboEntry(BlueprintComponents, FixedString, AssetPath, bIncludeInFilter));
SortedClassList.Add(NewEntry);
}
}
if (SortedClassList.Num() > 0)
{
Sort(SortedClassList.GetData(), SortedClassList.Num(), SortComboEntry());
FString PreviousHeading;
for (int32 ClassIndex = 0; ClassIndex < SortedClassList.Num(); ClassIndex++)
{
FComponentClassComboEntryPtr& CurrentEntry = SortedClassList[ClassIndex];
const FString& CurrentHeadingText = CurrentEntry->GetHeadingText();
if (CurrentHeadingText != PreviousHeading)
{
// This avoids a redundant separator being added to the very top of the list
if (ClassIndex > 0)
{
FComponentClassComboEntryPtr NewSeparator(new FComponentClassComboEntry());
ComponentClassList.Add(NewSeparator);
示例8: CookSimpleWave
/**
* Cook a simple mono or stereo wave
*/
static void CookSimpleWave(USoundWave* SoundWave, FName FormatName, const IAudioFormat& Format, TArray<uint8>& Output)
{
FWaveModInfo WaveInfo;
TArray<uint8> Input;
check(!Output.Num());
bool bWasLocked = false;
// check if there is any raw sound data
if( SoundWave->RawData.GetBulkDataSize() > 0 )
{
// Lock raw wave data.
uint8* RawWaveData = ( uint8* )SoundWave->RawData.Lock( LOCK_READ_ONLY );
bWasLocked = true;
int32 RawDataSize = SoundWave->RawData.GetBulkDataSize();
// parse the wave data
if( !WaveInfo.ReadWaveHeader( RawWaveData, RawDataSize, 0 ) )
{
UE_LOG(LogAudioDerivedData, Warning, TEXT( "Only mono or stereo 16 bit waves allowed: %s (%d bytes)" ), *SoundWave->GetFullName(), RawDataSize );
}
else
{
Input.AddUninitialized(WaveInfo.SampleDataSize);
FMemory::Memcpy(Input.GetData(), WaveInfo.SampleDataStart, WaveInfo.SampleDataSize);
}
}
if(!Input.Num())
{
UE_LOG(LogAudioDerivedData, Warning, TEXT( "Can't cook %s because there is no source compressed or uncompressed PC sound data" ), *SoundWave->GetFullName() );
}
else
{
FSoundQualityInfo QualityInfo = { 0 };
QualityInfo.Quality = SoundWave->CompressionQuality;
QualityInfo.NumChannels = *WaveInfo.pChannels;
QualityInfo.SampleRate = *WaveInfo.pSamplesPerSec;
QualityInfo.SampleDataSize = Input.Num();
QualityInfo.DebugName = SoundWave->GetFullName();
// Cook the data.
if(Format.Cook(FormatName, Input, QualityInfo, Output))
{
//@todo tighten up the checking for empty results here
if (SoundWave->SampleRate != *WaveInfo.pSamplesPerSec)
{
UE_LOG(LogAudioDerivedData, Warning, TEXT( "Updated SoundWave->SampleRate during cooking %s." ), *SoundWave->GetFullName() );
SoundWave->SampleRate = *WaveInfo.pSamplesPerSec;
}
if (SoundWave->NumChannels != *WaveInfo.pChannels)
{
UE_LOG(LogAudioDerivedData, Warning, TEXT( "Updated SoundWave->NumChannels during cooking %s." ), *SoundWave->GetFullName() );
SoundWave->NumChannels = *WaveInfo.pChannels;
}
if (SoundWave->RawPCMDataSize != Input.Num())
{
UE_LOG(LogAudioDerivedData, Warning, TEXT( "Updated SoundWave->RawPCMDataSize during cooking %s." ), *SoundWave->GetFullName() );
SoundWave->RawPCMDataSize = Input.Num();
}
if (SoundWave->Duration != ( float )SoundWave->RawPCMDataSize / (SoundWave->SampleRate * sizeof( int16 ) * SoundWave->NumChannels))
{
UE_LOG(LogAudioDerivedData, Warning, TEXT( "Updated SoundWave->Duration during cooking %s." ), *SoundWave->GetFullName() );
SoundWave->Duration = ( float )SoundWave->RawPCMDataSize / (SoundWave->SampleRate * sizeof( int16 ) * SoundWave->NumChannels);
}
}
}
if (bWasLocked)
{
SoundWave->RawData.Unlock();
}
}
示例9: ScanData
FDataScanResult FDataScannerImpl::ScanData()
{
// Count running scanners
FScopeCounter ScopeCounter(&NumRunningScanners);
FStatsCollector::Accumulate(StatCreatedScanners, 1);
FStatsCollector::Accumulate(StatRunningScanners, 1);
// Init data
FRollingHash<WindowSize> RollingHash;
FChunkWriter ChunkWriter(FBuildPatchServicesModule::GetCloudDirectory(), StatsCollector);
FDataStructure DataStructure(DataStartOffset);
TMap<FGuid, FChunkInfo> ChunkInfoLookup;
TArray<uint8> ChunkBuffer;
TArray<uint8> NewChunkBuffer;
uint32 PaddedZeros = 0;
ChunkInfoLookup.Reserve(Data.Num() / WindowSize);
ChunkBuffer.SetNumUninitialized(WindowSize);
NewChunkBuffer.Reserve(WindowSize);
// Get a copy of the chunk inventory
TMap<uint64, TSet<FGuid>> ChunkInventory = CloudEnumeration->GetChunkInventory();
TMap<FGuid, int64> ChunkFileSizes = CloudEnumeration->GetChunkFileSizes();
TMap<FGuid, FSHAHash> ChunkShaHashes = CloudEnumeration->GetChunkShaHashes();
// Loop over and process all data
FGuid MatchedChunk;
uint64 TempTimer;
uint64 CpuTimer;
FStatsCollector::AccumulateTimeBegin(CpuTimer);
for (int32 idx = 0; (idx < Data.Num() || PaddedZeros < WindowSize) && !bShouldAbort; ++idx)
{
// Consume data
const uint32 NumDataNeeded = RollingHash.GetNumDataNeeded();
if (NumDataNeeded > 0)
{
FStatsScopedTimer ConsumeTimer(StatConsumeBytesTime);
uint32 NumConsumedBytes = 0;
if (idx < Data.Num())
{
NumConsumedBytes = FMath::Min<uint32>(NumDataNeeded, Data.Num() - idx);
RollingHash.ConsumeBytes(&Data[idx], NumConsumedBytes);
idx += NumConsumedBytes - 1;
}
// Zero Pad?
if (NumConsumedBytes < NumDataNeeded)
{
TArray<uint8> Zeros;
Zeros.AddZeroed(NumDataNeeded - NumConsumedBytes);
RollingHash.ConsumeBytes(Zeros.GetData(), Zeros.Num());
PaddedZeros = Zeros.Num();
}
check(RollingHash.GetNumDataNeeded() == 0);
continue;
}
const uint64 NumDataInWindow = WindowSize - PaddedZeros;
const uint64 WindowHash = RollingHash.GetWindowHash();
// Try find match
if (FindExistingChunk(ChunkInventory, ChunkShaHashes, WindowHash, RollingHash, MatchedChunk))
{
// Push the chunk to the structure
DataStructure.PushKnownChunk(MatchedChunk, NumDataInWindow);
FChunkInfo& ChunkInfo = ChunkInfoLookup.FindOrAdd(MatchedChunk);
ChunkInfo.Hash = WindowHash;
ChunkInfo.ShaHash = ChunkShaHashes[MatchedChunk];
ChunkInfo.IsNew = false;
FStatsCollector::Accumulate(StatMatchedData, NumDataInWindow);
// Clear matched window
RollingHash.Clear();
// Decrement idx to include current byte in next window
--idx;
}
else
{
// Collect unrecognized bytes
NewChunkBuffer.Add(RollingHash.GetWindowData().Bottom());
DataStructure.PushUnknownByte();
if (NumDataInWindow == 1)
{
NewChunkBuffer.AddZeroed(WindowSize - NewChunkBuffer.Num());
}
if (NewChunkBuffer.Num() == WindowSize)
{
const uint64 NewChunkHash = FRollingHash<WindowSize>::GetHashForDataSet(NewChunkBuffer.GetData());
if (FindExistingChunk(ChunkInventory, ChunkShaHashes, NewChunkHash, NewChunkBuffer, MatchedChunk))
{
DataStructure.RemapCurrentChunk(MatchedChunk);
FChunkInfo& ChunkInfo = ChunkInfoLookup.FindOrAdd(MatchedChunk);
ChunkInfo.Hash = NewChunkHash;
ChunkInfo.ShaHash = ChunkShaHashes[MatchedChunk];
ChunkInfo.IsNew = false;
FStatsCollector::Accumulate(StatMatchedData, WindowSize);
}
else
{
FStatsScopedTimer ChunkWriterTimer(StatChunkWriterTime);
const FGuid& NewChunkGuid = DataStructure.GetCurrentChunkId();
FStatsCollector::AccumulateTimeEnd(StatCpuTime, CpuTimer);
ChunkWriter.QueueChunk(NewChunkBuffer.GetData(), NewChunkGuid, NewChunkHash);
FStatsCollector::AccumulateTimeBegin(CpuTimer);
//.........这里部分代码省略.........
示例10: TEXT
FFeaturePackContentSource::FFeaturePackContentSource(FString InFeaturePackPath, bool bDontRegisterForSearch)
{
FeaturePackPath = InFeaturePackPath;
bPackValid = false;
// Create a pak platform file and mount the feature pack file.
FPakPlatformFile PakPlatformFile;
FString CommandLine;
PakPlatformFile.Initialize(&FPlatformFileManager::Get().GetPlatformFile(), TEXT(""));
FString MountPoint = "root:/";
PakPlatformFile.Mount(*InFeaturePackPath, 0, *MountPoint);
// Gets the manifest file as a JSon string
TArray<uint8> ManifestBuffer;
if( LoadPakFileToBuffer(PakPlatformFile, FPaths::Combine(*MountPoint, TEXT("manifest.json")), ManifestBuffer) == false )
{
RecordAndLogError( FString::Printf(TEXT("Error in Feature pack %s. Cannot find manifest."), *InFeaturePackPath));
Category = EContentSourceCategory::Unknown;
return;
}
FString ManifestString;
FFileHelper::BufferToString(ManifestString, ManifestBuffer.GetData(), ManifestBuffer.Num());
// Populate text fields from the manifest.
TSharedPtr<FJsonObject> ManifestObject;
TSharedRef<TJsonReader<>> ManifestReader = TJsonReaderFactory<>::Create(ManifestString);
FJsonSerializer::Deserialize(ManifestReader, ManifestObject);
if (ManifestReader->GetErrorMessage().IsEmpty() == false)
{
RecordAndLogError( FString::Printf(TEXT("Error in Feature pack %s. Failed to parse manifest: %s"), *InFeaturePackPath, *ManifestReader->GetErrorMessage()));
Category = EContentSourceCategory::Unknown;
return;
}
TSharedPtr<FString> ManifestObjectErrorMessage;
if (TryValidateManifestObject(ManifestObject, ManifestObjectErrorMessage) == false)
{
RecordAndLogError( FString::Printf(TEXT("Error in Feature pack %s. Manifest object error: %s"), *InFeaturePackPath, **ManifestObjectErrorMessage));
Category = EContentSourceCategory::Unknown;
return;
}
for (TSharedPtr<FJsonValue> NameValue : ManifestObject->GetArrayField("Name"))
{
TSharedPtr<FJsonObject> LocalizedNameObject = NameValue->AsObject();
LocalizedNames.Add(FLocalizedText(
LocalizedNameObject->GetStringField("Language"),
FText::FromString(LocalizedNameObject->GetStringField("Text"))));
}
for (TSharedPtr<FJsonValue> DescriptionValue : ManifestObject->GetArrayField("Description"))
{
TSharedPtr<FJsonObject> LocalizedDescriptionObject = DescriptionValue->AsObject();
LocalizedDescriptions.Add(FLocalizedText(
LocalizedDescriptionObject->GetStringField("Language"),
FText::FromString(LocalizedDescriptionObject->GetStringField("Text"))));
}
// Parse asset types field
for (TSharedPtr<FJsonValue> AssetTypesValue : ManifestObject->GetArrayField("AssetTypes"))
{
TSharedPtr<FJsonObject> LocalizedAssetTypesObject = AssetTypesValue->AsObject();
LocalizedAssetTypesList.Add(FLocalizedText(
LocalizedAssetTypesObject->GetStringField("Language"),
FText::FromString(LocalizedAssetTypesObject->GetStringField("Text"))));
}
// Parse asset types field
if( ManifestObject->HasField("SearchTags")==true)
{
for (TSharedPtr<FJsonValue> AssetTypesValue : ManifestObject->GetArrayField("SearchTags"))
{
TSharedPtr<FJsonObject> LocalizedAssetTypesObject = AssetTypesValue->AsObject();
LocalizedSearchTags.Add(FLocalizedTextArray(
LocalizedAssetTypesObject->GetStringField("Language"),
LocalizedAssetTypesObject->GetStringField("Text")));
}
}
// Parse class types field
ClassTypes = ManifestObject->GetStringField("ClassTypes");
// Parse initial focus asset if we have one - this is not required
if (ManifestObject->HasTypedField<EJson::String>("FocusAsset") == true)
{
FocusAssetIdent = ManifestObject->GetStringField("FocusAsset");
}
// Use the path as the sort key - it will be alphabetical that way
SortKey = FeaturePackPath;
ManifestObject->TryGetStringField("SortKey", SortKey);
FString CategoryString = ManifestObject->GetStringField("Category");
UEnum* Enum = FindObjectChecked<UEnum>(ANY_PACKAGE, TEXT("EContentSourceCategory"));
int32 Index = Enum->FindEnumIndex(FName(*CategoryString));
Category = Index != INDEX_NONE ? (EContentSourceCategory)Index : EContentSourceCategory::Unknown;
// Load image data
FString IconFilename = ManifestObject->GetStringField("Thumbnail");
//.........这里部分代码省略.........
示例11: BuildStreamedAudio
/** Build the streamed audio. This function is safe to call from any thread. */
void BuildStreamedAudio()
{
GetStreamedAudioDerivedDataKeySuffix(SoundWave, AudioFormatName, KeySuffix);
DerivedData->Chunks.Empty();
ITargetPlatformManagerModule* TPM = GetTargetPlatformManager();
const IAudioFormat* AudioFormat = NULL;
if (TPM)
{
AudioFormat = TPM->FindAudioFormat(AudioFormatName);
}
if (AudioFormat)
{
DerivedData->AudioFormat = AudioFormatName;
FByteBulkData* CompressedData = SoundWave.GetCompressedData(AudioFormatName);
TArray<uint8> CompressedBuffer;
CompressedBuffer.Empty(CompressedData->GetBulkDataSize());
CompressedBuffer.AddUninitialized(CompressedData->GetBulkDataSize());
void* BufferData = CompressedBuffer.GetData();
CompressedData->GetCopy(&BufferData, false);
TArray<TArray<uint8>> ChunkBuffers;
if (AudioFormat->SplitDataForStreaming(CompressedBuffer, ChunkBuffers))
{
for (int32 ChunkIndex = 0; ChunkIndex < ChunkBuffers.Num(); ++ChunkIndex)
{
FStreamedAudioChunk* NewChunk = new(DerivedData->Chunks) FStreamedAudioChunk();
NewChunk->DataSize = ChunkBuffers[ChunkIndex].Num();
NewChunk->BulkData.Lock(LOCK_READ_WRITE);
void* NewChunkData = NewChunk->BulkData.Realloc(ChunkBuffers[ChunkIndex].Num());
FMemory::Memcpy(NewChunkData, ChunkBuffers[ChunkIndex].GetData(), ChunkBuffers[ChunkIndex].Num());
NewChunk->BulkData.Unlock();
}
}
else
{
// Could not split so copy compressed data into a single chunk
FStreamedAudioChunk* NewChunk = new(DerivedData->Chunks) FStreamedAudioChunk();
NewChunk->DataSize = CompressedBuffer.Num();
NewChunk->BulkData.Lock(LOCK_READ_WRITE);
void* NewChunkData = NewChunk->BulkData.Realloc(CompressedBuffer.Num());
FMemory::Memcpy(NewChunkData, CompressedBuffer.GetData(), CompressedBuffer.Num());
NewChunk->BulkData.Unlock();
}
DerivedData->NumChunks = DerivedData->Chunks.Num();
// Store it in the cache.
PutDerivedDataInCache(DerivedData, KeySuffix);
}
if (DerivedData->Chunks.Num())
{
bool bInlineChunks = (CacheFlags & EStreamedAudioCacheFlags::InlineChunks) != 0;
bSucceeded = !bInlineChunks || DerivedData->TryInlineChunkData();
}
else
{
UE_LOG(LogAudio, Warning, TEXT("Failed to build %s derived data for %s"),
*AudioFormatName.GetPlainNameString(),
*SoundWave.GetPathName()
);
}
}
示例12: PostLoad
void UAtmosphericFogComponent::PostLoad()
{
Super::PostLoad();
if ( !IsTemplate() )
{
#if WITH_EDITOR
if (TransmittanceTexture_DEPRECATED)
{
// Copy data from Previous data
if (TransmittanceTexture_DEPRECATED->Source.IsValid())
{
TArray<uint8> RawData;
TArray<FColor> OutData;
TransmittanceTexture_DEPRECATED->Source.GetMipData(RawData, 0);
// Convert from FFloat16Color to FColor
for (int32 i = 0; i < RawData.Num(); i+=sizeof(FFloat16Color))
{
FFloat16Color* OriginalColor = (FFloat16Color*)&RawData[i];
FColor TempColor;
TempColor.R = FMath::Clamp<uint8>(OriginalColor->R.GetFloat() * 255, 0, 255);
TempColor.G = FMath::Clamp<uint8>(OriginalColor->G.GetFloat() * 255, 0, 255);
TempColor.B = FMath::Clamp<uint8>(OriginalColor->B.GetFloat() * 255, 0, 255);
OutData.Add(TempColor);
}
int32 TotalByte = OutData.Num() * sizeof(FColor);
TransmittanceData.Lock(LOCK_READ_WRITE);
FColor* TextureData = (FColor*)TransmittanceData.Realloc(TotalByte);
FMemory::Memcpy(TextureData, OutData.GetData(), TotalByte);
TransmittanceData.Unlock();
TransmittanceTexture_DEPRECATED = NULL;
}
}
if (IrradianceTexture_DEPRECATED)
{
if (IrradianceTexture_DEPRECATED->Source.IsValid())
{
TArray<uint8> RawData;
TArray<FColor> OutData;
IrradianceTexture_DEPRECATED->Source.GetMipData(RawData, 0);
// Convert from FFloat16Color to FColor
for (int32 i = 0; i < RawData.Num(); i+=sizeof(FFloat16Color))
{
FFloat16Color* OriginalColor = (FFloat16Color*)&RawData[i];
FColor TempColor;
TempColor.R = FMath::Clamp<uint8>(OriginalColor->R.GetFloat() * 255, 0, 255);
TempColor.G = FMath::Clamp<uint8>(OriginalColor->G.GetFloat() * 255, 0, 255);
TempColor.B = FMath::Clamp<uint8>(OriginalColor->B.GetFloat() * 255, 0, 255);
OutData.Add(TempColor);
}
int32 TotalByte = OutData.Num() * sizeof(FColor);
IrradianceData.Lock(LOCK_READ_WRITE);
FColor* TextureData = (FColor*)IrradianceData.Realloc(TotalByte);
FMemory::Memcpy(TextureData, OutData.GetData(), TotalByte);
IrradianceData.Unlock();
IrradianceTexture_DEPRECATED = NULL;
}
}
#endif
InitResource();
}
}
示例13: Restore
void FSavedCustomSortSectionInfo::Restore(USkeletalMesh* NewSkelMesh, int32 LODModelIndex, TArray<int32>& UnmatchedSections)
{
FStaticLODModel& LODModel = NewSkelMesh->GetImportedResource()->LODModels[LODModelIndex];
FSkeletalMeshLODInfo& LODInfo = NewSkelMesh->LODInfo[LODModelIndex];
// Re-order the UnmatchedSections so the old section index from the previous model is tried first
int32 PrevSectionIndex = UnmatchedSections.Find(SavedSectionIdx);
if( PrevSectionIndex != 0 && PrevSectionIndex != INDEX_NONE )
{
Exchange( UnmatchedSections[0], UnmatchedSections[PrevSectionIndex] );
}
// Find the strips in the old triangle data.
TArray< TArray<uint32> > OldStrips[2];
for( int32 IndexCopy=0; IndexCopy < (SavedSortOption==TRISORT_CustomLeftRight ? 2 : 1); IndexCopy++ )
{
const uint32* OldIndices = &SavedIndices[(SavedIndices.Num()>>1)*IndexCopy];
TArray<uint32> OldTriSet;
GetConnectedTriangleSets( SavedNumTriangles, OldIndices, OldTriSet );
// Convert to strips
int32 PrevTriSet = MAX_int32;
for( int32 TriIndex=0;TriIndex<SavedNumTriangles; TriIndex++ )
{
if( OldTriSet[TriIndex] != PrevTriSet )
{
OldStrips[IndexCopy].AddZeroed();
PrevTriSet = OldTriSet[TriIndex];
}
OldStrips[IndexCopy][OldStrips[IndexCopy].Num()-1].Add(OldIndices[TriIndex*3+0]);
OldStrips[IndexCopy][OldStrips[IndexCopy].Num()-1].Add(OldIndices[TriIndex*3+1]);
OldStrips[IndexCopy][OldStrips[IndexCopy].Num()-1].Add(OldIndices[TriIndex*3+2]);
}
}
bool bFoundMatchingSection = false;
// Try all remaining sections to find a match
for( int32 UnmatchedSectionsIdx=0; !bFoundMatchingSection && UnmatchedSectionsIdx<UnmatchedSections.Num(); UnmatchedSectionsIdx++ )
{
// Section of the new mesh to try
int32 SectionIndex = UnmatchedSections[UnmatchedSectionsIdx];
FSkelMeshSection& Section = LODModel.Sections[SectionIndex];
TArray<uint32> Indices;
LODModel.MultiSizeIndexContainer.GetIndexBuffer( Indices );
const uint32* NewSectionIndices = Indices.GetData() + Section.BaseIndex;
// Build the list of triangle sets in the new mesh's section
TArray<uint32> TriSet;
GetConnectedTriangleSets( Section.NumTriangles, NewSectionIndices, TriSet );
// Mapping from triangle set number to the array of indices that make up the contiguous strip.
TMap<uint32, TArray<uint32> > NewStripsMap;
// Go through each triangle and assign it to the appropriate contiguous strip.
// This is necessary if the strips in the index buffer are not contiguous.
int32 Index=0;
for( int32 s=0;s<TriSet.Num();s++ )
{
// Store the indices for this triangle in the appropriate contiguous set.
TArray<uint32>* ThisStrip = NewStripsMap.Find(TriSet[s]);
if( !ThisStrip )
{
ThisStrip = &NewStripsMap.Add(TriSet[s],TArray<uint32>());
}
// Add the three indices for this triangle.
ThisStrip->Add(NewSectionIndices[Index++]);
ThisStrip->Add(NewSectionIndices[Index++]);
ThisStrip->Add(NewSectionIndices[Index++]);
}
// Get the new vertices
TArray<FSoftSkinVertex> NewVertices;
LODModel.GetVertices(NewVertices);
// Do the processing once for each copy if the index data
for( int32 IndexCopy=0; IndexCopy < (SavedSortOption==TRISORT_CustomLeftRight ? 2 : 1); IndexCopy++ )
{
// Copy strips in the new mesh's section into an array. We'll remove items from
// here as we match to the old strips, so we need to keep a new copy of it each time.
TArray<TArray<uint32> > NewStrips;
for( TMap<uint32, TArray<uint32> >::TIterator It(NewStripsMap); It; ++It )
{
NewStrips.Add(It.Value());
}
// Match up old strips to new
int32 NumMismatchedStrips = 0;
TArray<TArray<uint32> > NewSortedStrips; // output
for( int32 OsIdx=0;OsIdx<OldStrips[IndexCopy].Num();OsIdx++ )
{
TArray<uint32>& OldStripIndices = OldStrips[IndexCopy][OsIdx];
int32 MatchingNewStrip = INDEX_NONE;
for( int32 NsIdx=0;NsIdx<NewStrips.Num() && MatchingNewStrip==INDEX_NONE;NsIdx++ )
{
// Check if we have the same number of triangles in the old and new strips.
//.........这里部分代码省略.........
示例14: SetAllAreaCosts
void FNavigationQueryFilter::SetAllAreaCosts(const TArray<float>& CostArray)
{
SetAllAreaCosts(CostArray.GetData(), CostArray.Num());
}
示例15: OnGizmoImportButtonClicked
FReply FLandscapeEditorDetailCustomization_CopyPaste::OnGizmoImportButtonClicked()
{
FEdModeLandscape* LandscapeEdMode = GetEditorMode();
if (LandscapeEdMode != NULL)
{
ALandscapeGizmoActiveActor* Gizmo = LandscapeEdMode->CurrentGizmoActor.Get();
if (Gizmo)
{
TArray<uint8> Data;
FFileHelper::LoadFileToArray(Data, *LandscapeEdMode->UISettings->GizmoHeightmapFilenameString);
if (Data.Num() <= 0
|| Data.Num() != (LandscapeEdMode->UISettings->GizmoImportSize.X * LandscapeEdMode->UISettings->GizmoImportSize.Y * 2))
{
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("UnrealEd", "LandscapeImport_BadHeightmapSize", "File size does not match"));
return FReply::Handled();
}
TArray<ULandscapeLayerInfoObject*> LayerInfos;
TArray<TArray<uint8> > LayerDataArrays;
TArray<uint8*> LayerDataPtrs;
for (int32 LayerIndex = 0; LayerIndex < LandscapeEdMode->UISettings->GizmoImportLayers.Num(); LayerIndex++)
{
const FGizmoImportLayer& Layer = LandscapeEdMode->UISettings->GizmoImportLayers[LayerIndex];
FString LayerName = Layer.LayerName.Replace(TEXT(" "), TEXT(""));
if (LayerName == TEXT(""))
{
FMessageDialog::Open(EAppMsgType::Ok,
FText::Format(NSLOCTEXT("UnrealEd", "LandscapeImport_BadLayerName", "You must enter a name for the layer being imported from {0}."), FText::FromString(Layer.LayerFilename)));
return FReply::Handled();
}
if (Layer.LayerFilename != TEXT("") && !Layer.bNoImport)
{
TArray<uint8>* LayerData = new(LayerDataArrays)(TArray<uint8>);
FFileHelper::LoadFileToArray(*LayerData, *Layer.LayerFilename);
if (LayerData->Num() != (LandscapeEdMode->UISettings->GizmoImportSize.X * LandscapeEdMode->UISettings->GizmoImportSize.Y))
{
FMessageDialog::Open(EAppMsgType::Ok,
FText::Format(NSLOCTEXT("UnrealEd", "LandscapeImport_BadLayerSize", "Layer {0} file size does not match the heightmap resolution."), FText::FromString(Layer.LayerFilename)));
return FReply::Handled();
}
LayerInfos.Add(LandscapeEdMode->CurrentToolTarget.LandscapeInfo->GetLayerInfoByName(FName(*LayerName)));
LayerDataPtrs.Add(&(*LayerData)[0]);
}
}
Gizmo->Import(LandscapeEdMode->UISettings->GizmoImportSize.X, LandscapeEdMode->UISettings->GizmoImportSize.Y, (uint16*)Data.GetData(), LayerInfos, LayerDataPtrs.Num() ? LayerDataPtrs.GetData() : NULL);
// Make sure gizmo actor is selected
GEditor->SelectNone(false, true);
GEditor->SelectActor(Gizmo, true, false, true);
}
}
return FReply::Handled();
}