Is it possible for Bake lighting commandlet to detect whether a bake is needed or not? (UE 4.27)

We bake lights automatically every night for many of our levels - it results in a hug perforce sync for everyone every morning. I have been wondering if it is possible for the commandlet to detect whether a light bake is actually needed? If not, it could just exit. I tried the following, but it seems to always think a bake is not needed. I am not familiar enough with level loading and commandlets to know if this is possible. In the editor, there is a message onscreen indicating that a bake is needed - I was thinking to check the same indicators that that message uses to know if a bake is needed, inside the commandlet. Namely, (World->NumLightingUnbuiltObjects > 0). But in the commandlet it appears that NumLightingUnbuiltObjects is always 0...

Anyone know if this is possible and how I might go about doing it?

Thank you!

in UResavePackagesCommandlet::PerformAdditionalOperations:

  if (bShouldBuildLighting)

  {

    GetRendererModule().UpdateMapNeedsLightingFullyRebuiltState(World);

    bool bNeedBake \= (World\-\>NumLightingUnbuiltObjects \> 0\);

    // also check for dirty packages

    for (TActorIterator\<ANavigationData\> It(World); It; \+\+It)

    {

      UPackage\* Package \= It\-\>GetOutermost();

      if (Package !\= nullptr \&\& Package\-\>IsDirty() \&\& !Package\-\>HasAnyFlags(RF\_Transient))

      {

        bNeedBake \= true;

        break;

      }

    }



    // Skip bake if lighting already up\-to\-date

    if (bNeedBake)

    {

… do the bake

}

else {

.. not needed, can skip it

}

Hello,

Thank you for reaching out.

I’ve been assigned this issue, and we will be looking into this modification for you.

Hello,

It is possible that the Render Thread has not yet finished processing the scene and updating it.

You can try calling “FlushRenderingCommands()” before calling “UpdateMapNeedsLightingFullyRebuiltState(…)” to wait for the data used by “UpdateMapNeedsLightingFullyRebuiltState(…)” to be updated by the Render Thread.

For engine modifications like this, we can offer information about existing functionality, and we leave the details of the implementation to you.

Please let us know if this helps.

Can we leave this open for a few more days?

Yes using the flush did work - thanks!

Ah I missed this post, thanks - I will try this!

Hello,

Thank you for the reply. This question will remain open for several more days after our response. If there is no further activity, it will automatically be closed by the system.

Please feel free to re-open the ticket by responding if you need further assistance with this issue or you can open a new ticket referencing this one.

Hello,

Thank you for the reply.

Can we now close your case? You can always re-open it if you find you need additional assistance for the same issue.

Yes, you can close it - thanks!