Reflected materials on reflected scene graph mesh components are incorrectly initialized

Summary

Reflected materials on reflected mesh components (scene graph) cannot be casted to the expted material subclass.

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Other

Steps to Reproduce

  • Create a custom material like m_custom_material (with at least one parameter) and a custom mesh like sm_custom_mesh.

  • Configure the material slot of the mesh to be m_custom_material.

  • Compile verse in a SG project to reflect them.
  • Create a custom component like the following:
using { /UnrealEngine.com/Temporary/SceneGraph }
using { /Verse.org/Simulation }

vz_test_reflected_material_component := class<final_super>(component) {
  OnBeginSimulation<override>(): void = {
    (super:)OnBeginSimulation()

    if (MeshComponent := Entity.GetComponent[mesh_component]) {
      if (ReflectedMeshComponent := sm_custom_mesh[MeshComponent]) {
        Print(ToDiagnostic(ReflectedMeshComponent.CustomMaterial))
        if (CustomMaterial := m_custom_material[ReflectedMeshComponent.CustomMaterial]) {
          Print("Material can be casted")
        } else {
          Print("Material can NOT be casted")
          Print("Overriding the material manually")
          set ReflectedMeshComponent.CustomMaterial = m_custom_material {}
        }
        Print(ToDiagnostic(ReflectedMeshComponent.CustomMaterial))
      } else {
        Print("Wrong mesh component")
      }
    }
  }
}
  • Add an entity to the scene that uses the custom mesh and add the custom component to it.

  • Run the simulation.

Here are the logs:

Assets_material /...-c1ab874f1c0b/vz_experiments_LevelInstance_3.vz_experiments:PersistentLevel.LevelEntity.LevelEntity.Entity.experiment_6-sm_custom_mesh_0.__verse_0x793F222D_CustomMaterial ❌UNEXPECTED
Material can NOT be casted ❌UNEXPECTED
Overriding the material manually
experiment_6-m_custom_material /...-c1ab874f1c0b/vz_experiments_LevelInstance_3.vz_experiments:PersistentLevel.LevelEntity.LevelEntity.experiment_6-m_custom_material_2147482645

Expected Result

The cast should succeed.

Observed Result

The cast should not fail.

Platform(s)

UEFN (v34.00)