Initial Version

First version of our quickfix.

Work by hooking the FHZBOcclusionTester::AddBounds method from unreal engine.

This method contains a check on the number of primitives being loaded to be smaller then 65536 :uint32 FHZBOcclusionTester::AddBounds( const FVector& BoundsCenter, const FVector& BoundsExtent ) { uint32 Index = Primitives.AddUninitialized(); check( Index < SizeX * SizeY ); Primitives[ Index ].Center = BoundsCenter; Primitives[ Index ].Extent = BoundsExtent; return Index; }

( SizeX and SizeY being enums defined in SceneRendering.h, with values of 256 )

When the check is failed, a crash directly occurs.

This is mitigated by checking if that limit is gonna be reached, and if so, drop one of the items and replace it with the item to be added. This means that the items over that maximum count won't be displayed ( you might see random items or ground textures appearing and disappearing when the bug should occur, but we consider it a minor disagreement )

The hooking code looks like this :

        void UOcclusionBugRemover::registerHooks() {
SUBSCRIBE_METHOD_MANUAL("[email protected]@@[email protected]@[email protected]", FHZBOcclusionTester::AddBounds, [](auto& scope, FHZBOcclusionTester* self, const FVector& BoundsCenter, const FVector& BoundsExtent) {
    uint32 Index;

    if (self->Primitives.Num() >= FHZBOcclusionTester::SizeX * FHZBOcclusionTester::SizeY -1 )
    {
        //self->Primitives.Empty();
        Index = self->Primitives.Num();
        self->Primitives[Index].Center = BoundsCenter;
        self->Primitives[Index].Extent = BoundsExtent;
        scope.Override(Index);
        return Index;
    }
    else
    {
        Index = self->Primitives.AddUninitialized();
        self->Primitives[Index].Center = BoundsCenter;
        self->Primitives[Index].Extent = BoundsExtent;
        scope.Override(Index);
        return Index;
    }
    })

}

Note : there is a rather high probability that this will be broken by the next big update of satisfactory Note2 : we will investigate if SizeX and SizeY values can be increased to avoid glitching items, but that will be for another day

Info

Created: Oct 9, 2020, 4:11:46 AM