Skip to content

Commit 0becf91

Browse files
authored
Merge pull request #4266 from rajat2004/multi-vehicle-trace
Fix trace toggling for multiple vehicles
2 parents c23a3a5 + d90a5a1 commit 0becf91

File tree

6 files changed

+22
-74
lines changed

6 files changed

+22
-74
lines changed

Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,6 @@ void SimHUD::EndPlay()
4343
}
4444
}
4545

46-
SimHUD::ImageType SimHUD::getSubwindowCameraType(int window_index)
47-
{
48-
//TODO: index check
49-
return getSubWindowSettings().at(window_index).image_type;
50-
}
51-
52-
void SimHUD::setSubwindowCameraType(int window_index, ImageType type)
53-
{
54-
getSubWindowSettings().at(window_index).image_type = type;
55-
}
56-
57-
bool SimHUD::getSubwindowVisible(int window_index)
58-
{
59-
return getSubWindowSettings().at(window_index).visible;
60-
}
61-
62-
void SimHUD::setSubwindowVisible(int window_index, bool is_visible)
63-
{
64-
getSubWindowSettings().at(window_index).visible = is_visible;
65-
}
66-
6746
void SimHUD::initializeSettings()
6847
{
6948
std::string settingsText;

Unity/AirLibWrapper/AirsimWrapper/Source/SimHUD/SimHUD.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ class SimHUD
2020
public:
2121
SimHUD(std::string sime_mode_name, int port_number);
2222
SimModeBase* GetSimMode();
23-
ImageType getSubwindowCameraType(int window_index);
24-
void setSubwindowCameraType(int window_index, ImageType type);
25-
bool getSubwindowVisible(int window_index);
26-
void setSubwindowVisible(int window_index, bool is_visible);
2723
virtual void BeginPlay();
2824
virtual void EndPlay();
2925
virtual void Tick(float DeltaSeconds);

Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.cpp

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -88,41 +88,7 @@ void ASimHUD::inputEventToggleHelp()
8888

8989
void ASimHUD::inputEventToggleTrace()
9090
{
91-
simmode_->getVehicleSimApi()->toggleTrace();
92-
}
93-
94-
ASimHUD::ImageType ASimHUD::getSubwindowCameraType(int window_index)
95-
{
96-
//TODO: index check
97-
return getSubWindowSettings().at(window_index).image_type;
98-
}
99-
100-
void ASimHUD::setSubwindowCameraType(int window_index, ImageType type)
101-
{
102-
getSubWindowSettings().at(window_index).image_type = type;
103-
updateWidgetSubwindowVisibility();
104-
}
105-
106-
APIPCamera* ASimHUD::getSubwindowCamera(int window_index)
107-
{
108-
return subwindow_cameras_[window_index]; //TODO: index check
109-
}
110-
111-
void ASimHUD::setSubwindowCamera(int window_index, APIPCamera* camera)
112-
{
113-
subwindow_cameras_[window_index] = camera; //TODO: index check
114-
updateWidgetSubwindowVisibility();
115-
}
116-
117-
bool ASimHUD::getSubwindowVisible(int window_index)
118-
{
119-
return getSubWindowSettings().at(window_index).visible;
120-
}
121-
122-
void ASimHUD::setSubwindowVisible(int window_index, bool is_visible)
123-
{
124-
getSubWindowSettings().at(window_index).visible = is_visible;
125-
updateWidgetSubwindowVisibility();
91+
simmode_->toggleTraceAll();
12692
}
12793

12894
void ASimHUD::updateWidgetSubwindowVisibility()
@@ -135,7 +101,7 @@ void ASimHUD::updateWidgetSubwindowVisibility()
135101

136102
if (camera != nullptr) {
137103
camera->setCameraTypeEnabled(camera_type, is_visible);
138-
//sub-window captures dont count as a request, set bCaptureEveryFrame and bCaptureOnMovement to display so we can show correctly the subwindow
104+
//sub-window captures don't count as a request, set bCaptureEveryFrame and bCaptureOnMovement to display so we can show correctly the subwindow
139105
camera->setCameraTypeUpdate(camera_type, false);
140106
}
141107

@@ -150,22 +116,25 @@ bool ASimHUD::isWidgetSubwindowVisible(int window_index)
150116
return widget_->getSubwindowVisibility(window_index) != 0;
151117
}
152118

153-
void ASimHUD::inputEventToggleSubwindow0()
119+
void ASimHUD::toggleSubwindowVisibility(int window_index)
154120
{
155-
getSubWindowSettings().at(0).visible = !getSubWindowSettings().at(0).visible;
121+
getSubWindowSettings().at(window_index).visible = !getSubWindowSettings().at(window_index).visible;
156122
updateWidgetSubwindowVisibility();
157123
}
158124

125+
void ASimHUD::inputEventToggleSubwindow0()
126+
{
127+
toggleSubwindowVisibility(0);
128+
}
129+
159130
void ASimHUD::inputEventToggleSubwindow1()
160131
{
161-
getSubWindowSettings().at(1).visible = !getSubWindowSettings().at(1).visible;
162-
updateWidgetSubwindowVisibility();
132+
toggleSubwindowVisibility(1);
163133
}
164134

165135
void ASimHUD::inputEventToggleSubwindow2()
166136
{
167-
getSubWindowSettings().at(2).visible = !getSubWindowSettings().at(2).visible;
168-
updateWidgetSubwindowVisibility();
137+
toggleSubwindowVisibility(2);
169138
}
170139

171140
void ASimHUD::inputEventToggleAll()

Unreal/Plugins/AirSim/Source/SimHUD/SimHUD.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ class AIRSIM_API ASimHUD : public AHUD
3434
void inputEventToggleSubwindow2();
3535
void inputEventToggleAll();
3636

37-
ImageType getSubwindowCameraType(int window_index);
38-
void setSubwindowCameraType(int window_index, ImageType type);
39-
APIPCamera* getSubwindowCamera(int window_index);
40-
void setSubwindowCamera(int window_index, APIPCamera* camera);
41-
bool getSubwindowVisible(int window_index);
42-
void setSubwindowVisible(int window_index, bool is_visible);
43-
4437
ASimHUD();
4538
virtual void BeginPlay() override;
4639
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
@@ -51,6 +44,7 @@ class AIRSIM_API ASimHUD : public AHUD
5144
void toggleRecordHandler();
5245
void updateWidgetSubwindowVisibility();
5346
bool isWidgetSubwindowVisible(int window_index);
47+
void toggleSubwindowVisibility(int window_index);
5448

5549
private:
5650
void initializeSubWindows();

Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,14 @@ bool ASimModeBase::isRecording() const
513513
return FRecordingThread::isRecording();
514514
}
515515

516+
void ASimModeBase::toggleTraceAll()
517+
{
518+
for (auto sim_api : getApiProvider()->getVehicleSimApis()) {
519+
auto* pawn_sim_api = static_cast<PawnSimApi*>(sim_api);
520+
pawn_sim_api->toggleTrace();
521+
}
522+
}
523+
516524
const APIPCamera* ASimModeBase::getCamera(const msr::airlib::CameraDetails& camera_details) const
517525
{
518526
return camera_details.external ? getExternalCamera(camera_details.camera_name)

Unreal/Plugins/AirSim/Source/SimMode/SimModeBase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class AIRSIM_API ASimModeBase : public AActor
7171
virtual void stopRecording();
7272
virtual bool isRecording() const;
7373

74+
virtual void toggleTraceAll();
75+
7476
void startApiServer();
7577
void stopApiServer();
7678
bool isApiServerStarted();

0 commit comments

Comments
 (0)