I wrote a plugin to get the frame of the camera.
I use FViewFamily and Canvas via GetRendererModule().BeginRenderingViewFamily(&Canvas, &ViewFamily); to render the picture.
Take FMinimalViewInfo via CameraComponent->GetCameraView and pass it to OverridePostProcessSettings to set the post-processing settings, but when I modify the scene and then save, or delete some actors in the scene, the whole UE crashes.
Some of the codes are as follows:
In Tick:
CameraComponent->GetCameraView(DeltaTime, ViewInfo);
if (!ViewState.GetReference()) {
FSceneInterface* SceneInterface = GetScene();
const ERHIFeatureLevel::Type FeatureLevel = World->FeatureLevel.GetValue();
ViewState.Allocate(FeatureLevel);
}
FSceneViewInitOptions ViewInitOptions;
ViewInitOptions.SceneViewStateInterface = ViewState.GetReference();
FSceneView* SceneView = new FSceneView(ViewInitOptions);
SceneView->StartFinalPostprocessSettings(ViewInitOptions.ViewOrigin);
SceneView->PreviousViewTransform = ViewInfo.PreviousViewTransform;
SceneView->OverridePostProcessSettings(ViewInfo.PostProcessSettings, ViewInfo.PostProcessBlendWeight);
for (int32 ExtraPPBlendIdx = 0; ExtraPPBlendIdx < ExtraPostProcessBlends.Num(); ++ExtraPPBlendIdx) {
FPostProcessSettings const& PPSettings = ExtraPostProcessBlends[ExtraPPBlendIdx];
float const Weight = ExtraPostProcessBlendWeights[ExtraPPBlendIdx];
SceneView->OverridePostProcessSettings(PPSettings, Weight);
}
SceneView->EndFinalPostprocessSettings(ViewInitOptions);
Why did such a crash occur and what should be done about it.