Пример #1
0
        public override void Deserialize(FAssetArchive Ar, long validPos)
        {
            base.Deserialize(Ar, validPos);

            var stripFlags = new FStripDataFlags(Ar);

            if (!stripFlags.IsDataStrippedForServer())
            {
                var numEntries = Ar.Read <int>();
                MeshBuildData = new Dictionary <FGuid, FMeshMapBuildData>(numEntries);
                for (var i = 0; i < numEntries; ++i)
                {
                    MeshBuildData[Ar.Read <FGuid>()] = new FMeshMapBuildData(Ar);
                }

                numEntries = Ar.Read <int>();
                LevelPrecomputedLightVolumeBuildData = new Dictionary <FGuid, FPrecomputedLightVolumeData>(numEntries);
                for (var i = 0; i < numEntries; ++i)
                {
                    LevelPrecomputedLightVolumeBuildData[Ar.Read <FGuid>()] = new FPrecomputedLightVolumeData(Ar);
                }

                if (FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.VolumetricLightmaps)
                {
                    numEntries = Ar.Read <int>();
                    LevelPrecomputedVolumetricLightmapBuildData = new Dictionary <FGuid, FPrecomputedVolumetricLightmapData>(numEntries);
                    for (var i = 0; i < numEntries; ++i)
                    {
                        LevelPrecomputedVolumetricLightmapBuildData[Ar.Read <FGuid>()] = new FPrecomputedVolumetricLightmapData(Ar);
                    }
                }

                numEntries     = Ar.Read <int>();
                LightBuildData = new Dictionary <FGuid, FLightComponentMapBuildData>(numEntries);
                for (var i = 0; i < numEntries; ++i)
                {
                    LightBuildData[Ar.Read <FGuid>()] = new FLightComponentMapBuildData(Ar);
                }

                if (FReflectionCaptureObjectVersion.Get(Ar) >= FReflectionCaptureObjectVersion.Type.MoveReflectionCaptureDataToMapBuildData)
                {
                    numEntries = Ar.Read <int>();
                    ReflectionCaptureBuildData = new Dictionary <FGuid, FReflectionCaptureMapBuildData>(numEntries);
                    for (var i = 0; i < numEntries; ++i)
                    {
                        ReflectionCaptureBuildData[Ar.Read <FGuid>()] = new FReflectionCaptureMapBuildData(Ar);
                    }
                }

                if (FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.SkyAtmosphereStaticLightingVersioning)
                {
                    numEntries             = Ar.Read <int>();
                    SkyAtmosphereBuildData = new Dictionary <FGuid, FSkyAtmosphereMapBuildData>(numEntries);
                    for (var i = 0; i < numEntries; ++i)
                    {
                        SkyAtmosphereBuildData[Ar.Read <FGuid>()] = new FSkyAtmosphereMapBuildData(Ar);
                    }
                }
            }
        }
Пример #2
0
        public FPrecomputedVolumetricLightmapData(FArchive Ar)
        {
            Bounds = Ar.Read <FBox>();
            IndirectionTextureDimensions = Ar.Read <FIntVector>();
            IndirectionTexture           = new FVolumetricLightmapDataLayer(Ar);

            BrickSize           = Ar.Read <int>();
            BrickDataDimensions = Ar.Read <FIntVector>();

            BrickData = new FVolumetricLightmapBrickLayer
            {
                AmbientVector  = new FVolumetricLightmapDataLayer(Ar),
                SHCoefficients = new FVolumetricLightmapDataLayer[6]
            };

            for (var i = 0; i < BrickData.SHCoefficients.Length; i++)
            {
                BrickData.SHCoefficients[i] = new FVolumetricLightmapDataLayer(Ar);
            }

            BrickData.SkyBentNormal             = new FVolumetricLightmapDataLayer(Ar);
            BrickData.DirectionalLightShadowing = new FVolumetricLightmapDataLayer(Ar);

            if (FMobileObjectVersion.Get(Ar) >= FMobileObjectVersion.Type.LQVolumetricLightmapLayers)
            {
                BrickData.LQLightColor     = new FVolumetricLightmapDataLayer(Ar);
                BrickData.LQLightDirection = new FVolumetricLightmapDataLayer(Ar);
            }

            if (FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.VolumetricLightmapStreaming)
            {
                SubLevelBrickPositions           = Ar.ReadArray <FIntVector>();
                IndirectionTextureOriginalValues = Ar.ReadArray <FColor>();
            }
        }
