Exemple #1
0
        public void SerializeRenderItem(FAssetArchive Ar, bool bHasVertexColors, byte numVertexColorChannels)
        {
            if (Ar.Game < EGame.GAME_UE4_24)
            {
                SerializeRenderItem_Legacy(Ar, bHasVertexColors, numVertexColorChannels);
                return;
            }

            var stripDataFlags  = Ar.Read <FStripDataFlags>();
            var bIsLODCookedOut = Ar.ReadBoolean();
            var bInlined        = Ar.ReadBoolean();

            RequiredBones = Ar.ReadArray <short>();
            if (!stripDataFlags.IsDataStrippedForServer() && !bIsLODCookedOut)
            {
                Sections = new FSkelMeshSection[Ar.Read <int>()];
                for (var i = 0; i < Sections.Length; i++)
                {
                    Sections[i] = new FSkelMeshSection();
                    Sections[i].SerializeRenderItem(Ar);
                }

                ActiveBoneIndices = Ar.ReadArray <short>();
                Ar.Position      += 4; //var buffersSize = Ar.Read<uint>();

                if (bInlined)
                {
                    SerializeStreamedData(Ar, bHasVertexColors);
                    if (Ar.Game == EGame.GAME_ROGUECOMPANY)
                    {
                        Ar.Position += 10; // FStripDataFlags, ElementSize, ElementCount
                        Ar.SkipBulkArrayData();
                        Ar.Position += 10;
                    }
                }
                else
                {
                    var bulk = new FByteBulkData(Ar);
                    if (bulk.Header.ElementCount > 0)
                    {
                        using (var tempAr = new FByteArchive("LodReader", bulk.Data, Ar.Versions))
                        {
                            SerializeStreamedData(tempAr, bHasVertexColors);
                        }

                        var skipBytes = 5;
                        if (FUE5ReleaseStreamObjectVersion.Get(Ar) < FUE5ReleaseStreamObjectVersion.Type.RemovingTessellation && !stripDataFlags.IsClassDataStripped((byte)EClassDataStripFlag.CDSF_AdjacencyData))
                        {
                            skipBytes += 5;
                        }
                        skipBytes   += 4 * 4 + 2 * 4 + 2 * 4;
                        skipBytes   += FSkinWeightVertexBuffer.MetadataSize(Ar);
                        Ar.Position += skipBytes;

                        if (HasClothData())
                        {
                            var clothIndexMapping = Ar.ReadArray <long>();
                            Ar.Position += 2 * 4;
                        }

                        var profileNames = Ar.ReadArray(Ar.ReadFName);
                    }
                }
            }
        }
        // UE ref https://github.com/EpicGames/UnrealEngine/blob/26450a5a59ef65d212cf9ce525615c8bd673f42a/Engine/Source/Runtime/Engine/Private/SkeletalMeshLODRenderData.cpp#L710
        public void SerializeRenderItem(FAssetArchive Ar, bool bHasVertexColors, byte numVertexColorChannels)
        {
            var stripDataFlags  = Ar.Read <FStripDataFlags>();
            var bIsLODCookedOut = false;

            if (Ar.Game != EGame.GAME_Splitgate)
            {
                bIsLODCookedOut = Ar.ReadBoolean();
            }
            var bInlined = Ar.ReadBoolean();

            RequiredBones = Ar.ReadArray <short>();
            if (!stripDataFlags.IsDataStrippedForServer() && !bIsLODCookedOut)
            {
                Sections = new FSkelMeshSection[Ar.Read <int>()];
                for (var i = 0; i < Sections.Length; i++)
                {
                    Sections[i] = new FSkelMeshSection();
                    Sections[i].SerializeRenderItem(Ar);
                }

                ActiveBoneIndices = Ar.ReadArray <short>();

                if (Ar.Game == EGame.GAME_KenaBridgeofSpirits)
                {
                    Ar.ReadArray <byte>(); // EAssetType_array1
                }
                Ar.Position += 4;          //var buffersSize = Ar.Read<uint>();

                if (bInlined)
                {
                    SerializeStreamedData(Ar, bHasVertexColors);
                    if (Ar.Game == EGame.GAME_RogueCompany)
                    {
                        Ar.Position += 12; // 1 (Long) + 2^16 (Int)
                        var elementSize  = Ar.Read <int>();
                        var elementCount = Ar.Read <int>();
                        if (elementSize > 0 && elementCount > 0)
                        {
                            Ar.SkipBulkArrayData();
                        }
                    }
                }
                else
                {
                    var bulk = new FByteBulkData(Ar);
                    if (bulk.Header.ElementCount > 0)
                    {
                        using (var tempAr = new FByteArchive("LodReader", bulk.Data, Ar.Versions))
                        {
                            SerializeStreamedData(tempAr, bHasVertexColors);
                        }

                        var skipBytes = 5;
                        if (FUE5ReleaseStreamObjectVersion.Get(Ar) < FUE5ReleaseStreamObjectVersion.Type.RemovingTessellation && !stripDataFlags.IsClassDataStripped((byte)EClassDataStripFlag.CDSF_AdjacencyData))
                        {
                            skipBytes += 5;
                        }
                        skipBytes   += 4 * 4 + 2 * 4 + 2 * 4;
                        skipBytes   += FSkinWeightVertexBuffer.MetadataSize(Ar);
                        Ar.Position += skipBytes;

                        if (HasClothData())
                        {
                            var clothIndexMapping = Ar.ReadArray <long>();
                            Ar.Position += 2 * 4;
                        }

                        var profileNames = Ar.ReadArray(Ar.ReadFName);
                    }
                }
            }

            if (Ar.Game == EGame.GAME_ReadyOrNot)
            {
                Ar.Position += 4;
            }
        }