sideeffects / HoudiniEngineForUnreal

Houdini Engine Plugin for Unreal Engine.
http://www.sidefx.com/unreal
Other
1.36k stars 374 forks source link

Unable to cook HDA after PIE session #159

Open haowang1013 opened 2 years ago

haowang1013 commented 2 years ago

Hi,

The plugin has a bug that the Houdini engine ticking is not resumed after PIE, which makes it impossible to cook/build any HDAs afterwards.

Repro steps:

  1. Start the editor, then start PIE immediately.
  2. Close PIE, try to cook/build any HDAs in the project.
  3. Nothing happens.

The bug is in

void FHoudiniEngineEditor::RegisterEditorDelegates()
{
    ...
    if (FHoudiniEngine::Get().IsTicking())
    {
        const bool bWasConnected = FHoudiniEngine::Get().GetSessionStatus() == EHoudiniSessionStatus::Connected;
        EndPIEEditorDelegateHandle = FEditorDelegates::EndPIE.AddLambda([&, bWasConnected](const bool bEndPIEIsSimulating)
        {
            if (bWasConnected)
            {
                // If the Houdini session was previously connected, we need to reestablish the connection after PIE.
                // We need to restart the current Houdini Engine Session
                // This will reuse the previous session if it didnt shutdown, or start a new one if needed.
                // (HARS shuts down when stopping the session, so we cant just reconnect when not using Session Sync)
                FHoudiniEngineCommands::RestartSession();
            }
#if 1
            else
            {
                FHoudiniEngine::Get().StartTicking();               
            }
#endif
            FEditorDelegates::EndPIE.Remove(EndPIEEditorDelegateHandle);
        });
    }   
}

So if the houdini engine wasn't connected before PIE, bWasConnected will be false and the plugin will never attempt to resume the ticking when PIE ends. The part within the #if 1/#endif section is my fix and I can veirfy it works.