void USoundCue::Serialize(FArchive& Ar) { // Always force the duration to be updated when we are saving or cooking if (Ar.IsSaving() || Ar.IsCooking()) { Duration = (FirstNode ? FirstNode->GetDuration() : 0.f); } Super::Serialize(Ar); if (Ar.UE4Ver() >= VER_UE4_COOKED_ASSETS_IN_EDITOR_SUPPORT) { FStripDataFlags StripFlags(Ar); #if WITH_EDITORONLY_DATA if (!StripFlags.IsEditorDataStripped()) { Ar << SoundCueGraph; } #endif } #if WITH_EDITOR else { Ar << SoundCueGraph; } #endif }
void UTexture::Serialize(FArchive& Ar) { Super::Serialize(Ar); FStripDataFlags StripFlags(Ar); /** Legacy serialization. */ #if WITH_EDITORONLY_DATA if (Ar.UE4Ver() < VER_UE4_TEXTURE_SOURCE_ART_REFACTOR) { UTexture::LegacySerialize(Ar, StripFlags); return; } if (Ar.UE4Ver() < VER_UE4_TEXTURE_FORMAT_RGBA_SWIZZLE) { switch (Source.Format) { case TSF_RGBA8: Source.Format = TSF_BGRA8; break; case TSF_RGBE8: Source.Format = TSF_BGRE8; break; } } if (!StripFlags.IsEditorDataStripped()) { Source.BulkData.Serialize(Ar, this); } #endif // #if WITH_EDITORONLY_DATA }
void UMorphTarget::Serialize( FArchive& Ar ) { Super::Serialize( Ar ); FStripDataFlags StripFlags( Ar ); if( !StripFlags.IsDataStrippedForServer() ) { Ar << MorphLODModels; } }
void Serialize(FArchive& Ar, UObject* Owner, int32 Idx) { const uint8 AdjacencyDataStripFlag = 1; FStripDataFlags StripFlags( Ar, Ar.IsCooking() && !Ar.CookingTarget()->SupportsFeature(ETargetPlatformFeatures::Tessellation) ? AdjacencyDataStripFlag : 0 ); UStaticMesh* StaticMesh = Cast<UStaticMesh>( Owner ); bool bNeedsCPUAccess = true; if( !StripFlags.IsEditorDataStripped() ) { RawTriangles.Serialize( Ar, Owner ); } Ar << Elements; if( !StripFlags.IsDataStrippedForServer() ) { PositionVertexBuffer.Serialize( Ar, bNeedsCPUAccess ); VertexBuffer.Serialize( Ar, bNeedsCPUAccess ); ColorVertexBuffer.Serialize( Ar, bNeedsCPUAccess ); Ar << NumVertices; IndexBuffer.Serialize( Ar, bNeedsCPUAccess ); if (Ar.UE4Ver() >= VER_UE4_SHADOW_ONLY_INDEX_BUFFERS) { ShadowIndexBuffer.Serialize(Ar, bNeedsCPUAccess); } if( !StripFlags.IsEditorDataStripped() ) { Ar << WireframeIndexBuffer; } if ( !StripFlags.IsClassDataStripped( AdjacencyDataStripFlag ) ) { AdjacencyIndexBuffer.Serialize( Ar, bNeedsCPUAccess ); } } if (Ar.IsLoading()) { if (PositionVertexBuffer.GetNumVertices() != NumVertices) { PositionVertexBuffer.RemoveLegacyShadowVolumeVertices(NumVertices); } if (VertexBuffer.GetNumVertices() != NumVertices) { VertexBuffer.RemoveLegacyShadowVolumeVertices(NumVertices); } if (VertexBuffer.GetNumVertices() != NumVertices) { ColorVertexBuffer.RemoveLegacyShadowVolumeVertices(NumVertices); } } }
/** * Serializer * * @param Ar Archive to serialize with * @param bNeedsCPUAccess Whether the elements need to be accessed by the CPU */ void FColorVertexBuffer::Serialize( FArchive& Ar, bool bNeedsCPUAccess ) { FStripDataFlags StripFlags(Ar, 0, VER_UE4_STATIC_SKELETAL_MESH_SERIALIZATION_FIX); if (Ar.IsSaving() && NumVertices > 0 && VertexData == NULL) { // ...serialize as if the vertex count were zero. Else on load serialization breaks. // This situation should never occur because VertexData should not be null if NumVertices // is greater than zero. So really this should be a checkf but I don't want to crash // the Editor when saving a package. UE_LOG(LogStaticMesh, Warning, TEXT("Color vertex buffer being saved with NumVertices=%d Stride=%d VertexData=NULL. This should never happen."), NumVertices, Stride ); int32 SerializedStride = 0; int32 SerializedNumVertices = 0; Ar << SerializedStride << SerializedNumVertices; } else { Ar << Stride << NumVertices; if (Ar.IsLoading() && NumVertices > 0) { // Allocate the vertex data storage type. AllocateData(bNeedsCPUAccess); } if (!StripFlags.IsDataStrippedForServer() || Ar.IsCountingMemory()) { if (VertexData != NULL) { // Serialize the vertex data. VertexData->Serialize(Ar); if (VertexData->Num() > 0) { // Make a copy of the vertex data pointer. Data = VertexData->GetDataPointer(); } } } } }
void UTexture::Serialize(FArchive& Ar) { Super::Serialize(Ar); FStripDataFlags StripFlags(Ar); /** Legacy serialization. */ #if WITH_EDITORONLY_DATA if (!StripFlags.IsEditorDataStripped()) { Source.BulkData.Serialize(Ar, this); } if ( GetLinkerUE4Version() < VER_UE4_TEXTURE_LEGACY_GAMMA ) { bUseLegacyGamma = true; } #endif // #if WITH_EDITORONLY_DATA }
void UTextureCube::Serialize(FArchive& Ar) { DECLARE_SCOPE_CYCLE_COUNTER(TEXT("UTextureCube::Serialize"), STAT_TextureCube_Serialize, STATGROUP_LoadTime); Super::Serialize(Ar); FStripDataFlags StripFlags(Ar); bool bCooked = Ar.IsCooking(); Ar << bCooked; if (bCooked || Ar.IsCooking()) { SerializeCookedPlatformData(Ar); } #if WITH_EDITOR if (Ar.IsLoading() && !Ar.IsTransacting() && !bCooked) { BeginCachePlatformData(); } #endif // #if WITH_EDITOR }
void UModel::Serialize( FArchive& Ar ) { Super::Serialize( Ar ); const int32 StripVertexBufferFlag = 1; FStripDataFlags StripFlags( Ar, GetOuter() && GetOuter()->IsA(ABrush::StaticClass()) ? StripVertexBufferFlag : FStripDataFlags::None ); Ar << Bounds; Vectors.BulkSerialize( Ar ); Points.BulkSerialize( Ar ); Nodes.BulkSerialize( Ar ); if( Ar.IsLoading() ) { for( int32 NodeIndex=0; NodeIndex<Nodes.Num(); NodeIndex++ ) { Nodes[NodeIndex].NodeFlags &= ~(NF_IsNew|NF_IsFront|NF_IsBack); } } Ar << Surfs; Verts.BulkSerialize( Ar ); if( Ar.IsLoading() && Ar.UE4Ver() < VER_UE4_REMOVE_ZONES_FROM_MODEL) { int32 NumZones; Ar << NumSharedSides << NumZones; FZoneProperties DummyZones[FBspNode::MAX_ZONES]; for( int32 i=0; i<NumZones; i++ ) { Ar << DummyZones[i]; } } else { Ar << NumSharedSides; } #if WITH_EDITOR Ar << Polys; LeafHulls.BulkSerialize( Ar ); Leaves.BulkSerialize( Ar ); #else if(Ar.IsLoading()) { UPolys* DummyPolys; Ar << DummyPolys; TArray<int32> DummyLeafHulls; DummyLeafHulls.BulkSerialize( Ar ); TArray<FLeaf> DummyLeaves; DummyLeaves.BulkSerialize( Ar ); } #endif Ar << RootOutside << Linked; if(Ar.IsLoading() && Ar.UE4Ver() < VER_UE4_REMOVE_ZONES_FROM_MODEL) { TArray<int32> DummyPortalNodes; DummyPortalNodes.BulkSerialize( Ar ); } Ar << NumUniqueVertices; // load/save vertex buffer if( StripFlags.IsEditorDataStripped() == false || StripFlags.IsClassDataStripped( StripVertexBufferFlag ) == false ) { Ar << VertexBuffer; } #if WITH_EDITOR if(GIsEditor) { CalculateUniqueVertCount(); } #endif // WITH_EDITOR // serialize the lighting guid if it's there Ar << LightingGuid; Ar << LightmassSettings; }
void UModel::Serialize( FArchive& Ar ) { Super::Serialize( Ar ); const int32 StripVertexBufferFlag = 1; FStripDataFlags StripFlags( Ar, GetOuter() && GetOuter()->IsA(ABrush::StaticClass()) ? StripVertexBufferFlag : FStripDataFlags::None ); Ar << Bounds; if (Ar.IsLoading() && Ar.UE4Ver() < VER_UE4_BSP_UNDO_FIX ) { TTransArray<FVector> OldVectors(this); TTransArray<FVector> OldPoints(this); TTransArray<FBspNode> OldNodes(this); OldVectors.BulkSerialize(Ar); OldPoints.BulkSerialize(Ar); OldNodes.BulkSerialize(Ar); Vectors = OldVectors; Points = OldPoints; Nodes = OldNodes; } else { Vectors.BulkSerialize(Ar); Points.BulkSerialize(Ar); Nodes.BulkSerialize(Ar); } if( Ar.IsLoading() ) { for( int32 NodeIndex=0; NodeIndex<Nodes.Num(); NodeIndex++ ) { Nodes[NodeIndex].NodeFlags &= ~(NF_IsNew|NF_IsFront|NF_IsBack); } } if (Ar.IsLoading() && Ar.UE4Ver() < VER_UE4_BSP_UNDO_FIX ) { TTransArray<FBspSurf> OldSurfs(this); TTransArray<FVert> OldVerts(this); Ar << OldSurfs; OldVerts.BulkSerialize(Ar); Surfs = OldSurfs; Verts = OldVerts; } else { Ar << Surfs; Verts.BulkSerialize(Ar); } if( Ar.IsLoading() && Ar.UE4Ver() < VER_UE4_REMOVE_ZONES_FROM_MODEL) { int32 NumZones; Ar << NumSharedSides << NumZones; FZoneProperties DummyZones[FBspNode::MAX_ZONES]; for( int32 i=0; i<NumZones; i++ ) { Ar << DummyZones[i]; } } else { Ar << NumSharedSides; } #if WITH_EDITOR bool bHasEditorOnlyData = !Ar.IsFilterEditorOnly(); if ( Ar.UE4Ver() < VER_UE4_REMOVE_UNUSED_UPOLYS_FROM_UMODEL ) { bHasEditorOnlyData = true; } // if we are cooking then don't save this stuff out if ( bHasEditorOnlyData ) { Ar << Polys; LeafHulls.BulkSerialize( Ar ); Leaves.BulkSerialize( Ar ); } #else bool bHasEditorOnlyData = !Ar.IsFilterEditorOnly(); if ( Ar.UE4Ver() < VER_UE4_REMOVE_UNUSED_UPOLYS_FROM_UMODEL ) { bHasEditorOnlyData = true; } if((Ar.IsLoading() || Ar.IsSaving()) && bHasEditorOnlyData) { UPolys* DummyPolys = NULL; Ar << DummyPolys; TArray<int32> DummyLeafHulls; DummyLeafHulls.BulkSerialize( Ar ); TArray<FLeaf> DummyLeaves; DummyLeaves.BulkSerialize( Ar ); } #endif Ar << RootOutside << Linked; if(Ar.IsLoading() && Ar.UE4Ver() < VER_UE4_REMOVE_ZONES_FROM_MODEL) { TArray<int32> DummyPortalNodes; DummyPortalNodes.BulkSerialize( Ar ); } Ar << NumUniqueVertices; // load/save vertex buffer if( StripFlags.IsEditorDataStripped() == false || StripFlags.IsClassDataStripped( StripVertexBufferFlag ) == false ) { Ar << VertexBuffer; } #if WITH_EDITOR if(GIsEditor) { CalculateUniqueVertCount(); } #endif // WITH_EDITOR // serialize the lighting guid if it's there Ar << LightingGuid; Ar << LightmassSettings; }