NegInfinity / ProjectExodus

Project Exodus - Unity to Unreal scene/project transfer tool.
BSD 3-Clause "New" or "Revised" License
497 stars 100 forks source link

Unreal Engine Crash #9

Open stratakos11 opened 5 years ago

stratakos11 commented 5 years ago

So i have a problem while importing JSON file on unreal engine.Here i upload my Json file,so u can have a look when u have time.https://drive.google.com/file/d/1rrHms5e_bMCT92SGdeYPpT8NGy2KnDlI/view

Thanks for providing us this awsome plugin for free <3 Much Love from Sparta

NegInfinity commented 5 years ago

Hi.

Apologies for the late reply. Your file/link requires access permissions. Please either gran permissions, or upload it somewhere where I can access it. (dropbox, mega, etc)

stratakos11 commented 5 years ago

https://mega.nz/#!EWgClabR!KrPuJGp8ONu-Nea2HjLcVAS0GZsKaMR6EGi8ZUGRmLM

ericblade commented 5 years ago

unityconvert.zip

@NegInfinity Here's one that crashes also. It's crashing on static mesh import. I can pretty much guarantee that my source geometry is broken in some way or another, which causes it to end up all funky when you try to import it to Unreal.

I traced it back to actually calling mesh->Build() in MeshBuilder/StaticMesh.cpp ..

The code fails here

    TArray<FText> buildErrors;
    mesh->Build(false, &buildErrors); // here
    if (buildErrors.Num() > 0){

when you're calling into Engine MeshDescriptionOperations.cpp FMeshDescriptionOperation::CreatePolygonNTB(..)

            for (int32 i = 0; i < 3; ++i)
            {
                const FVertexInstanceID VertexInstanceID = MeshTriangle.GetVertexInstanceID(i);
                UVs[i] = VertexUVs.Get(VertexInstanceID, 0); // UV0
                P[i] = VertexPositions[MeshDescription.GetVertexInstanceVertex(VertexInstanceID)];
            }

The crash is an assert at the UVs[i] = VertexUVs.Get(VertexInstanceID, 0);

My temporary? fix for this is to return early out of your MeshBuilder::setupStaticMesh() function, at the bottom of the if (!valid) check:

    UE_LOG(JsonLog, Log, TEXT("Mesh is valid: %d, mesh is validOrFixable: %d"), (int)valid, (int)fixable);
    if (!valid){
        UE_LOG(JsonLog, Warning, TEXT("Mesh is not valid!"));
        if (!fixable){
            UE_LOG(JsonLog, Warning, TEXT("Mesh is not fixable!"));
        }
        UE_LOG(JsonLog, Warning, TEXT("Unable to continue with %s"), *mesh->GetName());
        return;
    }

I do not know if that is the correct way to solve this problem, nor exactly how I would put together a small enough testcase to file a good bug with Epic on it -- because, IMO, their code shouldn't crash there, but it do.

NegInfinity commented 5 years ago

@ericblade Thanks for the report and sorry for the late reply.

It seems the mesh in question has no UV coordinates, and the engine expects it to be present. I'll write some sort of workaround for that.

ericblade commented 5 years ago

great -- i'm not sure what the proper fix for it is .. i don't know specifically which mesh that it's breaking on, but you have the source data files there. I can try to provide some info about what it is from Unity, if that helps at all.

Epic's support said basically "not our problem, but thanks for the bug report, it may end up fixed in the future, in the meantime file a bug with the plugin" :-)

Although 3 of my 4 scenes that I imported from Unity did have this problem, I have a lingering problem with ONE Unreal map that was a convert, that I'm not sure if there's some way to fix from the Unreal side, or what.

I get an error here in StaticMesh.cpp checkf(Owner->IsMeshDescriptionValid(0), TEXT("Bad MeshDescription on %s"), *GetPathNameSafe(Owner) in FStaticMeshRenderData::Cache

when attempting to load one of the converted maps. The 3 other maps I converted, despite some having this crash problem with the weird geometry, do not have a failure when trying to load. Interestingly, I can hit "Continue" in Visual Studio, and it will successfully load the map.

NegInfinity commented 5 years ago

@ericblade I pushed a simple fix for the crash, right now, Pull from master see if it works for you. I was able to load your test data into the engine this way.

The proper fix would be either generating UVs automatically or looking whether there's automatic UV generation somewhere deep within the unreal engine. So far I haven't found that, but might've overlooked it.

NegInfinity commented 5 years ago

@ericblade Additionally, when running into problems with this plugin, do report them here. I'm currently maintaining the plugin, so I'll be responding to the bug reports and the like.

ericblade commented 5 years ago

I'd say that this was far more successful than my solution -- i have a bunch of different items now in my import that i didn't even realize were in the exported level. AND it doesn't try to kill the editor when I load the map. very good, thank you!