本文整理汇总了C++中UMaterial::GetAllExpressionsInMaterialAndFunctionsOfType方法的典型用法代码示例。如果您正苦于以下问题:C++ UMaterial::GetAllExpressionsInMaterialAndFunctionsOfType方法的具体用法?C++ UMaterial::GetAllExpressionsInMaterialAndFunctionsOfType怎么用?C++ UMaterial::GetAllExpressionsInMaterialAndFunctionsOfType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UMaterial
的用法示例。
在下文中一共展示了UMaterial::GetAllExpressionsInMaterialAndFunctionsOfType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PostEditChangeProperty
void UMaterialParameterCollection::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
// If the array counts have changed, an element has been added or removed, and we need to update the uniform buffer layout,
// Which also requires recompiling any referencing materials
if (ScalarParameters.Num() != PreviousScalarParameters.Num()
|| VectorParameters.Num() != PreviousVectorParameters.Num())
{
// Limit the count of parameters to fit within uniform buffer limits
const uint32 MaxScalarParameters = 1024;
if (ScalarParameters.Num() > MaxScalarParameters)
{
ScalarParameters.RemoveAt(MaxScalarParameters, ScalarParameters.Num() - MaxScalarParameters);
}
const uint32 MaxVectorParameters = 1024;
if (VectorParameters.Num() > MaxVectorParameters)
{
VectorParameters.RemoveAt(MaxVectorParameters, VectorParameters.Num() - MaxVectorParameters);
}
// Generate a new Id so that unloaded materials that reference this collection will update correctly on load
StateId = FGuid::NewGuid();
// Update the uniform buffer layout
CreateBufferStruct();
// Recreate each instance of this collection
for (TObjectIterator<UWorld> It; It; ++It)
{
UWorld* CurrentWorld = *It;
CurrentWorld->AddParameterCollectionInstance(this, false);
}
// Build set of changed parameter names
TSet<FName> ParameterNames;
for (const FCollectionVectorParameter& Param : PreviousVectorParameters)
{
ParameterNames.Add(Param.ParameterName);
}
for (const FCollectionScalarParameter& Param : PreviousScalarParameters)
{
ParameterNames.Add(Param.ParameterName);
}
for (const FCollectionVectorParameter& Param : VectorParameters)
{
ParameterNames.Remove(Param.ParameterName);
}
for (const FCollectionScalarParameter& Param : ScalarParameters)
{
ParameterNames.Remove(Param.ParameterName);
}
// Create a material update context so we can safely update materials using this parameter collection.
{
FMaterialUpdateContext UpdateContext;
// Go through all materials in memory and recompile them if they use this material parameter collection
for (TObjectIterator<UMaterial> It; It; ++It)
{
UMaterial* CurrentMaterial = *It;
bool bRecompile = false;
// Preview materials often use expressions for rendering that are not in their Expressions array,
// And therefore their MaterialParameterCollectionInfos are not up to date.
if (CurrentMaterial->bIsPreviewMaterial)
{
bRecompile = true;
}
else
{
for (int32 FunctionIndex = 0; FunctionIndex < CurrentMaterial->MaterialParameterCollectionInfos.Num() && !bRecompile; FunctionIndex++)
{
if (CurrentMaterial->MaterialParameterCollectionInfos[FunctionIndex].ParameterCollection == this)
{
TArray<UMaterialExpressionCollectionParameter*> CollectionParameters;
CurrentMaterial->GetAllExpressionsInMaterialAndFunctionsOfType(CollectionParameters);
for (UMaterialExpressionCollectionParameter* CollectionParameter : CollectionParameters)
{
if (ParameterNames.Contains(CollectionParameter->ParameterName))
{
bRecompile = true;
break;
}
}
}
}
}
if (bRecompile)
{
UpdateContext.AddMaterial(CurrentMaterial);
// Propagate the change to this material
CurrentMaterial->PreEditChange(NULL);
//.........这里部分代码省略.........