Why is Procedural Mesh CreateMeshSection_LinearColor crashing my game?

I am currently trying to move the use of ProceduralMeshComponent->CreateMeshSection() from blueprint to a C++ class so that I can put it into it’s own thread rather than the Main Thread.

I realized in C++ you have to use the CreateMeshSection_LinearColor method for some reason. I end up getting some sort of component instance does not exist error if I try calling CreateMeshSection()

Here is the code that I’m trying to run.

void RenderProceduralMeshTask::DoWork()
{
	
	for (size_t i = 0; i < (&MeshInfoArray)->Num(); i++)
	{
		FFcrmMeshInfo MeshInfo = MeshInfoArray[i];

		try
		{
			MeshComponent->CreateMeshSection_LinearColor(i, MeshInfo.Vertices, MeshInfo.Triangles, MeshInfo.Normals, MeshInfo.UV0, MeshInfo.VertexColors,
				MeshInfo.Tangents, true);
		}
		catch (int error)
		{
			UE_LOG(LogTemp, Error, TEXT("CREATE MESH ERROR:::: %d"), error);
		}

	
	}
}

The Errors I receive are the following and I should also mention that this Crashes the editor when running this.

[2020.09.04-11.34.28:068][402]LogPhysics: Warning: Scale for /Game/Maps/UEDPIE_0_FcrmMeshViewer.FcrmMeshViewer:PersistentLevel.BP_MeshLoader_2.ProceduralMesh has a component set to zero, which will result in a bad body instance. Scale:X=0.000 Y=0.000 Z=0.000
[2020.09.04-11.34.28:068][402]LogPhysics: Warning: Initialising Body : Scale3D is (nearly) zero: Component: '/Game/Maps/UEDPIE_0_FcrmMeshViewer.FcrmMeshViewer:PersistentLevel.BP_MeshLoader_2.ProceduralMesh' 
[2020.09.04-11.34.28:076][402]LogTemp: Error: FNAME IS GOOD
[2020.09.04-11.34.28:076][402]LogTemp: Error: The array count is : 1
[2020.09.04-11.34.28:076][402]LogTemp: Warning: Start Thread
[2020.09.04-11.34.28:085][402]LogTemp: Warning: Task Finised
[2020.09.04-11.34.28:085][402]LogTemp: Error: DOWORK() FNAME IS GOOD
[2020.09.04-11.34.28:085][402]LogTemp: Warning: DoWork() 770496
[2020.09.04-11.34.28:085][402]LogScript: Warning: Script Msg: Divide by zero: Divide_VectorVector
[2020.09.04-11.34.28:086][402]LogBlueprintUserMessages: [BP_MeshLoader_2] Path Good
[2020.09.04-11.34.28:659][437]LogStats: FPlatformStackWalk::StackWalkAndDump -  0.538 s
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: === Handled ensure: ===
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: 
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: Ensure condition failed: GetShadowIndex() == 0 [File:D:\Build\++UE4+Licensee\Sync\Engine\Source\Runtime\Core\Public\HAL/IConsoleManager.h] [Line: 1262]
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: 
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: Stack: 
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: [Callstack] 0x00007fff6059b969 UE4Editor-Engine.dll!UnknownFunction []
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: [Callstack] 0x00007fff5f5c75d4 UE4Editor-Engine.dll!UnknownFunction []
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: [Callstack] 0x00007fff3845fa33 UE4Editor-ProceduralMeshComponent.dll!UnknownFunction []
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: [Callstack] 0x00007fff3845fd7b UE4Editor-ProceduralMeshComponent.dll!UnknownFunction []
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: [Callstack] 0x00007fff3845fe2a UE4Editor-ProceduralMeshComponent.dll!UnknownFunction []
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: [Callstack] 0x00007fff27e13e3a UE4Editor-FcrmMeshLoader.dll!RenderProceduralMeshTask::DoWork() [C:\Users\FcrmMeshLoaderUtil.cpp:77]
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: [Callstack] 0x00007fff27e1363f UE4Editor-FcrmMeshLoader.dll!FAutoDeleteAsyncTask<RenderProceduralMeshTask>::DoWork() [C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Core\Public\Async\AsyncWork.h:100]
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: [Callstack] 0x00007fff687562ed UE4Editor-Core.dll!UnknownFunction []
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: [Callstack] 0x00007fff68b2025b UE4Editor-Core.dll!UnknownFunction []
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: [Callstack] 0x00007fff68b17c30 UE4Editor-Core.dll!UnknownFunction []
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: [Callstack] 0x00007fffd4e67bd4 KERNEL32.DLL!UnknownFunction []
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: [Callstack] 0x00007fffd652ce51 ntdll.dll!UnknownFunction []
[2020.09.04-11.34.28:659][437]LogOutputDevice: Error: 
[2020.09.04-11.34.28:659][437]LogStats:                SubmitErrorReport -  0.000 s
[2020.09.04-11.34.31:124][441]LogStats:                    SendNewReport -  2.469 s
[2020.09.04-11.34.31:124][441]LogStats:             FDebug::EnsureFailed -  3.008 s
[2020.09.04-11.34.31:124][441]LogWindows: Windows GetLastError: The operation completed successfully. (0)
1 Like