2022-09-26 15:12:13 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
2022-10-01 02:06:09 -04:00
# include "MuT/CodeGenerator.h"
2022-09-26 15:12:13 -04:00
2024-10-01 19:09:05 -04:00
# include "ASTOpMeshTransformWithBoundingMesh.h"
2022-10-02 10:56:02 -04:00
# include "Containers/Array.h"
# include "Logging/LogCategory.h"
# include "Logging/LogMacros.h"
# include "Math/IntPoint.h"
2023-03-17 09:40:20 -04:00
# include "Math/UnrealMathUtility.h"
2022-10-02 10:56:02 -04:00
# include "MuR/ImagePrivate.h"
# include "MuR/Layout.h"
# include "MuR/MutableTrace.h"
# include "MuR/Operations.h"
# include "MuR/ParametersPrivate.h"
2022-10-01 02:04:57 -04:00
# include "MuR/Platform.h"
2022-10-02 10:56:02 -04:00
# include "MuT/ASTOpAddLOD.h"
2023-04-05 11:20:44 -04:00
# include "MuT/ASTOpAddExtensionData.h"
2022-10-01 02:04:57 -04:00
# include "MuT/ASTOpConditional.h"
# include "MuT/ASTOpConstantBool.h"
# include "MuT/ASTOpConstantResource.h"
2022-10-02 10:56:02 -04:00
# include "MuT/ASTOpImageCompose.h"
# include "MuT/ASTOpImageMipmap.h"
# include "MuT/ASTOpImagePixelFormat.h"
2023-11-12 04:02:15 -05:00
# include "MuT/ASTOpImageSwizzle.h"
2022-12-05 05:01:41 -05:00
# include "MuT/ASTOpImageLayer.h"
# include "MuT/ASTOpImageLayerColor.h"
2023-03-17 09:40:20 -04:00
# include "MuT/ASTOpImagePatch.h"
2023-10-05 04:46:46 -04:00
# include "MuT/ASTOpImageCrop.h"
2022-10-02 10:56:02 -04:00
# include "MuT/ASTOpInstanceAdd.h"
2022-10-01 02:04:57 -04:00
# include "MuT/ASTOpMeshBindShape.h"
2022-10-02 10:56:02 -04:00
# include "MuT/ASTOpMeshClipDeform.h"
2022-10-01 02:04:57 -04:00
# include "MuT/ASTOpMeshClipMorphPlane.h"
# include "MuT/ASTOpMeshMaskClipMesh.h"
2023-10-24 06:20:03 -04:00
# include "MuT/ASTOpMeshMaskClipUVMask.h"
2022-10-02 10:56:02 -04:00
# include "MuT/ASTOpMeshRemoveMask.h"
2022-10-19 15:14:57 -04:00
# include "MuT/ASTOpMeshDifference.h"
2022-10-21 22:27:28 -04:00
# include "MuT/ASTOpMeshMorph.h"
2023-01-04 15:46:42 -05:00
# include "MuT/ASTOpMeshOptimizeSkinning.h"
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
# include "MuT/ASTOpMeshExtractLayoutBlocks.h"
2022-10-02 10:56:02 -04:00
# include "MuT/ASTOpParameter.h"
2022-11-08 12:29:21 -05:00
# include "MuT/ASTOpLayoutRemoveBlocks.h"
# include "MuT/ASTOpLayoutFromMesh.h"
# include "MuT/ASTOpLayoutMerge.h"
# include "MuT/ASTOpLayoutPack.h"
2022-10-02 10:56:02 -04:00
# include "MuT/CodeGenerator_SecondPass.h"
# include "MuT/CodeOptimiser.h"
# include "MuT/CompilerPrivate.h"
# include "MuT/ErrorLogPrivate.h"
# include "MuT/NodeColour.h"
2023-10-05 03:48:29 -04:00
# include "MuT/NodeColourConstant.h"
2022-10-02 10:56:02 -04:00
# include "MuT/NodeComponent.h"
2024-07-23 07:00:39 -04:00
# include "MuT/NodeComponentSwitch.h"
# include "MuT/NodeComponentVariation.h"
2022-10-02 10:56:02 -04:00
# include "MuT/NodeImage.h"
2024-10-01 18:10:37 -04:00
# include "MuT/NodeImageConstant.h"
2022-10-02 10:56:02 -04:00
# include "MuT/NodeImageFormat.h"
# include "MuT/NodeImageFormatPrivate.h"
# include "MuT/NodeImageMipmap.h"
# include "MuT/NodeImageMipmapPrivate.h"
2023-11-12 04:02:15 -05:00
# include "MuT/NodeImageSwizzlePrivate.h"
2024-10-01 19:09:05 -04:00
# include "MuT/NodeMatrixConstant.h"
2022-10-02 10:56:02 -04:00
# include "MuT/NodeMesh.h"
# include "MuT/NodeMeshClipMorphPlane.h"
# include "MuT/NodeMeshClipWithMesh.h"
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
# include "MuT/NodeMeshConstantPrivate.h"
2022-10-02 10:56:02 -04:00
# include "MuT/NodeMeshFormat.h"
# include "MuT/NodeMeshFragment.h"
# include "MuT/NodeMeshGeometryOperation.h"
# include "MuT/NodeMeshInterpolate.h"
# include "MuT/NodeMeshMorph.h"
# include "MuT/NodeMeshReshape.h"
# include "MuT/NodeModifier.h"
2024-08-21 04:29:48 -04:00
# include "MuT/NodeModifierMeshClipDeform.h"
# include "MuT/NodeModifierMeshClipMorphPlane.h"
# include "MuT/NodeModifierMeshClipWithMesh.h"
# include "MuT/NodeModifierMeshClipWithUVMask.h"
2024-10-01 19:09:05 -04:00
# include "MuT/NodeModifierMeshTransformInMesh.h"
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
# include "MuT/NodeModifierSurfaceEdit.h"
2022-10-02 10:56:02 -04:00
# include "MuT/NodeObject.h"
# include "MuT/NodeObjectGroupPrivate.h"
2024-06-10 04:10:54 -04:00
# include "MuT/NodeObjectNew.h"
2022-10-02 10:56:02 -04:00
# include "MuT/NodePrivate.h"
# include "MuT/NodeRange.h"
# include "MuT/NodeRangeFromScalar.h"
# include "MuT/NodeScalar.h"
# include "MuT/NodeScalarConstant.h"
# include "MuT/NodeSurface.h"
2024-06-26 08:38:06 -04:00
# include "MuT/NodeSurfaceNew.h"
# include "MuT/NodeSurfaceVariation.h"
# include "MuT/NodeSurfaceSwitch.h"
2022-10-02 10:56:02 -04:00
# include "MuT/TablePrivate.h"
# include "Trace/Detail/Channel.h"
2022-09-26 15:12:13 -04:00
namespace mu
{
2023-03-17 09:40:20 -04:00
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
CodeGenerator : : CodeGenerator ( CompilerOptions : : Private * options )
{
2024-06-26 08:38:06 -04:00
CompilerOptions = options ;
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
// Create the message log
2024-06-26 08:38:06 -04:00
ErrorLog = new mu : : ErrorLog ;
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
// Add the parent at the top of the hierarchy
2024-06-26 08:38:06 -04:00
CurrentParents . Add ( FParentKey ( ) ) ;
2023-03-17 09:40:20 -04:00
}
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
//---------------------------------------------------------------------------------------------
2023-12-19 05:19:14 -05:00
void CodeGenerator : : GenerateRoot ( const Ptr < const Node > pNode )
2023-03-17 09:40:20 -04:00
{
MUTABLE_CPUPROFILER_SCOPE ( Generate ) ;
2022-09-26 15:12:13 -04:00
2023-06-15 06:49:52 -04:00
// First pass
2024-06-26 08:38:06 -04:00
FirstPass . Generate ( ErrorLog , pNode . get ( ) , CompilerOptions - > bIgnoreStates , this ) ;
2022-09-26 15:12:13 -04:00
2023-06-15 06:49:52 -04:00
// Second pass
2024-06-26 08:38:06 -04:00
SecondPassGenerator SecondPass ( & FirstPass , CompilerOptions ) ;
bool bSuccess = SecondPass . Generate ( ErrorLog , pNode . get ( ) ) ;
2023-06-15 06:49:52 -04:00
if ( ! bSuccess )
2022-09-26 15:12:13 -04:00
{
2023-03-17 09:40:20 -04:00
return ;
2022-09-26 15:12:13 -04:00
}
2023-06-15 06:49:52 -04:00
// Main pass for each state
2023-03-17 09:40:20 -04:00
{
MUTABLE_CPUPROFILER_SCOPE ( MainPass ) ;
2022-09-26 15:12:13 -04:00
2023-12-19 05:19:14 -05:00
int32 CurrentStateIndex = 0 ;
2024-06-26 08:38:06 -04:00
for ( const TPair < FObjectState , const Node * > & s : FirstPass . States )
2023-03-17 09:40:20 -04:00
{
MUTABLE_CPUPROFILER_SCOPE ( MainPassState ) ;
2022-09-26 15:12:13 -04:00
2023-12-19 05:19:14 -05:00
FGenericGenerationOptions Options ;
Options . State = CurrentStateIndex ;
2024-06-10 04:10:54 -04:00
Ptr < ASTOp > stateRoot = Generate_Generic ( pNode , Options ) ;
2024-06-26 08:38:06 -04:00
States . Emplace ( s . Key , stateRoot ) ;
2022-09-26 15:12:13 -04:00
2024-07-22 04:20:21 -04:00
AdditionalComponents . Empty ( ) ;
2023-12-19 05:19:14 -05:00
+ + CurrentStateIndex ;
2023-03-17 09:40:20 -04:00
}
}
2022-09-26 15:12:13 -04:00
}
2024-06-10 04:10:54 -04:00
Ptr < ASTOp > CodeGenerator : : Generate_Generic ( const Ptr < const Node > pNode , const FGenericGenerationOptions & Options )
2022-09-26 15:12:13 -04:00
{
2023-03-17 09:40:20 -04:00
if ( ! pNode )
{
return nullptr ;
}
2022-09-26 15:12:13 -04:00
2023-12-19 05:19:14 -05:00
// Type-specific generation
2024-01-18 03:27:38 -05:00
if ( pNode - > GetType ( ) - > IsA ( NodeScalar : : GetStaticType ( ) ) )
2022-09-26 15:12:13 -04:00
{
2024-01-18 03:27:38 -05:00
const NodeScalar * ScalarNode = static_cast < const NodeScalar * > ( pNode . get ( ) ) ;
2022-10-26 13:00:52 -04:00
FScalarGenerationResult ScalarResult ;
2023-12-19 05:19:14 -05:00
GenerateScalar ( ScalarResult , Options , ScalarNode ) ;
2022-09-26 15:12:13 -04:00
return ScalarResult . op ;
}
2024-01-18 03:27:38 -05:00
else if ( pNode - > GetType ( ) - > IsA ( NodeColour : : GetStaticType ( ) ) )
2022-09-26 15:12:13 -04:00
{
2024-01-18 03:27:38 -05:00
const NodeColour * ColorNode = static_cast < const NodeColour * > ( pNode . get ( ) ) ;
2022-10-26 13:00:52 -04:00
FColorGenerationResult Result ;
2023-12-19 05:19:14 -05:00
GenerateColor ( Result , Options , ColorNode ) ;
2022-09-26 15:12:13 -04:00
return Result . op ;
}
2024-01-18 03:27:38 -05:00
else if ( pNode - > GetType ( ) - > IsA ( NodeProjector : : GetStaticType ( ) ) )
2023-03-17 09:40:20 -04:00
{
2024-01-18 03:27:38 -05:00
const NodeProjector * projNode = static_cast < const NodeProjector * > ( pNode . get ( ) ) ;
2023-03-17 09:40:20 -04:00
FProjectorGenerationResult ProjResult ;
2023-12-19 05:19:14 -05:00
GenerateProjector ( ProjResult , Options , projNode ) ;
2023-03-17 09:40:20 -04:00
return ProjResult . op ;
}
2022-09-26 15:12:13 -04:00
2024-01-18 03:27:38 -05:00
else if ( pNode - > GetType ( ) - > IsA ( NodeSurfaceNew : : GetStaticType ( ) ) )
2023-03-17 09:40:20 -04:00
{
2024-01-18 03:27:38 -05:00
const NodeSurfaceNew * surfNode = static_cast < const NodeSurfaceNew * > ( pNode . get ( ) ) ;
2023-03-17 09:40:20 -04:00
// This happens only if we generate a node graph that has a NodeSurfaceNew at the root.
FSurfaceGenerationResult surfResult ;
2024-06-10 04:10:54 -04:00
FSurfaceGenerationOptions SurfaceOptions ( Options ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
GenerateSurface ( surfResult , SurfaceOptions , surfNode ) ;
2023-03-17 09:40:20 -04:00
return surfResult . surfaceOp ;
}
2022-09-26 15:12:13 -04:00
2024-01-18 03:27:38 -05:00
else if ( pNode - > GetType ( ) - > IsA ( NodeSurfaceVariation : : GetStaticType ( ) ) )
2023-03-17 09:40:20 -04:00
{
// This happens only if we generate a node graph that has a NodeSurfaceVariation at the root.
return nullptr ;
}
2022-09-26 15:12:13 -04:00
2024-01-18 03:27:38 -05:00
else if ( pNode - > GetType ( ) - > IsA ( NodeSurfaceSwitch : : GetStaticType ( ) ) )
2023-11-02 06:39:15 -04:00
{
2023-12-19 05:19:14 -05:00
// This happens only if we generate a node graph that has a NodeSurfaceSwitch at the root.
2023-11-02 06:39:15 -04:00
return nullptr ;
}
2024-01-18 03:27:38 -05:00
else if ( pNode - > GetType ( ) - > IsA ( NodeModifier : : GetStaticType ( ) ) )
2023-03-17 09:40:20 -04:00
{
// This happens only if we generate a node graph that has a modifier at the root.
return nullptr ;
}
2022-09-26 15:12:13 -04:00
2024-06-10 04:10:54 -04:00
else if ( pNode - > GetType ( ) - > IsA ( NodeComponent : : GetStaticType ( ) ) )
{
const NodeComponent * ComponentNode = static_cast < const NodeComponent * > ( pNode . get ( ) ) ;
2024-07-22 04:20:21 -04:00
FComponentGenerationOptions ComponentOptions ( Options , nullptr ) ;
2024-06-10 04:10:54 -04:00
FGenericGenerationResult Result ;
2024-07-22 04:20:21 -04:00
GenerateComponent ( ComponentOptions , Result , ComponentNode ) ;
2024-06-10 04:10:54 -04:00
return Result . op ;
}
2022-09-26 15:12:13 -04:00
2023-12-19 05:19:14 -05:00
Ptr < ASTOp > ResultOp ;
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
// See if it was already generated
2023-12-19 05:19:14 -05:00
FGeneratedCacheKey Key ;
Key . Node = pNode ;
Key . Options = Options ;
FGeneratedGenericNodesMap : : ValueType * it = GeneratedGenericNodes . Find ( Key ) ;
2023-03-17 09:40:20 -04:00
if ( it )
{
2023-12-19 05:19:14 -05:00
ResultOp = it - > op ;
2023-03-17 09:40:20 -04:00
}
else
{
2023-12-19 05:19:14 -05:00
FGenericGenerationResult Result ;
// Generate for each different type of node
2024-06-10 04:10:54 -04:00
if ( pNode - > GetType ( ) = = NodeObjectNew : : GetStaticType ( ) )
2023-12-19 05:19:14 -05:00
{
Generate_ObjectNew ( Options , Result , static_cast < const NodeObjectNew * > ( pNode . get ( ) ) ) ;
}
else if ( pNode - > GetType ( ) = = NodeObjectGroup : : GetStaticType ( ) )
{
Generate_ObjectGroup ( Options , Result , static_cast < const NodeObjectGroup * > ( pNode . get ( ) ) ) ;
}
else
{
check ( false ) ;
}
ResultOp = Result . op ;
GeneratedGenericNodes . Add ( Key , Result ) ;
2022-09-26 15:12:13 -04:00
}
2023-03-17 09:40:20 -04:00
// debug: expensive check of all code generation
2023-12-19 05:19:14 -05:00
// if (ResultOp)
2022-09-26 15:12:13 -04:00
// {
// ASTOpList roots;
2023-12-19 05:19:14 -05:00
// roots.push_back(ResultOp);
2022-09-26 15:12:13 -04:00
// ASTOp::FullAssert(roots);
// }
2023-12-19 05:19:14 -05:00
return ResultOp ;
2023-03-17 09:40:20 -04:00
}
2022-09-26 15:12:13 -04:00
2023-12-19 05:19:14 -05:00
void CodeGenerator : : GenerateRange ( FRangeGenerationResult & Result , const FGenericGenerationOptions & Options , Ptr < const NodeRange > Untyped )
2023-03-17 09:40:20 -04:00
{
if ( ! Untyped )
{
2022-10-26 13:00:52 -04:00
Result = FRangeGenerationResult ( ) ;
2023-03-17 09:40:20 -04:00
return ;
}
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
// See if it was already generated
2023-12-19 05:19:14 -05:00
FGeneratedCacheKey Key ;
Key . Node = Untyped ;
Key . Options = Options ;
FGeneratedRangeMap : : ValueType * it = GeneratedRanges . Find ( Key ) ;
2023-03-17 09:40:20 -04:00
if ( it )
{
2022-10-26 13:00:52 -04:00
Result = * it ;
2023-03-17 09:40:20 -04:00
return ;
}
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
// Generate for each different type of node
2024-01-18 03:27:38 -05:00
if ( Untyped - > GetType ( ) = = NodeRangeFromScalar : : GetStaticType ( ) )
2023-03-17 09:40:20 -04:00
{
2024-01-18 03:27:38 -05:00
const NodeRangeFromScalar * FromScalar = static_cast < const NodeRangeFromScalar * > ( Untyped . get ( ) ) ;
2022-10-26 13:00:52 -04:00
Result = FRangeGenerationResult ( ) ;
Result . rangeName = FromScalar - > GetName ( ) ;
2023-12-19 05:19:14 -05:00
FScalarGenerationResult ChildResult ;
GenerateScalar ( ChildResult , Options , FromScalar - > GetSize ( ) ) ;
Result . sizeOp = ChildResult . op ;
2023-03-17 09:40:20 -04:00
}
else
{
check ( false ) ;
}
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
// Cache the result
2023-12-19 05:19:14 -05:00
GeneratedRanges . Add ( Key , Result ) ;
2023-03-17 09:40:20 -04:00
}
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
2024-06-13 04:48:11 -04:00
Ptr < ASTOp > CodeGenerator : : GenerateTableVariable ( Ptr < const Node > InNode , const FTableCacheKey & CacheKey , bool bAddNoneOption , const FString & DefaultRowName )
2023-03-17 09:40:20 -04:00
{
Ptr < ASTOp > result ;
2022-09-26 15:12:13 -04:00
2022-10-26 13:00:52 -04:00
FParameterDesc param ;
2024-02-12 06:10:50 -05:00
param . m_name = CacheKey . ParameterName ;
2024-03-22 06:16:33 -04:00
if ( param . m_name . Len ( ) = = 0 )
2022-09-26 15:12:13 -04:00
{
2024-03-22 06:16:33 -04:00
param . m_name = CacheKey . Table - > GetName ( ) ;
2022-09-26 15:12:13 -04:00
}
2024-03-22 06:16:33 -04:00
param . m_type = PARAMETER_TYPE : : T_INT ;
2023-03-15 06:56:26 -04:00
param . m_defaultValue . Set < ParamIntType > ( 0 ) ;
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
// Add the possible values
{
// See if there is a string column. If there is one, we will use it as names for the
// options. Only the first string column will be used.
2024-06-13 04:48:11 -04:00
int32 nameCol = - 1 ;
2024-02-12 06:10:50 -05:00
int32 cols = CacheKey . Table - > GetPrivate ( ) - > Columns . Num ( ) ;
2023-03-17 09:40:20 -04:00
for ( int32 c = 0 ; c < cols & & nameCol < 0 ; + + c )
{
2024-02-12 06:10:50 -05:00
if ( CacheKey . Table - > GetPrivate ( ) - > Columns [ c ] . Type = = ETableColumnType : : String )
2023-03-17 09:40:20 -04:00
{
nameCol = c ;
}
}
2022-09-26 15:12:13 -04:00
2024-01-11 02:41:42 -05:00
if ( bAddNoneOption )
2022-09-26 15:12:13 -04:00
{
2023-09-26 04:43:37 -04:00
FParameterDesc : : FIntValueDesc nullValue ;
2022-09-26 15:12:13 -04:00
nullValue . m_value = - 1 ;
nullValue . m_name = " None " ;
2022-10-11 05:14:05 -04:00
param . m_possibleValues . Add ( nullValue ) ;
2023-03-15 06:56:26 -04:00
param . m_defaultValue . Set < ParamIntType > ( nullValue . m_value ) ;
2022-09-26 15:12:13 -04:00
}
2023-03-17 09:40:20 -04:00
// Add every row
2024-08-21 04:29:48 -04:00
int32 RowCount = CacheKey . Table - > GetPrivate ( ) - > Rows . Num ( ) ;
2024-10-01 18:10:37 -04:00
check ( RowCount < MAX_int16 ) // max FIntValueDesc allows
for ( int32 RowIndex = 0 ; RowIndex < RowCount ; + + RowIndex )
2023-03-17 09:40:20 -04:00
{
2023-09-26 04:43:37 -04:00
FParameterDesc : : FIntValueDesc value ;
2024-10-01 18:10:37 -04:00
value . m_value = RowIndex ;
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
if ( nameCol > - 1 )
{
2024-10-01 18:10:37 -04:00
value . m_name = CacheKey . Table - > GetPrivate ( ) - > Rows [ RowIndex ] . Values [ nameCol ] . String ;
2023-03-17 09:40:20 -04:00
}
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
param . m_possibleValues . Add ( value ) ;
2022-09-26 15:12:13 -04:00
2024-03-22 06:16:33 -04:00
// Set the first row as the default one (if there is none option)
2024-10-01 18:10:37 -04:00
if ( RowIndex = = 0 & & ! bAddNoneOption )
2024-03-22 06:16:33 -04:00
{
param . m_defaultValue . Set < ParamIntType > ( value . m_value ) ;
}
// Set the selected row as default (if exists)
if ( value . m_name = = DefaultRowName )
{
param . m_defaultValue . Set < ParamIntType > ( value . m_value ) ;
}
2022-09-26 15:12:13 -04:00
}
}
2023-03-17 09:40:20 -04:00
Ptr < ASTOpParameter > op = new ASTOpParameter ( ) ;
op - > type = OP_TYPE : : NU_PARAMETER ;
op - > parameter = param ;
2022-09-26 15:12:13 -04:00
2024-06-26 08:38:06 -04:00
FirstPass . ParameterNodes . Add ( InNode , op ) ;
2024-02-12 06:10:50 -05:00
2023-03-17 09:40:20 -04:00
return op ;
}
2022-09-26 15:12:13 -04:00
2024-08-05 03:50:33 -04:00
Ptr < const Layout > CodeGenerator : : GenerateLayout ( Ptr < const NodeLayout > SourceLayout , uint32 MeshIDPrefix )
2023-03-17 09:40:20 -04:00
{
2024-08-05 03:50:33 -04:00
Ptr < const Layout > * it = GeneratedLayouts . Find ( { SourceLayout , MeshIDPrefix } ) ;
2023-03-17 09:40:20 -04:00
if ( it )
{
return * it ;
}
2022-09-26 15:12:13 -04:00
2024-07-17 04:18:05 -04:00
Ptr < Layout > GeneratedLayout = new Layout ;
GeneratedLayout - > Size = SourceLayout - > Size ;
GeneratedLayout - > MaxSize = SourceLayout - > MaxSize ;
GeneratedLayout - > Strategy = SourceLayout - > Strategy ;
GeneratedLayout - > ReductionMethod = SourceLayout - > ReductionMethod ;
2024-07-15 04:48:43 -04:00
2024-07-17 04:18:05 -04:00
const int32 BlockCount = SourceLayout - > Blocks . Num ( ) ;
GeneratedLayout - > Blocks . SetNum ( BlockCount ) ;
for ( int32 BlockIndex = 0 ; BlockIndex < BlockCount ; + + BlockIndex )
{
const FSourceLayoutBlock & From = SourceLayout - > Blocks [ BlockIndex ] ;
FLayoutBlock & To = GeneratedLayout - > Blocks [ BlockIndex ] ;
To . Min = From . Min ;
To . Size = From . Size ;
To . Priority = From . Priority ;
To . bReduceBothAxes = From . bReduceBothAxes ;
To . bReduceByTwo = From . bReduceByTwo ;
// Assign unique ids to each layout block
uint64 Id = uint64 ( MeshIDPrefix ) < < 32 | uint64 ( BlockIndex ) ;
To . Id = Id ;
}
check ( GeneratedLayout - > Blocks . IsEmpty ( ) | | GeneratedLayout - > Blocks [ 0 ] . Id ! = FLayoutBlock : : InvalidBlockId ) ;
2024-08-05 03:50:33 -04:00
GeneratedLayouts . Add ( { SourceLayout , MeshIDPrefix } , GeneratedLayout ) ;
2024-07-17 04:18:05 -04:00
return GeneratedLayout ;
2023-03-17 09:40:20 -04:00
}
2022-09-26 15:12:13 -04:00
2024-08-05 03:50:33 -04:00
Ptr < ASTOp > CodeGenerator : : GenerateImageBlockPatch ( Ptr < ASTOp > InBlockOp ,
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
const NodeModifierSurfaceEdit : : FTexture & Patch ,
2024-08-05 03:50:33 -04:00
Ptr < Image > PatchMask ,
2023-06-15 06:49:52 -04:00
Ptr < ASTOp > conditionAd ,
const FImageGenerationOptions & ImageOptions )
2023-03-17 09:40:20 -04:00
{
// Blend operation
2024-08-05 03:50:33 -04:00
Ptr < ASTOp > FinalOp ;
2023-03-17 09:40:20 -04:00
{
MUTABLE_CPUPROFILER_SCOPE ( PatchBlend ) ;
2022-09-26 15:12:13 -04:00
2024-08-05 03:50:33 -04:00
Ptr < ASTOpImageLayer > LayerOp = new ASTOpImageLayer ( ) ;
2024-08-21 04:29:48 -04:00
LayerOp - > blendType = Patch . PatchBlendType ;
2024-08-05 03:50:33 -04:00
LayerOp - > base = InBlockOp ;
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
// When we patch from edit nodes, we want to apply it to all the channels.
2024-08-05 03:50:33 -04:00
// \todo: since we can choose the patch function, maybe we want to be able to select this as well.
2024-08-21 04:29:48 -04:00
LayerOp - > Flags = Patch . bPatchApplyToAlpha ? OP : : ImageLayerArgs : : F_APPLY_TO_ALPHA : 0 ;
2022-09-26 15:12:13 -04:00
2024-08-21 04:29:48 -04:00
NodeImage * ImageNode = Patch . PatchImage . get ( ) ;
2024-08-05 03:50:33 -04:00
Ptr < ASTOp > BlendOp ;
if ( ImageNode )
2023-03-17 09:40:20 -04:00
{
2023-06-15 06:49:52 -04:00
FImageGenerationResult BlendResult ;
2024-08-05 03:50:33 -04:00
GenerateImage ( ImageOptions , BlendResult , ImageNode ) ;
BlendOp = BlendResult . op ;
2023-03-17 09:40:20 -04:00
}
else
{
2024-08-21 04:29:48 -04:00
BlendOp = GenerateMissingImageCode ( TEXT ( " Patch top image " ) , EImageFormat : : IF_RGB_UBYTE , nullptr , ImageOptions ) ;
2023-03-17 09:40:20 -04:00
}
2024-08-05 03:50:33 -04:00
BlendOp = GenerateImageFormat ( BlendOp , InBlockOp - > GetImageDesc ( ) . m_format ) ;
BlendOp = GenerateImageSize ( BlendOp , ImageOptions . RectSize ) ;
LayerOp - > blend = BlendOp ;
2022-09-26 15:12:13 -04:00
2024-08-05 03:50:33 -04:00
// Create the rect mask constant
Ptr < ASTOp > RectConstantOp ;
2023-03-17 09:40:20 -04:00
{
2024-08-05 03:50:33 -04:00
Ptr < NodeImageConstant > pNode = new NodeImageConstant ( ) ;
pNode - > SetValue ( PatchMask . get ( ) ) ;
2024-10-01 20:57:52 -04:00
FImageGenerationOptions ConstantOptions ;
2024-08-05 03:50:33 -04:00
FImageGenerationResult ConstantResult ;
GenerateImage ( ConstantOptions , ConstantResult , pNode ) ;
RectConstantOp = ConstantResult . op ;
}
2024-08-21 04:29:48 -04:00
NodeImage * MaskNode = Patch . PatchMask . get ( ) ;
2024-08-05 03:50:33 -04:00
Ptr < ASTOp > MaskOp ;
if ( MaskNode )
{
// Combine the block rect mask with the user provided mask.
2023-06-15 06:49:52 -04:00
FImageGenerationResult MaskResult ;
2024-08-05 03:50:33 -04:00
GenerateImage ( ImageOptions , MaskResult , MaskNode ) ;
MaskOp = MaskResult . op ;
Ptr < ASTOpImageLayer > PatchCombineOp = new ASTOpImageLayer ;
PatchCombineOp - > base = MaskOp ;
PatchCombineOp - > blend = RectConstantOp ;
PatchCombineOp - > blendType = EBlendType : : BT_MULTIPLY ;
MaskOp = PatchCombineOp ;
2023-03-17 09:40:20 -04:00
}
else
{
2024-08-05 03:50:33 -04:00
MaskOp = RectConstantOp ;
2023-03-17 09:40:20 -04:00
}
2024-08-05 03:50:33 -04:00
MaskOp = GenerateImageFormat ( MaskOp , EImageFormat : : IF_L_UBYTE ) ;
MaskOp = GenerateImageSize ( MaskOp , ImageOptions . RectSize ) ;
LayerOp - > mask = MaskOp ;
2022-09-26 15:12:13 -04:00
2024-08-05 03:50:33 -04:00
FinalOp = LayerOp ;
2023-03-17 09:40:20 -04:00
}
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
// Condition to enable this patch
if ( conditionAd )
{
Ptr < ASTOp > conditionalAd ;
{
Ptr < ASTOpConditional > op = new ASTOpConditional ( ) ;
op - > type = OP_TYPE : : IM_CONDITIONAL ;
2024-08-05 03:50:33 -04:00
op - > no = InBlockOp ;
op - > yes = FinalOp ;
2023-03-17 09:40:20 -04:00
op - > condition = conditionAd ;
conditionalAd = op ;
}
2022-09-26 15:12:13 -04:00
2024-08-05 03:50:33 -04:00
FinalOp = conditionalAd ;
2023-03-17 09:40:20 -04:00
}
2022-09-26 15:12:13 -04:00
2024-08-05 03:50:33 -04:00
return FinalOp ;
2023-03-17 09:40:20 -04:00
}
2022-09-26 15:12:13 -04:00
2024-06-10 04:10:54 -04:00
//---------------------------------------------------------------------------------------------
2024-07-22 04:20:21 -04:00
void CodeGenerator : : GenerateComponent ( const FComponentGenerationOptions & InOptions , FGenericGenerationResult & OutResult , const NodeComponent * InUntypedNode )
2024-06-10 04:10:54 -04:00
{
if ( ! InUntypedNode )
{
OutResult = FGenericGenerationResult ( ) ;
return ;
}
// See if it was already generated
FGeneratedComponentCacheKey Key ;
Key . Node = InUntypedNode ;
Key . Options = InOptions ;
GeneratedComponentMap : : ValueType * it = GeneratedComponents . Find ( Key ) ;
if ( it )
{
OutResult = * it ;
return ;
}
// Generate for each different type of node
const FNodeType * Type = InUntypedNode - > GetType ( ) ;
if ( Type = = NodeComponentNew : : GetStaticType ( ) )
{
GenerateComponent_New ( InOptions , OutResult , static_cast < const NodeComponentNew * > ( InUntypedNode ) ) ;
}
else if ( Type = = NodeComponentEdit : : GetStaticType ( ) )
{
// Nothing to do because it is all preprocessed in the first code generator stage
//GenerateComponent_Edit(InOptions, OutResult, static_cast<const NodeComponentEdit*>(InUntypedNode));
2024-07-22 04:20:21 -04:00
OutResult . op = InOptions . BaseInstance ;
2024-06-10 04:10:54 -04:00
}
2024-07-23 07:00:39 -04:00
else if ( Type = = NodeComponentSwitch : : GetStaticType ( ) )
{
GenerateComponent_Switch ( InOptions , OutResult , static_cast < const NodeComponentSwitch * > ( InUntypedNode ) ) ;
}
else if ( Type = = NodeComponentVariation : : GetStaticType ( ) )
{
GenerateComponent_Variation ( InOptions , OutResult , static_cast < const NodeComponentVariation * > ( InUntypedNode ) ) ;
}
2024-06-10 04:10:54 -04:00
else
{
check ( false ) ;
}
// Cache the result
GeneratedComponents . Add ( Key , OutResult ) ;
}
2024-07-22 04:20:21 -04:00
void CodeGenerator : : GenerateComponent_New ( const FComponentGenerationOptions & Options , FGenericGenerationResult & Result , const NodeComponentNew * InNode )
2024-06-10 04:10:54 -04:00
{
const NodeComponentNew & node = * InNode ;
2022-09-26 15:12:13 -04:00
2023-03-17 09:40:20 -04:00
// Create the expression for each component in this object
2024-06-10 04:10:54 -04:00
Ptr < ASTOpAddLOD > LODsOp = new ASTOpAddLOD ( ) ;
for ( int32 LODIndex = 0 ; LODIndex < node . LODs . Num ( ) ; + + LODIndex )
2023-03-17 09:40:20 -04:00
{
2024-06-10 04:10:54 -04:00
if ( const NodeLOD * LODNode = node . LODs [ LODIndex ] . get ( ) )
2023-03-17 09:40:20 -04:00
{
2024-06-26 08:38:06 -04:00
CurrentParents . Last ( ) . Lod = LODIndex ;
2022-09-26 15:12:13 -04:00
2024-06-10 04:10:54 -04:00
FLODGenerationOptions LODOptions ( Options , LODIndex , InNode ) ;
FGenericGenerationResult LODResult ;
Generate_LOD ( LODOptions , LODResult , LODNode ) ;
2022-09-26 15:12:13 -04:00
2024-06-10 04:10:54 -04:00
LODsOp - > lods . Emplace ( LODsOp , LODResult . op ) ;
2023-03-17 09:40:20 -04:00
}
}
2022-09-26 15:12:13 -04:00
2024-06-10 04:10:54 -04:00
Ptr < ASTOpInstanceAdd > InstanceOp = new ASTOpInstanceAdd ( ) ;
InstanceOp - > type = OP_TYPE : : IN_ADDCOMPONENT ;
2024-07-22 04:20:21 -04:00
InstanceOp - > instance = Options . BaseInstance ;
2024-06-10 04:10:54 -04:00
InstanceOp - > value = LODsOp ;
InstanceOp - > id = node . Id ;
2022-09-26 15:12:13 -04:00
2024-06-10 04:10:54 -04:00
Result . op = InstanceOp ;
2024-07-22 04:20:21 -04:00
// Add a conditional if this component has conditions
for ( const FirstPassGenerator : : FComponent & Component : FirstPass . Components )
{
if ( Component . Component ! = InNode )
{
continue ;
}
if ( Component . ComponentCondition | | Component . ObjectCondition )
{
// TODO: This could be done earlier?
Ptr < ASTOpFixed > ConditionOp = new ASTOpFixed ( ) ;
ConditionOp - > op . type = OP_TYPE : : BO_AND ;
ConditionOp - > SetChild ( ConditionOp - > op . args . BoolBinary . a , Component . ObjectCondition ) ;
ConditionOp - > SetChild ( ConditionOp - > op . args . BoolBinary . b , Component . ComponentCondition ) ;
Ptr < ASTOpConditional > IfOp = new ASTOpConditional ( ) ;
IfOp - > type = OP_TYPE : : IN_CONDITIONAL ;
IfOp - > no = Options . BaseInstance ;
IfOp - > yes = Result . op ;
IfOp - > condition = ConditionOp ;
Result . op = IfOp ;
}
}
2023-03-17 09:40:20 -04:00
}
2022-09-26 15:12:13 -04:00
2024-07-23 07:00:39 -04:00
void CodeGenerator : : GenerateComponent_Switch ( const FComponentGenerationOptions & Options , FGenericGenerationResult & Result , const NodeComponentSwitch * Node )
{
MUTABLE_CPUPROFILER_SCOPE ( NodeComponentSwitch ) ;
if ( Node - > Options . Num ( ) = = 0 )
{
// No options in the switch!
Result . op = Options . BaseInstance ;
return ;
}
Ptr < ASTOpSwitch > Op = new ASTOpSwitch ( ) ;
Op - > type = OP_TYPE : : IN_SWITCH ;
// Variable value
if ( Node - > Parameter )
{
Op - > variable = Generate_Generic ( Node - > Parameter . get ( ) , Options ) ;
}
else
{
// This argument is required
Op - > variable = GenerateMissingScalarCode ( TEXT ( " Switch variable " ) , 0.0f , Node - > GetMessageContext ( ) ) ;
}
// Options
for ( int32 OptionIndex = 0 ; OptionIndex < Node - > Options . Num ( ) ; + + OptionIndex )
{
Ptr < ASTOp > Branch ;
if ( Node - > Options [ OptionIndex ] )
{
FGenericGenerationResult BaseResult ;
GenerateComponent ( Options , BaseResult , Node - > Options [ OptionIndex ] . get ( ) ) ;
Branch = BaseResult . op ;
}
else
{
// This argument is not required
Branch = Options . BaseInstance ;
}
Op - > cases . Emplace ( OptionIndex , Op , Branch ) ;
}
Result . op = Op ;
}
void CodeGenerator : : GenerateComponent_Variation ( const FComponentGenerationOptions & Options , FGenericGenerationResult & Result , const NodeComponentVariation * Node )
{
Ptr < ASTOp > CurrentMeshOp = Options . BaseInstance ;
// Default case
if ( Node - > DefaultComponent )
{
FGenericGenerationResult BranchResults ;
GenerateComponent ( Options , BranchResults , Node - > DefaultComponent . get ( ) ) ;
CurrentMeshOp = BranchResults . op ;
}
// Process variations in reverse order, since conditionals are built bottom-up.
for ( int32 VariationIndex = Node - > Variations . Num ( ) - 1 ; VariationIndex > = 0 ; - - VariationIndex )
{
int32 TagIndex = - 1 ;
const FString & Tag = Node - > Variations [ VariationIndex ] . Tag ;
for ( int32 i = 0 ; i < FirstPass . Tags . Num ( ) ; + + i )
{
if ( FirstPass . Tags [ i ] . Tag = = Tag )
{
TagIndex = i ;
}
}
if ( TagIndex < 0 )
{
ErrorLog - > GetPrivate ( ) - > Add (
FString : : Printf ( TEXT ( " Unknown tag found in component variation [%s]. " ) , * Tag ) ,
ELMT_WARNING ,
Node - > GetMessageContext ( ) ,
ELMSB_UNKNOWN_TAG
) ;
continue ;
}
Ptr < ASTOp > VariationMeshOp = Options . BaseInstance ;
if ( Node - > Variations [ VariationIndex ] . Component )
{
FGenericGenerationResult BranchResults ;
GenerateComponent ( Options , BranchResults , Node - > Variations [ VariationIndex ] . Component . get ( ) ) ;
VariationMeshOp = BranchResults . op ;
}
Ptr < ASTOpConditional > Conditional = new ASTOpConditional ;
Conditional - > type = OP_TYPE : : IN_CONDITIONAL ;
Conditional - > no = CurrentMeshOp ;
Conditional - > yes = VariationMeshOp ;
Conditional - > condition = FirstPass . Tags [ TagIndex ] . GenericCondition ;
CurrentMeshOp = Conditional ;
}
Result . op = CurrentMeshOp ;
}
2023-07-28 04:00:17 -04:00
Ptr < ASTOp > CodeGenerator : : ApplyTiling ( Ptr < ASTOp > Source , UE : : Math : : TIntVector2 < int32 > Size , EImageFormat Format )
2023-03-17 09:40:20 -04:00
{
// For now always apply tiling
2024-06-26 08:38:06 -04:00
if ( CompilerOptions - > ImageTiling = = 0 )
2023-03-17 09:40:20 -04:00
{
return Source ;
}
2024-06-26 08:38:06 -04:00
int32 TileSize = CompilerOptions - > ImageTiling ;
2023-03-17 09:40:20 -04:00
int32 TilesX = FMath : : DivideAndRoundUp < int32 > ( Size [ 0 ] , TileSize ) ;
int32 TilesY = FMath : : DivideAndRoundUp < int32 > ( Size [ 1 ] , TileSize ) ;
if ( TilesX * TilesY < = 2 )
{
return Source ;
}
Ptr < ASTOpFixed > BaseImage = new ASTOpFixed ;
BaseImage - > op . type = OP_TYPE : : IM_PLAINCOLOUR ;
BaseImage - > op . args . ImagePlainColour . size [ 0 ] = Size [ 0 ] ;
BaseImage - > op . args . ImagePlainColour . size [ 1 ] = Size [ 1 ] ;
BaseImage - > op . args . ImagePlainColour . format = Format ;
BaseImage - > op . args . ImagePlainColour . LODs = 1 ;
Ptr < ASTOp > CurrentImage = BaseImage ;
for ( int32 Y = 0 ; Y < TilesY ; + + Y )
{
for ( int32 X = 0 ; X < TilesX ; + + X )
{
int32 MinX = X * TileSize ;
int32 MinY = Y * TileSize ;
int32 TileSizeX = FMath : : Min ( TileSize , Size [ 0 ] - MinX ) ;
int32 TileSizeY = FMath : : Min ( TileSize , Size [ 1 ] - MinY ) ;
2023-10-05 04:46:46 -04:00
Ptr < ASTOpImageCrop > TileImage = new ASTOpImageCrop ( ) ;
TileImage - > Source = Source ;
TileImage - > Min [ 0 ] = MinX ;
TileImage - > Min [ 1 ] = MinY ;
TileImage - > Size [ 0 ] = TileSizeX ;
TileImage - > Size [ 1 ] = TileSizeY ;
2023-03-17 09:40:20 -04:00
Ptr < ASTOpImagePatch > PatchedImage = new ASTOpImagePatch ( ) ;
PatchedImage - > base = CurrentImage ;
PatchedImage - > patch = TileImage ;
PatchedImage - > location [ 0 ] = MinX ;
PatchedImage - > location [ 1 ] = MinY ;
CurrentImage = PatchedImage ;
}
}
return CurrentImage ;
}
2022-09-26 15:12:13 -04:00
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
Ptr < Image > CodeGenerator : : GenerateImageBlockPatchMask ( const NodeModifierSurfaceEdit : : FTexture & Patch , FIntPoint GridSize , int32 BlockPixelsX , int32 BlockPixelsY , box < FIntVector2 > RectInCells )
2024-08-05 03:50:33 -04:00
{
// Create a patching mask for the block
Ptr < Image > PatchMask ;
FIntVector2 SourceTextureSize = { GridSize [ 0 ] * BlockPixelsX , GridSize [ 1 ] * BlockPixelsY } ;
FInt32Rect BlockRectInPixels ;
BlockRectInPixels . Min = { RectInCells . min [ 0 ] * BlockPixelsX , RectInCells . min [ 1 ] * BlockPixelsY } ;
BlockRectInPixels . Max = { ( RectInCells . min [ 0 ] + RectInCells . size [ 0 ] ) * BlockPixelsX , ( RectInCells . min [ 1 ] + RectInCells . size [ 1 ] ) * BlockPixelsY } ;
2024-08-21 04:29:48 -04:00
for ( const FBox2f & PatchRect : Patch . PatchBlocks )
2024-08-05 03:50:33 -04:00
{
// Does the patch rect intersects the current block at all?
FInt32Rect PatchRectInPixels ;
PatchRectInPixels . Min = { int32 ( PatchRect . Min [ 0 ] * SourceTextureSize [ 0 ] ) , int32 ( PatchRect . Min [ 1 ] * SourceTextureSize [ 1 ] ) } ;
PatchRectInPixels . Max = { int32 ( PatchRect . Max [ 0 ] * SourceTextureSize [ 0 ] ) , int32 ( PatchRect . Max [ 1 ] * SourceTextureSize [ 1 ] ) } ;
FInt32Rect BlockPatchRect = PatchRectInPixels ;
BlockPatchRect . Clip ( BlockRectInPixels ) ;
if ( BlockPatchRect . Area ( ) > 0 )
{
FInt32Point BlockSize = BlockRectInPixels . Size ( ) ;
if ( ! PatchMask )
{
PatchMask = new mu : : Image ( BlockSize [ 0 ] , BlockSize [ 1 ] , 1 , mu : : EImageFormat : : IF_L_UBYTE , mu : : EInitializationType : : Black ) ;
}
uint8 * Pixels = PatchMask - > GetMipData ( 0 ) ;
FInt32Point BlockPatchOffset = BlockPatchRect . Min - BlockRectInPixels . Min ;
FInt32Point BlockPatchSize = BlockPatchRect . Size ( ) ;
for ( int32 RowIndex = BlockPatchOffset [ 1 ] ; RowIndex < BlockPatchOffset [ 1 ] + BlockPatchSize [ 1 ] ; + + RowIndex )
{
uint8 * RowPixels = Pixels + RowIndex * BlockSize [ 0 ] + BlockPatchOffset [ 0 ] ;
FMemory : : Memset ( RowPixels , 255 , BlockPatchSize [ 0 ] ) ;
}
}
}
return PatchMask ;
}
2022-09-26 15:12:13 -04:00
//---------------------------------------------------------------------------------------------
2024-10-01 19:27:30 -04:00
void CodeGenerator : : GenerateSurface ( FSurfaceGenerationResult & SurfaceResult ,
2024-06-10 04:10:54 -04:00
const FSurfaceGenerationOptions & Options ,
2024-10-01 19:27:30 -04:00
Ptr < const NodeSurfaceNew > SurfaceNode )
2022-09-26 15:12:13 -04:00
{
2023-10-05 04:46:46 -04:00
MUTABLE_CPUPROFILER_SCOPE ( GenerateSurface ) ;
2022-09-26 15:12:13 -04:00
// Build a series of operations to assemble the surface
2024-10-01 19:27:30 -04:00
Ptr < ASTOp > LastSurfOp ;
2022-09-26 15:12:13 -04:00
// Generate the mesh
//------------------------------------------------------------------------
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
FMeshGenerationResult MeshResults ;
2022-09-26 15:12:13 -04:00
// We don't add the mesh here, since it will be added directly at the top of the
2024-07-22 04:20:21 -04:00
// component expression in the NodeComponentNew generator with the right merges
2022-09-26 15:12:13 -04:00
// and conditions.
// But we store it to be used then.
// Do we need to generate the mesh? Or was it already generated for state conditions
// accepting the current state?
2024-10-01 19:27:30 -04:00
FirstPassGenerator : : FSurface * TargetSurface = nullptr ;
for ( FirstPassGenerator : : FSurface & Surface : FirstPass . Surfaces )
2022-09-26 15:12:13 -04:00
{
2024-10-01 19:27:30 -04:00
if ( Surface . Node ! = SurfaceNode )
{
continue ;
}
2022-09-26 15:12:13 -04:00
2024-10-01 19:27:30 -04:00
// Check state conditions
const bool bSurfaceValidForThisState =
Options . State > = Surface . StateCondition . Num ( ) | |
Surface . StateCondition [ Options . State ] ;
if ( ! bSurfaceValidForThisState )
{
continue ;
}
if ( Surface . ResultSurfaceOp )
{
// Reuse the entire surface
SurfaceResult . surfaceOp = Surface . ResultSurfaceOp ;
return ;
}
else
{
// Not already generated, we will generate this
TargetSurface = & Surface ;
}
2022-09-26 15:12:13 -04:00
}
2024-10-01 19:27:30 -04:00
if ( ! TargetSurface )
2022-09-26 15:12:13 -04:00
{
return ;
}
2023-06-15 06:49:52 -04:00
// This assumes that the lods are processed in order. It checks it this way because some platforms may have empty lods at the top.
2024-10-01 19:27:30 -04:00
const bool bIsBaseForSharedSurface =
SurfaceNode - > SharedSurfaceId ! = INDEX_NONE & &
! SharedMeshOptionsMap . Contains ( SurfaceNode - > SharedSurfaceId ) ;
2023-06-15 06:49:52 -04:00
// If this is true, we will reuse the surface properties from a higher LOD, se we can skip the generation of material properties and images.
2024-10-01 19:27:30 -04:00
const bool bShareSurface = SurfaceNode - > SharedSurfaceId ! = INDEX_NONE & & ! bIsBaseForSharedSurface ;
2023-06-15 06:49:52 -04:00
2024-10-01 18:55:36 -04:00
// Gather all modifiers that apply to this surface
TArray < FirstPassGenerator : : FModifier > Modifiers ;
constexpr bool bModifiersForBeforeOperations = false ;
// Store the data necessary to apply modifiers for the pre-normal operations stage.
// TODO: Should we merge with currently active tags from the InOptions?
2024-10-01 20:57:52 -04:00
GetModifiersFor ( SurfaceNode - > Tags , bModifiersForBeforeOperations , Modifiers ) ;
2024-10-01 18:55:36 -04:00
// This pass on the modifiers is only to detect errors that cannot be detected at the point they are applied.
2024-10-01 19:27:30 -04:00
CheckModifiersForSurface ( * SurfaceNode , Modifiers ) ;
2024-10-01 19:29:23 -04:00
TBitArray < > LayoutFromExtension ;
2024-10-01 19:27:30 -04:00
//if (SurfaceNode->Mesh)
2022-09-26 15:12:13 -04:00
{
MUTABLE_CPUPROFILER_SCOPE ( SurfaceMesh ) ;
2024-10-01 19:27:30 -04:00
Ptr < ASTOp > LastMeshOp ;
2022-09-26 15:12:13 -04:00
// Generate the mesh
2024-10-01 20:57:52 -04:00
FMeshGenerationOptions MeshOptions ;
2022-10-18 04:42:25 -04:00
MeshOptions . bLayouts = true ;
2023-12-19 05:19:14 -05:00
MeshOptions . State = Options . State ;
2024-10-01 19:27:30 -04:00
MeshOptions . ActiveTags = SurfaceNode - > Tags ;
2022-10-18 04:42:25 -04:00
2023-06-15 06:49:52 -04:00
const FMeshGenerationResult * SharedMeshResults = nullptr ;
if ( bShareSurface )
{
// Do we have the surface we need to share it with?
2024-10-01 19:27:30 -04:00
SharedMeshResults = SharedMeshOptionsMap . Find ( SurfaceNode - > SharedSurfaceId ) ;
2023-06-15 06:49:52 -04:00
check ( SharedMeshResults ) ;
// Override the layouts with the ones from the surface we share
MeshOptions . OverrideLayouts = SharedMeshResults - > GeneratedLayouts ;
}
2023-06-06 09:14:59 -04:00
// Normalize UVs if we're going to work with images and layouts.
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// TODO: This should come from per-layout settings!
2024-10-01 19:27:30 -04:00
const bool bNormalizeUVs = false ; // !SurfaceNode->Images.IsEmpty();
2023-06-06 09:14:59 -04:00
MeshOptions . bNormalizeUVs = bNormalizeUVs ;
2023-10-20 05:27:15 -04:00
// Ensure UV islands remain within their main layout block on lower LODs to avoid unexpected reordering
// of the layout blocks when reusing a surface between LODs. Used to fix small displacements on vertices
// that may cause them to fall on a different block.
MeshOptions . bClampUVIslands = bShareSurface & & bNormalizeUVs ;
2024-10-01 19:27:30 -04:00
GenerateMesh ( MeshOptions , MeshResults , SurfaceNode - > Mesh ) ;
2022-09-26 15:12:13 -04:00
// Apply the modifier for the post-normal operations stage.
2024-10-01 19:27:30 -04:00
LastMeshOp = ApplyMeshModifiers ( Modifiers , MeshOptions , MeshResults , SharedMeshResults , SurfaceNode - > GetMessageContext ( ) , nullptr ) ;
2022-09-26 15:12:13 -04:00
2024-10-01 19:27:30 -04:00
// Base mesh is allowed to be missing, aggregate all layouts and operations per layout indices in the
// generated mesh, base and extends.
TArray < CodeGenerator : : FGeneratedLayout > SurfaceReferenceLayouts ;
TArray < Ptr < ASTOp > > SurfaceLayoutOps ;
2022-09-26 15:12:13 -04:00
2024-10-01 19:27:30 -04:00
int32 MaxLayoutNum = MeshResults . GeneratedLayouts . Num ( ) ;
for ( const FMeshGenerationResult : : FExtraLayouts & ExtraLayoutData : MeshResults . ExtraMeshLayouts )
{
MaxLayoutNum = FMath : : Max ( MaxLayoutNum , ExtraLayoutData . GeneratedLayouts . Num ( ) ) ;
}
SurfaceReferenceLayouts . SetNum ( MaxLayoutNum ) ;
SurfaceLayoutOps . SetNum ( MaxLayoutNum ) ;
2024-10-01 19:29:23 -04:00
LayoutFromExtension . Init ( false , MaxLayoutNum ) ;
2024-10-01 19:27:30 -04:00
// Add layouts form the base mesh.
for ( int32 LayoutIndex = 0 ; LayoutIndex < MeshResults . GeneratedLayouts . Num ( ) ; + + LayoutIndex )
{
if ( ! MeshResults . GeneratedLayouts [ LayoutIndex ] . Layout )
{
continue ;
}
SurfaceReferenceLayouts [ LayoutIndex ] = MeshResults . GeneratedLayouts [ LayoutIndex ] ;
if ( SharedMeshResults )
{
check ( SharedMeshResults - > LayoutOps . IsValidIndex ( LayoutIndex ) ) ;
SurfaceLayoutOps [ LayoutIndex ] = SharedMeshResults - > LayoutOps [ LayoutIndex ] ;
}
else
{
Ptr < ASTOpConstantResource > ConstantLayoutOp = new ASTOpConstantResource ( ) ;
ConstantLayoutOp - > Type = OP_TYPE : : LA_CONSTANT ;
ConstantLayoutOp - > SetValue (
SurfaceReferenceLayouts [ LayoutIndex ] . Layout ,
CompilerOptions - > OptimisationOptions . DiskCacheContext ) ;
SurfaceLayoutOps [ LayoutIndex ] = ConstantLayoutOp ;
}
}
// Add extra layouts. In case there is a missing reference layout, the first visited will
// take the role.
for ( const FMeshGenerationResult : : FExtraLayouts & ExtraLayoutsData : MeshResults . ExtraMeshLayouts )
{
if ( ! ExtraLayoutsData . MeshFragment )
{
// No mesh to add, we assume there are no layouts to add either.
check ( ExtraLayoutsData . GeneratedLayouts . IsEmpty ( ) ) ;
continue ;
}
const TArray < CodeGenerator : : FGeneratedLayout > & ExtraGeneratedLayouts = ExtraLayoutsData . GeneratedLayouts ;
for ( int32 LayoutIndex = 0 ; LayoutIndex < ExtraGeneratedLayouts . Num ( ) ; + + LayoutIndex )
{
if ( ! ExtraGeneratedLayouts [ LayoutIndex ] . Layout )
2023-06-15 06:49:52 -04:00
{
2024-10-01 19:27:30 -04:00
continue ;
}
2024-10-01 20:53:07 -04:00
bool bLayoutSetByThisExtension = false ;
2024-10-01 19:27:30 -04:00
if ( ! SurfaceReferenceLayouts [ LayoutIndex ] . Layout )
{
// This Layout slot is not set by the base surface, set it as reference.
SurfaceReferenceLayouts [ LayoutIndex ] = ExtraGeneratedLayouts [ LayoutIndex ] ;
2024-10-01 20:53:07 -04:00
bLayoutSetByThisExtension = true ;
LayoutFromExtension [ LayoutIndex ] = bLayoutSetByThisExtension ;
2024-10-01 19:27:30 -04:00
}
2024-10-01 20:53:07 -04:00
if ( SharedMeshResults )
2024-10-01 19:27:30 -04:00
{
2024-10-01 20:53:07 -04:00
if ( ! SurfaceLayoutOps [ LayoutIndex ] & & bLayoutSetByThisExtension )
{
check ( SharedMeshResults - > LayoutOps . IsValidIndex ( LayoutIndex ) ) ;
SurfaceLayoutOps [ LayoutIndex ] = SharedMeshResults - > LayoutOps [ LayoutIndex ] ;
}
2023-06-15 06:49:52 -04:00
}
else
{
2024-10-01 20:53:07 -04:00
Ptr < ASTOpConstantResource > LayoutFragmentConstantOp = new ASTOpConstantResource ( ) ;
LayoutFragmentConstantOp - > Type = OP_TYPE : : LA_CONSTANT ;
LayoutFragmentConstantOp - > SetValue (
ExtraLayoutsData . GeneratedLayouts [ LayoutIndex ] . Layout ,
CompilerOptions - > OptimisationOptions . DiskCacheContext ) ;
Ptr < ASTOpLayoutMerge > LayoutMergeOp = new ASTOpLayoutMerge ( ) ;
// Base may be null if the base does not have a mesh with a layout at LayoutIndex.
// In that case, when applying the condition this can generate null layouts.
LayoutMergeOp - > Base = SurfaceLayoutOps [ LayoutIndex ] ;
LayoutMergeOp - > Added = LayoutFragmentConstantOp ;
if ( ExtraLayoutsData . Condition )
{
Ptr < ASTOpConditional > ConditionalOp = new ASTOpConditional ( ) ;
ConditionalOp - > type = OP_TYPE : : LA_CONDITIONAL ;
ConditionalOp - > no = SurfaceLayoutOps [ LayoutIndex ] ;
ConditionalOp - > yes = LayoutMergeOp ;
ConditionalOp - > condition = ExtraLayoutsData . Condition ;
SurfaceLayoutOps [ LayoutIndex ] = ConditionalOp ;
}
else
{
SurfaceLayoutOps [ LayoutIndex ] = LayoutMergeOp ;
}
2023-06-15 06:49:52 -04:00
}
2024-10-01 19:27:30 -04:00
}
}
2022-09-26 15:12:13 -04:00
2024-10-01 19:27:30 -04:00
check ( SurfaceReferenceLayouts . Num ( ) = = SurfaceLayoutOps . Num ( ) ) ;
for ( int32 LayoutIndex = 0 ; LayoutIndex < SurfaceReferenceLayouts . Num ( ) ; + + LayoutIndex )
{
if ( ! SurfaceReferenceLayouts [ LayoutIndex ] . Layout )
{
continue ;
}
2023-12-07 05:06:15 -05:00
2024-10-01 19:27:30 -04:00
if ( SurfaceReferenceLayouts [ LayoutIndex ] . Layout - > GetLayoutPackingStrategy ( ) = = mu : : EPackStrategy : : Overlay )
{
continue ;
}
2022-11-08 12:29:21 -05:00
2024-10-01 19:27:30 -04:00
// Add layout packing instructions
if ( ! SharedMeshResults )
{
// Make sure we removed unnecessary blocks
Ptr < ASTOpLayoutFromMesh > ExtractOp = new ASTOpLayoutFromMesh ( ) ;
ExtractOp - > Mesh = LastMeshOp ;
check ( LayoutIndex < 256 ) ;
ExtractOp - > LayoutIndex = uint8 ( LayoutIndex ) ;
2022-09-26 15:12:13 -04:00
2024-10-01 19:27:30 -04:00
Ptr < ASTOpLayoutRemoveBlocks > RemoveOp = new ASTOpLayoutRemoveBlocks ( ) ;
RemoveOp - > Source = SurfaceLayoutOps [ LayoutIndex ] ;
RemoveOp - > ReferenceLayout = ExtractOp ;
SurfaceLayoutOps [ LayoutIndex ] = RemoveOp ;
2022-09-26 15:12:13 -04:00
2024-10-01 19:27:30 -04:00
// Pack uv blocks
Ptr < ASTOpLayoutPack > LayoutPackOp = new ASTOpLayoutPack ( ) ;
LayoutPackOp - > Source = SurfaceLayoutOps [ LayoutIndex ] ;
SurfaceLayoutOps [ LayoutIndex ] = LayoutPackOp ;
}
2022-09-26 15:12:13 -04:00
2024-10-01 19:27:30 -04:00
// Create the expression to apply the layout to the mesh
{
Ptr < ASTOpFixed > ApplyLayoutOp = new ASTOpFixed ( ) ;
ApplyLayoutOp - > op . type = OP_TYPE : : ME_APPLYLAYOUT ;
ApplyLayoutOp - > SetChild ( ApplyLayoutOp - > op . args . MeshApplyLayout . mesh , LastMeshOp ) ;
ApplyLayoutOp - > SetChild ( ApplyLayoutOp - > op . args . MeshApplyLayout . layout , SurfaceLayoutOps [ LayoutIndex ] ) ;
ApplyLayoutOp - > op . args . MeshApplyLayout . channel = ( uint16 ) LayoutIndex ;
LastMeshOp = ApplyLayoutOp ;
}
}
2022-09-26 15:12:13 -04:00
2024-10-01 19:27:30 -04:00
MeshResults . GeneratedLayouts = MoveTemp ( SurfaceReferenceLayouts ) ;
MeshResults . LayoutOps = MoveTemp ( SurfaceLayoutOps ) ;
2022-09-26 15:12:13 -04:00
// Store in the surface for later use.
2024-10-01 19:27:30 -04:00
TargetSurface - > ResultMeshOp = LastMeshOp ;
2022-09-26 15:12:13 -04:00
}
2023-06-15 06:49:52 -04:00
// Create the expression for each texture, if we are not reusing the surface from another LOD.
2022-09-26 15:12:13 -04:00
//------------------------------------------------------------------------
2023-06-15 06:49:52 -04:00
if ( ! bShareSurface )
{
2024-10-01 19:27:30 -04:00
for ( int32 ImageIndex = 0 ; ImageIndex < SurfaceNode - > Images . Num ( ) ; + + ImageIndex )
2023-06-15 06:49:52 -04:00
{
2023-10-05 04:46:46 -04:00
MUTABLE_CPUPROFILER_SCOPE ( SurfaceTexture ) ;
2022-09-26 15:12:13 -04:00
2024-02-21 09:50:13 -05:00
// Any image-specific format or mipmapping needs to be applied at the end
Ptr < NodeImageMipmap > mipmapNode ;
Ptr < NodeImageFormat > formatNode ;
Ptr < NodeImageSwizzle > swizzleNode ;
bool bFound = false ;
2024-10-01 19:27:30 -04:00
Ptr < NodeImage > pImageNode = SurfaceNode - > Images [ ImageIndex ] . Image ;
2024-02-21 09:50:13 -05:00
while ( ! bFound & & pImageNode )
2022-09-26 15:12:13 -04:00
{
2024-02-21 09:50:13 -05:00
if ( pImageNode - > GetType ( ) = = NodeImageMipmap : : GetStaticType ( ) )
2023-06-15 06:49:52 -04:00
{
2024-02-21 09:50:13 -05:00
NodeImageMipmap * tm = static_cast < NodeImageMipmap * > ( pImageNode . get ( ) ) ;
if ( ! mipmapNode ) mipmapNode = tm ;
pImageNode = tm - > GetSource ( ) ;
}
else if ( pImageNode - > GetType ( ) = = NodeImageFormat : : GetStaticType ( ) )
{
NodeImageFormat * tf = static_cast < NodeImageFormat * > ( pImageNode . get ( ) ) ;
if ( ! formatNode ) formatNode = tf ;
pImageNode = tf - > GetSource ( ) ;
}
else if ( pImageNode - > GetType ( ) = = NodeImageSwizzle : : GetStaticType ( ) )
{
NodeImageSwizzle * ts = static_cast < NodeImageSwizzle * > ( pImageNode . get ( ) ) ;
2024-09-16 11:41:29 -04:00
if ( ! ts - > GetPrivate ( ) - > m_sources . IsEmpty ( ) )
2022-09-26 15:12:13 -04:00
{
2024-09-16 11:41:29 -04:00
NodeImage * Source = ts - > GetSource ( 0 ) . get ( ) ;
bool bAllSourcesAreTheSame = true ;
for ( int32 SourceIndex = 1 ; SourceIndex < ts - > GetPrivate ( ) - > m_sources . Num ( ) ; + + SourceIndex )
{
bAllSourcesAreTheSame = bAllSourcesAreTheSame & & ( Source = = ts - > GetSource ( SourceIndex ) ) ;
}
if ( ! swizzleNode & & bAllSourcesAreTheSame )
{
swizzleNode = ts ;
pImageNode = Source ;
}
else
{
bFound = true ;
}
2023-06-15 06:49:52 -04:00
}
2024-10-01 19:27:04 -04:00
else
{
// break loop if swizzle has no sources.
bFound = true ;
}
2023-06-15 06:49:52 -04:00
}
2024-02-21 09:50:13 -05:00
else
{
bFound = true ;
}
}
if ( bFound )
{
2024-10-01 19:27:30 -04:00
const NodeSurfaceNew : : FImageData & ImageData = SurfaceNode - > Images [ ImageIndex ] ;
2022-09-26 15:12:13 -04:00
2024-10-01 18:55:36 -04:00
const int32 LayoutIndex = ImageData . LayoutIndex ;
2023-06-15 06:49:52 -04:00
// If the layout index has been set to negative, it means we should ignore the layout for this image.
CompilerOptions : : TextureLayoutStrategy ImageLayoutStrategy = ( LayoutIndex < 0 )
? CompilerOptions : : TextureLayoutStrategy : : None
: CompilerOptions : : TextureLayoutStrategy : : Pack
;
2023-12-19 05:19:14 -05:00
if ( ImageLayoutStrategy = = CompilerOptions : : TextureLayoutStrategy : : None )
2023-06-15 06:49:52 -04:00
{
// Generate the image
2024-10-01 20:57:52 -04:00
FImageGenerationOptions ImageOptions ;
2023-12-19 05:19:14 -05:00
ImageOptions . State = Options . State ;
2023-06-15 06:49:52 -04:00
ImageOptions . ImageLayoutStrategy = ImageLayoutStrategy ;
2024-10-01 19:27:30 -04:00
ImageOptions . ActiveTags = SurfaceNode - > Tags ;
2023-12-19 05:19:14 -05:00
ImageOptions . RectSize = { 0 , 0 } ;
2023-06-15 06:49:52 -04:00
FImageGenerationResult Result ;
GenerateImage ( ImageOptions , Result , pImageNode ) ;
Ptr < ASTOp > imageAd = Result . op ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// Placeholder block. Ideally this should be the actual image size
constexpr int32 FakeLayoutSize = 256 ;
FIntPoint GridSize ( FakeLayoutSize , FakeLayoutSize ) ;
FLayoutBlockDesc LayoutBlockDesc ;
LayoutBlockDesc . BlockPixelsX = 1 ;
LayoutBlockDesc . BlockPixelsY = 1 ;
box < FIntVector2 > RectInCells ;
RectInCells . min = { 0 , 0 } ;
RectInCells . size = { FakeLayoutSize , FakeLayoutSize } ;
2024-10-01 19:27:30 -04:00
imageAd = ApplyImageBlockModifiers ( Modifiers , ImageOptions , imageAd , ImageData , GridSize , LayoutBlockDesc , RectInCells , SurfaceNode - > GetMessageContext ( ) ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
2023-06-15 06:49:52 -04:00
check ( imageAd ) ;
2022-09-26 15:12:13 -04:00
2023-11-12 04:02:15 -05:00
if ( swizzleNode )
{
Ptr < ASTOpImageSwizzle > fop = new ASTOpImageSwizzle ( ) ;
fop - > Format = swizzleNode - > GetPrivate ( ) - > m_format ;
fop - > Sources [ 0 ] = imageAd ;
fop - > Sources [ 1 ] = imageAd ;
fop - > Sources [ 2 ] = imageAd ;
fop - > Sources [ 3 ] = imageAd ;
fop - > SourceChannels [ 0 ] = swizzleNode - > GetPrivate ( ) - > m_sourceChannels [ 0 ] ;
fop - > SourceChannels [ 1 ] = swizzleNode - > GetPrivate ( ) - > m_sourceChannels [ 1 ] ;
fop - > SourceChannels [ 2 ] = swizzleNode - > GetPrivate ( ) - > m_sourceChannels [ 2 ] ;
fop - > SourceChannels [ 3 ] = swizzleNode - > GetPrivate ( ) - > m_sourceChannels [ 3 ] ;
check ( fop - > Format ! = EImageFormat : : IF_NONE ) ;
imageAd = fop ;
}
2023-06-15 06:49:52 -04:00
if ( mipmapNode )
2022-09-26 15:12:13 -04:00
{
2023-06-15 06:49:52 -04:00
Ptr < ASTOpImageMipmap > op = new ASTOpImageMipmap ( ) ;
op - > Levels = 0 ;
op - > Source = imageAd ;
op - > BlockLevels = 0 ;
2022-09-26 15:12:13 -04:00
2024-03-26 07:54:30 -04:00
op - > AddressMode = mipmapNode - > GetPrivate ( ) - > m_settings . AddressMode ;
op - > FilterType = mipmapNode - > GetPrivate ( ) - > m_settings . FilterType ;
2023-06-15 06:49:52 -04:00
imageAd = op ;
2022-09-26 15:12:13 -04:00
}
2023-06-15 06:49:52 -04:00
if ( formatNode )
{
Ptr < ASTOpImagePixelFormat > fop = new ASTOpImagePixelFormat ( ) ;
fop - > Format = formatNode - > GetPrivate ( ) - > m_format ;
fop - > FormatIfAlpha = formatNode - > GetPrivate ( ) - > m_formatIfAlpha ;
fop - > Source = imageAd ;
check ( fop - > Format ! = EImageFormat : : IF_NONE ) ;
imageAd = fop ;
}
2022-09-26 15:12:13 -04:00
2023-06-15 06:49:52 -04:00
Ptr < ASTOpInstanceAdd > op = new ASTOpInstanceAdd ( ) ;
op - > type = OP_TYPE : : IN_ADDIMAGE ;
2024-10-01 19:27:30 -04:00
op - > instance = LastSurfOp ;
2023-06-15 06:49:52 -04:00
op - > value = imageAd ;
2024-10-01 19:27:30 -04:00
op - > name = SurfaceNode - > Images [ ImageIndex ] . Name ;
2022-09-26 15:12:13 -04:00
2024-10-01 19:27:30 -04:00
LastSurfOp = op ;
2023-06-15 06:49:52 -04:00
}
2022-09-26 15:12:13 -04:00
2023-11-14 00:29:43 -05:00
else if ( ImageLayoutStrategy = = CompilerOptions : : TextureLayoutStrategy : : Pack ) //-V547
{
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
if ( LayoutIndex > = MeshResults . GeneratedLayouts . Num ( ) | |
LayoutIndex > = MeshResults . LayoutOps . Num ( ) )
2023-06-15 06:49:52 -04:00
{
2024-10-01 19:27:30 -04:00
ErrorLog - > GetPrivate ( ) - > Add ( " Missing layout in object, or its parent. " , ELMT_ERROR , SurfaceNode - > GetMessageContext ( ) ) ;
2023-06-15 06:49:52 -04:00
}
else
{
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
const Layout * pLayout = MeshResults . GeneratedLayouts [ LayoutIndex ] . Layout . get ( ) ;
2023-06-15 06:49:52 -04:00
check ( pLayout ) ;
2022-09-26 15:12:13 -04:00
2023-06-15 06:49:52 -04:00
Ptr < ASTOpInstanceAdd > op = new ASTOpInstanceAdd ( ) ;
op - > type = OP_TYPE : : IN_ADDIMAGE ;
2024-10-01 19:27:30 -04:00
op - > instance = LastSurfOp ;
2022-09-26 15:12:13 -04:00
2023-06-15 06:49:52 -04:00
// Image
//-------------------------------------
2022-09-26 15:12:13 -04:00
2023-10-17 13:23:36 -04:00
// Size of a layout block in pixels
2024-08-05 03:50:33 -04:00
FIntPoint GridSize = pLayout - > GetGridSize ( ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// Try to guess the layout block description from the first valid block that is generated.
FLayoutBlockDesc LayoutBlockDesc ;
if ( formatNode )
{
LayoutBlockDesc . FinalFormat = formatNode - > GetPrivate ( ) - > m_formatIfAlpha ;
if ( LayoutBlockDesc . FinalFormat = = EImageFormat : : IF_NONE )
{
LayoutBlockDesc . FinalFormat = formatNode - > GetPrivate ( ) - > m_format ;
}
}
2022-09-26 15:12:13 -04:00
2023-12-19 05:19:14 -05:00
bool bImageSizeWarning = false ;
2022-09-26 15:12:13 -04:00
2023-12-19 05:19:14 -05:00
// Start with a blank image. It will be completed later with the blockSize, format and mips information
Ptr < ASTOpFixed > BlankImageOp ;
2023-06-15 06:49:52 -04:00
Ptr < ASTOp > imageAd ;
{
2023-12-19 05:19:14 -05:00
BlankImageOp = new ASTOpFixed ( ) ;
BlankImageOp - > op . type = OP_TYPE : : IM_BLANKLAYOUT ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
BlankImageOp - > SetChild ( BlankImageOp - > op . args . ImageBlankLayout . layout , MeshResults . LayoutOps [ LayoutIndex ] ) ;
2023-12-19 05:19:14 -05:00
// The rest ok the op will be completed below
BlankImageOp - > op . args . ImageBlankLayout . mipmapCount = 0 ;
imageAd = BlankImageOp ;
2023-06-15 06:49:52 -04:00
}
2022-09-26 15:12:13 -04:00
2024-10-01 19:29:23 -04:00
// Skip the block addition for this image if the layout was from a extension.
if ( ! LayoutFromExtension [ LayoutIndex ] )
2023-06-15 06:49:52 -04:00
{
2024-10-01 19:29:23 -04:00
for ( int32 BlockIndex = 0 ; BlockIndex < pLayout - > GetBlockCount ( ) ; + + BlockIndex )
2024-03-13 07:21:23 -04:00
{
2024-10-01 19:29:23 -04:00
// Generate the image
2024-10-01 20:57:52 -04:00
FImageGenerationOptions ImageOptions ;
2024-10-01 19:29:23 -04:00
ImageOptions . State = Options . State ;
ImageOptions . ImageLayoutStrategy = ImageLayoutStrategy ;
ImageOptions . RectSize = { 0 , 0 } ;
ImageOptions . ActiveTags = SurfaceNode - > Tags ;
ImageOptions . LayoutToApply = pLayout ;
ImageOptions . LayoutBlockId = pLayout - > Blocks [ BlockIndex ] . Id ;
FImageGenerationResult ImageResult ;
GenerateImage ( ImageOptions , ImageResult , pImageNode ) ;
Ptr < ASTOp > blockAd = ImageResult . op ;
if ( ! blockAd )
{
// The GenerateImage(...) above has failed, skip this block
SurfaceResult . surfaceOp = nullptr ;
continue ;
}
// Calculate the desc of the generated block.
constexpr bool bReturnBestOption = true ;
FImageDesc BlockDesc = blockAd - > GetImageDesc ( bReturnBestOption , nullptr ) ;
// Block in layout grid units (cells)
box < FIntVector2 > RectInCells ;
RectInCells . min = pLayout - > Blocks [ BlockIndex ] . Min ;
RectInCells . size = pLayout - > Blocks [ BlockIndex ] . Size ;
// Try to update the layout block desc if we don't know it yet.
UpdateLayoutBlockDesc ( LayoutBlockDesc , BlockDesc , RectInCells . size ) ;
// Even if we force the size afterwards, we need some size hint in some cases, like image projections.
ImageOptions . RectSize = UE : : Math : : TIntVector2 < int32 > ( BlockDesc . m_size ) ;
blockAd = ApplyImageBlockModifiers ( Modifiers , ImageOptions , blockAd , ImageData , GridSize , LayoutBlockDesc , RectInCells , SurfaceNode - > GetMessageContext ( ) ) ;
// Enforce block size and optimizations
blockAd = GenerateImageSize ( blockAd , FIntVector2 ( BlockDesc . m_size ) ) ;
EImageFormat baseFormat = imageAd - > GetImageDesc ( ) . m_format ;
// Actually don't do it, it will be propagated from the top format operation.
//Ptr<ASTOp> blockAd = GenerateImageFormat(blockAd, baseFormat);
// Apply tiling to avoid generating chunks of image that are too big.
blockAd = ApplyTiling ( blockAd , ImageOptions . RectSize , LayoutBlockDesc . FinalFormat ) ;
// Compose layout operation
Ptr < ASTOpImageCompose > composeOp = new ASTOpImageCompose ( ) ;
composeOp - > Layout = MeshResults . LayoutOps [ LayoutIndex ] ;
composeOp - > Base = imageAd ;
composeOp - > BlockImage = blockAd ;
// Set the absolute block index.
check ( pLayout - > Blocks [ BlockIndex ] . Id ! = FLayoutBlock : : InvalidBlockId ) ;
composeOp - > BlockId = pLayout - > Blocks [ BlockIndex ] . Id ;
imageAd = composeOp ;
2024-03-13 07:21:23 -04:00
}
2023-06-15 06:49:52 -04:00
}
check ( imageAd ) ;
2024-10-01 20:57:52 -04:00
FMeshGenerationOptions ModifierOptions ;
2024-09-02 05:32:25 -04:00
ModifierOptions . State = Options . State ;
2024-10-01 19:27:30 -04:00
ModifierOptions . ActiveTags = SurfaceNode - > Tags ;
2024-10-01 20:57:52 -04:00
imageAd = ApplyImageExtendModifiers ( Modifiers , ModifierOptions , MeshResults , imageAd , ImageLayoutStrategy ,
2024-10-01 18:55:36 -04:00
LayoutIndex , ImageData , GridSize , LayoutBlockDesc ,
2024-10-01 19:27:30 -04:00
SurfaceNode - > GetMessageContext ( ) ) ;
2023-06-15 06:49:52 -04:00
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// Complete the base op
BlankImageOp - > op . args . ImageBlankLayout . blockSize [ 0 ] = uint16 ( LayoutBlockDesc . BlockPixelsX ) ;
BlankImageOp - > op . args . ImageBlankLayout . blockSize [ 1 ] = uint16 ( LayoutBlockDesc . BlockPixelsY ) ;
BlankImageOp - > op . args . ImageBlankLayout . format = GetUncompressedFormat ( LayoutBlockDesc . FinalFormat ) ;
BlankImageOp - > op . args . ImageBlankLayout . generateMipmaps = LayoutBlockDesc . bBlocksHaveMips ;
BlankImageOp - > op . args . ImageBlankLayout . mipmapCount = 0 ;
2023-06-15 06:49:52 -04:00
2023-11-12 04:02:15 -05:00
if ( swizzleNode )
{
Ptr < ASTOpImageSwizzle > fop = new ASTOpImageSwizzle ( ) ;
fop - > Format = swizzleNode - > GetPrivate ( ) - > m_format ;
2024-09-16 11:41:29 -04:00
for ( int32 ChannelIndex = 0 ; ChannelIndex < swizzleNode - > GetPrivate ( ) - > m_sourceChannels . Num ( ) ; + + ChannelIndex )
{
fop - > Sources [ ChannelIndex ] = imageAd ;
fop - > SourceChannels [ ChannelIndex ] = swizzleNode - > GetPrivate ( ) - > m_sourceChannels [ ChannelIndex ] ;
}
2023-11-12 04:02:15 -05:00
check ( fop - > Format ! = EImageFormat : : IF_NONE ) ;
imageAd = fop ;
}
2023-06-15 06:49:52 -04:00
2024-03-13 07:21:23 -04:00
// Apply mipmap and format if necessary, skip if format is IF_NONE (possibly because a block was skipped above)
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
bool bNeedsMips =
( mipmapNode & & LayoutBlockDesc . FinalFormat ! = EImageFormat : : IF_NONE )
| |
LayoutBlockDesc . bBlocksHaveMips ;
if ( bNeedsMips )
2023-06-15 06:49:52 -04:00
{
Ptr < ASTOpImageMipmap > mop = new ASTOpImageMipmap ( ) ;
// At the end of the day, we want all the mipmaps. Maybe the code
// optimiser will split the process later.
mop - > Levels = 0 ;
mop - > bOnlyTail = false ;
mop - > Source = imageAd ;
// We have to avoid mips smaller than the image format block size, so
// we will devide the layout block by the format block
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
const FImageFormatData & PixelFormatInfo = GetImageFormatData ( LayoutBlockDesc . FinalFormat ) ;
2023-06-15 06:49:52 -04:00
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
int32 mipsX = FMath : : CeilLogTwo ( LayoutBlockDesc . BlockPixelsX / PixelFormatInfo . PixelsPerBlockX ) ;
int32 mipsY = FMath : : CeilLogTwo ( LayoutBlockDesc . BlockPixelsY / PixelFormatInfo . PixelsPerBlockY ) ;
2023-09-07 05:44:55 -04:00
mop - > BlockLevels = ( uint8 ) FMath : : Max ( mipsX , mipsY ) ;
2024-01-25 11:06:57 -05:00
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
if ( LayoutBlockDesc . BlockPixelsX < PixelFormatInfo . PixelsPerBlockX | | LayoutBlockDesc . BlockPixelsY < PixelFormatInfo . PixelsPerBlockY )
2024-01-25 11:06:57 -05:00
{
// In this case, the mipmap will never be useful for blocks, so we indicate that
// it should make the mips at the root of the expression.
mop - > bOnlyTail = true ;
}
2023-06-15 06:49:52 -04:00
2023-12-19 05:19:14 -05:00
mop - > AddressMode = EAddressMode : : ClampToEdge ;
2024-03-26 07:54:30 -04:00
mop - > FilterType = EMipmapFilterType : : SimpleAverage ;
2023-06-15 06:49:52 -04:00
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
if ( mipmapNode )
{
mop - > AddressMode = mipmapNode - > GetPrivate ( ) - > m_settings . AddressMode ;
mop - > FilterType = mipmapNode - > GetPrivate ( ) - > m_settings . FilterType ;
}
2023-06-15 06:49:52 -04:00
imageAd = mop ;
}
if ( formatNode )
{
Ptr < ASTOpImagePixelFormat > fop = new ASTOpImagePixelFormat ( ) ;
fop - > Format = formatNode - > GetPrivate ( ) - > m_format ;
fop - > FormatIfAlpha = formatNode - > GetPrivate ( ) - > m_formatIfAlpha ;
fop - > Source = imageAd ;
check ( fop - > Format ! = EImageFormat : : IF_NONE ) ;
imageAd = fop ;
}
op - > value = imageAd ;
// Name
2024-10-01 19:27:30 -04:00
op - > name = SurfaceNode - > Images [ ImageIndex ] . Name ;
2023-06-15 06:49:52 -04:00
2024-10-01 19:27:30 -04:00
LastSurfOp = op ;
2023-06-15 06:49:52 -04:00
}
}
else
{
// Unimplemented texture layout strategy
check ( false ) ;
}
}
}
// Create the expression for each vector
//------------------------------------------------------------------------
2024-10-01 19:27:30 -04:00
for ( int32 t = 0 ; t < SurfaceNode - > Vectors . Num ( ) ; + + t )
2023-06-15 06:49:52 -04:00
{
//MUTABLE_CPUPROFILER_SCOPE(SurfaceVector);
2024-10-01 19:27:30 -04:00
if ( Ptr < NodeColour > pVectorNode = SurfaceNode - > Vectors [ t ] . Vector )
2023-06-15 06:49:52 -04:00
{
Ptr < ASTOpInstanceAdd > op = new ASTOpInstanceAdd ( ) ;
op - > type = OP_TYPE : : IN_ADDVECTOR ;
2024-10-01 19:27:30 -04:00
op - > instance = LastSurfOp ;
2023-06-15 06:49:52 -04:00
// Vector
2023-12-19 05:19:14 -05:00
FColorGenerationResult VectorResult ;
GenerateColor ( VectorResult , Options , pVectorNode ) ;
op - > value = VectorResult . op ;
2023-06-15 06:49:52 -04:00
// Name
2024-10-01 19:27:30 -04:00
op - > name = SurfaceNode - > Vectors [ t ] . Name ;
2023-06-15 06:49:52 -04:00
2024-10-01 19:27:30 -04:00
LastSurfOp = op ;
2023-06-15 06:49:52 -04:00
}
}
// Create the expression for each scalar
//------------------------------------------------------------------------
2024-10-01 19:27:30 -04:00
for ( int32 t = 0 ; t < SurfaceNode - > Scalars . Num ( ) ; + + t )
2023-06-15 06:49:52 -04:00
{
// MUTABLE_CPUPROFILER_SCOPE(SurfaceScalar);
2024-10-01 19:27:30 -04:00
if ( NodeScalarPtr pScalarNode = SurfaceNode - > Scalars [ t ] . Scalar )
2023-06-15 06:49:52 -04:00
{
Ptr < ASTOpInstanceAdd > op = new ASTOpInstanceAdd ( ) ;
op - > type = OP_TYPE : : IN_ADDSCALAR ;
2024-10-01 19:27:30 -04:00
op - > instance = LastSurfOp ;
2023-06-15 06:49:52 -04:00
// Scalar
2023-12-19 05:19:14 -05:00
FScalarGenerationResult ScalarResult ;
GenerateScalar ( ScalarResult , Options , pScalarNode ) ;
op - > value = ScalarResult . op ;
2023-06-15 06:49:52 -04:00
// Name
2024-10-01 19:27:30 -04:00
op - > name = SurfaceNode - > Scalars [ t ] . Name ;
2023-06-15 06:49:52 -04:00
2024-10-01 19:27:30 -04:00
LastSurfOp = op ;
2023-06-15 06:49:52 -04:00
}
}
// Create the expression for each string
//------------------------------------------------------------------------
2024-10-01 19:27:30 -04:00
for ( int32 t = 0 ; t < SurfaceNode - > Strings . Num ( ) ; + + t )
2023-06-15 06:49:52 -04:00
{
2024-10-01 19:27:30 -04:00
if ( NodeStringPtr pStringNode = SurfaceNode - > Strings [ t ] . String )
2023-06-15 06:49:52 -04:00
{
Ptr < ASTOpInstanceAdd > op = new ASTOpInstanceAdd ( ) ;
op - > type = OP_TYPE : : IN_ADDSTRING ;
2024-10-01 19:27:30 -04:00
op - > instance = LastSurfOp ;
2023-06-15 06:49:52 -04:00
2023-12-19 05:19:14 -05:00
FStringGenerationResult StringResult ;
GenerateString ( StringResult , Options , pStringNode ) ;
op - > value = StringResult . op ;
2023-06-15 06:49:52 -04:00
// Name
2024-10-01 19:27:30 -04:00
op - > name = SurfaceNode - > Strings [ t ] . Name ;
2023-06-15 06:49:52 -04:00
2024-10-01 19:27:30 -04:00
LastSurfOp = op ;
2023-06-15 06:49:52 -04:00
}
}
}
2022-09-26 15:12:13 -04:00
2024-10-01 19:27:30 -04:00
SurfaceResult . surfaceOp = LastSurfOp ;
TargetSurface - > ResultSurfaceOp = LastSurfOp ;
2023-06-15 06:49:52 -04:00
// If we are going to share this surface properties, remember it.
if ( bIsBaseForSharedSurface )
{
2024-10-01 19:27:30 -04:00
check ( ! SharedMeshOptionsMap . Contains ( SurfaceNode - > SharedSurfaceId ) ) ;
SharedMeshOptionsMap . Add ( SurfaceNode - > SharedSurfaceId , MeshResults ) ;
2023-06-15 06:49:52 -04:00
}
2022-09-26 15:12:13 -04:00
}
//---------------------------------------------------------------------------------------------
2024-06-10 04:10:54 -04:00
void CodeGenerator : : Generate_LOD ( const FLODGenerationOptions & Options , FGenericGenerationResult & Result , const NodeLOD * InNode )
2023-12-19 05:19:14 -05:00
{
2024-06-10 04:10:54 -04:00
const NodeLOD & node = * InNode ;
2023-12-19 05:19:14 -05:00
2024-06-10 04:10:54 -04:00
MUTABLE_CPUPROFILER_SCOPE ( Generate_LOD ) ;
2022-09-26 15:12:13 -04:00
// Build a series of operations to assemble the component
Ptr < ASTOp > lastCompOp ;
Ptr < ASTOp > lastMeshOp ;
2023-09-26 04:43:37 -04:00
FString lastMeshName ;
2022-09-26 15:12:13 -04:00
// This generates a different ID for each surface. It can be used to match it to the
// mesh surface, or for debugging. It cannot be 0 because it is a special case for the
// merge operation.
2024-06-10 04:10:54 -04:00
int32 surfaceID = 1 ;
2022-09-26 15:12:13 -04:00
// Look for all surfaces that belong to this component
2024-06-26 08:38:06 -04:00
for ( int32 i = 0 ; i < FirstPass . Surfaces . Num ( ) ; + + i , + + surfaceID )
2022-09-26 15:12:13 -04:00
{
2024-06-26 08:38:06 -04:00
const FirstPassGenerator : : FSurface & its = FirstPass . Surfaces [ i ] ;
2024-06-10 04:10:54 -04:00
if ( its . Component = = Options . Component
& &
its . LOD = = Options . LODIndex )
2022-09-26 15:12:13 -04:00
{
// Apply state conditions: only generate it if it enabled in this state
{
bool enabledInThisState = true ;
2024-06-26 08:38:06 -04:00
if ( its . StateCondition . Num ( ) & & Options . State > = 0 )
2022-09-26 15:12:13 -04:00
{
enabledInThisState =
2024-06-26 08:38:06 -04:00
( Options . State < its . StateCondition . Num ( ) )
2022-09-26 15:12:13 -04:00
& &
2024-06-26 08:38:06 -04:00
( its . StateCondition [ Options . State ] ) ;
2022-09-26 15:12:13 -04:00
}
if ( ! enabledInThisState )
{
continue ;
}
}
Ptr < ASTOpInstanceAdd > sop = new ASTOpInstanceAdd ( ) ;
sop - > type = OP_TYPE : : IN_ADDSURFACE ;
2024-06-26 08:38:06 -04:00
sop - > name = its . Node - > Name ;
2022-09-26 15:12:13 -04:00
sop - > instance = lastCompOp ;
2024-06-10 04:10:54 -04:00
FSurfaceGenerationOptions SurfaceOptions ( Options ) ;
2022-10-26 13:00:52 -04:00
FSurfaceGenerationResult surfaceGenerationResult ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
GenerateSurface ( surfaceGenerationResult , SurfaceOptions , its . Node ) ;
2022-09-26 15:12:13 -04:00
sop - > value = surfaceGenerationResult . surfaceOp ;
sop - > id = surfaceID ;
2024-06-26 08:38:06 -04:00
sop - > ExternalId = its . Node - > ExternalId ;
sop - > SharedSurfaceId = its . Node - > SharedSurfaceId ;
2022-09-26 15:12:13 -04:00
Ptr < ASTOp > surfaceAt = sop ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
Ptr < ASTOp > SurfaceConditionOp = its . FinalCondition ;
2022-09-26 15:12:13 -04:00
{
Ptr < ASTOpConditional > op = new ASTOpConditional ( ) ;
op - > type = OP_TYPE : : IN_CONDITIONAL ;
op - > no = lastCompOp ;
op - > yes = surfaceAt ;
2024-07-22 04:20:21 -04:00
op - > condition = SurfaceConditionOp ;
2022-09-26 15:12:13 -04:00
lastCompOp = op ;
}
// Add the mesh with its condition
2024-06-10 04:10:54 -04:00
2022-09-26 15:12:13 -04:00
// We add the merge op even for the first mesh, so that we set the surface id.
2024-06-10 04:10:54 -04:00
Ptr < ASTOp > mergeAd ;
{
2024-06-26 08:38:06 -04:00
Ptr < ASTOp > added = its . ResultMeshOp ;
2022-12-05 05:01:41 -05:00
2022-09-26 15:12:13 -04:00
Ptr < ASTOpFixed > mop = new ASTOpFixed ( ) ;
mop - > op . type = OP_TYPE : : ME_MERGE ;
mop - > SetChild ( mop - > op . args . MeshMerge . base , lastMeshOp ) ;
mop - > SetChild ( mop - > op . args . MeshMerge . added , added ) ;
mop - > op . args . MeshMerge . newSurfaceID = surfaceID ;
mergeAd = mop ;
}
2024-07-22 04:20:21 -04:00
if ( SurfaceConditionOp )
2022-09-26 15:12:13 -04:00
{
Ptr < ASTOpConditional > op = new ASTOpConditional ( ) ;
op - > type = OP_TYPE : : ME_CONDITIONAL ;
op - > no = lastMeshOp ;
op - > yes = mergeAd ;
2024-07-22 04:20:21 -04:00
op - > condition = SurfaceConditionOp ;
2022-09-26 15:12:13 -04:00
lastMeshOp = op ;
}
else
{
lastMeshOp = mergeAd ;
}
}
}
2023-01-04 15:46:42 -05:00
// Add op to optimize the skinning of the resulting mesh
{
Ptr < ASTOpMeshOptimizeSkinning > mop = new ASTOpMeshOptimizeSkinning ( ) ;
mop - > source = lastMeshOp ;
lastMeshOp = mop ;
}
2022-09-26 15:12:13 -04:00
// Add the component mesh
{
Ptr < ASTOpInstanceAdd > iop = new ASTOpInstanceAdd ( ) ;
iop - > type = OP_TYPE : : IN_ADDMESH ;
iop - > instance = lastCompOp ;
iop - > value = lastMeshOp ;
lastCompOp = iop ;
}
2023-12-19 05:19:14 -05:00
Result . op = lastCompOp ;
2022-09-26 15:12:13 -04:00
}
//---------------------------------------------------------------------------------------------
2023-12-19 05:19:14 -05:00
// Ptr<ASTOp> CodeGenerator::Visit( const NodeObjectNew::Private& node )
void CodeGenerator : : Generate_ObjectNew ( const FGenericGenerationOptions & Options , FGenericGenerationResult & Result , const NodeObjectNew * InNode )
{
MUTABLE_CPUPROFILER_SCOPE ( NodeObjectNew ) ;
2022-09-26 15:12:13 -04:00
2024-07-22 04:20:21 -04:00
// There is always at least a null parent
bool bIsChildObject = CurrentParents . Num ( ) > 1 ;
// Add this object as current parent
2024-06-26 08:38:06 -04:00
CurrentParents . Add ( FParentKey ( ) ) ;
CurrentParents . Last ( ) . ObjectNode = InNode ;
2022-09-26 15:12:13 -04:00
// Parse the child objects first, which will accumulate operations in the patching lists
2024-06-10 04:10:54 -04:00
for ( int32 t = 0 ; t < InNode - > Children . Num ( ) ; + + t )
2022-09-26 15:12:13 -04:00
{
2024-06-10 04:10:54 -04:00
if ( const NodeObject * pChildNode = InNode - > Children [ t ] . get ( ) )
2022-09-26 15:12:13 -04:00
{
Ptr < ASTOp > paramOp ;
// If there are parent objects, the condition of this object depends on the
// condition of the parent object
2024-06-26 08:38:06 -04:00
if ( CurrentObject . Num ( ) )
2022-09-26 15:12:13 -04:00
{
2024-06-26 08:38:06 -04:00
paramOp = CurrentObject . Last ( ) . Condition ;
2022-09-26 15:12:13 -04:00
}
else
{
// In case there is no group node, we generate a constant true condition
// This condition will be overwritten by the group nodes.
Ptr < ASTOpConstantBool > op = new ASTOpConstantBool ( ) ;
op - > value = true ;
paramOp = op ;
}
2023-12-19 05:19:14 -05:00
FObjectGenerationData data ;
2024-06-26 08:38:06 -04:00
data . Condition = paramOp ;
CurrentObject . Add ( data ) ;
2022-09-26 15:12:13 -04:00
2024-06-10 04:10:54 -04:00
// This op is ignored: everything is stored as patches to apply to the parent when it is compiled.
Generate_Generic ( pChildNode , Options ) ;
2022-09-26 15:12:13 -04:00
2024-06-26 08:38:06 -04:00
CurrentObject . Pop ( ) ;
2022-09-26 15:12:13 -04:00
}
}
2024-06-10 04:10:54 -04:00
// Create the expression adding all the components
Ptr < ASTOp > LastCompOp ;
2024-07-22 04:20:21 -04:00
Ptr < ASTOp > PlaceholderOp ;
if ( bIsChildObject )
{
PlaceholderOp = new ASTOpInstanceAdd ;
LastCompOp = PlaceholderOp ;
}
2022-09-26 15:12:13 -04:00
2024-06-10 04:10:54 -04:00
// Add the components in this node
for ( int32 t = 0 ; t < InNode - > Components . Num ( ) ; + + t )
{
const NodeComponent * ComponentNode = InNode - > Components [ t ] . get ( ) ;
if ( ComponentNode )
{
2024-07-22 04:20:21 -04:00
FComponentGenerationOptions ComponentOptions ( Options , LastCompOp ) ;
2024-06-10 04:10:54 -04:00
FGenericGenerationResult ComponentResult ;
2024-07-22 04:20:21 -04:00
GenerateComponent ( ComponentOptions , ComponentResult , ComponentNode ) ;
LastCompOp = ComponentResult . op ;
2022-09-26 15:12:13 -04:00
}
}
2024-06-10 04:10:54 -04:00
2024-07-22 04:20:21 -04:00
// If we didn't generate anything, make sure we don't use the placeholder.
if ( LastCompOp = = PlaceholderOp )
2024-06-10 04:10:54 -04:00
{
2024-07-22 04:20:21 -04:00
LastCompOp = nullptr ;
PlaceholderOp = nullptr ;
}
// Add the components from child objects
FAdditionalComponentKey ThisKey ;
ThisKey . ObjectNode = CurrentParents . Last ( ) . ObjectNode ;
TArray < FAdditionalComponentData > * ThisAdditionalComponents = AdditionalComponents . Find ( ThisKey ) ;
if ( LastCompOp & & ThisAdditionalComponents )
{
for ( const FAdditionalComponentData & Additional : * ThisAdditionalComponents )
2024-06-10 04:10:54 -04:00
{
2024-07-22 04:20:21 -04:00
check ( Additional . PlaceholderOp ) ;
ASTOp : : Replace ( Additional . PlaceholderOp , LastCompOp ) ;
LastCompOp = Additional . ComponentOp ;
2024-06-10 04:10:54 -04:00
}
}
2024-07-22 04:20:21 -04:00
// Store this chain of components for use in parent objects if necessary
2024-06-10 04:10:54 -04:00
// 2 is because there must be a parent and there is always a null element as well.
2024-07-22 04:20:21 -04:00
if ( LastCompOp & & bIsChildObject )
2024-06-10 04:10:54 -04:00
{
2024-07-22 04:20:21 -04:00
// TODO: Directly to the root object?
const FParentKey & ParentObjectKey = CurrentParents [ CurrentParents . Num ( ) - 2 ] ;
FAdditionalComponentKey ParentKey ;
ParentKey . ObjectNode = ParentObjectKey . ObjectNode ;
FAdditionalComponentData Data ;
Data . ComponentOp = LastCompOp ;
Data . PlaceholderOp = PlaceholderOp ;
AdditionalComponents . FindOrAdd ( ParentKey ) . Add ( Data ) ;
2024-06-10 04:10:54 -04:00
}
2024-07-22 04:20:21 -04:00
Ptr < ASTOp > RootOp = LastCompOp ;
2022-09-26 15:12:13 -04:00
2023-04-05 11:20:44 -04:00
// Add an ASTOpAddExtensionData for each connected ExtensionData node
2024-06-10 04:10:54 -04:00
for ( const NodeObjectNew : : FNamedExtensionDataNode & NamedNode : InNode - > ExtensionDataNodes )
2023-04-05 11:20:44 -04:00
{
if ( ! NamedNode . Node . get ( ) )
{
// No node connected
continue ;
}
// Name must be valid
2023-09-26 04:43:37 -04:00
check ( NamedNode . Name . Len ( ) > 0 ) ;
2023-04-05 11:20:44 -04:00
2023-12-19 05:19:14 -05:00
FExtensionDataGenerationResult ChildResult ;
GenerateExtensionData ( ChildResult , Options , NamedNode . Node ) ;
2023-04-05 11:20:44 -04:00
2023-12-19 05:19:14 -05:00
if ( ! ChildResult . Op . get ( ) )
2023-04-05 11:20:44 -04:00
{
// Failed to generate anything for this node
continue ;
}
2023-12-19 05:19:14 -05:00
FConditionalExtensionDataOp & SavedOp = ConditionalExtensionDataOps . AddDefaulted_GetRef ( ) ;
2024-06-26 08:38:06 -04:00
if ( CurrentObject . Num ( ) > 0 )
2023-04-05 11:20:44 -04:00
{
2024-06-26 08:38:06 -04:00
SavedOp . Condition = CurrentObject . Last ( ) . Condition ;
2023-04-05 11:20:44 -04:00
}
2023-12-19 05:19:14 -05:00
SavedOp . ExtensionDataOp = ChildResult . Op ;
2023-04-05 11:20:44 -04:00
SavedOp . ExtensionDataName = NamedNode . Name ;
}
2024-06-26 08:38:06 -04:00
if ( CurrentObject . Num ( ) = = 0 )
2023-04-05 11:20:44 -04:00
{
2023-12-19 05:19:14 -05:00
for ( const FConditionalExtensionDataOp & SavedOp : ConditionalExtensionDataOps )
2023-04-05 11:20:44 -04:00
{
Ptr < ASTOpAddExtensionData > ExtensionPinOp = new ASTOpAddExtensionData ( ) ;
2024-07-22 04:20:21 -04:00
ExtensionPinOp - > Instance = ASTChild ( ExtensionPinOp , RootOp ) ;
2023-04-05 11:20:44 -04:00
ExtensionPinOp - > ExtensionData = ASTChild ( ExtensionPinOp , SavedOp . ExtensionDataOp ) ;
ExtensionPinOp - > ExtensionDataName = SavedOp . ExtensionDataName ;
if ( SavedOp . Condition . get ( ) )
{
Ptr < ASTOpConditional > ConditionOp = new ASTOpConditional ( ) ;
ConditionOp - > type = OP_TYPE : : IN_CONDITIONAL ;
2024-07-22 04:20:21 -04:00
ConditionOp - > no = RootOp ;
2023-04-05 11:20:44 -04:00
ConditionOp - > yes = ExtensionPinOp ;
ConditionOp - > condition = ASTChild ( ConditionOp , SavedOp . Condition ) ;
2024-07-22 04:20:21 -04:00
RootOp = ConditionOp ;
2023-04-05 11:20:44 -04:00
}
else
{
2024-07-22 04:20:21 -04:00
RootOp = ExtensionPinOp ;
2023-04-05 11:20:44 -04:00
}
}
}
2024-06-26 08:38:06 -04:00
CurrentParents . Pop ( ) ;
2022-09-26 15:12:13 -04:00
2024-07-22 04:20:21 -04:00
Result . op = RootOp ;
2022-09-26 15:12:13 -04:00
}
//---------------------------------------------------------------------------------------------
2023-12-19 05:19:14 -05:00
//Ptr<ASTOp> CodeGenerator::Visit( const NodeObjectGroup::Private& node )
void CodeGenerator : : Generate_ObjectGroup ( const FGenericGenerationOptions & Options , FGenericGenerationResult & Result , const NodeObjectGroup * InNode )
{
const NodeObjectGroup : : Private & node = * InNode - > GetPrivate ( ) ;
2023-09-26 04:43:37 -04:00
TArray < FString > usedNames ;
2022-09-26 15:12:13 -04:00
// Parse the child objects first, which will accumulate operations in the patching lists
2022-10-11 05:14:05 -04:00
for ( int32 t = 0 ; t < node . m_children . Num ( ) ; + + t )
2022-09-26 15:12:13 -04:00
{
if ( const NodeObject * pChildNode = node . m_children [ t ] . get ( ) )
{
// Look for the child condition in the first pass
Ptr < ASTOp > conditionOp ;
bool found = false ;
2024-06-26 08:38:06 -04:00
for ( int32 i = 0 ; ! found & & i ! = FirstPass . Objects . Num ( ) ; i + + )
2022-09-26 15:12:13 -04:00
{
2024-06-26 08:38:06 -04:00
FirstPassGenerator : : FObject & it = FirstPass . Objects [ i ] ;
if ( it . Node = = pChildNode )
2022-09-26 15:12:13 -04:00
{
found = true ;
2024-06-26 08:38:06 -04:00
conditionOp = it . Condition ;
2022-09-26 15:12:13 -04:00
}
}
// \todo
// TrunkStraight_02_BranchTop crash
// It may happen with partial compilations?
// check(found);
2023-12-19 05:19:14 -05:00
FObjectGenerationData data ;
2024-06-26 08:38:06 -04:00
data . Condition = conditionOp ;
CurrentObject . Add ( data ) ;
2022-09-26 15:12:13 -04:00
// This op is ignored: everything is stored as patches to apply to the parent when
// it is compiled.
2024-06-10 04:10:54 -04:00
Generate_Generic ( pChildNode , Options ) ;
2022-09-26 15:12:13 -04:00
2024-06-26 08:38:06 -04:00
CurrentObject . Pop ( ) ;
2022-09-26 15:12:13 -04:00
// Check for duplicated child names
2023-09-26 04:43:37 -04:00
FString strChildName = pChildNode - > GetName ( ) ;
if ( usedNames . Contains ( strChildName ) )
2022-09-26 15:12:13 -04:00
{
2023-09-26 04:43:37 -04:00
FString Msg = FString : : Printf ( TEXT ( " Object group has more than one children with the same name [%s]. " ) , * strChildName ) ;
2024-06-26 08:38:06 -04:00
ErrorLog - > GetPrivate ( ) - > Add ( Msg , ELMT_WARNING , InNode - > GetMessageContext ( ) ) ;
2022-09-26 15:12:13 -04:00
}
else
{
2023-09-26 04:43:37 -04:00
usedNames . Add ( strChildName ) ;
2022-09-26 15:12:13 -04:00
}
}
}
}
2023-12-19 05:19:14 -05:00
2022-09-26 15:12:13 -04:00
//---------------------------------------------------------------------------------------------
2023-12-19 05:19:14 -05:00
Ptr < ASTOp > CodeGenerator : : GenerateMissingBoolCode ( const TCHAR * Where , bool Value , const void * ErrorContext )
2022-09-26 15:12:13 -04:00
{
// Log a warning
2023-12-19 05:19:14 -05:00
FString Msg = FString : : Printf ( TEXT ( " Required connection not found: %s " ) , Where ) ;
2024-06-26 08:38:06 -04:00
ErrorLog - > GetPrivate ( ) - > Add ( Msg , ELMT_ERROR , ErrorContext ) ;
2022-09-26 15:12:13 -04:00
// Create a constant node
2023-11-24 03:10:23 -05:00
Ptr < NodeBoolConstant > pNode = new NodeBoolConstant ( ) ;
2023-12-19 05:19:14 -05:00
pNode - > SetValue ( Value ) ;
2022-09-26 15:12:13 -04:00
2023-12-19 05:19:14 -05:00
FBoolGenerationResult ChildResult ;
FGenericGenerationOptions Options ;
GenerateBool ( ChildResult , Options , pNode ) ;
return ChildResult . op ;
2022-09-26 15:12:13 -04:00
}
//---------------------------------------------------------------------------------------------
void CodeGenerator : : GetModifiersFor (
2023-11-02 04:40:17 -04:00
const TArray < FString > & SurfaceTags ,
2024-10-01 18:55:36 -04:00
bool bModifiersForBeforeOperations ,
2023-11-02 04:40:17 -04:00
TArray < FirstPassGenerator : : FModifier > & OutModifiers )
2022-09-26 15:12:13 -04:00
{
MUTABLE_CPUPROFILER_SCOPE ( GetModifiersFor ) ;
2023-11-02 04:40:17 -04:00
if ( SurfaceTags . IsEmpty ( ) )
2022-09-26 15:12:13 -04:00
{
2023-11-02 04:40:17 -04:00
return ;
}
2024-06-26 08:38:06 -04:00
for ( const FirstPassGenerator : : FModifier & m : FirstPass . Modifiers )
2023-11-02 04:40:17 -04:00
{
// Correct stage?
2024-06-26 08:38:06 -04:00
if ( m . Node - > bApplyBeforeNormalOperations ! = bModifiersForBeforeOperations )
2023-11-02 04:40:17 -04:00
{
continue ;
}
2022-09-26 15:12:13 -04:00
2023-11-02 04:40:17 -04:00
// Already there?
bool bAlreadyAdded =
2024-06-26 08:38:06 -04:00
OutModifiers . FindByPredicate ( [ & m ] ( const FirstPassGenerator : : FModifier & c ) { return c . Node = = m . Node ; } )
2023-11-02 04:40:17 -04:00
! =
nullptr ;
2022-09-26 15:12:13 -04:00
2023-11-02 04:40:17 -04:00
if ( bAlreadyAdded )
{
continue ;
}
2022-09-26 15:12:13 -04:00
2023-11-02 04:40:17 -04:00
// Matching tags?
bool bApply = false ;
2022-09-26 15:12:13 -04:00
2024-06-26 08:38:06 -04:00
switch ( m . Node - > MultipleTagsPolicy )
2023-11-02 04:40:17 -04:00
{
case EMutableMultipleTagPolicy : : OnlyOneRequired :
{
2024-06-26 08:38:06 -04:00
for ( const FString & Tag : m . Node - > RequiredTags )
2022-09-26 15:12:13 -04:00
{
2023-11-02 04:40:17 -04:00
if ( SurfaceTags . Contains ( Tag ) )
{
bApply = true ;
break ;
}
2022-09-26 15:12:13 -04:00
}
2023-11-02 04:40:17 -04:00
break ;
}
case EMutableMultipleTagPolicy : : AllRequired :
{
bApply = true ;
2024-06-26 08:38:06 -04:00
for ( const FString & Tag : m . Node - > RequiredTags )
2023-11-02 04:40:17 -04:00
{
if ( ! SurfaceTags . Contains ( Tag ) )
{
bApply = false ;
break ;
}
}
}
}
if ( bApply )
{
OutModifiers . Add ( m ) ;
2022-09-26 15:12:13 -04:00
}
}
}
//---------------------------------------------------------------------------------------------
2024-10-01 18:55:36 -04:00
Ptr < ASTOp > CodeGenerator : : ApplyMeshModifiers (
const TArray < FirstPassGenerator : : FModifier > & Modifiers ,
const FMeshGenerationOptions & Options ,
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
FMeshGenerationResult & BaseMeshResult ,
const FMeshGenerationResult * SharedMeshResults ,
const void * ErrorContext ,
const NodeMeshConstant * OriginalMeshNode )
2022-09-26 15:12:13 -04:00
{
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
Ptr < ASTOp > LastMeshOp = BaseMeshResult . MeshOp ;
2022-09-26 15:12:13 -04:00
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
Ptr < ASTOp > PreModifiersMesh = LastMeshOp ;
2024-10-01 18:55:36 -04:00
int32 CurrentLOD = CurrentParents . Last ( ) . Lod ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// Process mesh extend modifiers (from edit modifiers)
int32 EditIndex = 0 ;
for ( const FirstPassGenerator : : FModifier & m : Modifiers )
{
2024-09-10 10:26:02 -04:00
if ( ModifiersToIgnore . Contains ( m ) )
{
// Prevent recursion.
continue ;
}
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
if ( m . Node - > GetType ( ) = = NodeModifierSurfaceEdit : : GetStaticType ( ) )
{
const NodeModifierSurfaceEdit * Edit = static_cast < const NodeModifierSurfaceEdit * > ( m . Node ) ;
BaseMeshResult . ExtraMeshLayouts . Emplace ( ) ;
2024-09-05 09:33:43 -04:00
bool bAffectsCurrentLOD = Edit - > LODs . IsValidIndex ( CurrentLOD ) ;
if ( bAffectsCurrentLOD & & Edit - > LODs [ CurrentLOD ] . MeshAdd )
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
{
2024-09-05 09:33:43 -04:00
Ptr < NodeMesh > pAdd = Edit - > LODs [ CurrentLOD ] . MeshAdd ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// Store the data necessary to apply modifiers for the pre-normal operations stage.
FMeshGenerationOptions MergedMeshOptions ( Options ) ;
MergedMeshOptions . ActiveTags = Edit - > EnableTags ; // TODO: Append to current?
if ( SharedMeshResults )
{
check ( SharedMeshResults - > ExtraMeshLayouts . IsValidIndex ( EditIndex ) ) ;
MergedMeshOptions . OverrideLayouts = SharedMeshResults - > ExtraMeshLayouts [ EditIndex ] . GeneratedLayouts ;
}
FMeshGenerationResult AddResults ;
GenerateMesh ( MergedMeshOptions , AddResults , pAdd ) ;
// Apply the modifier for the post-normal operations stage to the added mesh
FMeshGenerationOptions ModifierOptions ( Options ) ;
ModifierOptions . ActiveTags = Edit - > EnableTags ;
2024-10-01 18:55:36 -04:00
TArray < FirstPassGenerator : : FModifier > ChildModifiers ;
constexpr bool bModifiersForBeforeOperations = false ;
2024-10-01 20:57:52 -04:00
GetModifiersFor ( ModifierOptions . ActiveTags , bModifiersForBeforeOperations , ChildModifiers ) ;
2024-10-01 18:55:36 -04:00
2024-09-10 10:26:02 -04:00
ModifiersToIgnore . Push ( m ) ;
2024-10-01 18:55:36 -04:00
Ptr < ASTOp > AddedMeshOp = ApplyMeshModifiers ( ChildModifiers , ModifierOptions , AddResults , SharedMeshResults , ErrorContext , nullptr ) ;
2024-09-10 10:26:02 -04:00
ModifiersToIgnore . Pop ( ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
FMeshGenerationResult : : FExtraLayouts data ;
data . GeneratedLayouts = AddResults . GeneratedLayouts ;
data . Condition = m . FinalCondition ;
data . MeshFragment = AddedMeshOp ;
BaseMeshResult . ExtraMeshLayouts [ EditIndex ] = data ;
Ptr < ASTOpFixed > mop = new ASTOpFixed ( ) ;
mop - > op . type = OP_TYPE : : ME_MERGE ;
mop - > SetChild ( mop - > op . args . MeshMerge . base , LastMeshOp ) ;
mop - > SetChild ( mop - > op . args . MeshMerge . added , AddedMeshOp ) ;
// will merge the meshes under the same surface
mop - > op . args . MeshMerge . newSurfaceID = 0 ;
// Condition to apply
if ( m . FinalCondition )
{
Ptr < ASTOpConditional > conditionalAd = new ASTOpConditional ( ) ;
conditionalAd - > type = OP_TYPE : : ME_CONDITIONAL ;
conditionalAd - > no = LastMeshOp ;
conditionalAd - > yes = mop ;
conditionalAd - > condition = m . FinalCondition ;
LastMeshOp = conditionalAd ;
}
else
{
LastMeshOp = mop ;
}
}
+ + EditIndex ;
}
}
// "remove" operation to group all the removes
Ptr < ASTOpMeshRemoveMask > RemoveOp ;
// Process mesh remove modifiers (from edit modifiers)
for ( const FirstPassGenerator : : FModifier & m : Modifiers )
{
if ( m . Node - > GetType ( ) = = NodeModifierSurfaceEdit : : GetStaticType ( ) )
{
const NodeModifierSurfaceEdit * Edit = static_cast < const NodeModifierSurfaceEdit * > ( m . Node ) ;
2024-09-05 09:33:43 -04:00
bool bAffectsCurrentLOD = Edit - > LODs . IsValidIndex ( CurrentLOD ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// Apply mesh removes from child objects "edit surface" nodes.
// "Removes" need to come after "Adds" because some removes may refer to added meshes,
// and not the base.
// \TODO: Apply base removes first, and then "added meshes" removes here. It may have lower memory footprint during generation.
2024-09-05 09:33:43 -04:00
if ( bAffectsCurrentLOD & & Edit - > LODs [ CurrentLOD ] . MeshRemove )
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
{
2024-09-05 09:33:43 -04:00
Ptr < NodeMesh > pRemove = Edit - > LODs [ CurrentLOD ] . MeshRemove ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
FMeshGenerationResult removeResults ;
2024-10-01 20:57:52 -04:00
FMeshGenerationOptions RemoveMeshOptions ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
RemoveMeshOptions . bLayouts = false ;
RemoveMeshOptions . State = Options . State ;
RemoveMeshOptions . ActiveTags = Edit - > EnableTags ;
GenerateMesh ( RemoveMeshOptions , removeResults , pRemove ) ;
Ptr < ASTOpFixed > maskOp = new ASTOpFixed ( ) ;
maskOp - > op . type = OP_TYPE : : ME_MASKDIFF ;
// By default, remove from the base
Ptr < ASTOp > removeFrom = BaseMeshResult . BaseMeshOp ;
maskOp - > SetChild ( maskOp - > op . args . MeshMaskDiff . source , removeFrom ) ;
maskOp - > SetChild ( maskOp - > op . args . MeshMaskDiff . fragment , removeResults . MeshOp ) ;
if ( ! RemoveOp )
{
RemoveOp = new ASTOpMeshRemoveMask ( ) ;
RemoveOp - > source = LastMeshOp ;
2024-09-16 03:38:54 -04:00
RemoveOp - > FaceCullStrategy = Edit - > FaceCullStrategy ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
LastMeshOp = RemoveOp ;
}
RemoveOp - > AddRemove ( m . FinalCondition , maskOp ) ;
}
}
}
// Process mesh morph modifiers (from edit modifiers)
for ( const FirstPassGenerator : : FModifier & m : Modifiers )
{
if ( m . Node - > GetType ( ) = = NodeModifierSurfaceEdit : : GetStaticType ( ) )
{
const NodeModifierSurfaceEdit * Edit = static_cast < const NodeModifierSurfaceEdit * > ( m . Node ) ;
if ( Edit - > MeshMorph . IsEmpty ( ) )
{
continue ;
}
check ( OriginalMeshNode ) ;
Ptr < Mesh > TargetMesh = OriginalMeshNode - > FindMorph ( Edit - > MeshMorph ) ;
if ( ! TargetMesh )
{
continue ;
}
{
// Target mesh
Ptr < ASTOpConstantResource > TargetMeshOp = new ASTOpConstantResource ;
TargetMeshOp - > Type = OP_TYPE : : ME_CONSTANT ;
TargetMeshOp - > SetValue ( TargetMesh - > Clone ( ) , CompilerOptions - > OptimisationOptions . DiskCacheContext ) ;
2024-10-01 18:10:37 -04:00
TargetMeshOp - > SourceDataDescriptor = OriginalMeshNode - > SourceDataDescriptor ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// Morph generation through mesh diff
Ptr < ASTOpMeshDifference > diffAd ;
{
Ptr < ASTOpMeshDifference > op = new ASTOpMeshDifference ( ) ;
op - > Base = BaseMeshResult . BaseMeshOp ;
op - > Target = TargetMeshOp ;
// Morphing tex coords here is not supported:
// Generating the homogoneous UVs is difficult since we don't have the base
// layout yet.
op - > bIgnoreTextureCoords = true ;
diffAd = op ;
}
// Morph operation
Ptr < ASTOp > morphAd ;
{
Ptr < ASTOpMeshMorph > op = new ASTOpMeshMorph ( ) ;
// Factor
if ( Edit - > MorphFactor )
{
FScalarGenerationResult ChildResult ;
GenerateScalar ( ChildResult , Options , Edit - > MorphFactor ) ;
op - > Factor = ChildResult . op ;
}
else
{
Ptr < NodeScalarConstant > auxNode = new NodeScalarConstant ( ) ;
auxNode - > SetValue ( 1.0f ) ;
FScalarGenerationResult ChildResult ;
GenerateScalar ( ChildResult , Options , auxNode ) ;
op - > Factor = ChildResult . op ;
}
// Base
op - > Base = LastMeshOp ;
// Targets
op - > Target = diffAd ;
morphAd = op ;
}
// Condition to apply the morph
if ( m . FinalCondition )
{
Ptr < ASTOpConditional > conditionalAd = new ASTOpConditional ( ) ;
conditionalAd - > type = OP_TYPE : : ME_CONDITIONAL ;
conditionalAd - > no = LastMeshOp ;
conditionalAd - > yes = morphAd ;
conditionalAd - > condition = m . FinalCondition ;
LastMeshOp = conditionalAd ;
}
else
{
LastMeshOp = morphAd ;
}
}
}
}
2022-09-26 15:12:13 -04:00
// Process clip-with-mesh modifiers
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
RemoveOp = nullptr ;
for ( const FirstPassGenerator : : FModifier & m : Modifiers )
2022-09-26 15:12:13 -04:00
{
2024-06-26 08:38:06 -04:00
if ( m . Node - > GetType ( ) = = NodeModifierMeshClipWithMesh : : GetStaticType ( ) )
2022-09-26 15:12:13 -04:00
{
2024-06-26 08:38:06 -04:00
const NodeModifierMeshClipWithMesh * TypedClipNode = static_cast < const NodeModifierMeshClipWithMesh * > ( m . Node ) ;
2022-09-26 15:12:13 -04:00
Ptr < ASTOpMeshMaskClipMesh > op = new ASTOpMeshMaskClipMesh ( ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
op - > source = PreModifiersMesh ;
2022-09-26 15:12:13 -04:00
// Parameters
2024-10-01 20:57:52 -04:00
FMeshGenerationOptions ClipOptions ;
2022-10-18 04:42:25 -04:00
ClipOptions . bLayouts = false ;
2023-12-19 05:19:14 -05:00
ClipOptions . State = Options . State ;
2022-10-18 04:42:25 -04:00
FMeshGenerationResult clipResult ;
2024-08-21 04:29:48 -04:00
GenerateMesh ( ClipOptions , clipResult , TypedClipNode - > ClipMesh ) ;
2024-06-26 08:38:06 -04:00
op - > clip = clipResult . MeshOp ;
2022-09-26 15:12:13 -04:00
if ( ! op - > clip )
{
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
ErrorLog - > GetPrivate ( ) - > Add ( " Clip mesh has not been generated " , ELMT_ERROR , ErrorContext ) ;
2022-09-26 15:12:13 -04:00
continue ;
}
Ptr < ASTOp > maskAt = op ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
if ( ! RemoveOp )
2022-09-26 15:12:13 -04:00
{
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
RemoveOp = new ASTOpMeshRemoveMask ( ) ;
RemoveOp - > source = LastMeshOp ;
2024-09-16 03:38:54 -04:00
RemoveOp - > FaceCullStrategy = TypedClipNode - > FaceCullStrategy ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
LastMeshOp = RemoveOp ;
2022-09-26 15:12:13 -04:00
}
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
Ptr < ASTOp > fullCondition = m . FinalCondition ;
2022-09-26 15:12:13 -04:00
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
RemoveOp - > AddRemove ( fullCondition , maskAt ) ;
2022-09-26 15:12:13 -04:00
}
}
2023-10-24 06:20:03 -04:00
// Process clip-with-mask modifiers
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
for ( const FirstPassGenerator : : FModifier & m : Modifiers )
2023-10-24 06:20:03 -04:00
{
2024-06-26 08:38:06 -04:00
if ( m . Node - > GetType ( ) = = NodeModifierMeshClipWithUVMask : : GetStaticType ( ) )
2023-10-24 06:20:03 -04:00
{
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// Create a constant mesh with the original UVs required by this modifier.
// TODO: Optimize, by caching.
// TODO: Optimize by formatting and keeping only UVs
check ( OriginalMeshNode ) ;
const Mesh * OriginalMesh = OriginalMeshNode - > GetPrivate ( ) - > Value . get ( ) ;
Ptr < ASTOpConstantResource > UVMeshOp = new ASTOpConstantResource ( ) ;
UVMeshOp - > Type = OP_TYPE : : ME_CONSTANT ;
UVMeshOp - > SetValue ( OriginalMesh - > Clone ( ) , CompilerOptions - > OptimisationOptions . DiskCacheContext ) ;
2024-10-01 18:10:37 -04:00
UVMeshOp - > SourceDataDescriptor = OriginalMeshNode - > SourceDataDescriptor ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
2024-06-26 08:38:06 -04:00
const NodeModifierMeshClipWithUVMask * TypedClipNode = static_cast < const NodeModifierMeshClipWithUVMask * > ( m . Node ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
Ptr < ASTOp > MeshMaskAt ;
2023-10-24 06:20:03 -04:00
Ptr < ASTOpMeshMaskClipUVMask > op = new ASTOpMeshMaskClipUVMask ( ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
MeshMaskAt = op ;
op - > Source = BaseMeshResult . BaseMeshOp ;
op - > UVSource = UVMeshOp ;
2024-08-21 04:29:48 -04:00
op - > LayoutIndex = TypedClipNode - > LayoutIndex ;
2023-10-24 06:20:03 -04:00
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
if ( TypedClipNode - > ClipMask )
2023-10-24 06:20:03 -04:00
{
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// Parameters to generate the mask image
2024-10-01 20:57:52 -04:00
FImageGenerationOptions ClipOptions ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
ClipOptions . ImageLayoutStrategy = CompilerOptions : : TextureLayoutStrategy : : None ;
ClipOptions . LayoutBlockId = FLayoutBlock : : InvalidBlockId ;
ClipOptions . State = Options . State ;
FImageGenerationResult ClipMaskResult ;
GenerateImage ( ClipOptions , ClipMaskResult , TypedClipNode - > ClipMask ) ;
// It could be IF_L_UBIT, but since this should be optimized out at compile time, leave the most cpu efficient.
op - > MaskImage = GenerateImageFormat ( ClipMaskResult . op , mu : : EImageFormat : : IF_L_UBYTE ) ;
if ( ! op - > MaskImage )
{
ErrorLog - > GetPrivate ( ) - > Add ( " Clip UV mask has not been generated " , ELMT_ERROR , ErrorContext ) ;
continue ;
}
2023-10-24 06:20:03 -04:00
}
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
else if ( TypedClipNode - > ClipLayout )
2023-10-24 06:20:03 -04:00
{
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// Generate the layout with blocks to extract
Ptr < const Layout > Layout = GenerateLayout ( TypedClipNode - > ClipLayout , 0 ) ;
Ptr < ASTOpConstantResource > LayoutOp = new ASTOpConstantResource ( ) ;
LayoutOp - > Type = OP_TYPE : : LA_CONSTANT ;
LayoutOp - > SetValue ( Layout , CompilerOptions - > OptimisationOptions . DiskCacheContext ) ;
op - > MaskLayout = LayoutOp ;
2023-10-24 06:20:03 -04:00
}
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
else
{
// No mask or layout specified to clip. Don't clip anything.
}
2023-10-24 06:20:03 -04:00
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
if ( MeshMaskAt )
{
if ( ! RemoveOp )
{
RemoveOp = new ASTOpMeshRemoveMask ( ) ;
RemoveOp - > source = LastMeshOp ;
2024-09-16 03:38:54 -04:00
RemoveOp - > FaceCullStrategy = TypedClipNode - > FaceCullStrategy ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
LastMeshOp = RemoveOp ;
}
Ptr < ASTOp > fullCondition = m . FinalCondition ;
RemoveOp - > AddRemove ( fullCondition , MeshMaskAt ) ;
}
2023-10-24 06:20:03 -04:00
}
}
2022-09-26 15:12:13 -04:00
// Process clip-morph-plane modifiers
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
for ( const FirstPassGenerator : : FModifier & m : Modifiers )
2022-09-26 15:12:13 -04:00
{
Ptr < ASTOp > modifiedMeshOp ;
2024-06-26 08:38:06 -04:00
if ( m . Node - > GetType ( ) = = NodeModifierMeshClipMorphPlane : : GetStaticType ( ) )
2022-09-26 15:12:13 -04:00
{
2024-08-21 04:29:48 -04:00
const NodeModifierMeshClipMorphPlane * TypedNode = static_cast < const NodeModifierMeshClipMorphPlane * > ( m . Node ) ;
2022-09-26 15:12:13 -04:00
Ptr < ASTOpMeshClipMorphPlane > op = new ASTOpMeshClipMorphPlane ( ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
op - > source = LastMeshOp ;
2024-09-16 03:38:54 -04:00
op - > FaceCullStrategy = TypedNode - > Parameters . FaceCullStrategy ;
2022-09-26 15:12:13 -04:00
// Morph to an ellipse
{
2022-10-26 13:00:52 -04:00
FShape morphShape ;
morphShape . type = ( uint8_t ) FShape : : Type : : Ellipse ;
2024-08-21 04:29:48 -04:00
morphShape . position = TypedNode - > Parameters . Origin ;
morphShape . up = TypedNode - > Parameters . Normal ;
2022-09-26 15:12:13 -04:00
// TODO: Move rotation to ellipse rotation reference base instead of passing it directly
2024-08-21 04:29:48 -04:00
morphShape . size = FVector3f ( TypedNode - > Parameters . Radius1 , TypedNode - > Parameters . Radius2 , TypedNode - > Parameters . Rotation ) ;
2022-09-26 15:12:13 -04:00
// Generate a "side" vector.
// \todo: make generic and move to the vector class
{
// Generate vector perpendicular to normal for ellipse rotation reference base
2024-03-18 04:26:21 -04:00
FVector3f aux_base ( 0.f , 1.f , 0.f ) ;
2022-09-26 15:12:13 -04:00
2024-08-21 04:29:48 -04:00
if ( FMath : : Abs ( FVector3f : : DotProduct ( TypedNode - > Parameters . Normal , aux_base ) ) > 0.95f )
2022-09-26 15:12:13 -04:00
{
2024-03-18 04:26:21 -04:00
aux_base = FVector3f ( 0.f , 0.f , 1.f ) ;
2022-09-26 15:12:13 -04:00
}
2024-08-21 04:29:48 -04:00
morphShape . side = FVector3f : : CrossProduct ( TypedNode - > Parameters . Normal , aux_base ) ;
2022-09-26 15:12:13 -04:00
}
op - > morphShape = morphShape ;
}
// Selection box
2024-09-16 03:38:54 -04:00
op - > VertexSelectionType = TypedNode - > Parameters . VertexSelectionType ;
if ( op - > VertexSelectionType = = EClipVertexSelectionType : : Shape )
2022-09-26 15:12:13 -04:00
{
2022-10-26 13:00:52 -04:00
FShape selectionShape ;
2024-08-21 04:29:48 -04:00
selectionShape . type = ( uint8 ) FShape : : Type : : AABox ;
selectionShape . position = TypedNode - > Parameters . SelectionBoxOrigin ;
selectionShape . size = TypedNode - > Parameters . SelectionBoxRadius ;
2022-09-26 15:12:13 -04:00
op - > selectionShape = selectionShape ;
}
2024-09-16 03:38:54 -04:00
else if ( op - > VertexSelectionType = = EClipVertexSelectionType : : BoneHierarchy )
2022-09-26 15:12:13 -04:00
{
2024-08-21 04:29:48 -04:00
op - > vertexSelectionBone = TypedNode - > Parameters . VertexSelectionBone ;
op - > vertexSelectionBoneMaxRadius = TypedNode - > Parameters . MaxEffectRadius ;
2022-09-26 15:12:13 -04:00
}
// Parameters
2024-08-21 04:29:48 -04:00
op - > dist = TypedNode - > Parameters . DistanceToPlane ;
op - > factor = TypedNode - > Parameters . LinearityFactor ;
2022-09-26 15:12:13 -04:00
modifiedMeshOp = op ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
Ptr < ASTOp > fullCondition = m . FinalCondition ;
2022-09-26 15:12:13 -04:00
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
Ptr < ASTOpConditional > ConditionalOp = new ASTOpConditional ( ) ;
ConditionalOp - > type = OP_TYPE : : ME_CONDITIONAL ;
ConditionalOp - > no = LastMeshOp ;
ConditionalOp - > yes = modifiedMeshOp ;
ConditionalOp - > condition = fullCondition ;
LastMeshOp = ConditionalOp ;
2022-09-26 15:12:13 -04:00
}
}
// Process clip deform modifiers.
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
for ( const FirstPassGenerator : : FModifier & M : Modifiers )
2022-09-26 15:12:13 -04:00
{
Ptr < ASTOp > ModifiedMeshOp ;
2024-06-26 08:38:06 -04:00
if ( M . Node - > GetType ( ) = = NodeModifierMeshClipDeform : : GetStaticType ( ) )
2022-09-26 15:12:13 -04:00
{
2024-08-21 04:29:48 -04:00
const NodeModifierMeshClipDeform * TypedClipNode = static_cast < const NodeModifierMeshClipDeform * > ( M . Node ) ;
2022-09-26 15:12:13 -04:00
Ptr < ASTOpMeshBindShape > BindOp = new ASTOpMeshBindShape ( ) ;
Ptr < ASTOpMeshClipDeform > ClipOp = new ASTOpMeshClipDeform ( ) ;
2024-09-16 03:38:54 -04:00
ClipOp - > FaceCullStrategy = TypedClipNode - > FaceCullStrategy ;
2024-10-01 20:57:52 -04:00
FMeshGenerationOptions ClipOptions ;
2022-10-18 04:42:25 -04:00
ClipOptions . bLayouts = false ;
2024-09-16 03:38:54 -04:00
ClipOptions . State = Options . State ;
2022-10-18 04:42:25 -04:00
FMeshGenerationResult ClipShapeResult ;
GenerateMesh ( ClipOptions , ClipShapeResult , TypedClipNode - > ClipMesh ) ;
2024-06-26 08:38:06 -04:00
ClipOp - > ClipShape = ClipShapeResult . MeshOp ;
2022-09-26 15:12:13 -04:00
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
BindOp - > Mesh = LastMeshOp ;
2024-06-26 08:38:06 -04:00
BindOp - > Shape = ClipShapeResult . MeshOp ;
2022-10-26 19:35:18 -04:00
BindOp - > BindingMethod = static_cast < uint32 > ( TypedClipNode - > BindingMethod ) ;
2022-09-26 15:12:13 -04:00
ClipOp - > Mesh = BindOp ;
if ( ! ClipOp - > ClipShape )
{
2024-06-26 08:38:06 -04:00
ErrorLog - > GetPrivate ( ) - > Add
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
( " Clip shape mesh has not been generated " , ELMT_ERROR , ErrorContext ) ;
2022-09-26 15:12:13 -04:00
}
else
{
ModifiedMeshOp = ClipOp ;
}
}
if ( ModifiedMeshOp )
{
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
Ptr < ASTOp > FullCondition = M . FinalCondition ;
2022-09-26 15:12:13 -04:00
Ptr < ASTOpConditional > Op = new ASTOpConditional ( ) ;
Op - > type = OP_TYPE : : ME_CONDITIONAL ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
Op - > no = LastMeshOp ;
2022-09-26 15:12:13 -04:00
Op - > yes = ModifiedMeshOp ;
Op - > condition = FullCondition ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
LastMeshOp = Op ;
2022-09-26 15:12:13 -04:00
}
}
2024-10-01 19:09:05 -04:00
// Process transform mesh within mesh modifiers.
for ( const FirstPassGenerator : : FModifier & m : Modifiers )
{
if ( m . Node - > GetType ( ) = = NodeModifierMeshTransformInMesh : : GetStaticType ( ) )
{
const NodeModifierMeshTransformInMesh * TypedTransformNode = static_cast < const NodeModifierMeshTransformInMesh * > ( m . Node ) ;
// If a matrix node is not connected, the op won't do anything, so let's not create it at all.
if ( TypedTransformNode - > MatrixNode )
{
Ptr < ASTOpMeshTransformWithBoundingMesh > transformOp = new ASTOpMeshTransformWithBoundingMesh ( ) ;
transformOp - > source = LastMeshOp ;
// Transform matrix.
if ( TypedTransformNode - > MatrixNode )
{
FMatrixGenerationResult ChildResult ;
GenerateMatrix ( ChildResult , Options , TypedTransformNode - > MatrixNode ) ;
transformOp - > matrix = ChildResult . op ;
}
if ( TypedTransformNode - > BoundingMesh )
{
// Parameters
2024-10-01 20:57:52 -04:00
FMeshGenerationOptions MeshOptions ;
2024-10-01 19:09:05 -04:00
MeshOptions . bLayouts = false ;
MeshOptions . State = Options . State ;
FMeshGenerationResult BoundingMeshResult ;
GenerateMesh ( MeshOptions , BoundingMeshResult , TypedTransformNode - > BoundingMesh ) ;
transformOp - > boundingMesh = BoundingMeshResult . MeshOp ;
if ( ! transformOp - > boundingMesh )
{
ErrorLog - > GetPrivate ( ) - > Add ( " Bounding mesh has not been generated " , ELMT_ERROR , ErrorContext ) ;
continue ;
}
}
// Condition to apply the transform op
if ( m . FinalCondition )
{
Ptr < ASTOpConditional > conditionalAd = new ASTOpConditional ( ) ;
conditionalAd - > type = OP_TYPE : : ME_CONDITIONAL ;
conditionalAd - > no = LastMeshOp ;
conditionalAd - > yes = transformOp ;
conditionalAd - > condition = m . FinalCondition ;
LastMeshOp = conditionalAd ;
}
else
{
LastMeshOp = transformOp ;
}
}
}
}
2022-09-26 15:12:13 -04:00
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
return LastMeshOp ;
}
2024-10-01 18:55:36 -04:00
Ptr < ASTOp > CodeGenerator : : ApplyImageBlockModifiers (
const TArray < FirstPassGenerator : : FModifier > & Modifiers ,
const FImageGenerationOptions & Options , Ptr < ASTOp > BaseImageOp ,
const NodeSurfaceNew : : FImageData & ImageData ,
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
FIntPoint GridSize ,
const FLayoutBlockDesc & LayoutBlockDesc ,
box < FIntVector2 > RectInCells ,
2024-10-01 18:55:36 -04:00
const void * ErrorContext )
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
{
Ptr < ASTOp > LastImageOp = BaseImageOp ;
2024-09-05 09:33:43 -04:00
int32 CurrentLOD = CurrentParents . Last ( ) . Lod ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// Process patch image modifiers (from edit modifiers)
for ( const FirstPassGenerator : : FModifier & m : Modifiers )
{
if ( m . Node - > GetType ( ) = = NodeModifierSurfaceEdit : : GetStaticType ( ) )
{
const NodeModifierSurfaceEdit * Edit = static_cast < const NodeModifierSurfaceEdit * > ( m . Node ) ;
2024-09-05 09:33:43 -04:00
bool bAffectsCurrentLOD = Edit - > LODs . IsValidIndex ( CurrentLOD ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
2024-10-01 18:55:36 -04:00
if ( ! bAffectsCurrentLOD )
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
{
continue ;
}
2024-10-01 18:55:36 -04:00
const NodeModifierSurfaceEdit : : FTexture * MatchingEdit = Edit - > LODs [ CurrentLOD ] . Textures . FindByPredicate (
[ & ] ( const NodeModifierSurfaceEdit : : FTexture & Candidate )
{
return ( Candidate . MaterialParameterName = = ImageData . MaterialParameterName ) ;
} ) ;
if ( ! MatchingEdit )
{
continue ;
}
if ( MatchingEdit - > PatchImage . get ( ) )
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
{
// Does the current block need to be patched? Find out by building a mask.
2024-10-01 18:55:36 -04:00
Ptr < Image > PatchMask = GenerateImageBlockPatchMask ( * MatchingEdit , GridSize , LayoutBlockDesc . BlockPixelsX , LayoutBlockDesc . BlockPixelsY , RectInCells ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
if ( PatchMask )
{
2024-10-01 18:55:36 -04:00
LastImageOp = GenerateImageBlockPatch ( LastImageOp , * MatchingEdit , PatchMask , m . FinalCondition , Options ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
}
}
}
2024-10-01 18:55:36 -04:00
else
{
// This modifier doesn't affect the per-block image operations.
}
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
2024-10-01 18:55:36 -04:00
}
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
return LastImageOp ;
}
void CodeGenerator : : UpdateLayoutBlockDesc ( CodeGenerator : : FLayoutBlockDesc & Out , FImageDesc BlockDesc , FIntVector2 LayoutCellSize )
{
if ( Out . BlockPixelsX = = 0 & & LayoutCellSize . X > 0 & & LayoutCellSize . Y > 0 )
{
Out . BlockPixelsX = FMath : : Max ( 1 , BlockDesc . m_size [ 0 ] / LayoutCellSize [ 0 ] ) ;
Out . BlockPixelsY = FMath : : Max ( 1 , BlockDesc . m_size [ 1 ] / LayoutCellSize [ 1 ] ) ;
Out . bBlocksHaveMips = BlockDesc . m_lods > 1 ;
if ( Out . FinalFormat = = EImageFormat : : IF_NONE )
{
Out . FinalFormat = BlockDesc . m_format ;
}
}
} ;
Ptr < ASTOp > CodeGenerator : : ApplyImageExtendModifiers (
2024-10-01 18:55:36 -04:00
const TArray < FirstPassGenerator : : FModifier > & Modifiers ,
2024-10-01 20:57:52 -04:00
const FGenericGenerationOptions & Options ,
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
const FMeshGenerationResult & BaseMeshResults ,
Ptr < ASTOp > BaseImageOp ,
CompilerOptions : : TextureLayoutStrategy ImageLayoutStrategy ,
2024-10-01 18:55:36 -04:00
int32 LayoutIndex ,
const NodeSurfaceNew : : FImageData & ImageData ,
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
FIntPoint GridSize ,
CodeGenerator : : FLayoutBlockDesc & InOutLayoutBlockDesc ,
2024-10-01 18:55:36 -04:00
const void * ModifiedNodeErrorContext )
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
{
Ptr < ASTOp > LastImageOp = BaseImageOp ;
2024-09-05 09:33:43 -04:00
int32 CurrentLOD = CurrentParents . Last ( ) . Lod ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
// Process mesh extend modifiers (from edit modifiers)
int32 EditIndex = 0 ;
for ( const FirstPassGenerator : : FModifier & m : Modifiers )
{
if ( m . Node - > GetType ( ) = = NodeModifierSurfaceEdit : : GetStaticType ( ) )
{
const NodeModifierSurfaceEdit * Edit = static_cast < const NodeModifierSurfaceEdit * > ( m . Node ) ;
int32 ThisEditIndex = EditIndex ;
+ + EditIndex ;
2024-09-05 09:33:43 -04:00
bool bAffectsCurrentLOD = Edit - > LODs . IsValidIndex ( CurrentLOD ) ;
if ( ! bAffectsCurrentLOD )
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
{
continue ;
}
2024-10-01 18:55:36 -04:00
const NodeModifierSurfaceEdit : : FTexture * MatchingEdit = Edit - > LODs [ CurrentLOD ] . Textures . FindByPredicate (
[ & ] ( const NodeModifierSurfaceEdit : : FTexture & Candidate )
{
return ( Candidate . MaterialParameterName = = ImageData . MaterialParameterName ) ;
} ) ;
2024-09-05 09:33:43 -04:00
2024-10-01 18:55:36 -04:00
if ( ! MatchingEdit | | ( MatchingEdit & & ! MatchingEdit - > Extend ) )
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
{
2024-10-01 18:55:36 -04:00
if ( Edit - > LODs [ CurrentLOD ] . MeshAdd )
{
// When extending a mesh section it is mandatory to provide textures for all section textures handled by Mutable.
FString Msg = FString : : Printf ( TEXT ( " Required texture [%s] is missing when trying to extend a mesh section. " ) , * ImageData . MaterialParameterName ) ;
2024-10-01 19:27:10 -04:00
ErrorLog - > GetPrivate ( ) - > Add ( Msg , ELMT_INFO , Edit - > GetMessageContext ( ) , ModifiedNodeErrorContext ) ;
2024-10-01 18:55:36 -04:00
}
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
continue ;
}
const TArray < FGeneratedLayout > & ExtraLayouts = BaseMeshResults . ExtraMeshLayouts [ ThisEditIndex ] . GeneratedLayouts ;
if ( LayoutIndex > = ExtraLayouts . Num ( ) | | ! ExtraLayouts [ LayoutIndex ] . Layout )
{
2024-10-01 18:55:36 -04:00
ErrorLog - > GetPrivate ( ) - > Add ( TEXT ( " Trying to extend a layout that doesn't exist. " ) , ELMT_WARNING , Edit - > GetMessageContext ( ) , ModifiedNodeErrorContext ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
}
else
{
Ptr < const Layout > pExtendLayout = ExtraLayouts [ LayoutIndex ] . Layout ;
Ptr < ASTOp > lastBase = LastImageOp ;
for ( int32 b = 0 ; b < pExtendLayout - > GetBlockCount ( ) ; + + b )
{
// Generate the image block
2024-10-01 20:57:52 -04:00
FImageGenerationOptions ImageOptions ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
ImageOptions . State = Options . State ;
ImageOptions . ImageLayoutStrategy = ImageLayoutStrategy ;
ImageOptions . ActiveTags = Edit - > EnableTags ; // TODO: Merge with current tags?
ImageOptions . RectSize = { 0 , 0 } ;
ImageOptions . LayoutToApply = pExtendLayout ;
ImageOptions . LayoutBlockId = pExtendLayout - > Blocks [ b ] . Id ;
FImageGenerationResult ExtendResult ;
2024-10-01 18:55:36 -04:00
GenerateImage ( ImageOptions , ExtendResult , MatchingEdit - > Extend ) ;
[mutable] Convert the following nodes to modifiers: EditMaterial, ExtendMaterial, RemoveMesh, RemoveMeshBlocks, MorphMaterial.
- Rename some existing modifier nodes to actually be prefixed "Modifier" instead of "Mesh".
- Added additional entry points for modifiers during code generation. Now there are 4: right after generating a mesh constant, right after all mesh operations have been generated, right after a texture block has been generated and right after a texture has been generated.
- Fix bug with mesh clip with UV mask when layout blocks were used.
- For legacy data conversion autogenerated tags are created and assigned to the material nodes and the new modifier nodes.
- MorphMaterial code generation has been redesigned passing all morphs to the MutableTools layer.
#jira UE-221279
#jira UE-221278
#rnx
[REVIEW] [at]genis.sole, [at]gerard.martin, [at]pere.rifa
#rb genis.sole, gerard.martin, pere.rifa
[CL 35952198 by jordi rovira in ue5-main branch]
2024-09-02 04:15:31 -04:00
Ptr < ASTOp > fragmentAd = ExtendResult . op ;
// Block in layout grid units
box < FIntVector2 > rectInCells ;
rectInCells . min = pExtendLayout - > Blocks [ b ] . Min ;
rectInCells . size = pExtendLayout - > Blocks [ b ] . Size ;
FImageDesc ExtendDesc = fragmentAd - > GetImageDesc ( ) ;
// If we don't know the size of a layout block in pixels, calculate it
UpdateLayoutBlockDesc ( InOutLayoutBlockDesc , ExtendDesc , rectInCells . size ) ;
// Adjust the format and size of the block to be added
// Actually don't do it, it will be propagated from the top format operation.
//fragmentAd = GenerateImageFormat(fragmentAd, FinalImageFormat);
UE : : Math : : TIntVector2 < int32 > expectedSize ;
expectedSize [ 0 ] = InOutLayoutBlockDesc . BlockPixelsX * rectInCells . size [ 0 ] ;
expectedSize [ 1 ] = InOutLayoutBlockDesc . BlockPixelsY * rectInCells . size [ 1 ] ;
fragmentAd = GenerateImageSize ( fragmentAd , expectedSize ) ;
// Apply tiling to avoid generating chunks of image that are too big.
fragmentAd = ApplyTiling ( fragmentAd , expectedSize , InOutLayoutBlockDesc . FinalFormat ) ;
// Compose operation
Ptr < ASTOpImageCompose > composeOp = new ASTOpImageCompose ( ) ;
composeOp - > Layout = BaseMeshResults . LayoutOps [ LayoutIndex ] ;
composeOp - > Base = lastBase ;
composeOp - > BlockImage = fragmentAd ;
// Set the absolute block index.
check ( pExtendLayout - > Blocks [ b ] . Id ! = FLayoutBlock : : InvalidBlockId ) ;
composeOp - > BlockId = pExtendLayout - > Blocks [ b ] . Id ;
lastBase = composeOp ;
}
// Condition to enable this image extension
if ( m . FinalCondition )
{
Ptr < ASTOp > conditionalAd ;
Ptr < ASTOpConditional > cop = new ASTOpConditional ( ) ;
cop - > type = OP_TYPE : : IM_CONDITIONAL ;
cop - > no = LastImageOp ;
cop - > yes = lastBase ;
cop - > condition = m . FinalCondition ;
conditionalAd = cop ;
LastImageOp = conditionalAd ;
}
else
{
LastImageOp = lastBase ;
}
}
}
}
return LastImageOp ;
2022-09-26 15:12:13 -04:00
}
2023-10-05 03:48:29 -04:00
2024-10-01 18:55:36 -04:00
void CodeGenerator : : CheckModifiersForSurface ( const NodeSurfaceNew & Node , const TArray < FirstPassGenerator : : FModifier > & Modifiers )
{
int32 CurrentLOD = CurrentParents . Last ( ) . Lod ;
2024-10-01 18:57:48 -04:00
for ( const FirstPassGenerator : : FModifier & Mod : Modifiers )
2024-10-01 18:55:36 -04:00
{
// A mistake in the surface edit modifier usually results in no change visible. Try to detect it.
2024-10-01 18:57:48 -04:00
if ( Mod . Node - > GetType ( ) = = NodeModifierSurfaceEdit : : GetStaticType ( ) )
2024-10-01 18:55:36 -04:00
{
2024-10-01 18:57:48 -04:00
const NodeModifierSurfaceEdit * Edit = static_cast < const NodeModifierSurfaceEdit * > ( Mod . Node ) ;
2024-10-01 18:55:36 -04:00
bool bAffectsCurrentLOD = Edit - > LODs . IsValidIndex ( CurrentLOD ) ;
if ( ! bAffectsCurrentLOD )
{
continue ;
}
2024-10-01 18:57:48 -04:00
if ( Node . Images . IsEmpty ( ) | | Edit - > LODs [ CurrentLOD ] . Textures . IsEmpty ( ) )
2024-10-01 18:55:36 -04:00
{
continue ;
}
bool bAtLeastSomeTexture = false ;
for ( NodeSurfaceNew : : FImageData Data : Node . Images )
{
const NodeModifierSurfaceEdit : : FTexture * MatchingEdit = Edit - > LODs [ CurrentLOD ] . Textures . FindByPredicate (
[ & ] ( const NodeModifierSurfaceEdit : : FTexture & Candidate )
{
return ( Candidate . MaterialParameterName = = Data . MaterialParameterName ) ;
} ) ;
if ( MatchingEdit )
{
bAtLeastSomeTexture = true ;
break ;
}
}
if ( ! bAtLeastSomeTexture )
{
ErrorLog - > GetPrivate ( ) - > Add ( TEXT ( " A mesh section modifier applies to a section but no texture matches. " ) , ELMT_WARNING , Edit - > GetMessageContext ( ) , Node . GetMessageContext ( ) ) ;
}
}
}
}
2023-10-05 03:48:29 -04:00
Ptr < ASTOp > CodeGenerator : : GenerateDefaultTableValue ( ETableColumnType NodeType )
{
switch ( NodeType )
{
case mu : : ETableColumnType : : Scalar :
{
//TODO(Max):MTBL-1660
//Ptr<NodeScalarConstant> pNode = new NodeScalarConstant();
//pNode->SetValue(-UE_MAX_FLT);
//
//return Generate(pNode);
return nullptr ;
}
case mu : : ETableColumnType : : Color :
{
mu : : Ptr < mu : : NodeColourConstant > pNode = new NodeColourConstant ( ) ;
2024-06-25 13:34:33 -04:00
pNode - > Value = mu : : DefaultMutableColorValue ;
2023-10-05 03:48:29 -04:00
2023-12-19 05:19:14 -05:00
FColorGenerationResult ChildResult ;
FGenericGenerationOptions Options ;
GenerateColor ( ChildResult , Options , pNode ) ;
return ChildResult . op ;
2023-10-05 03:48:29 -04:00
}
case mu : : ETableColumnType : : Image :
{
//TODO(Max):MTBL-1660
//FImageGenerationOptions DummyOptions;
//FImageGenerationResult DefaultValue;
//
//mu::Ptr<mu::NodeImageReference> ImageNode = new mu::NodeImageReference();
//ImageNode->SetImageReference(-1);
//
//GenerateImage(DummyOptions, DefaultValue, ImageNode);
//
//return DefaultValue.op;
return nullptr ;
}
case mu : : ETableColumnType : : Mesh :
/* The default mesh is always null */
return nullptr ;
default :
break ;
}
return nullptr ;
}
2022-09-26 15:12:13 -04:00
}