Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
#include "Developer/AssetTools/Public/IAssetTools.h"
#include "Developer/AssetTools/Public/AssetToolsModule.h"

#include "Toolkits/AssetEditorManager.h"
#include "Toolkits/ToolkitManager.h"

#include "Dialogs/DlgPickAssetPath.h"
#include "AssetRegistryModule.h"

Expand Down Expand Up @@ -110,7 +111,7 @@ static void MapSkinVerts(
UVertexAnimProfile* InProfile, const TArray <FFinalSkinVertex>& SkinVerts,
TArray <int32>& UniqueVertsSourceID, TArray <FVector2D>& OutUVSet_Vert)
{
TArray <FVector> UniqueVerts;
TArray <FVector3f> UniqueVerts;
TArray <int32> UniqueID;
UniqueID.SetNumZeroed(SkinVerts.Num());

Expand Down Expand Up @@ -234,8 +235,8 @@ static void SkinnedMeshVATData(

const int32 NumLODs = InSkinnedMeshComponent->GetNumLODs();

const auto& RefSkeleton = InSkinnedMeshComponent->SkeletalMesh->RefSkeleton;
const auto& GlobalRefSkeleton = InSkinnedMeshComponent->SkeletalMesh->Skeleton->GetReferenceSkeleton();
const auto& RefSkeleton = InSkinnedMeshComponent->SkeletalMesh->GetRefSkeleton();
const auto& GlobalRefSkeleton = InSkinnedMeshComponent->SkeletalMesh->GetSkeleton()->GetReferenceSkeleton();

TArray <FVector2D> GridUVs_Vert;
TArray <FVector2D> GridUVs_Bone;
Expand Down Expand Up @@ -296,15 +297,15 @@ static void SkinnedMeshVATData(

for (int32 o = 0; o < FinalVertices.Num(); o++)
{
const FVector Pos = FinalVertices[o].Position;
const FVector3f Pos = FinalVertices[o].Position;
float Lowest = MAX_FLT;
int32 WinnerID = INDEX_NONE;

for (int32 u = 0; u < UniqueSourceID.Num(); u++)
{
const FVector TargetPos = AnimMeshFinalVertices[UniqueSourceID[u]].Position;
const FVector3f TargetPos = AnimMeshFinalVertices[UniqueSourceID[u]].Position;

const float Dist = FVector::Dist(Pos, TargetPos);
const float Dist = FVector3f::Dist(Pos, TargetPos);
if (Dist < Lowest)
{
Lowest = Dist;
Expand Down Expand Up @@ -499,7 +500,7 @@ void GatherAndBakeAllAnimVertData(
FSkeletalMeshRenderData& SkeletalMeshRenderData = PreviewComponent->MeshObject->GetSkeletalMeshRenderData();
FSkeletalMeshLODRenderData& LODData = SkeletalMeshRenderData.LODRenderData[0];
const auto& ActiveBoneIndices = LODData.ActiveBoneIndices;
TArray <FMatrix> RefToLocal;
TArray <FMatrix44f> RefToLocal;

// 3� Store Values
// Vert Anim
Expand Down Expand Up @@ -539,12 +540,13 @@ void GatherAndBakeAllAnimVertData(
{
const int32 IndexInZeroed = k;
const int32 VertID = UniqueSourceIDs[k];
const FVector Delta = FinalVerts[VertID].Position - RefPoseFinalVerts[VertID].Position;
const FVector3f Delta = FinalVerts[VertID].Position - RefPoseFinalVerts[VertID].Position;
MaxValueOffset = FMath::Max(Delta.GetAbsMax(), MaxValueOffset);
ZeroedPos[IndexInZeroed] = Delta;
ZeroedPos[IndexInZeroed] = FVector4(Delta);

const FVector DeltaNormal = FinalVerts[VertID].TangentZ.ToFVector() - RefPoseFinalVerts[VertID].TangentZ.ToFVector();
ZeroedNorm[IndexInZeroed] = DeltaNormal;
const FVector3f DeltaNormal = FinalVerts[VertID].TangentZ.ToFVector3f() - RefPoseFinalVerts[VertID].TangentZ.ToFVector3f();
ZeroedNorm[IndexInZeroed] = FVector4(DeltaNormal);

}

GridVertPos.Append(ZeroedPos);
Expand All @@ -558,8 +560,8 @@ void GatherAndBakeAllAnimVertData(
// Bone Anim
if (Profile->Anims_Bone.Num())
{
const auto& RefSkeleton = PreviewComponent->SkeletalMesh->RefSkeleton;
const auto& GlobalRefSkeleton = PreviewComponent->SkeletalMesh->Skeleton->GetReferenceSkeleton();
const auto& RefSkeleton = PreviewComponent->SkeletalMesh->GetRefSkeleton();
const auto& GlobalRefSkeleton = PreviewComponent->SkeletalMesh->GetSkeleton()->GetReferenceSkeleton();
// Ref Pose in Row 0
{
PreviewComponent->EnablePreview(true, NULL);
Expand Down Expand Up @@ -610,12 +612,12 @@ void GatherAndBakeAllAnimVertData(
{
const int32 GlobalID = GlobalRefSkeleton.FindBoneIndex(RefSkeleton.GetBoneName(k));

FVector Pos = RefToLocal[k].GetOrigin();
ZeroedBonePos[GlobalID] = Pos;
FVector3f Pos = RefToLocal[k].GetOrigin();
ZeroedBonePos[GlobalID] = FVector4(Pos);

MaxValuePosBone = FMath::Max(MaxValuePosBone, Pos.GetAbsMax());

FQuat Q = RefToLocal[k].ToQuat();
FQuat Q = FQuat(RefToLocal[k].ToQuat());
QuatSave(Q);
ZeroedBoneRot[GlobalID] = FVector4(Q.X, Q.Y, Q.Z, Q.W);
}
Expand Down Expand Up @@ -1109,7 +1111,7 @@ void FVATEditorUtils::UVChannelsToSkeletalMesh(USkeletalMesh* Skel, const int32
int32 SoftIndex = 0;
Skel->GetImportedModel()->LODModels[LODIndex].GetSectionFromVertexIndex(i, SectionIndex, SoftIndex);

Skel->GetImportedModel()->LODModels[LODIndex].Sections[SectionIndex].SoftVertices[SoftIndex].UVs[UVChannelStart+j] = UVChannels[j][i];
Skel->GetImportedModel()->LODModels[LODIndex].Sections[SectionIndex].SoftVertices[SoftIndex].UVs[UVChannelStart+j] = FVector2f(UVChannels[j][i]);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "Developer/AssetTools/Public/IAssetTools.h"
#include "Developer/AssetTools/Public/AssetToolsModule.h"

#include "Toolkits/AssetEditorManager.h"
#include "Toolkits/ToolkitManager.h"
#include "Dialogs/DlgPickAssetPath.h"
#include "AssetRegistryModule.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
#include "Developer/AssetTools/Public/IAssetTools.h"
#include "Developer/AssetTools/Public/AssetToolsModule.h"

#include "Toolkits/AssetEditorManager.h"
#include "Toolkits/ToolkitManager.h"
#include "Dialogs/DlgPickAssetPath.h"
#include "AssetRegistryModule.h"

Expand Down Expand Up @@ -336,7 +336,8 @@ static void SkinnedMeshToRawMeshes(USkinnedMeshComponent* InSkinnedMeshComponent
// Copy skinned vertex positions
for (int32 VertIndex = 0; VertIndex < FinalVertices.Num(); ++VertIndex)
{
RawMesh.VertexPositions.Add(InComponentToWorld.TransformPosition(FinalVertices[VertIndex].Position));
FVector4d vert = InComponentToWorld.TransformPosition(FVector(FinalVertices[VertIndex].Position));
RawMesh.VertexPositions.Add(FVector3f(vert.X, vert.Y, vert.Z));
}

const uint32 NumTexCoords = FMath::Min(LODData.StaticVertexBuffers.StaticMeshVertexBuffer.GetNumTexCoords(), (uint32)MAX_MESH_TEXTURE_COORDS);
Expand All @@ -362,9 +363,9 @@ static void SkinnedMeshToRawMeshes(USkinnedMeshComponent* InSkinnedMeshComponent
const FVector4 UnpackedTangentZ = SkinnedVertex.TangentZ.ToFVector4();
const FVector TangentY = (TangentZ ^ TangentX).GetSafeNormal() * UnpackedTangentZ.W;

RawMesh.WedgeTangentX.Add(TangentX);
RawMesh.WedgeTangentY.Add(TangentY);
RawMesh.WedgeTangentZ.Add(TangentZ);
RawMesh.WedgeTangentX.Add(FVector3f(TangentX));
RawMesh.WedgeTangentY.Add(FVector3f(TangentY));
RawMesh.WedgeTangentZ.Add(FVector3f(TangentZ));

for (uint32 TexCoordIndex = 0; TexCoordIndex < MAX_MESH_TEXTURE_COORDS; TexCoordIndex++)
{
Expand Down Expand Up @@ -394,7 +395,7 @@ static void SkinnedMeshToRawMeshes(USkinnedMeshComponent* InSkinnedMeshComponent
// use the remapping of material indices if there is a valid value
if (SrcLODInfo.LODMaterialMap.IsValidIndex(SectionIndex) && SrcLODInfo.LODMaterialMap[SectionIndex] != INDEX_NONE)
{
MaterialIndex = FMath::Clamp<int32>(SrcLODInfo.LODMaterialMap[SectionIndex], 0, InSkinnedMeshComponent->SkeletalMesh->Materials.Num());
MaterialIndex = FMath::Clamp<int32>(SrcLODInfo.LODMaterialMap[SectionIndex], 0, InSkinnedMeshComponent->SkeletalMesh->GetMaterials().Num());
}

// copy face info
Expand Down Expand Up @@ -474,7 +475,7 @@ UStaticMesh* FVertexAnimUtils::ConvertMeshesToStaticMesh(const TArray<UMeshCompo
}
else if (false)//(IsValidStaticMeshComponent(StaticMeshComponent))
{
OverallMaxLODs = FMath::Max(StaticMeshComponent->GetStaticMesh()->RenderData->LODResources.Num(), OverallMaxLODs);
OverallMaxLODs = FMath::Max(StaticMeshComponent->GetStaticMesh()->GetRenderData()->LODResources.Num(), OverallMaxLODs);
}
}

Expand Down Expand Up @@ -546,7 +547,7 @@ UStaticMesh* FVertexAnimUtils::ConvertMeshesToStaticMesh(const TArray<UMeshCompo
StaticMesh = NewObject<UStaticMesh>(Package, *MeshName, RF_Public | RF_Standalone);
StaticMesh->InitResources();

StaticMesh->LightingGuid = FGuid::NewGuid();
StaticMesh->SetLightingGuid(FGuid::NewGuid());

// Determine which texture coordinate map should be used for storing/generating the lightmap UVs
const uint32 LightMapIndex = FMath::Min(MaxInUseTextureCoordinate + 1, (uint32)MAX_MESH_TEXTURE_COORDS - 1);
Expand All @@ -572,7 +573,11 @@ UStaticMesh* FVertexAnimUtils::ConvertMeshesToStaticMesh(const TArray<UMeshCompo
// Copy materials to new mesh
for (UMaterialInterface* Material : Materials)
{
StaticMesh->StaticMaterials.Add(FStaticMaterial(Material));
//StaticMesh->GetStaticMaterials().Add(FStaticMaterial(Material)); // Can we do this? Unsure of the async implication.

auto materials = StaticMesh->GetStaticMaterials();
materials.Add(FStaticMaterial(Material));
StaticMesh->SetStaticMaterials(materials);
}

//Set the Imported version before calling the build
Expand Down Expand Up @@ -650,7 +655,7 @@ void FVertexAnimUtils::VATUVsToStaticMeshLODs(UStaticMesh* StaticMesh, const int
for (int32 WedgeIndex = 0; WedgeIndex < Mesh.WedgeIndices.Num(); ++WedgeIndex)
{
int32 VertID = Mesh.WedgeIndices[WedgeIndex];
FVector Position = Mesh.VertexPositions[VertID];
FVector Position = FVector(Mesh.VertexPositions[VertID]);

for (uint32 TexCoordIndex = 0; TexCoordIndex < MAX_MESH_TEXTURE_COORDS; TexCoordIndex++)
{
Expand All @@ -662,7 +667,7 @@ void FVertexAnimUtils::VATUVsToStaticMeshLODs(UStaticMesh* StaticMesh, const int
if (Mesh.WedgeTexCoords[TexCoordIndex].Num() != Mesh.WedgeIndices.Num())
Mesh.WedgeTexCoords[TexCoordIndex].SetNum(Mesh.WedgeIndices.Num());

Mesh.WedgeTexCoords[TexCoordIndex][WedgeIndex] = UVs[PaintingMeshLODIndex][VertID];
Mesh.WedgeTexCoords[TexCoordIndex][WedgeIndex] = FVector2f(UVs[PaintingMeshLODIndex][VertID]);
}
else if(TexCoordIndex >= NumUVChannels)
{
Expand Down Expand Up @@ -725,7 +730,7 @@ void FVertexAnimUtils::VATColorsToStaticMeshLODs(UStaticMesh* StaticMesh, const
for (int32 WedgeIndex = 0; WedgeIndex < Mesh.WedgeIndices.Num(); ++WedgeIndex)
{
int32 VertID = Mesh.WedgeIndices[WedgeIndex];
FVector Position = Mesh.VertexPositions[VertID];
FVector Position = FVector(Mesh.VertexPositions[VertID]);
Mesh.WedgeColors[WedgeIndex] = Colors[PaintingMeshLODIndex][VertID];
}

Expand Down
2 changes: 1 addition & 1 deletion VertexAnimToolset/VertexAnimToolset.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"DocsURL": "https://github.com/Rexocrates/Vertex_Anim_Toolset/blob/main/Vertex%20Anim%20Toolset%20Documentation.pdf",
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/content/d998b22372a44975b312e85cf663bbab",
"SupportURL": "https://github.com/Rexocrates/Vertex_Anim_Toolset/issues",
"EngineVersion": "4.26.0",
"EngineVersion": "5.0.0",
"CanContainContent": true,
"Installed": false,
"Modules": [
Expand Down