sideeffects / HoudiniEngineForUnreal-v2

Houdini Engine Plugin for Unreal Engine 4 - Version 2
http://www.sidefx.com/unreal
Other
294 stars 75 forks source link

[Bug] Exception When Closing Play Before Assets are Fully Loaded #168

Open blhook opened 2 years ago

blhook commented 2 years ago

I currently have an actor that is attached to the HoudiniPublicAPI in such that when they spawn, they spawn an HDA (see code on bottom for example). When this actor spawns using Play-in-Editor, it will spawn the Actor as expected, as well as the HDA. Generally the play can be stopped fine, too. That said, if the play is stopped before the HDA fully instantiates, this causes an exception in the lambdas of HoudiniEngineDetails.cpp, especially ShouldEnableResetParametersButtonLambda at the code: UHoudiniParameter* NextParm = NextHAC->GetParameterAt(n);. We can circumvent this problem by adding !NextHAC->IsValidLowLevel() to the If performed for the continue (line #229), and then fixing a bad check from a different function to include MainHAC->IsPendingKill() which is missing.

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"

#include "HoudiniPublicAPIAssetWrapper.h"
#include "HoudiniPublicAPI.h"
#include "HoudiniPublicAPIBlueprintLib.h"

#include "TestHoudiniActor.generated.h"

UCLASS()
class ATestHoudiniActor : public AActor
{
    GENERATED_BODY()

public:
    UPROPERTY(EditAnywhere, meta =
        (DisplayName = "Houdini Asset"))
    UHoudiniAsset* HDAToLoad;

protected:
    void BeginPlay() override;

private:
    UPROPERTY()
    UHoudiniPublicAPIAssetWrapper* Asset;
};

inline void ATestHoudiniActor::BeginPlay()
{
    Super::BeginPlay();
    UHoudiniPublicAPI* const HoudiniApi = UHoudiniPublicAPIBlueprintLib::GetAPI();
    Asset = HoudiniApi->InstantiateAsset(HDAToLoad, GetActorTransform(), GetWorld(), nullptr, true);
}