Skip to content

Commit

Permalink
bumped version to 20240424
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeioris committed Apr 24, 2024
1 parent abc0baf commit 78a7384
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Source/glTFRuntime/Private/glTFRuntimeAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,13 @@ void UglTFRuntimeAsset::LoadStaticMeshFromRuntimeLODsAsync(const TArray<FglTFRun
Parser->LoadStaticMeshFromRuntimeLODsAsync(RuntimeLODs, AsyncCallback, StaticMeshConfig);
}

void UglTFRuntimeAsset::LoadSkeletalMeshFromRuntimeLODsAsync(const TArray<FglTFRuntimeMeshLOD>& RuntimeLODs, const int32 SkinIndex, const FglTFRuntimeSkeletalMeshAsync& AsyncCallback, const FglTFRuntimeSkeletalMeshConfig& SkeletalMeshConfig)
{
GLTF_CHECK_PARSER_VOID();

Parser->LoadSkeletalMeshFromRuntimeLODsAsync(RuntimeLODs, SkinIndex, AsyncCallback, SkeletalMeshConfig);
}

float UglTFRuntimeAsset::GetDownloadTime() const
{
GLTF_CHECK_PARSER(0);
Expand Down
66 changes: 66 additions & 0 deletions Source/glTFRuntime/Private/glTFRuntimeParserSkeletalMeshes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3722,6 +3722,72 @@ USkeletalMesh* FglTFRuntimeParser::LoadSkeletalMeshFromRuntimeLODs(const TArray<
return FinalizeSkeletalMeshWithLODs(SkeletalMeshContext);
}

void FglTFRuntimeParser::LoadSkeletalMeshFromRuntimeLODsAsync(const TArray<FglTFRuntimeMeshLOD>& RuntimeLODs, const int32 SkinIndex, const FglTFRuntimeSkeletalMeshAsync& AsyncCallback, const FglTFRuntimeSkeletalMeshConfig& SkeletalMeshConfig)
{
TSharedRef<FglTFRuntimeSkeletalMeshContext, ESPMode::ThreadSafe> SkeletalMeshContext = MakeShared<FglTFRuntimeSkeletalMeshContext, ESPMode::ThreadSafe>(AsShared(), SkeletalMeshConfig);
SkeletalMeshContext->SkinIndex = SkinIndex;

Async(EAsyncExecution::Thread, [this, SkeletalMeshContext, RuntimeLODs, AsyncCallback]()
{
FglTFRuntimeSkeletalMeshContextFinalizer AsyncFinalizer(SkeletalMeshContext, AsyncCallback);

if (RuntimeLODs.Num() < 1)
{
AddError("LoadSkeletalMeshFromRuntimeLODsAsync()", "No RuntimeLOD specified");
return;
}

if (RuntimeLODs[0].Primitives.Num() < 1)
{
AddError("LoadSkeletalMeshFromRuntimeLODsAsync()", "No Primitives for RuntimeLOD 0");
return;
}

const TMap<int32, FName>& BaseBoneMap = RuntimeLODs[0].Primitives[0].OverrideBoneMap;

SkeletalMeshContext->LODs.Add(const_cast<FglTFRuntimeMeshLOD*>(&RuntimeLODs[0]));

auto ContainsBone = [BaseBoneMap](FName BoneName) -> bool
{
for (const TPair<int32, FName>& Pair : BaseBoneMap)
{
if (Pair.Value == BoneName)
{
return true;
}
}
return false;
};

for (int32 LODIndex = 1; LODIndex < RuntimeLODs.Num(); LODIndex++)
{
if (RuntimeLODs[LODIndex].Primitives.Num() < 1)
{
AddError("LoadSkeletalMeshFromRuntimeLODsAsync()", "Invalid RuntimeLOD, no Primitives defined");
return;
}

for (const FglTFRuntimePrimitive& Primitive : RuntimeLODs[LODIndex].Primitives)
{
FglTFRuntimePrimitive& NonConstPrimitive = const_cast<FglTFRuntimePrimitive&>(Primitive);

for (TPair<int32, FName>& Pair : NonConstPrimitive.OverrideBoneMap)
{
if (!ContainsBone(Pair.Value))
{
AddError("LoadSkeletalMeshFromRuntimeLODsAsync()", FString::Printf(TEXT("Unknown bone %s"), *Pair.Value.ToString()));
return;
}
}
}

SkeletalMeshContext->LODs.Add(const_cast<FglTFRuntimeMeshLOD*>(&RuntimeLODs[LODIndex]));
}

SkeletalMeshContext->SkeletalMesh = CreateSkeletalMeshFromLODs(SkeletalMeshContext);
});
}

const FBox& FglTFRuntimeSkeletalMeshContext::GetBoneBox(const int32 BoneIndex)
{
// unfortunately we need access to SkinWeightVertexBuffer.GetBoneIndex (and it is not available in 4.25)
Expand Down
3 changes: 3 additions & 0 deletions Source/glTFRuntime/Public/glTFRuntimeAsset.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class GLTFRUNTIME_API UglTFRuntimeAsset : public UObject
UFUNCTION(BlueprintCallable, meta = (AdvancedDisplay = "SkeletalMeshConfig", AutoCreateRefTerm = "SkeletalMeshConfig"), Category = "glTFRuntime")
USkeletalMesh* LoadSkeletalMeshFromRuntimeLODs(const TArray<FglTFRuntimeMeshLOD>& RuntimeLODs, const int32 SkinIndex, const FglTFRuntimeSkeletalMeshConfig& SkeletalMeshConfig);

UFUNCTION(BlueprintCallable, meta = (AdvancedDisplay = "SkeletalMeshConfig", AutoCreateRefTerm = "SkeletalMeshConfig"), Category = "glTFRuntime")
void LoadSkeletalMeshFromRuntimeLODsAsync(const TArray<FglTFRuntimeMeshLOD>& RuntimeLODs, const int32 SkinIndex, const FglTFRuntimeSkeletalMeshAsync& AsyncCallback, const FglTFRuntimeSkeletalMeshConfig& SkeletalMeshConfig);

UFUNCTION(BlueprintCallable, meta = (AdvancedDisplay = "SkeletonConfig", AutoCreateRefTerm = "SkeletonConfig"), Category = "glTFRuntime")
USkeleton* LoadSkeleton(const int32 SkinIndex, const FglTFRuntimeSkeletonConfig& SkeletonConfig);

Expand Down
2 changes: 2 additions & 0 deletions Source/glTFRuntime/Public/glTFRuntimeParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -2116,6 +2116,8 @@ class GLTFRUNTIME_API FglTFRuntimeParser : public FGCObject, public TSharedFromT

USkeletalMesh* LoadSkeletalMesh(const int32 MeshIndex, const int32 SkinIndex, const FglTFRuntimeSkeletalMeshConfig& SkeletalMeshConfig);
USkeletalMesh* LoadSkeletalMeshFromRuntimeLODs(const TArray<FglTFRuntimeMeshLOD>& RuntimeLODs, const int32 SkinIndex, const FglTFRuntimeSkeletalMeshConfig& SkeletalMeshConfig);
void LoadSkeletalMeshFromRuntimeLODsAsync(const TArray<FglTFRuntimeMeshLOD>& RuntimeLODs, const int32 SkinIndex, const FglTFRuntimeSkeletalMeshAsync& AsyncCallback, const FglTFRuntimeSkeletalMeshConfig& SkeletalMeshConfig);

UAnimSequence* LoadSkeletalAnimation(USkeletalMesh* SkeletalMesh, const int32 AnimationIndex, const FglTFRuntimeSkeletalAnimationConfig& SkeletalAnimationConfig);
UAnimSequence* LoadSkeletalAnimationByName(USkeletalMesh* SkeletalMesh, const FString AnimationName, const FglTFRuntimeSkeletalAnimationConfig& SkeletalAnimationConfig);
UAnimSequence* LoadNodeSkeletalAnimation(USkeletalMesh* SkeletalMesh, const int32 NodeIndex, const FglTFRuntimeSkeletalAnimationConfig& SkeletalAnimationConfig);
Expand Down
2 changes: 1 addition & 1 deletion glTFRuntime.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "20231127",
"VersionName": "20240424",
"FriendlyName": "glTFRuntime",
"Description": "Manage glTF files at runtime",
"Category": "Runtime",
Expand Down

0 comments on commit 78a7384

Please sign in to comment.