Files
UnrealEngineUWP/Engine/Source/Developer/MeshMergeUtilities/Private/SkeletalMeshAdapter.cpp
Marcus Wassmer 834e95f3d3 Merging //UE4/Dev-Main@4680011 to Dev-Rendering (//UE4/Dev-Rendering)
#rb none

[CL 4680455 by Marcus Wassmer in Dev-Rendering branch]
2019-01-03 19:28:34 -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();
}