1mikiii99
(1mikiii99)
May 27, 2023, 10:31am
1
Hi hope yall doing well.
I have this c++ bluepring function library for getting character vertices which works fine in UE4 but when using same thing in UE5 it says
warning C4996: ‘USkinnedMeshComponent::SkeletalMesh’: Replaced by SkinnedAsset. Use GetSkinnedAsset()/SetSkinnedAsset() instead, or GetSkeletalMeshAsset/SetSkeletalMeshAsset() when called from a USkeletalMeshComponent. Please update your code to the new API before upgrading to the next release, otherwise your project will no longer compile.
I dont know how to replace USkinnedMeshComponent in my code with what UE5 suggesting.
MY CODE
Thanks everyone
1 Like
f35vtol
(f35vtol)
July 5, 2023, 3:21am
2
Has anyone solved this?? I get same error,
3dRaven
(3dRaven)
July 5, 2023, 8:53am
3
// Copyright Epic Games, Inc. All Rights Reserved.
#include "BPLibraryFuncs.h"
#include "SkeletalRenderPublic.h"
#include "Rendering/SkeletalMeshRenderData.h"
#include "GameFramework/PawnMovementComponent.h"
#include "Kismet/KismetMathLibrary.h"
#include "SkeletalMeshTypes.h"
UBPLibraryFuncs::UBPLibraryFuncs(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{}
bool UBPLibraryFuncs::BP_GetSkeletalMeshVertexLocations(USkeletalMeshComponent* Mesh, TArray<FVector3f>& Locations, int32 LODIndex)
{
if (!Mesh || !Mesh->SkeletalMesh) return false;
//CPU or GPU skinning
if (Mesh->GetCPUSkinningEnabled()) {
TArray<FFinalSkinVertex> SkinnedVertices;
Mesh->GetCPUSkinnedVertices(SkinnedVertices, LODIndex);
Locations.Empty();
Locations.AddUninitialized(SkinnedVertices.Num());
for (int32 i = 0; i < SkinnedVertices.Num(); ++i) {
Locations[i] = SkinnedVertices[i].Position;
}
}
else {
const FSkeletalMeshRenderData* RenderData = Mesh->GetSkeletalMeshRenderData();
if (!RenderData) return false;
FSkinWeightVertexBuffer& SkinWeightBuffer = *Mesh->GetSkinWeightBuffer(LODIndex);
const FSkeletalMeshLODRenderData& LOD = RenderData->LODRenderData[LODIndex];
const FSkinWeightVertexBuffer& Buffer = LOD.SkinWeightVertexBuffer;
TArray<FMatrix44f> CacheToLocals;
Mesh->GetCurrentRefToLocalMatrices(CacheToLocals, LODIndex);
Mesh->ComputeSkinnedPositions(Mesh, Locations, CacheToLocals,LOD, Buffer);
}
const FTransform ToWorld = Mesh->GetComponentTransform();
for (FVector3f& EachVertex : Locations) {
EachVertex = (FVector3f)ToWorld.TransformPosition((FVector)EachVertex);
}
return true;
}
void UBPLibraryFuncs::BP_SetCPUSkinningEnabled(USkinnedMeshComponent* Mesh, bool bEnable, bool bRecreateRenderStateImmediately)
{
Mesh->SetCPUSkinningEnabled(bEnable, bRecreateRenderStateImmediately);
}
f35vtol
(f35vtol)
July 5, 2023, 9:12am
4
Thanks!
I manged to get everything to compile after changing my code to use SkinnedAsset rather than SkeletalMesh:
//From:
SkeletalMesh = Context.AnimInstanceProxy->GetSkelMeshComponent()->SkeletalMesh;
//To:
SkeletalMesh = Context.AnimInstanceProxy->GetSkelMeshComponent()->GetSkinnedAsset();
Everything appears to be working now.