x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Spawn SceneCapture Crashes Game

Here is the code im using to spawn a scene capture actor. I want each scene capture to render to a texture which I can use in code for calculations.

 #include "SensorMountedVehicle.h"
 #include "Components/SceneCaptureComponent2D.h"
 #include "Engine/SceneCapture2D.h"
 #include "Blueprint/UserWidget.h"
 #include "Blueprint/UserWidget.h"
 #include "Engine/World.h"
 #include "Engine/EngineTypes.h"
 #include "TextureResource.h"
 #include "Engine/TextureRenderTarget2D.h"
 #include "InputCoreTypes.h"
 #include "Styling/SlateBrush.h"
 #include "ConstructorHelpers.h"
 #include "TextFormatter.h"
 
 void ASensorMountedVehicle::BeginPlay()
 {
     Super::BeginPlay();
     UE_LOG(LogTemp, Error, TEXT("NumSensor: %d"), sensors.Num());
     sensorRenderTargets.Reset();
     for (auto& sensor : sensors) {
         auto s = sensor.GetDefaultObject();
         UE_LOG(LogTemp, Error, TEXT("%f %f %f %f, %f %f %f, %f %f %f, %d"), 
             s->rot_x, s->rot_y, s->rot_z, s->rot_w, s->scale_x, s->scale_y, s->scale_z,
             s->trans_x, s->trans_y, s->trans_z, (int)s->type.GetValue()
         );
 
         ASceneCapture2D *sceneCaptureActor = (class ASceneCapture2D *)GetWorld()->SpawnActor<ASceneCapture2D>(ASceneCapture2D::StaticClass());
         if (sceneCaptureActor) {
             sceneCaptureActor->AttachToComponent(this->GetRootComponent(), FAttachmentTransformRules::KeepRelativeTransform);
             FTransform trans = FTransform(
                 FQuat(s->rot_x, s->rot_y, s->rot_z, s->rot_w),
                 FVector(s->scale_x, s->scale_y, s->scale_z),
                 FVector(s->trans_x, s->trans_y, s->trans_z)
             );
             sceneCaptureActor->AddActorWorldTransform(trans);
 
             auto *captureComponent = sceneCaptureActor->GetCaptureComponent2D();
             captureComponent->FOVAngle = 90.0;
             captureComponent->ProjectionType = ECameraProjectionMode::Perspective;
             UTextureRenderTarget2D *renderTarget2D = NewObject<UTextureRenderTarget2D>();
             sensorRenderTargets.Add(captureComponent->TextureTarget);
             captureComponent->TextureTarget = renderTarget2D;
 
             //sceneCaptureActor->bCaptureOnMovement = false;
             //sceneCaptureActor->bCaptureEveryFrame = false;
             //sceneCaptureActor->MaxViewDistanceO.verride = -1.0f;
             captureComponent->bAutoActivate = true;
             captureComponent->DetailMode = EDetailMode::DM_High;
             switch (sensor.GetDefaultObject()->type) {
             case SensorType::RADAR:
                 UE_LOG(LogTemp, Error, TEXT("Found Radar"));
                 captureComponent->CaptureSource = SCS_SceneColorHDR;
                 break;
             case SensorType::LIDAR:
                 UE_LOG(LogTemp, Error, TEXT("Found Lidar"));
                 captureComponent->CaptureSource = SCS_SceneDepth;
                 break;
             default:
                 UE_LOG(LogTemp, Error, TEXT("Sensor config has unknown type"));
                 break;
             }
 
             //sceneCaptureActor->RegisterComponent();
             mountedSensors.Add(sceneCaptureActor);
         }
         else {
             UE_LOG(LogTemp, Error, TEXT("SceneCapture loaded is null"));
         }
     }
 }
 
 ASensorMountedVehicle::~ASensorMountedVehicle()
 {
     for (auto& sensor : mountedSensors) {
         delete sensor;
     }
 }
 

When running, this causes the entire editor to crash with the following output

 Assertion failed: UnscaledViewRect.Width() > 0 [File:D:\Build\++UE4+Release-4.18+Compile\Sync\Engine\Source\Runtime\Engine\Private\SceneView.cpp] [Line: 646]
 
 UE4Editor_Core!FDebug::AssertFailed() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\core\private\misc\assertionmacros.cpp:414]
 UE4Editor_Engine!FSceneView::FSceneView() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\engine\private\sceneview.cpp:647]
 UE4Editor_Renderer!CreateSceneRendererForSceneCapture() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\renderer\private\scenecapturerendering.cpp:421]
 UE4Editor_Renderer!CreateSceneRendererForSceneCapture() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\renderer\private\scenecapturerendering.cpp:537]
 UE4Editor_Renderer!FScene::UpdateSceneCaptureContents() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\renderer\private\scenecapturerendering.cpp:582]
 UE4Editor_Engine!USceneCaptureComponent::UpdateDeferredCaptures() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\engine\private\components\scenecapturecomponent.cpp:408]
 UE4Editor_Renderer!FRendererModule::BeginRenderingViewFamily() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\renderer\private\scenerendering.cpp:2257]
 UE4Editor_Engine!UGameViewportClient::Draw() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\engine\private\gameviewportclient.cpp:1278]
 UE4Editor_Engine!FViewport::Draw() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\engine\private\unrealclient.cpp:1213]
 UE4Editor_UnrealEd!UEditorEngine::Tick() [d:\build\++ue4+release-4.18+compile\sync\engine\source\editor\unrealed\private\editorengine.cpp:1862]
 UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [d:\build\++ue4+release-4.18+compile\sync\engine\source\editor\unrealed\private\unrealedengine.cpp:396]
 UE4Editor!FEngineLoop::Tick() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\launch\private\launchengineloop.cpp:3296]
 UE4Editor!GuardedMain() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\launch\private\launch.cpp:166]
 UE4Editor!GuardedMainWrapper() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:134]
 UE4Editor!WinMain() [d:\build\++ue4+release-4.18+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:210]
 UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253]
 kernel32
 ntdll

Not sure whats happening

Product Version: UE 4.18
Tags:
more ▼

asked Mar 08 '18 at 03:56 AM in C++ Programming

avatar image

lufthansa747
3 1 3 8

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question