1
0
Fork 0

VSCode applied formatting.

This commit is contained in:
James Turner 2022-05-16 12:15:05 +01:00
parent 15cb5ab075
commit 3f670c84b1

View file

@ -25,41 +25,41 @@
#include <config.h>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <simgear/compiler.h>
#include <simgear/structure/exception.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/debug/OsgIoCapture.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/props/props_io.hxx>
#include <simgear/structure/exception.hxx>
#include <osg/Camera>
#include <osg/GraphicsContext>
#include <osg/Group>
#include <osg/Matrixd>
#include <osg/Viewport>
#include <osg/Version>
#include <osg/Notify>
#include <osg/Version>
#include <osg/View>
#include <osgViewer/ViewerEventHandlers>
#include <osgViewer/Viewer>
#include <osg/Viewport>
#include <osgViewer/GraphicsWindow>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <Scenery/scenery.hxx>
#include <Main/fg_os.hxx>
#include <Main/fg_props.hxx>
#include <Main/util.hxx>
#include <Main/globals.hxx>
#include "renderer.hxx"
#include "CameraGroup.hxx"
#include "FGEventHandler.hxx"
#include "VRManager.hxx"
#include "WindowBuilder.hxx"
#include "WindowSystemAdapter.hxx"
#include "renderer.hxx"
#include <Main/fg_os.hxx>
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
#include <Main/sentryIntegration.hxx>
#include <Main/util.hxx>
#include <Scenery/scenery.hxx>
#if defined(SG_MAC)
#include <GUI/CocoaHelpers.h>
@ -116,40 +116,23 @@ static void setStereoMode( const char * mode )
DisplaySettings::StereoMode stereoMode = DisplaySettings::QUAD_BUFFER;
bool stereoOn = true;
if (strcmp(mode,"QUAD_BUFFER")==0)
{
if (strcmp(mode, "QUAD_BUFFER") == 0) {
stereoMode = DisplaySettings::QUAD_BUFFER;
}
else if (strcmp(mode,"ANAGLYPHIC")==0)
{
} else if (strcmp(mode, "ANAGLYPHIC") == 0) {
stereoMode = DisplaySettings::ANAGLYPHIC;
}
else if (strcmp(mode,"HORIZONTAL_SPLIT")==0)
{
} else if (strcmp(mode, "HORIZONTAL_SPLIT") == 0) {
stereoMode = DisplaySettings::HORIZONTAL_SPLIT;
}
else if (strcmp(mode,"VERTICAL_SPLIT")==0)
{
} else if (strcmp(mode, "VERTICAL_SPLIT") == 0) {
stereoMode = DisplaySettings::VERTICAL_SPLIT;
}
else if (strcmp(mode,"LEFT_EYE")==0)
{
} else if (strcmp(mode, "LEFT_EYE") == 0) {
stereoMode = DisplaySettings::LEFT_EYE;
}
else if (strcmp(mode,"RIGHT_EYE")==0)
{
} else if (strcmp(mode, "RIGHT_EYE") == 0) {
stereoMode = DisplaySettings::RIGHT_EYE;
}
else if (strcmp(mode,"HORIZONTAL_INTERLACE")==0)
{
} else if (strcmp(mode, "HORIZONTAL_INTERLACE") == 0) {
stereoMode = DisplaySettings::HORIZONTAL_INTERLACE;
}
else if (strcmp(mode,"VERTICAL_INTERLACE")==0)
{
} else if (strcmp(mode, "VERTICAL_INTERLACE") == 0) {
stereoMode = DisplaySettings::VERTICAL_INTERLACE;
}
else if (strcmp(mode,"CHECKERBOARD")==0)
{
} else if (strcmp(mode, "CHECKERBOARD") == 0) {
stereoMode = DisplaySettings::CHECKERBOARD;
} else {
stereoOn = false;
@ -218,10 +201,9 @@ void fgOSOpenWindow(bool stencil)
osg::setNotifyHandler(new NotifyLogger);
auto composite_viewer = dynamic_cast<osgViewer::CompositeViewer*>(
globals->get_renderer()->getViewerBase()
);
if (0) {}
else if (composite_viewer) {
globals->get_renderer()->getViewerBase());
if (0) {
} else if (composite_viewer) {
/* We are using CompositeViewer. */
SG_LOG(SG_VIEW, SG_DEBUG, "Using CompositeViewer");
osgViewer::ViewerBase* viewer = globals->get_renderer()->getViewerBase();
@ -267,8 +249,7 @@ void fgOSOpenWindow(bool stencil)
// The viewer won't start without some root.
view->setSceneData(new osg::Group);
globals->get_renderer()->setView(view);
}
else {
} else {
/* Not using CompositeViewer. */
SG_LOG(SG_VIEW, SG_DEBUG, "Not CompositeViewer.");
SG_LOG(SG_VIEW, SG_DEBUG, "Creating osgViewer::Viewer");
@ -377,8 +358,7 @@ static std::ostream& operator<< (std::ostream& out, const cpu_set_t& mask)
{
out << "0x";
unsigned char* mask2 = (unsigned char*)&mask;
for (unsigned i=0; i<sizeof(mask); ++i)
{
for (unsigned i = 0; i < sizeof(mask); ++i) {
char buffer[8];
snprintf(buffer, sizeof(buffer), "%02x", (unsigned)mask2[i]);
out << buffer;
@ -396,8 +376,7 @@ value='clear' and 'revert':
'revert'
Restores thread affinities stored from previous 'clear'.
*/
struct AffinityControl : SGPropertyChangeListener
{
struct AffinityControl : SGPropertyChangeListener {
AffinityControl()
{
m_node = globals->get_props()->getNode("/sim/affinity-control", true /*create*/);
@ -407,65 +386,45 @@ struct AffinityControl : SGPropertyChangeListener
{
#ifdef __linux__
std::string s = m_node->getStringValue();
if (s == m_state)
{
if (s == m_state) {
SG_LOG(SG_VIEW, SG_ALERT, "Ignoring m_node=" << s << " because same as m_state.");
}
else if (s == "clear")
{
} else if (s == "clear") {
char buffer[64];
snprintf(buffer, sizeof(buffer), "/proc/%i/task", getpid());
SGPath path(buffer);
simgear::Dir dir(path);
m_thread_masks.clear();
simgear::PathList pids = dir.children(
simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT
);
for (SGPath path: pids)
{
simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT);
for (SGPath path : pids) {
std::string leaf = path.file();
int pid = atoi(leaf.c_str());
cpu_set_t mask;
int e = sched_getaffinity(pid, sizeof(mask), &mask);
SG_LOG(SG_VIEW, SG_ALERT, "Called sched_getaffinity()"
<< " pid=" << pid
<< " => e=" << e
<< " mask=" << mask
);
if (!e)
{
<< " pid=" << pid << " => e=" << e << " mask=" << mask);
if (!e) {
m_thread_masks[pid] = mask;
memset(&mask, 255, sizeof(mask));
e = sched_setaffinity(pid, sizeof(mask), &mask);
SG_LOG(SG_VIEW, SG_ALERT, "Called sched_setaffinity()"
<< " pid=" << pid
<< " => e=" << e
<< " mask=" << mask
);
<< " pid=" << pid << " => e=" << e << " mask=" << mask);
//assert(!e);
}
}
m_state = s;
}
else if (s == "revert")
{
for (auto it: m_thread_masks)
{
} else if (s == "revert") {
for (auto it : m_thread_masks) {
pid_t pid = it.first;
cpu_set_t mask = it.second;
int e = sched_setaffinity(pid, sizeof(mask), &mask);
SG_LOG(SG_VIEW, SG_ALERT, "Called sched_setaffinity()"
<< " pid=" << pid
<< " => e=" << e
<< " mask=" << mask
);
<< " pid=" << pid << " => e=" << e << " mask=" << mask);
//assert(!e);
}
m_thread_masks.clear();
m_state = s;
}
else
{
} else {
SG_LOG(SG_VIEW, SG_ALERT, "Unrecognised m_node=" << s);
}
#endif
@ -487,8 +446,7 @@ int fgOSMainLoop()
viewer_base->realize();
std::string affinity = fgGetString("/sim/thread-cpu-affinity");
SG_LOG(SG_VIEW, SG_ALERT, "affinity=" << affinity);
if (affinity != "")
{
if (affinity != "") {
ShowAffinities();
if (affinity == "osg") {
SG_LOG(SG_VIEW, SG_ALERT, "Resetting affinity of current thread getpid()=" << getpid());
@ -501,18 +459,14 @@ int fgOSMainLoop()
while (!viewer_base->done()) {
fgIdleHandler idleFunc = globals->get_renderer()->getEventHandler()->getIdleHandler();
if (idleFunc)
{
if (idleFunc) {
_lastUpdate.stamp();
(*idleFunc)();
if (fgGetBool("/sim/position-finalized", false))
{
if (simHost && simFrameCount && simTotalHostTime && simFrameResetCount)
{
if (fgGetBool("/sim/position-finalized", false)) {
if (simHost && simFrameCount && simTotalHostTime && simFrameResetCount) {
int curFrameCount = simFrameCount->getIntValue();
double totalSimTime = simTotalHostTime->getDoubleValue();
if (simFrameResetCount->getBoolValue())
{
if (simFrameResetCount->getBoolValue()) {
curFrameCount = 0;
totalSimTime = 0;
simFrameResetCount->setBoolValue(false);
@ -521,8 +475,7 @@ int fgOSMainLoop()
double idle_wait = 0;
if (frameWait)
idle_wait = frameWait->getDoubleValue();
if (lastSimFrame_ms > 0)
{
if (lastSimFrame_ms > 0) {
totalSimTime += lastSimFrame_ms - idle_wait;
simTotalHostTime->setDoubleValue(totalSimTime);
curFrameCount++;
@ -608,8 +561,7 @@ void fgOSFullScreen()
osgViewer::GraphicsWindow* window = windows[0];
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (wsi == NULL)
{
if (wsi == NULL) {
SG_LOG(SG_VIEW, SG_ALERT, "ERROR: No WindowSystemInterface available. Cannot toggle window fullscreen.");
return;
}
@ -637,11 +589,8 @@ void fgOSFullScreen()
//bool isFullScreen = x == 0 && y == 0 && width == (int)screenWidth && height == (int)screenHeight;
bool isFullScreen = !window->getWindowDecoration();
SG_LOG(SG_VIEW, SG_DEBUG, "Toggling fullscreen. Previous window rectangle ("
<< x << ", " << y << ") x (" << width << ", " << height << "), fullscreen: " << isFullScreen
<< ", number of screens: " << wsi->getNumScreens());
if (isFullScreen)
{
SG_LOG(SG_VIEW, SG_DEBUG, "Toggling fullscreen. Previous window rectangle (" << x << ", " << y << ") x (" << width << ", " << height << "), fullscreen: " << isFullScreen << ", number of screens: " << wsi->getNumScreens());
if (isFullScreen) {
// limit x,y coordinates and window size to screen area
if (previous_x + previous_width > (int)screenWidth)
previous_x = 0;
@ -653,9 +602,7 @@ void fgOSFullScreen()
y = previous_y;
width = previous_width;
height = previous_height;
}
else
{
} else {
// remember previous setting
previous_x = x;
previous_y = y;