Esempio n. 1
0
        public override void Deserialize(FAssetArchive Ar, long validPos)
        {
            base.Deserialize(Ar, validPos);

            const int StripVertexBufferFlag = 1;
            var       stripData             = new FStripDataFlags(Ar);

            Bounds = Ar.Read <FBoxSphereBounds>();

            Vectors = Ar.ReadBulkArray <FVector>();
            Points  = Ar.ReadBulkArray <FVector>();
            Nodes   = Ar.ReadBulkArray <FBspNode>();

            if (Ar.Ver < EUnrealEngineObjectUE4Version.BSP_UNDO_FIX)
            {
                var surfsOwner = new FPackageIndex(Ar);
                Surfs = Ar.ReadArray(() => new FBspSurf(Ar));
            }
            else
            {
                Surfs = Ar.ReadArray(() => new FBspSurf(Ar));
            }
            Verts = Ar.ReadBulkArray <FVert>();

            NumSharedSides = Ar.Read <int>();
            if (Ar.Ver < EUnrealEngineObjectUE4Version.REMOVE_ZONES_FROM_MODEL)
            {
                var dummyZones = Ar.ReadArray <FZoneProperties>();
            }

            var bHasEditorOnlyData = !Ar.IsFilterEditorOnly || Ar.Ver < EUnrealEngineObjectUE4Version.REMOVE_UNUSED_UPOLYS_FROM_UMODEL;

            if (bHasEditorOnlyData)
            {
                var dummyPolys = new FPackageIndex(Ar);
                Ar.SkipBulkArrayData(); // DummyLeafHulls
                Ar.SkipBulkArrayData(); // DummyLeaves
            }

            RootOutside = Ar.ReadBoolean();
            Linked      = Ar.ReadBoolean();

            if (Ar.Ver < EUnrealEngineObjectUE4Version.REMOVE_ZONES_FROM_MODEL)
            {
                var dummyPortalNodes = Ar.ReadBulkArray <int>();
            }

            NumUniqueVertices = Ar.Read <uint>();

            if (!stripData.IsEditorDataStripped() || !stripData.IsClassDataStripped(StripVertexBufferFlag))
            {
                VertexBuffer = new FModelVertexBuffer(Ar);
            }

            LightingGuid      = Ar.Read <FGuid>();
            LightmassSettings = Ar.ReadArray(() => new FLightmassPrimitiveSettings(Ar));
        }
Esempio n. 2
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
                }
            }
        }