Files
Richard TalbotWatkin 21ecacd4d6 Deprecated direct access to UStaticMesh::SourceModels, SectionInfoMap and OriginalSectionInfoMap.
Added new accessors for getting individual SourceModels, or the entire array.
#rb none
#jira none

[CL 7668562 by Richard TalbotWatkin in 4.23 branch]
2019-07-31 03:40:28 -04:00

87 lines
2.3 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "StaticMeshAdapter.h"
#include "MaterialBakingStructures.h"
#include "Engine/StaticMesh.h"
#include "UObject/Package.h"
#include "MeshMergeHelpers.h"
FStaticMeshAdapter::FStaticMeshAdapter(UStaticMesh* InStaticMesh)
: StaticMesh(InStaticMesh)
{
checkf(StaticMesh != nullptr, TEXT("Invalid static mesh in adapter"));
NumLODs = StaticMesh->GetNumLODs();
}
int32 FStaticMeshAdapter::GetNumberOfLODs() const
{
return NumLODs;
}
void FStaticMeshAdapter::RetrieveRawMeshData(int32 LODIndex, FMeshDescription& InOutRawMesh, bool bPropogateMeshData) const
{
FMeshMergeHelpers::RetrieveMesh(StaticMesh, LODIndex, InOutRawMesh);
}
void FStaticMeshAdapter::RetrieveMeshSections(int32 LODIndex, TArray<FSectionInfo>& InOutSectionInfo) const
{
FMeshMergeHelpers::ExtractSections(StaticMesh, LODIndex, InOutSectionInfo);
}
int32 FStaticMeshAdapter::GetMaterialIndex(int32 LODIndex, int32 SectionIndex) const
{
return StaticMesh->GetSectionInfoMap().Get(LODIndex, SectionIndex).MaterialIndex;
}
void FStaticMeshAdapter::ApplySettings(int32 LODIndex, FMeshData& InOutMeshData) const
{
InOutMeshData.LightMapIndex = StaticMesh->LightMapCoordinateIndex;
}
UPackage* FStaticMeshAdapter::GetOuter() const
{
return nullptr;
}
FString FStaticMeshAdapter::GetBaseName() const
{
return StaticMesh->GetOutermost()->GetName();
}
void FStaticMeshAdapter::SetMaterial(int32 MaterialIndex, UMaterialInterface* Material)
{
StaticMesh->StaticMaterials[MaterialIndex] = Material;
}
void FStaticMeshAdapter::RemapMaterialIndex(int32 LODIndex, int32 SectionIndex, int32 NewMaterialIndex)
{
FMeshSectionInfo SectionInfo = StaticMesh->GetSectionInfoMap().Get(LODIndex, SectionIndex);
SectionInfo.MaterialIndex = NewMaterialIndex;
StaticMesh->GetSectionInfoMap().Set(LODIndex, SectionIndex, SectionInfo);
}
int32 FStaticMeshAdapter::AddMaterial(UMaterialInterface* Material)
{
return StaticMesh->StaticMaterials.Add(Material);
}
void FStaticMeshAdapter::UpdateUVChannelData()
{
StaticMesh->UpdateUVChannelData(false);
}
bool FStaticMeshAdapter::IsAsset() const
{
return true;
}
int32 FStaticMeshAdapter::LightmapUVIndex() const
{
return StaticMesh->LightMapCoordinateIndex;
}
FBoxSphereBounds FStaticMeshAdapter::GetBounds() const
{
return StaticMesh->GetBounds();
}