Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions Unreal/Plugins/AirSim/Source/CameraDirector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,21 +344,7 @@ void ACameraDirector::notifyViewModeChanged()
{
bool nodisplay = ECameraDirectorMode::CAMERA_DIRECTOR_MODE_NODISPLAY == mode_;

if (fpv_camera_)
fpv_camera_->onViewModeChanged(nodisplay);
if (backup_camera_)
backup_camera_->onViewModeChanged(nodisplay);
if (ExternalCamera)
ExternalCamera->onViewModeChanged(nodisplay);
if (front_camera_)
front_camera_->onViewModeChanged(nodisplay);

UWorld* world = GetWorld();
UGameViewportClient* gameViewport = world->GetGameViewport();
if (mode_ == ECameraDirectorMode::CAMERA_DIRECTOR_MODE_NODISPLAY) {
gameViewport->bDisableWorldRendering = 1;
}
else {
gameViewport->bDisableWorldRendering = 0;
}
gameViewport->bDisableWorldRendering = nodisplay;
}
27 changes: 18 additions & 9 deletions Unreal/Plugins/AirSim/Source/PIPCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ void APIPCamera::BeginPlay()
render_targets_[image_type] = NewObject<UTextureRenderTarget2D>();
}

onViewModeChanged(false);
//We set all cameras to start as nodisplay
//This improves performance because the capture components are no longer updating every frame and only update while requesting an image
onViewModeChanged(true);

gimbal_stabilization_ = 0;
gimbald_rotator_ = this->GetActorRotation();
Expand Down Expand Up @@ -270,6 +272,20 @@ void APIPCamera::setCameraTypeEnabled(ImageType type, bool enabled)
enableCaptureComponent(type, enabled);
}

void APIPCamera::setCaptureUpdate(USceneCaptureComponent2D* capture, bool nodisplay)
{
capture->bCaptureEveryFrame = !nodisplay;
capture->bCaptureOnMovement = !nodisplay;
capture->bAlwaysPersistRenderingState = true;
}

void APIPCamera::setCameraTypeUpdate(ImageType type, bool nodisplay)
{
USceneCaptureComponent2D* capture = getCaptureComponent(type, false);
if (capture != nullptr)
setCaptureUpdate(capture, nodisplay);
}

void APIPCamera::setCameraPose(const msr::airlib::Pose& relative_pose)
{
FTransform pose = ned_transform_->fromRelativeNed(relative_pose);
Expand Down Expand Up @@ -579,14 +595,7 @@ void APIPCamera::onViewModeChanged(bool nodisplay)
for (unsigned int image_type = 0; image_type < imageTypeCount(); ++image_type) {
USceneCaptureComponent2D* capture = getCaptureComponent(static_cast<ImageType>(image_type), false);
if (capture) {
if (nodisplay) {
capture->bCaptureEveryFrame = false;
capture->bCaptureOnMovement = false;
}
else {
capture->bCaptureEveryFrame = true;
capture->bCaptureOnMovement = true;
}
setCaptureUpdate(capture, nodisplay);
}
}
}
3 changes: 3 additions & 0 deletions Unreal/Plugins/AirSim/Source/PIPCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class AIRSIM_API APIPCamera : public ACameraActor

void setCameraTypeEnabled(ImageType type, bool enabled);
bool getCameraTypeEnabled(ImageType type) const;
void setCaptureUpdate(USceneCaptureComponent2D* capture, bool nodisplay);
void setCameraTypeUpdate(ImageType type, bool nodisplay);

void setupCameraFromSettings(const CameraSetting& camera_setting, const NedTransform& ned_transform);
void setCameraPose(const msr::airlib::Pose& relative_pose);
void setCameraFoV(float fov_degrees);
Expand Down
5 changes: 4 additions & 1 deletion Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,11 @@ void ASimHUD::updateWidgetSubwindowVisibility()

bool is_visible = getSubWindowSettings().at(window_index).visible && camera != nullptr;

if (camera != nullptr)
if (camera != nullptr) {
camera->setCameraTypeEnabled(camera_type, is_visible);
//sub-window captures don�t count as a request, set bCaptureEveryFrame and bCaptureOnMovement to display so we can show correctly the subwindow
camera->setCameraTypeUpdate(camera_type, false);
}

widget_->setSubwindowVisibility(window_index,
is_visible,
Expand Down