Is there a way to abort the UVAtlasCreate operation if it is taking too long?

Apr 22, 2015 at 2:34 PM
For some models (200K+ polygons) the operation may around 20 minutes, so what would be the appropriate way to abort the operation?

Notice, I have the latest update (April 2015), using a core i5, 8G ram

Many thanks in advance,
Hasan
Coordinator
Apr 22, 2015 at 6:08 PM
Edited Apr 22, 2015 at 6:38 PM
It should abort if your statusCallback returns a failed HRESULT. It looks like there's a bug if you just return E_ABORT once, but if your callback handler goes into a failure mode once and stays there, it will abort.
HRESULT __cdecl UVAtlasCallback( float fPercentDone  )
{
    static ULONGLONG s_lastTick = 0;
    static bool s_abort = false;

    ULONGLONG tick = GetTickCount64();

    if ( ( tick - s_lastTick ) > 1000 )
    {
        wprintf( L"%.2f%%   \r", fPercentDone * 100 );
        s_lastTick = tick;
    }

    if ( !s_abort && _kbhit() )
    {
        if ( _getch() == 27 )
        {
            wprintf(L"*** ABORT ***");
            s_abort = true;
        }
    }

    return s_abort ? E_ABORT : S_OK;
}
Of course, this assumes you just exit your program when you abort which is not necessarily what you want to do here. I'll take a look as to why it has to be a stateful abort (workitem 1292).
Marked as answer by has981 on 4/23/2015 at 12:51 AM
Apr 23, 2015 at 7:51 AM
Thanks walbourn for your response,

I noticed in workitem referenced that fix was made by adding checking for result of status callback,

So would that be safe to do in my local copy (i.e., check for schemer result and return hr upon failure everywhere), or there would be pitfalls I should be aware of?

Hasan
Coordinator
Apr 23, 2015 at 6:13 PM
The workaround above will work without any updates to the library.