Пример #3
0
        public FSkeletalMaterial(FAssetArchive Ar)
        {
            Material = Ar.ReadObject <UMaterialInterface>();
            if (FEditorObjectVersion.Get(Ar) >= FEditorObjectVersion.Type.RefactorMeshEditorMaterials)
            {
                MaterialSlotName = Ar.ReadFName();
                var bSerializeImportedMaterialSlotName = false;
                if (FCoreObjectVersion.Get(Ar) >= FCoreObjectVersion.Type.SkeletalMaterialEditorDataStripping)
                {
                    bSerializeImportedMaterialSlotName = Ar.ReadBoolean();
                }

                if (bSerializeImportedMaterialSlotName)
                {
                    ImportedMaterialSlotName = Ar.ReadFName();
                }
            }
            else
            {
                if (Ar.Ver >= UE4Version.VER_UE4_MOVE_SKELETALMESH_SHADOWCASTING)
                {
                    Ar.Position += 4;
                }

                if (FRecomputeTangentCustomVersion.Get(Ar) >= FRecomputeTangentCustomVersion.Type.RuntimeRecomputeTangent)
                {
                    Ar.Position += 4;
                }
            }
            if (FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.TextureStreamingMeshUVChannelData)
            {
                UVChannelData = new FMeshUVChannelInfo(Ar);
            }
        }
Пример #4
0
        public override void Deserialize(FAssetArchive Ar, long validPos)
        {
            base.Deserialize(Ar, validPos);

            var bCooked = false;

            if (FFortniteMainBranchObjectVersion.Get(Ar) >= FFortniteMainBranchObjectVersion.Type.SerializeInstancedStaticMeshRenderData ||
                FEditorObjectVersion.Get(Ar) >= FEditorObjectVersion.Type.SerializeInstancedStaticMeshRenderData)
            {
                bCooked = Ar.ReadBoolean();
            }

            PerInstanceSMData = Ar.ReadBulkArray(() => new FInstancedStaticMeshInstanceData(Ar));

            if (FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.PerInstanceCustomData)
            {
                PerInstanceSMCustomData = Ar.ReadBulkArray(Ar.Read <float>);
            }

            if (bCooked && (FFortniteMainBranchObjectVersion.Get(Ar) >= FFortniteMainBranchObjectVersion.Type.SerializeInstancedStaticMeshRenderData ||
                            FEditorObjectVersion.Get(Ar) >= FEditorObjectVersion.Type.SerializeInstancedStaticMeshRenderData))
            {
                var renderDataSizeBytes = Ar.Read <long>();

                if (renderDataSizeBytes > 0)
                {
                    // idk what to do here... But it fixes the warnings ­ЪциРђЇ
                    Ar.Position = validPos;
                }
            }
        }
Пример #5
0
        public FSkeletalMaterial(FAssetArchive Ar)
        {
            Material = new FPackageIndex(Ar).ResolvedObject;
            if (FEditorObjectVersion.Get(Ar) >= FEditorObjectVersion.Type.RefactorMeshEditorMaterials)
            {
                MaterialSlotName = Ar.ReadFName();
                var bSerializeImportedMaterialSlotName = !Ar.Owner.HasFlags(EPackageFlags.PKG_FilterEditorOnly);
                if (FCoreObjectVersion.Get(Ar) >= FCoreObjectVersion.Type.SkeletalMaterialEditorDataStripping)
                {
                    bSerializeImportedMaterialSlotName = Ar.ReadBoolean();
                }

                if (bSerializeImportedMaterialSlotName)
                {
                    ImportedMaterialSlotName = Ar.ReadFName();
                }
            }
            else
            {
                if (Ar.Ver >= EUnrealEngineObjectUE4Version.MOVE_SKELETALMESH_SHADOWCASTING)
                {
                    Ar.Position += 4;
                }

                if (FRecomputeTangentCustomVersion.Get(Ar) >= FRecomputeTangentCustomVersion.Type.RuntimeRecomputeTangent)
                {
                    var bRecomputeTangent = Ar.ReadBoolean();
                }
            }
            if (FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.TextureStreamingMeshUVChannelData)
            {
                UVChannelData = new FMeshUVChannelInfo(Ar);
            }
        }
