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 [FONT=courier new]USkeletalMesh (and other related classes).
For example, in UE 4.16 I have:
[FONT=courier new]FStaticLODModel* LodModel = new FStaticLODModel();
SkeletalMesh->GetImportedResource()->LODModels.Add(LodModel);
In UE 4.19 I can’t see anymore [FONT=courier new]FStaticLODModel, so I thought it has been replaced with [FONT=courier new]FSkeletalMeshLODModel; also the method [FONT=courier new]GetImportedResource() has disappeared in UE 4.19, and the most similar method I found is [FONT=courier new]GetImportedModel().
So the previous two rows may be replaced with:
[FONT=courier new]FSkeletalMeshLODModel* LodModel = new FSkeletalMeshLODModel();
SkeletalMesh->GetImportedModel()->LODModels.Add(LodModel);
[HR][/HR]
Another thing is, in UE 4.16 I have this piece of code:
[FONT=courier new]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 [FONT=courier new]MultiSizeIndexContainer, but I find an [FONT=courier new]IndexBuffer attribute, so I replaced this snippet with:
[FONT=courier new]LodModel->NumVertices = data->vertexCount;
LodModel->NumTexCoords = 1;
for (uint32_t index = 0; index < data->indexCount; index++)
{
LodModel->IndexBuffer.Add(data->indexBuffer[index]);
}
[HR][/HR]
The last thing (the most critical one) is this piece of code in UE 4.16:
[FONT=courier new]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 [FONT=courier new]BuildVertexBuffers has disappeared, and I’ve found nothing to replace it… so I just wrote this:
[FONT=courier new]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?