Fix warnings and coding style issues

This commit is contained in:
Alexander Bock
2018-04-21 08:26:59 -04:00
parent 818ee225a5
commit db66084ad8
16 changed files with 96 additions and 59 deletions

View File

@@ -315,7 +315,7 @@ void mainInitFunc() {
std::string screenshotPath = "${SCREENSHOTS}";
std::string screenshotNames = "OpenSpace";
if (OsEng.configuration().shouldUseScreenshotDate) {
std::time_t now = std::time(nullptr);
std::tm* nowTime = std::localtime(&now);

View File

@@ -85,14 +85,14 @@ struct Configuration {
std::string onScreenTextScaling = "window";
bool usePerSceneCache = false;
bool isRenderingOnMasterDisabled = false;
bool isSceneTranslationOnMasterDisabled = false;
std::map<std::string, ghoul::Dictionary> moduleConfigurations;
std::string renderingMethod = "Framebuffer";
struct OpenGLDebugContext {
bool isActive = false;
bool isSynchronous = true;

View File

@@ -22,8 +22,8 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___INPUTDEVICESTATES___H__
#define __OPENSPACE_CORE___INPUTDEVICESTATES___H__
#ifndef __OPENSPACE_CORE___CAMERAINTERACTIONSTATES___H__
#define __OPENSPACE_CORE___CAMERAINTERACTIONSTATES___H__
#include <openspace/interaction/delayedvariable.h>
#include <ghoul/glm.h>
@@ -43,7 +43,7 @@ public:
virtual ~CameraInteractionStates() = default;
virtual void updateStateFromInput(const InputState& inputState, double deltaTime) = 0;
void setRotationalFriction(double friction);
void setHorizontalFriction(double friction);
void setVerticalFriction(double friction);
@@ -78,4 +78,4 @@ protected:
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___INPUTDEVICESTATES___H__
#endif // __OPENSPACE_CORE___CAMERAINTERACTIONSTATES___H__

View File

@@ -22,8 +22,8 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___CAMERAINTERACTIONSTATES___H__
#define __OPENSPACE_CORE___CAMERAINTERACTIONSTATES___H__
#ifndef __OPENSPACE_CORE___INPUTDEVICESTATES___H__
#define __OPENSPACE_CORE___INPUTDEVICESTATES___H__
#include <openspace/interaction/delayedvariable.h>
#include <ghoul/glm.h>
@@ -43,7 +43,7 @@ public:
virtual ~CameraInteractionStates() = default;
virtual void updateStateFromInput(const InputState& inputState, double deltaTime) = 0;
void setRotationalFriction(double friction);
void setHorizontalFriction(double friction);
void setVerticalFriction(double friction);
@@ -78,4 +78,4 @@ protected:
} // namespace openspace::interaction
#endif // __OPENSPACE_CORE___CAMERAINTERACTIONSTATES___H__
#endif // __OPENSPACE_CORE___INPUTDEVICESTATES___H__

View File

@@ -22,8 +22,8 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___JOYSTICKSTATE___H__
#define __OPENSPACE_CORE___JOYSTICKSTATE___H__
#ifndef __OPENSPACE_CORE___JOYSTICKCAMERASTATES___H__
#define __OPENSPACE_CORE___JOYSTICKCAMERASTATES___H__
#include <openspace/interaction/camerainteractionstates.h>
@@ -115,8 +115,9 @@ std::string to_string(const openspace::interaction::JoystickCameraStates::AxisTy
namespace ghoul {
template <>
openspace::interaction::JoystickCameraStates::AxisType from_string(const std::string& string);
openspace::interaction::JoystickCameraStates::AxisType
from_string(const std::string& string);
} // namespace ghoul
#endif // __OPENSPACE_CORE___JOYSTICKSTATE___H__
#endif // __OPENSPACE_CORE___JOYSTICKCAMERASTATES___H__

View File

@@ -123,4 +123,4 @@ openspace::interaction::JoystickAction from_string(const std::string& str);
} // namespace ghoul
#endif // __OPENSPACE_CORE___JOYSTICKSTATE___H__
#endif // __OPENSPACE_CORE___JOYSTICKINPUTSTATE___H__

View File

@@ -86,8 +86,10 @@ public:
void setJoystickAxisMapping(
int axis,
JoystickCameraStates::AxisType mapping,
JoystickCameraStates::AxisInvert shouldInvert = JoystickCameraStates::AxisInvert::No,
JoystickCameraStates::AxisNormalize shouldNormalize = JoystickCameraStates::AxisNormalize::No
JoystickCameraStates::AxisInvert shouldInvert =
JoystickCameraStates::AxisInvert::No,
JoystickCameraStates::AxisNormalize shouldNormalize =
JoystickCameraStates::AxisNormalize::No
);
JoystickCameraStates::AxisInformation joystickAxisMapping(int axis) const;

View File

@@ -86,7 +86,7 @@ private:
properties::FloatProperty _followFocusNodeRotationDistance;
properties::FloatProperty _minimumAllowedDistance;
properties::FloatProperty _mouseSensitivity;
properties::FloatProperty _joystickSensitivity;

View File

@@ -146,15 +146,19 @@ namespace {
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo ZoomSensitivityDistanceThresholdInfo = {
static const openspace::properties::Property::PropertyInfo
ZoomSensitivityDistanceThresholdInfo = {
"ZoomSensitivityDistanceThreshold",
"Threshold of distance to target node for whether or not to use exponential zooming",
"Threshold of distance to target node for whether or not to use exponential "
"zooming",
"" // @TODO Missing documentation
};
static const openspace::properties::Property::PropertyInfo ZoomBoundarySphereMultiplierInfo = {
static const openspace::properties::Property::PropertyInfo
ZoomBoundarySphereMultiplierInfo = {
"ZoomBoundarySphereMultiplier",
"Multiplies a node's boundary sphere by this in order to limit zoom & prevent surface collision",
"Multiplies a node's boundary sphere by this in order to limit zoom & prevent "
"surface collision",
"" // @TODO Missing documentation
};
@@ -226,7 +230,12 @@ TouchInteraction::TouchInteraction()
, _orbitSpeedThreshold(OrbitSpinningThreshold, 0.005f, 0.f, 0.01f)
, _spinSensitivity(SpinningSensitivityInfo, 1.f, 0.f, 2.f)
, _zoomSensitivity(ZoomSensitivityInfo, 1.025f, 1.0f, 1.1f)
, _zoomSensitivityDistanceThreshold(ZoomSensitivityDistanceThresholdInfo, 0.05, 0.01, 0.25)
, _zoomSensitivityDistanceThreshold(
ZoomSensitivityDistanceThresholdInfo,
0.05,
0.01,
0.25
)
, _zoomBoundarySphereMultiplier(ZoomBoundarySphereMultiplierInfo, 1.001, 1.0, 1.01)
, _inputStillThreshold(InputSensitivityInfo, 0.0005f, 0.f, 0.001f)
// used to void wrongly interpreted roll interactions
@@ -252,8 +261,8 @@ TouchInteraction::TouchInteraction()
0.f,
1.f
)
, _ignoreGui(
{ "Ignore GUI", "Disable GUI touch interaction", "" }, // @TODO Missing documentation
, _ignoreGui( // @TODO Missing documentation
{ "Ignore GUI", "Disable GUI touch interaction", "" },
false
)
, _vel{ glm::dvec2(0.0), 0.0, 0.0, glm::dvec2(0.0) }
@@ -582,9 +591,15 @@ void TouchInteraction::directControl(const std::vector<TuioCursor>& list) {
[&sb](const TuioCursor& c) { return c.getSessionID() == sb.id; }
);
if (c != list.end()) {
screenPoints.push_back(glm::dvec2(2 * (c->getX() - 0.5), -2 * (c->getY() - 0.5))); // normalized -1 to 1 coordinates on screen
// normalized -1 to 1 coordinates on screen
screenPoints.push_back(
glm::dvec2(2 * (c->getX() - 0.5), -2 * (c->getY() - 0.5))
);
} else {
OsEng.moduleEngine().module<ImGUIModule>()->touchInput = { 1, glm::dvec2(0.0, 0.0), 1 };
OsEng.moduleEngine().module<ImGUIModule>()->touchInput = {
1,
glm::dvec2(0.0, 0.0), 1
};
resetAfterInput();
return;
}
@@ -891,7 +906,10 @@ int TouchInteraction::interpretInteraction(const std::vector<TuioCursor>& list,
}
);
double normalizedCentroidDistance = glm::distance(_centroid, lastCentroid) / list.size();
double normalizedCentroidDistance = glm::distance(
_centroid,
lastCentroid
) / list.size();
#ifdef TOUCH_DEBUG_PROPERTIES
_debugProperties.normalizedCentroidDistance = normalizedCentroidDistance;
_debugProperties.rollOn = rollOn;
@@ -935,17 +953,22 @@ void TouchInteraction::computeVelocities(const std::vector<TuioCursor>& list,
#ifdef TOUCH_DEBUG_PROPERTIES
const std::map<int, std::string> interactionNames = {
{ROT, "Rotation"},
{PINCH, "Pinch"},
{PAN, "Pan"},
{ROLL, "Roll"},
{PICK, "Pick"}
{ ROT, "Rotation" },
{ PINCH, "Pinch" },
{ PAN, "Pan" },
{ ROLL, "Roll" },
{ PICK, "Pick" }
};
_debugProperties.interpretedInteraction = interactionNames.at(action);
if (pinchConsecCt > 0 && action != PINCH) {
if( pinchConsecCt > 3 )
LINFO("PINCH_gesture_ended_with " << pinchConsecZoomFactor << " drag_distance_and " << pinchConsecCt << " counts.");
if (pinchConsecCt > 3) {
LDEBUG(fmt::format(
"PINCH gesture ended with {} drag distance and {} counts",
pinchConsecZoomFactor,
pinchConsecCt
));
}
pinchConsecCt = 0;
pinchConsecZoomFactor = 0.0;
}
@@ -988,13 +1011,16 @@ void TouchInteraction::computeVelocities(const std::vector<TuioCursor>& list,
glm::dvec3 centerPos = _focusNode->worldPosition();
glm::dvec3 currDistanceToFocusNode = camPos - centerPos;
double distanceFromFocusSurface = length(currDistanceToFocusNode) - _focusNode->boundingSphere();
double distanceFromFocusSurface =
length(currDistanceToFocusNode) - _focusNode->boundingSphere();
double zoomFactor = (distance - lastDistance);
#ifdef TOUCH_DEBUG_PROPERTIES
pinchConsecCt++;
pinchConsecZoomFactor += zoomFactor;
#endif
if ((length(currDistanceToFocusNode) / distanceFromFocusSurface) > _zoomSensitivityDistanceThreshold) {
if ((length(currDistanceToFocusNode) / distanceFromFocusSurface) >
_zoomSensitivityDistanceThreshold)
{
zoomFactor *= pow(
distanceFromFocusSurface,
static_cast<float>(_zoomSensitivity)
@@ -1184,10 +1210,14 @@ void TouchInteraction::step(double dt) {
#ifdef TOUCH_DEBUG_PROPERTIES
//Show velocity status every N frames
/*if (++stepVelUpdate >= 60) {
if (++stepVelUpdate >= 60) {
stepVelUpdate = 0;
LINFO("DistToFocusNode " << length(centerToCamera) << " stepZoomVelUpdate " << _vel.zoom);
}*/
LINFO(fmt::format(
"DistToFocusNode {} stepZoomVelUpdate {}",
length(centerToCamera),
_vel.zoom
));
}
#endif
_tap = false;

View File

@@ -421,7 +421,7 @@ void OpenSpaceEngine::create(int argc, char** argv,
// Determining SGCT configuration file
LDEBUG("Determining SGCT configuration file");
std::string sgctConfigurationPath = _engine->_configuration->windowConfiguration;
if (!commandlineArgumentPlaceholders.sgctConfigurationName.empty()) {
LDEBUG(fmt::format(
"Overwriting SGCT configuration file with commandline argument: {}",
@@ -543,7 +543,7 @@ void OpenSpaceEngine::initialize() {
scriptEngine().initialize();
writeStaticDocumentation();
_shutdown.waitTime = _engine->_configuration->shutdownCountdown;
if (!commandlineArgumentPlaceholders.sceneName.empty()) {
@@ -597,7 +597,7 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) {
if (_scene) {
_syncEngine->removeSyncables(_timeManager->getSyncables());
if (_scene && _scene->camera()) {
_syncEngine->removeSyncables(_scene->camera()->getSyncables());
_syncEngine->removeSyncables(_scene->camera()->getSyncables());
}
_renderEngine->setScene(nullptr);
_renderEngine->setCamera(nullptr);
@@ -828,7 +828,7 @@ void OpenSpaceEngine::loadFonts() {
));
}
}
try {
bool initSuccess = ghoul::fontrendering::FontRenderer::initialize();
if (!initSuccess) {

View File

@@ -57,7 +57,7 @@ void JoystickCameraStates::updateStateFromInput(const InputState& inputState,
value = 0.f;
hasValue = false;
}
if (t.normalize) {
value = (value + 1.f) / 2.f;
}
@@ -148,8 +148,7 @@ void JoystickCameraStates::updateStateFromInput(const InputState& inputState,
else {
_localRotationState.velocity.decelerate(deltaTime);
}
for (int i = 0; i < JoystickInputState::MaxButtons; ++i) {
auto itRange = _buttonMapping.equal_range(i);
for (auto it = itRange.first; it != itRange.second; ++it) {
@@ -251,7 +250,7 @@ openspace::interaction::JoystickCameraStates::AxisType from_string(
const std::string& string)
{
using T = openspace::interaction::JoystickCameraStates::AxisType;
static const std::map<std::string, T> Map = {
{ "None", T::None },
{ "Orbit X", T::OrbitX },

View File

@@ -32,7 +32,9 @@ MouseCameraStates::MouseCameraStates(double sensitivity, double velocityScaleFac
: CameraInteractionStates(sensitivity, velocityScaleFactor)
{}
void MouseCameraStates::updateStateFromInput(const InputState& inputState, double deltaTime) {
void MouseCameraStates::updateStateFromInput(const InputState& inputState,
double deltaTime)
{
glm::dvec2 mousePosition = inputState.mousePosition();
bool button1Pressed = inputState.isMouseButtonPressed(MouseButton::Button1);

View File

@@ -297,9 +297,10 @@ void NavigationHandler::restoreCameraStateFromFile(const std::string& filepath)
}
}
void NavigationHandler::setJoystickAxisMapping(int axis, JoystickCameraStates::AxisType mapping,
JoystickCameraStates::AxisInvert shouldInvert,
JoystickCameraStates::AxisNormalize shouldNormalize)
void NavigationHandler::setJoystickAxisMapping(int axis,
JoystickCameraStates::AxisType mapping,
JoystickCameraStates::AxisInvert shouldInvert,
JoystickCameraStates::AxisNormalize shouldNormalize)
{
_orbitalNavigator->joystickStates().setAxisMapping(
axis,
@@ -309,7 +310,9 @@ void NavigationHandler::setJoystickAxisMapping(int axis, JoystickCameraStates::A
);
}
JoystickCameraStates::AxisInformation NavigationHandler::joystickAxisMapping(int axis) const {
JoystickCameraStates::AxisInformation
NavigationHandler::joystickAxisMapping(int axis) const
{
return _orbitalNavigator->joystickStates().axisMapping(axis);
}
@@ -323,7 +326,7 @@ float NavigationHandler::joystickAxisDeadzone(int axis) const {
void NavigationHandler::bindJoystickButtonCommand(int button, std::string command,
JoystickAction action,
JoystickCameraStates::ButtonCommandRemote remote)
JoystickCameraStates::ButtonCommandRemote remote)
{
_orbitalNavigator->joystickStates().bindButtonCommand(
button,

View File

@@ -101,7 +101,7 @@ int bindJoystickAxis(lua_State* L) {
if (n > 2) {
shouldInvert = lua_toboolean(L, 3);
}
bool shouldNormalize = false;
if (n > 3) {
shouldNormalize = lua_toboolean(L, 4);
@@ -178,7 +178,7 @@ int bindJoystickButton(lua_State* L) {
action,
interaction::JoystickCameraStates::ButtonCommandRemote(isRemote)
);
lua_settop(L, 0);
return 0;
}

View File

@@ -456,7 +456,7 @@ glm::dvec3 OrbitalNavigator::translateHorizontally(double deltaTime,
-_mouseStates.globalRotationVelocity().y * deltaTime,
-_mouseStates.globalRotationVelocity().x * deltaTime,
0) * speedScale);
glm::dquat joystickRotationDiffCamSpace = glm::dquat(glm::dvec3(
-_joystickStates.globalRotationVelocity().y * deltaTime,
-_joystickStates.globalRotationVelocity().x * deltaTime,