Пример #6
0
 public FPackedNormal(FArchive Ar)
 {
     Data = Ar.Read <uint>();
     if (FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.IncreaseNormalPrecision)
     {
         Data ^= 0x80808080;
     }
 }
Пример #7
0
 public FStaticMaterial(FAssetArchive Ar)
 {
     MaterialInterface = new FPackageIndex(Ar).ResolvedObject;
     MaterialSlotName  = Ar.ReadFName();
     if (FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.TextureStreamingMeshUVChannelData)
     {
         UVChannelData = new FMeshUVChannelInfo(Ar);
     }
 }
Пример #8
0
        public override void Deserialize(FAssetArchive Ar, long validPos)
        {
            base.Deserialize(Ar, validPos);

            if (FRenderingObjectVersion.Get(Ar) < FRenderingObjectVersion.Type.MovedParticleCutoutsToRequiredModule)
            {
                return;
            }
            var bCooked = Ar.ReadBoolean();

            if (bCooked)
            {
                BoundingGeometry = Ar.ReadArray <FVector2D>();
            }
        }
Пример #9
0
 public FModelVertexBuffer(FArchive Ar)
 {
     if (FRenderingObjectVersion.Get(Ar) < FRenderingObjectVersion.Type.IncreaseNormalPrecision)
     {
         var deprecatedVertices = Ar.ReadBulkArray <FDeprecatedModelVertex>();
         Vertices = new FModelVertex[deprecatedVertices.Length];
         for (int i = 0; i < Vertices.Length; i++)
         {
             Vertices[i] = deprecatedVertices[i];
         }
     }
     else
     {
         Vertices = Ar.ReadArray(() => new FModelVertex(Ar));
     }
 }
Пример #10
0
 public FStaticMeshSection(FArchive Ar)
 {
     MaterialIndex       = Ar.Read <int>();
     FirstIndex          = Ar.Read <int>();
     NumTriangles        = Ar.Read <int>();
     MinVertexIndex      = Ar.Read <int>();
     MaxVertexIndex      = Ar.Read <int>();
     EnableCollision     = Ar.ReadBoolean();
     CastShadow          = Ar.ReadBoolean();
     ForceOpaque         = FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.StaticMeshSectionForceOpaqueField && Ar.ReadBoolean();
     VisibleInRayTracing = Ar.Game >= EGame.GAME_UE4_26 && Ar.ReadBoolean();
     if (Ar.Game == EGame.GAME_ROGUECOMPANY)
     {
         Ar.Position += 4;
     }
 }
Пример #11
0
        public FPaintedVertex(FArchive Ar)
        {
            Position = Ar.Read <FVector>();

            if (FRenderingObjectVersion.Get(Ar) < FRenderingObjectVersion.Type.IncreaseNormalPrecision)
            {
                var temp = new FPackedNormal(Ar);
                Normal = temp;
            }
            else
            {
                Normal = Ar.Read <FVector4>();
            }

            Color = Ar.Read <FColor>();
        }
Пример #12
0
 public void SerializeForEditor(FAssetArchive Ar)
 {
     Normal = new FPackedNormal[3];
     Pos    = Ar.Read <FVector>();
     if (FRenderingObjectVersion.Get(Ar) < FRenderingObjectVersion.Type.IncreaseNormalPrecision)
     {
         Normal[0] = new FPackedNormal(Ar);
         Normal[1] = new FPackedNormal(Ar);
         Normal[2] = new FPackedNormal(Ar);
     }
     else
     {
         // New normals are stored with full floating point precision
         Normal[0] = new FPackedNormal(Ar.Read <FVector>());
         Normal[1] = new FPackedNormal(Ar.Read <FVector>());
         Normal[2] = new FPackedNormal(Ar.Read <FVector4>());
     }
 }
