本文整理汇总了C++中UObject::GetResourceSize方法的典型用法代码示例。如果您正苦于以下问题:C++ UObject::GetResourceSize方法的具体用法?C++ UObject::GetResourceSize怎么用?C++ UObject::GetResourceSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UObject
的用法示例。
在下文中一共展示了UObject::GetResourceSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CompareClasses
bool FContentComparisonHelper::CompareClasses(const FString& InBaseClassName, const TArray<FString>& InBaseClassesToIgnore, int32 InRecursionDepth)
{
TMap<FString,TArray<FContentComparisonAssetInfo> > ClassToAssetsMap;
UClass* TheClass = (UClass*)StaticFindObject(UClass::StaticClass(), ANY_PACKAGE, *InBaseClassName, true);
if (TheClass != NULL)
{
TArray<UClass*> IgnoreBaseClasses;
for (int32 IgnoreIdx = 0; IgnoreIdx < InBaseClassesToIgnore.Num(); IgnoreIdx++)
{
UClass* IgnoreClass = (UClass*)StaticFindObject(UClass::StaticClass(), ANY_PACKAGE, *(InBaseClassesToIgnore[IgnoreIdx]), true);
if (IgnoreClass != NULL)
{
IgnoreBaseClasses.Add(IgnoreClass);
}
}
for( TObjectIterator<UClass> It; It; ++It )
{
UClass* TheAssetClass = *It;
if ((TheAssetClass->IsChildOf(TheClass) == true) &&
(TheAssetClass->HasAnyClassFlags(CLASS_Abstract) == false))
{
bool bSkipIt = false;
for (int32 CheckIdx = 0; CheckIdx < IgnoreBaseClasses.Num(); CheckIdx++)
{
UClass* CheckClass = IgnoreBaseClasses[CheckIdx];
if (TheAssetClass->IsChildOf(CheckClass) == true)
{
// UE_LOG(LogEngineUtils, Warning, TEXT("Skipping class derived from other content comparison class..."));
// UE_LOG(LogEngineUtils, Warning, TEXT("\t%s derived from %s"), *TheAssetClass->GetFullName(), *CheckClass->GetFullName());
bSkipIt = true;
}
}
if (bSkipIt == false)
{
TArray<FContentComparisonAssetInfo>* AssetList = ClassToAssetsMap.Find(TheAssetClass->GetFullName());
if (AssetList == NULL)
{
TArray<FContentComparisonAssetInfo> TempAssetList;
ClassToAssetsMap.Add(TheAssetClass->GetFullName(), TempAssetList);
AssetList = ClassToAssetsMap.Find(TheAssetClass->GetFullName());
}
check(AssetList);
// Serialize object with reference collector.
const int32 MaxRecursionDepth = 6;
InRecursionDepth = FMath::Clamp<int32>(InRecursionDepth, 1, MaxRecursionDepth);
TMap<UObject*,bool> RecursivelyGatheredReferences;
RecursiveObjectCollection(TheAssetClass, 0, InRecursionDepth, RecursivelyGatheredReferences);
// Add them to the asset list
for (TMap<UObject*,bool>::TIterator GatheredIt(RecursivelyGatheredReferences); GatheredIt; ++GatheredIt)
{
UObject* Object = GatheredIt.Key();
if (Object)
{
bool bAddIt = true;
if (ReferenceClassesOfInterest.Num() > 0)
{
FString CheckClassName = Object->GetClass()->GetName();
if (ReferenceClassesOfInterest.Find(CheckClassName) == NULL)
{
bAddIt = false;
}
}
if (bAddIt == true)
{
int32 NewIndex = AssetList->AddZeroed();
FContentComparisonAssetInfo& Info = (*AssetList)[NewIndex];
Info.AssetName = Object->GetFullName();
Info.ResourceSize = Object->GetResourceSize(EResourceSizeMode::Inclusive);
}
}
}
}
}
}
}
else
{
UE_LOG(LogEngineUtils, Warning, TEXT("Failed to find class: %s"), *InBaseClassName);
return false;
}
#if 0
// Log them all out
UE_LOG(LogEngineUtils, Log, TEXT("CompareClasses on %s"), *InBaseClassName);
for (TMap<FString,TArray<FContentComparisonAssetInfo>>::TIterator It(ClassToAssetsMap); It; ++It)
{
FString ClassName = It.Key();
TArray<FContentComparisonAssetInfo>& AssetList = It.Value();
UE_LOG(LogEngineUtils, Log, TEXT("\t%s"), *ClassName);
for (int32 AssetIdx = 0; AssetIdx < AssetList.Num(); AssetIdx++)
{
FContentComparisonAssetInfo& Info = AssetList(AssetIdx);
UE_LOG(LogEngineUtils, Log, TEXT("\t\t%s,%f"), *(Info.AssetName), Info.ResourceSize/1024.0f);
}
//.........这里部分代码省略.........
示例2: Add
//.........这里部分代码省略.........
// If Count represents the Model itself, we do NOT want to increment it now.
StatsEntry->Count--;
for (const auto& Element : ModelComponent->GetElements())
{
StatsEntry->Triangles += Element.NumTriangles;
StatsEntry->Sections++;
}
StatsEntry->InstSections = StatsEntry->Sections;
StatsEntry->InstTriangles = StatsEntry->Triangles;
}
else if( StaticMeshComponent )
{
// This stat is used by multiple components so accumulate instanced vertex color memory.
StatsEntry->InstVertexColorMem += (float)InstVertexColorMem / 1024.0f;
}
else if (LandscapeComponent)
{
// If Count represents the Landscape itself, we do NOT want to increment it now.
StatsEntry->Count--;
}
}
else
{
// We don't. Create new base entry.
UPrimitiveStats* NewStatsEntry = NewObject<UPrimitiveStats>();
NewStatsEntry->AddToRoot();
NewStatsEntry->Object = Resource;
NewStatsEntry->Actors.AddUnique(ActorOuter);
NewStatsEntry->Count = 1;
NewStatsEntry->Triangles = 0;
NewStatsEntry->InstTriangles = 0;
NewStatsEntry->ResourceSize = (float)(FArchiveCountMem(Resource).GetNum() + Resource->GetResourceSize(EResourceSizeMode::Exclusive)) / 1024.0f;
NewStatsEntry->Sections = 0;
NewStatsEntry->InstSections = 0;
NewStatsEntry->RadiusMin = InPrimitiveComponent->Bounds.SphereRadius;
NewStatsEntry->RadiusAvg = InPrimitiveComponent->Bounds.SphereRadius;
NewStatsEntry->RadiusMax = InPrimitiveComponent->Bounds.SphereRadius;
NewStatsEntry->LightsLM = LightsLMCount;
NewStatsEntry->LightsOther = (float)LightsOtherCount;
NewStatsEntry->LightMapData = (float)LightMapData / 1024.0f;
NewStatsEntry->LMSMResolution = LMSMResolution;
NewStatsEntry->VertexColorMem = (float)VertexColorMem / 1024.0f;
NewStatsEntry->InstVertexColorMem = (float)InstVertexColorMem / 1024.0f;
NewStatsEntry->UpdateNames();
// Fix up triangle and section count...
// ... in the case of a static mesh component.
if( StaticMeshComponent )
{
UStaticMesh* StaticMesh = StaticMeshComponent->StaticMesh;
if( StaticMesh && StaticMesh->RenderData )
{
for( int32 SectionIndex=0; SectionIndex<StaticMesh->RenderData->LODResources[0].Sections.Num(); SectionIndex++ )
{
const FStaticMeshSection& StaticMeshSection = StaticMesh->RenderData->LODResources[0].Sections[SectionIndex];
NewStatsEntry->Triangles += StaticMeshSection.NumTriangles;
NewStatsEntry->Sections++;
}
}
}
// ... in the case of a model component (aka BSP).
else if( ModelComponent )
{
示例3: GatherDependenciesRecursively
//.........这里部分代码省略.........
}
}
}
else
{
// This asset is new to us so far! Let's add it to the tree. Later as we descend through references, we might find that the
// asset is referenced by something else as well, in which case we'll pull it out and move it to a "shared" top-level box
// Don't bother showing code references
const FString AssetPackageNameString = AssetPackageName.ToString();
if( !AssetPackageNameString.StartsWith( TEXT( "/Script/" ) ) )
{
FTreeMapNodeDataRef ChildTreeMapNode = MakeShareable( new FTreeMapNodeData() );
Node->Children.Add( ChildTreeMapNode );
ChildTreeMapNode->Parent = Node.Get(); // Keep back-pointer to parent node
VisitedAssetPackageNames.Add( AssetPackageName, ChildTreeMapNode );
FNodeSizeMapData& NodeSizeMapData = NodeSizeMapDataMap.Add( ChildTreeMapNode );
// Set some defaults for this node. These will be used if we can't actually locate the asset.
// @todo sizemap urgent: We need a better indication in the UI when there are one or more missing assets. Because missing assets have a size
// of zero, they are nearly impossible to zoom into. At the least, we should have some Output Log spew when assets cannot be loaded
NodeSizeMapData.AssetData.AssetName = AssetPackageName;
NodeSizeMapData.AssetData.AssetClass = FName( *LOCTEXT( "MissingAsset", "MISSING!" ).ToString() );
NodeSizeMapData.AssetSize = 0;
NodeSizeMapData.bHasKnownSize = false;
// Find the asset using the asset registry
// @todo sizemap: Asset registry-based reference gathering is faster but possibly not as exhaustive (no PostLoad created references, etc.) Maybe should be optional?
// @todo sizemap: With AR-based reference gathering, sometimes the size map is missing root level dependencies until you reopen it a few times (Buggy BP)
// @todo sizemap: With AR-based reference gathering, reference changes at editor-time do not appear in the Size Map until you restart
// @todo sizemap: With AR-based reference gathering, opening the size map for all engine content caused the window to not respond until a restart
// @todo sizemap: We don't really need the asset registry given we need to load the objects to figure out their size, unless we make that AR-searchable.
// ---> This would allow us to not have to wait for AR initialization. But if we made size AR-searchable, we could run very quickly for large data sets!
const bool bUseAssetRegistryForDependencies = false;
const FString AssetPathString = AssetPackageNameString + TEXT(".") + FPackageName::GetLongPackageAssetName( AssetPackageNameString );
const FAssetData FoundAssetData = AssetRegistryModule.Get().GetAssetByObjectPath( FName( *AssetPathString ) );
if( FoundAssetData.IsValid() )
{
NodeSizeMapData.AssetData = FoundAssetData;
// Now actually load up the asset. We need it in memory in order to accurately determine its size.
// @todo sizemap: We could async load these packages to make the editor experience a bit nicer (smoother progress)
UObject* Asset = StaticLoadObject( UObject::StaticClass(), nullptr, *AssetPathString );
if( Asset != nullptr )
{
TArray<FName> ReferencedAssetPackageNames;
if( bUseAssetRegistryForDependencies )
{
AssetRegistryModule.Get().GetDependencies( AssetPackageName, ReferencedAssetPackageNames );
}
else
{
SizeMapInternals::FAssetReferenceFinder References( Asset );
for( UObject* Object : References.GetReferencedAssets() )
{
ReferencedAssetPackageNames.Add( FName( *Object->GetOutermost()->GetPathName() ) );
}
}
// For textures, make sure we're getting the worst case size, not the size of the currently loaded set of mips
// @todo sizemap: We should instead have a special EResourceSizeMode that asks for the worst case size. Some assets (like UTextureCube) currently always report resident mip size, even when asked for inclusive size
if( Asset->IsA( UTexture2D::StaticClass() ) )
{
NodeSizeMapData.AssetSize = Asset->GetResourceSize( EResourceSizeMode::Inclusive );
}
else
{
NodeSizeMapData.AssetSize = Asset->GetResourceSize( EResourceSizeMode::Exclusive );
}
NodeSizeMapData.bHasKnownSize = NodeSizeMapData.AssetSize != UObject::RESOURCE_SIZE_NONE && NodeSizeMapData.AssetSize != 0;
if( !NodeSizeMapData.bHasKnownSize )
{
// Asset has no meaningful size
NodeSizeMapData.AssetSize = 0;
// @todo sizemap urgent: Try to serialize to figure out how big it is (not into sub-assets though!)
// FObjectMemoryAnalyzer ObjectMemoryAnalyzer( Asset );
}
// Now visit all of the assets that we are referencing
GatherDependenciesRecursively( AssetRegistryModule, InAssetThumbnailPool, VisitedAssetPackageNames, ReferencedAssetPackageNames, ChildTreeMapNode, SharedRootNode, NumAssetsWhichFailedToLoad );
}
else
{
++NumAssetsWhichFailedToLoad;
}
}
else
{
++NumAssetsWhichFailedToLoad;
}
}
}
}
}