Skip to content

Commit

Permalink
fix: updated preview method to load character asset correctly (#16)
Browse files Browse the repository at this point in the history
- fixed an issue that caused assets of the same type to stack after
switching asset types. EG multiple pants being equipped
  • Loading branch information
HarrisonHough authored Oct 18, 2024
1 parent 4436cd1 commit 821277c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.2.1] 2024-10-18

### Fixed

- Fixed issue where previously selected assets were not being removed

## [0.2.0] 2024-10-05

### Added
Expand Down
Binary file modified Content/Samples/BasicLoader/Blueprints/BP_SampleRpmActor.uasset
Binary file not shown.
Binary file modified Content/Samples/BasicLoader/RpmBasicLoader.umap
Binary file not shown.
2 changes: 2 additions & 0 deletions Source/RpmNextGen/Private/RpmActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ void ARpmActor::RemoveMeshComponentsOfType(const FString& AssetType)
if (ComponentToRemove)
{
ComponentToRemove->DestroyComponent();
ComponentToRemove = nullptr;
}
}
LoadedMeshComponentsByAssetType.Remove(AssetType);
Expand All @@ -132,6 +133,7 @@ void ARpmActor::RemoveAllMeshes()
if (ComponentToRemove)
{
ComponentToRemove->DestroyComponent();
ComponentToRemove = nullptr;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Source/RpmNextGen/Private/RpmLoaderComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ void URpmLoaderComponent::LoadGltfRuntimeAssetFromCache(const FAsset& Asset)
{
UE_LOG(LogReadyPlayerMe, Error, TEXT("Failed to load gltf asset"));
}
OnNewAssetLoaded.Broadcast(Asset, GltfRuntimeAsset);
OnAssetLoaded.Broadcast(Asset, GltfRuntimeAsset);
return;
}
}
UE_LOG(LogReadyPlayerMe, Error, TEXT("Failed to load gltf asset from cache"));
OnNewAssetLoaded.Broadcast(Asset, nullptr);
OnAssetLoaded.Broadcast(Asset, nullptr);
}

void URpmLoaderComponent::LoadCharacterAssetsFromCache(TMap<FString, FAsset> AssetMap)
Expand Down Expand Up @@ -137,7 +137,7 @@ void URpmLoaderComponent::LoadAssetPreview(FAsset AssetData, bool bUseCache)
PreviewRequest.Params.Assets = ParamAssets;
const FString& Url = CharacterApi->GeneratePreviewUrl(PreviewRequest);

FileApi->LoadAssetFileFromUrl(Url, AssetData);
FileApi->LoadFileFromUrl(Url);
}

void URpmLoaderComponent::HandleAssetLoaded(const TArray<unsigned char>* Data, const FAsset& Asset)
Expand All @@ -152,7 +152,7 @@ void URpmLoaderComponent::HandleAssetLoaded(const TArray<unsigned char>* Data, c
{
UE_LOG(LogReadyPlayerMe, Error, TEXT("Failed to load gltf asset"));
}
OnNewAssetLoaded.Broadcast(Asset, GltfRuntimeAsset);
OnAssetLoaded.Broadcast(Asset, GltfRuntimeAsset);
}

void URpmLoaderComponent::HandleCharacterAssetLoaded(const TArray<unsigned char>* Data, const FString& FileName)
Expand Down
4 changes: 2 additions & 2 deletions Source/RpmNextGen/Public/RpmLoaderComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnCharacterCreated, FRpmCharacterDa
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnCharacterUpdated, FRpmCharacterData, CharacterData);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnCharacterFound, FRpmCharacterData, CharacterData);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnCharacterAssetLoaded, const FRpmCharacterData&, CharacterData, UglTFRuntimeAsset*, GltfRuntimeAsset);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnNewAssetLoaded, const FAsset&, Asset, UglTFRuntimeAsset*, GltfRuntimeAsset );
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnAssetLoaded, const FAsset&, Asset, UglTFRuntimeAsset*, GltfRuntimeAsset );

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class RPMNEXTGEN_API URpmLoaderComponent : public UActorComponent
Expand All @@ -33,7 +33,7 @@ class RPMNEXTGEN_API URpmLoaderComponent : public UActorComponent
UPROPERTY(BlueprintAssignable, Category = "Ready Player Me" )
FOnCharacterAssetLoaded OnCharacterAssetLoaded;
UPROPERTY(BlueprintAssignable, Category = "Ready Player Me" )
FOnNewAssetLoaded OnNewAssetLoaded;
FOnAssetLoaded OnAssetLoaded;
UPROPERTY(BlueprintAssignable, Category = "Ready Player Me" )
FOnCharacterCreated OnCharacterCreated;
UPROPERTY(BlueprintAssignable, Category = "Ready Player Me" )
Expand Down

0 comments on commit 821277c

Please sign in to comment.