I’m porting a plugin written for UE 4.16 to UE 4.19, and I’ve seen a lot of things have changed for the class USkeletalMesh (and other related classes).
For example, in UE 4.16 I have:
FStaticLODModel* LodModel = new FStaticLODModel();
SkeletalMesh->GetImportedResource()->LODModels.Add(LodModel);
In UE 4.19 I can’t see anymore FStaticLODModel
, so I thought it has been replaced with FSkeletalMeshLODModel
; also the method GetImportedResource()
has disappeared in UE 4.19, and the most similar method I found is GetImportedModel()
.
So the previous two rows may be replaced with:
FSkeletalMeshLODModel* LodModel = new FSkeletalMeshLODModel();
SkeletalMesh->GetImportedModel()->LODModels.Add(LodModel);
Another thing is, in UE 4.16 I have this piece of code:
LodModel->MultiSizeIndexContainer.CreateIndexBuffer(sizeof(uint16_t));
LodModel->NumVertices = data->vertexCount;
LodModel->NumTexCoords = 1;
for (uint32_t index = 0; index < data->indexCount; index++)
{
LodModel->MultiSizeIndexContainer.GetIndexBuffer()->AddItem(data->indexBuffer[index]);
}
In UE 4.19 I can’t find the field MultiSizeIndexContainer
, but I find an IndexBuffer
attribute, so I replaced this snippet with:
LodModel->NumVertices = data->vertexCount;
LodModel->NumTexCoords = 1;
for (uint32_t index = 0; index < data->indexCount; index++)
{
LodModel->IndexBuffer.Add(data->indexBuffer[index]);
}
The last thing (the most critical one) is this piece of code in UE 4.16:
const uint32 vert_flags = FStaticLODModel::EVertexFlags::None | FStaticLODModel::EVertexFlags::UseFullPrecisionUVs;
LodModel->BuildVertexBuffers(vert_flags);
SkeletalMesh->Skeleton = NewObject<USkeleton>();
SkeletalMesh->Skeleton->MergeAllBonesToBoneTree(SkeletalMesh);
SkeletalMesh->PostLoad();
In UE 4.19 the method BuildVertexBuffers
has disappeared, and I’ve found nothing to replace it… so I just wrote this:
SkeletalMesh->bUseFullPrecisionUVs = true;
SkeletalMesh->bHasVertexColors = false;
SkeletalMesh->Skeleton = NewObject<USkeleton>();
SkeletalMesh->Skeleton->MergeAllBonesToBoneTree(SkeletalMesh);
SkeletalMesh->PostLoad();
It compiles correctly, but it randomly crashes when cycling on the SkeletalMesh
’s IndexBuffer
, also whether I’m using the same meshes, so I think there is something I’m not replacing correctly…
May someone help me to understand what has changed in UE 4.19 and how to correctly replace those snippets of code?