Not sure if I’m just doing something wrong here, but on Windows, in Unreal Engine 5.4, if I attempt to make any changes to my mesh, UOctreeDynamicMeshComponent::NotifyMeshUpdated
will early return, because the UOctreeDynamicMeshComponent::GetCurrentSceneProxy
check always fails.
I’ve set some breakpoints to confirm that UOctreeDynamicMeshComponent::CreateSceneProxy
was called. It seems as if the address is changing from the point it is created and the point GetCurrentSceneProxy
is called.
I thought there may have been a problem with the UPrimitiveComponent::SceneProxy
assignment after CreateSceneProxy was called, so I tried retrieving it from SceneData::GetSceneProxy
in NotifyMeshUpdated
. A pointer exists at that point, but the cast to FOctreeDynamicMeshSceneProxy*
seems to fail.
I’m editing the mesh through EditMesh
, which calls NotifyMeshUpdated
itself. I’ve tried a handful of things, such as moving the logic to Tick
, and marking the render state as dirty every frame, just to see if I can get it to work in any way, to no luck.
My minimal reproduction is:
OctreeDynamicMeshComponent->GetDynamicMesh()->EditMesh(
[](FDynamicMesh3& MeshToChange)
{
MeshToChange.Clear();
int Vertex0 = MeshToChange.AppendVertex(*new FVector3d(0.0, 0.0, 0.0));
int Vertex1 = MeshToChange.AppendVertex(*new FVector3d(100.0, 0.0, 0.0));
int Vertex2 = MeshToChange.AppendVertex(*new FVector3d(0.0, 100.0, 0.0));
int Triangle = MeshToChange.AppendTriangle(Vertex0, Vertex1, Vertex2);
if (Triangle > -1)
{
UE_LOG(LogTemp, Display, TEXT("Valid Triangle created"));
}
UE::Geometry::FMeshNormals::QuickComputeVertexNormals(MeshToChange);
},
EDynamicMeshChangeType::GeneralEdit
);
OctreeDynamicMeshComponent->MarkRenderStateDirty();
if (Material)
OctreeDynamicMeshComponent->SetMaterial(0, Material);
I’ve tried looking around to see if I’m maybe just misusing it, but the only thing I’ve come across is a post from 2022 where someone was running into a similar problem as me, where the SceneProxy was always null: How do you use a UOctreeDynamicMeshComponent?