SplineMeshComponent rendering unreliable after post-construction script editing

I have a c++ source file combined with blueprints that creates a spline road in the construction script. I have found the rendering unreliable however. The only guaranteed way to show the meshes is via the Standalone Game.

I have tried forcing visilibity of meshes, MarkRenderStateDirty(), UpdateSpline() and registering each SplineMesh seperately as grouped.

Here is the process.

  1. Add blueprint.
  2. Play in PIE. Usually shows the meshes.
  3. Stop and edit a spline point or world position of the spline component.
  4. This will stop the meshes rendering in PIE/NewWindow. In simulate mode the spline is shown with edits included but no meshes.
  5. Start a standalone game. This shows the mesh.
  6. Most times when starting in PIE after standalone, the mesh will show. However not always.

Here is a video I made to show the problem.

HI Doublezer0,

I attempted to reproduce this in 4.9.2 but I couldn’t get your results. Would you be able to upload a small test project that has the issue?

Sure I will post one in the morning. Thanks

Hey. Sorry it took so long. I tried to move the blueprint to another project and it failed hard with reparenting. So I just cloned my project and removed some of the unused assets. The project has an instance of the BP_KMLSpline already in the map but if you want to test adding/removing you can find it in the Blueprints folder.

Test Project Rar

Hey Doublezer0-

I found that in the case of the mesh not appearing properly during PIE, if you let PIE run for ~10 seconds before exiting that the mesh will appear the next time you PIE. To help investigate further could you point out where in your code the spline mesh is being created?


This all happens in the KMLSpline.cpp.

First I add a component to attach to a scene component in the Constructor.
PathSpline = CreateDefaultSubobject(TEXT(“Path”));

After some maths I then create the pline points in the BuildSplinePathFromVectors() function.

At the end of this function I make sure I force the spline to be editable within the viewport as these functions are called from c++ source via blueprints.
PathSpline->bSplineHasBeenEdited = true;

Once this is all done I build the SplineMeshComponents in a function.
USplineMeshComponent* SplineMesh = NewObject(this, USplineMeshComponent::StaticClass());

I flag the meshes for cleanup with :
SplineMesh->CreationMethod = EComponentCreationMethod::UserConstructionScript;

Once all meshes are defined in the loop I make sure I end the function with :

Hi Doublezer0,

We have looked through your project and we believe the issue could have something to do with the changes to the spline points not being saved over the values from the KML file during PIE. Do you have any code or scripting that does this, that we missed?

We are also thinking it could be a load order issue in PIE vs Standalone mode.

Everything is within the KMLSpline.cpp. What happens is:

  1. I load the KML data (func LoadKmlFile).
  2. I parse the data to vectors ( func ParseKmlNodeToVectors )
  3. I build the spline points from the data ( func BuildSplinePathFromVectors )
  4. The data is stored as a struct in an array of structs ( KmlSplineDataStruct )
  5. I then build the splinemeshcomponents (func BuildSplineStaticMesh)

The splinemeshcomponents are all built from data stored in the structs which reflects what is in the editor as the construction script updates the structs with the current spline data (location, roll, scale, mesh). The KML data is only retrieved once at the start where the data is then stored within the array of structs. I don’t use any save method such as the built-in save game YET. I have plans for this once I have all the data I need but it’s not necessary unless you want to move a post-edited spline to another map or save your progress as you go to a file rather that within the map only.

It was my impression that something was happening during the Standalone load that was updating the SceneProxy which was not happening during a PIE load. I tried marking the spline as dirty to update the render data but it did nothing.
Something I might add is that my data stored in the structs is a reflection of the spline’s RenderData which I see in the SplineComponent.cpp is an internal storage system. I had thought about updating that instead of adding to my own struct and rebuilding every construction tick but my method allows for adding custom data later on, such as extending the struct and adding new functionality without breaking the epic source.

If you need anymore information I will endeavour to get back to you asap.
Thanks for the assistance so far.

Hi Marc,

I created JIRA UE-21922 for your issue and our developers will be investigating the issue further. We will post back here with updates and/or questions as we have them.



Thanks. Is there somewhere I can view the status of the issue?

We don’t currently have JIRA information available to the public but this is something we would like to implement in the future.

For now if you would like an update, just post here and AnswerHub will send me a notification.