Files
UnrealEngineUWP/Engine/Source/Developer/MeshMergeUtilities/Private/SkeletalMeshAdapter.cpp
chris gagnon aad5335ff6 Copying //UE4/Dev-Editor to Dev-Main (//UE4/Dev-Main)
#rb none
#lockdown Nick.Penwarden

#ROBOMERGE-OWNER: ryan.gerleve
#ROBOMERGE-AUTHOR: chris.gagnon
#ROBOMERGE-SOURCE: CL 4676940 in //UE4/Main/...
#ROBOMERGE-BOT: ENGINE (Main -> Dev-Networking)

[CL 4676943 by chris gagnon in Dev-Networking branch]
2019-01-02 15:37:07 -05:00

81 lines
2.4 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "SkeletalMeshAdapter.h"
#include "MeshMergeHelpers.h"
#include "Components/SkeletalMeshComponent.h"
#include "Engine/SkeletalMesh.h"
#include "UObject/Package.h"
#include "Rendering/SkeletalMeshModel.h"
FSkeletalMeshComponentAdapter::FSkeletalMeshComponentAdapter(USkeletalMeshComponent* InSkeletalMeshComponent)
: SkeletalMeshComponent(InSkeletalMeshComponent), SkeletalMesh(InSkeletalMeshComponent->SkeletalMesh)
{
checkf(SkeletalMesh != nullptr, TEXT("Invalid skeletal mesh in adapter"));
NumLODs = SkeletalMesh->GetLODNum();
}
int32 FSkeletalMeshComponentAdapter::GetNumberOfLODs() const
{
return NumLODs;
}
void FSkeletalMeshComponentAdapter::RetrieveRawMeshData(int32 LODIndex, FMeshDescription& InOutRawMesh, bool bPropogateMeshData) const
{
FMeshMergeHelpers::RetrieveMesh(SkeletalMeshComponent, LODIndex, InOutRawMesh, bPropogateMeshData);
}
void FSkeletalMeshComponentAdapter::RetrieveMeshSections(int32 LODIndex, TArray<FSectionInfo>& InOutSectionInfo) const
{
FMeshMergeHelpers::ExtractSections(SkeletalMeshComponent, LODIndex, InOutSectionInfo);
}
int32 FSkeletalMeshComponentAdapter::GetMaterialIndex(int32 LODIndex, int32 SectionIndex) const
{
return SkeletalMesh->GetImportedModel()->LODModels[LODIndex].Sections[SectionIndex].MaterialIndex;
}
UPackage* FSkeletalMeshComponentAdapter::GetOuter() const
{
return nullptr;
}
FString FSkeletalMeshComponentAdapter::GetBaseName() const
{
return SkeletalMesh->GetOutermost()->GetName();
}
void FSkeletalMeshComponentAdapter::SetMaterial(int32 MaterialIndex, UMaterialInterface* Material)
{
SkeletalMesh->Materials[MaterialIndex] = Material;
}
void FSkeletalMeshComponentAdapter::RemapMaterialIndex(int32 LODIndex, int32 SectionIndex, int32 NewMaterialIndex)
{
SkeletalMesh->GetImportedModel()->LODModels[LODIndex].Sections[SectionIndex].MaterialIndex = NewMaterialIndex;
}
int32 FSkeletalMeshComponentAdapter::AddMaterial(UMaterialInterface* Material)
{
return SkeletalMesh->Materials.Add(Material);
}
void FSkeletalMeshComponentAdapter::UpdateUVChannelData()
{
SkeletalMesh->UpdateUVChannelData(false);
}
bool FSkeletalMeshComponentAdapter::IsAsset() const
{
return true;
}
int32 FSkeletalMeshComponentAdapter::LightmapUVIndex() const
{
return INDEX_NONE;
}
FBoxSphereBounds FSkeletalMeshComponentAdapter::GetBounds() const
{
return SkeletalMesh->GetBounds();
}