Пример #13
0
        public FModelVertex(FArchive Ar)
        {
            Position = Ar.Read <FVector>();

            if (FRenderingObjectVersion.Get(Ar) < FRenderingObjectVersion.Type.IncreaseNormalPrecision)
            {
                TangentX = (FVector)Ar.Read <FDeprecatedSerializedPackedNormal>();
                TangentZ = (FVector4)Ar.Read <FDeprecatedSerializedPackedNormal>();
            }
            else
            {
                TangentX = Ar.Read <FVector>();
                TangentZ = Ar.Read <FVector4>();
            }

            TexCoord       = Ar.Read <FVector2D>();
            ShadowTexCoord = Ar.Read <FVector2D>();
        }
Пример #14
0
 public FStaticMeshSection(FArchive Ar)
 {
     MaterialIndex    = Ar.Read <int>();
     FirstIndex       = Ar.Read <int>();
     NumTriangles     = Ar.Read <int>();
     MinVertexIndex   = Ar.Read <int>();
     MaxVertexIndex   = Ar.Read <int>();
     bEnableCollision = Ar.ReadBoolean();
     bCastShadow      = Ar.ReadBoolean();
     if (Ar.Game == EGame.GAME_PlayerUnknownsBattlegrounds)
     {
         Ar.Position += 5;                                                    // byte + int
     }
     bForceOpaque         = FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.StaticMeshSectionForceOpaqueField && Ar.ReadBoolean();
     bVisibleInRayTracing = !Ar.Versions["StaticMesh.HasVisibleInRayTracing"] || Ar.ReadBoolean();
     if (Ar.Game == EGame.GAME_RogueCompany)
     {
         Ar.Position += 4;
     }
 }
Пример #15
0
        public FReflectionCaptureData(FAssetArchive Ar)
        {
            CubemapSize       = Ar.Read <int>();
            AverageBrightness = Ar.Read <float>();

            if (FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.StoreReflectionCaptureBrightnessForCooking)
            {
                Brightness = Ar.Read <float>();
            }

            FullHDRCapturedData = Ar.ReadArray <byte>(); // Can also be stripped, but still a byte[]

            if (FMobileObjectVersion.Get(Ar) >= FMobileObjectVersion.Type.StoreReflectionCaptureCompressedMobile)
            {
                EncodedCaptureData = new FPackageIndex(Ar);
            }
            else
            {
                var _ = Ar.ReadArray <byte>();
            }
        }
Пример #16
0
        public override void Deserialize(FAssetArchive Ar, long validPos)
        {
            base.Deserialize(Ar, validPos);
            _parent = GetOrDefault <ResolvedObject>(nameof(Parent));
            bHasStaticPermutationResource = GetOrDefault <bool>("bHasStaticPermutationResource");
            BasePropertyOverrides         = GetOrDefault <FMaterialInstanceBasePropertyOverrides>(nameof(BasePropertyOverrides));
            StaticParameters = GetOrDefault <FStaticParameterSet>(nameof(StaticParameters));

            var bSavedCachedData = FUE5MainStreamObjectVersion.Get(Ar) >= FUE5MainStreamObjectVersion.Type.MaterialSavedCachedData && Ar.ReadBoolean();

            if (bSavedCachedData)
            {
                CachedData = new FStructFallback(Ar, "MaterialInstanceCachedData");
            }

            if (bHasStaticPermutationResource)
            {
                if (Ar.Ver >= EUnrealEngineObjectUE4Version.PURGED_FMATERIAL_COMPILE_OUTPUTS)
                {
                    if (FRenderingObjectVersion.Get(Ar) < FRenderingObjectVersion.Type.MaterialAttributeLayerParameters)
                    {
                        StaticParameters = new FStaticParameterSet(Ar);
                    }

#if READ_SHADER_MAPS
                    DeserializeInlineShaderMaps(Ar, LoadedMaterialResources);
#else
                    Ar.Position = validPos; // TODO This skips every data after the inline shader map data, find a way to properly skip it
#endif
                }
            }

#if !READ_SHADER_MAPS
            Ar.Position = validPos;
#endif
        }
