How to set APostProcessVolume Brush Settings in C++?

I have an update. I found a post that fixed the linker error I mentioned in the “Spawn new Box Brush in C++” post by mortmaire

I needed to include “UnrealEd” to the Build.cs PublicDependencyModuleNames

Source:

Including that dependency in the build.cs file broke some other files I had due to undefined identifiers, but after including the appropriate headers that was fixed. Not sure why those errors only surfaced after the new additions to build.cs.

Anyway, the PPV Brush Settings do appear now, but even with a cube size of 5000, 5000, 5000 and spawning directly on top of the mesh I want highlighted it does not highlight. Setting the unbound flag at runtime will highlight the mesh, so I know that the PPV highlighting itself is working, just the volume aspect of it is not working. Here is the updated portion of the UHighlightManager::HighlightMesh function where I make a brush and attempt to set it to the PPV.

        //Spawn the PPV
        APostProcessVolume* PPV = (APostProcessVolume*)(CurrentWorld->SpawnActor(APostProcessVolume::StaticClass(), &MeshToToggle->GetComponentTransform()));

        //Fill PPV with highlights
        FillWeightedBlendables(PPV);

        //PPV->bUnbound = true;
        PPV->SpawnCollisionHandlingMethod = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;

        //Create cube volume
        UCubeBuilder* CubeAdditiveBrushBuilder = Cast<UCubeBuilder>(GEditor->FindBrushBuilder(UCubeBuilder::StaticClass()));
        CubeAdditiveBrushBuilder->X = 5000.0f;
        CubeAdditiveBrushBuilder->Y = 5000.0f;
        CubeAdditiveBrushBuilder->Z = 5000.0f;
        CubeAdditiveBrushBuilder->Build(CurrentWorld);

        //Create the brush
        ABrush* NewBrush = CurrentWorld->SpawnBrush();
        //PPV->BrushBuilder = NewObject<UBrushBuilder>(NewBrush, UCubeBuilder::StaticClass(), NAME_None, RF_Transactional);
        PPV->BrushBuilder = CubeAdditiveBrushBuilder;
        PPV->Brush = NewObject<UModel>(NewBrush, NAME_None, RF_Transactional);
        PPV->Brush->Initialize(NewBrush, false);
        PPV->BrushType = EBrushType::Brush_Add;
        PPV->BrushBuilder->Build(NewBrush->GetWorld(), NewBrush);
        //PPV->SetNeedRebuild(NewBrush->GetLevel());
        //GEditor->RebuildAlteredBSP(); //causes a crash, not sure if necessary or I'm doing something wrong.

        NewHighlight.PPV = PPV;

        Highlights.Add(NewHighlight);

Furthermore, I found another problem. I tried turning off the unbound flag on the manually created PPV that I was initially testing with and then I moved it on top of the object I was trying to highlight. When I toggled the highlight nothing happened. I then ejected the camera at runtime so I could get closer to the object and when I got closer the highlighting turned on. I then realized that for me to be able to see the highlighting the camera AND the object I am highlighting BOTH need to be in side the PPV volume.

This brings me to the realization that even IF I figured out how to spawn smaller PPVs on the different limbs I want to highlight, I wouldn’t be able to see the highlighting because the camera is not inside the PPV volume.

Technically, I could turn all those PPV volumes into narrow cylinders the ends of which intersect the object I am highlighting and the camera so I am looking at each object through it’s own individual PPV cylinder pipe that dynamically repositions to track the camera, but that sounds insane.

There has to be a better method than PPVs to be able to highlight multiple limbs of a mesh, simultaneously, with different colors. If anyone knows a good solution to this, please share your arcane knowledge.