Пример #17
0
        public FStaticMeshRenderData(FAssetArchive Ar, bool bCooked)
        {
            if (!bCooked)
            {
                return;
            }

            // TODO Read minMobileLODIdx only when platform is desktop and CVar r.StaticMesh.KeepMobileMinLODSettingOnDesktop is nonzero
            if (Ar.Versions["StaticMesh.KeepMobileMinLODSettingOnDesktop"])
            {
                var minMobileLODIdx = Ar.Read <int>();
            }

            LODs = Ar.ReadArray(() => new FStaticMeshLODResources(Ar));
            if (Ar.Game >= EGame.GAME_UE4_23)
            {
                var numInlinedLODs = Ar.Read <byte>();
            }

            if (Ar.Game >= EGame.GAME_UE5_0)
            {
                NaniteResources = new FNaniteResources(Ar);
                SerializeInlineDataRepresentations(Ar);
            }

            if (Ar.Ver >= EUnrealEngineObjectUE4Version.RENAME_CROUCHMOVESCHARACTERDOWN)
            {
                var stripped = false;
                if (Ar.Ver >= EUnrealEngineObjectUE4Version.RENAME_WIDGET_VISIBILITY)
                {
                    var stripDataFlags = Ar.Read <FStripDataFlags>();
                    stripped = stripDataFlags.IsDataStrippedForServer();
                    if (Ar.Game >= EGame.GAME_UE4_21)
                    {
                        stripped |= stripDataFlags.IsClassDataStripped(0x01);
                    }
                }

                if (!stripped)
                {
                    for (var i = 0; i < LODs.Length; i++)
                    {
                        var bValid = Ar.ReadBoolean();
                        if (bValid)
                        {
                            if (Ar.Game >= EGame.GAME_UE5_0)
                            {
                                var _ = new FDistanceFieldVolumeData5(Ar);
                            }
                            else
                            {
                                var _ = new FDistanceFieldVolumeData(Ar);
                            }
                        }
                    }
                }
            }

            Bounds = Ar.Read <FBoxSphereBounds>();

            if (Ar.Versions["StaticMesh.HasLODsShareStaticLighting"])
            {
                bLODsShareStaticLighting = Ar.ReadBoolean();
            }

            if (Ar.Game < EGame.GAME_UE4_14)
            {
                var bReducedBySimplygon = Ar.ReadBoolean();
            }

            if (FRenderingObjectVersion.Get(Ar) < FRenderingObjectVersion.Type.TextureStreamingMeshUVChannelData)
            {
                Ar.Position += 4 * MAX_STATIC_UV_SETS_UE4; // StreamingTextureFactor for each UV set
                Ar.Position += 4;                          // MaxStreamingTextureFactor
            }

            ScreenSize = new float[Ar.Game >= EGame.GAME_UE4_9 ? MAX_STATIC_LODS_UE4 : 4];
            for (var i = 0; i < ScreenSize.Length; i++)
            {
                if (Ar.Game >= EGame.GAME_UE4_20) // FPerPlatformProperty
                {
                    var bFloatCooked = Ar.ReadBoolean();
                }

                ScreenSize[i] = Ar.Read <float>();
            }

            if (Ar.Game == EGame.GAME_Borderlands3)
            {
                var count = Ar.Read <int>();
                for (var i = 0; i < count; i++)
                {
                    var count2 = Ar.Read <byte>();
                    Ar.Position += count2 * 12; // bool, bool, float
                }
            }
        }
Пример #18
0
 public FStaticParameterBase(FArchive Ar)
 {
     ParameterInfo = FRenderingObjectVersion.Get(Ar) < FRenderingObjectVersion.Type.MaterialAttributeLayerParameters ? new FMaterialParameterInfo {
         Name = Ar.ReadFName()
     } : new FMaterialParameterInfo(Ar);
 }