Updating Ghoul repository

Updating SGCT repository
Removing compiler warnings
This commit is contained in:
Alexander Bock
2017-03-10 09:32:16 -05:00
parent dbceb169f7
commit bcf92804b6
39 changed files with 201 additions and 164 deletions

View File

@@ -44,6 +44,8 @@ namespace documentation {
* description of the Verifier subclass and what it tests for.
*/
struct Verifier {
virtual ~Verifier() = default;
/**
* This method tests whether the \p key contained in the \p dictionary adheres to
* whatever the concrete Verifer needs to test. The actual testing depends on the

View File

@@ -108,11 +108,10 @@ namespace interaction {
class InteractionMode
{
class InteractionMode {
public:
InteractionMode();
~InteractionMode();
virtual ~InteractionMode();
// Mutators
virtual void setFocusNode(SceneGraphNode* focusNode);

View File

@@ -120,7 +120,7 @@ class ParallelConnection {
*/
static scripting::LuaLibrary luaLibrary();
Status status();
size_t nConnections();
int nConnections();
std::shared_ptr<ghoul::Event<>> connectionEvent();

View File

@@ -38,8 +38,8 @@ namespace ghoul {
namespace openspace {
class RenderData;
class RaycastData;
struct RenderData;
struct RaycastData;
class VolumeRaycaster {
public:

View File

@@ -170,8 +170,6 @@ bool RenderableModel::deinitialize() {
void RenderableModel::render(const RenderData& data) {
_programObject->activate();
double lt;
// Fading
if (_performFade && _fading > 0.f) {
_fading = _fading - 0.01f;
@@ -243,7 +241,6 @@ void RenderableModel::update(const UpdateData& data) {
// _time = futureTime;
//}
double lt;
_sunPos = OsEng.renderEngine().scene()->sceneGraphNode("Sun")->worldPosition();
}

View File

@@ -203,9 +203,9 @@ void RenderablePlane::render(const RenderData& data) {
if (textureNode != nullptr){
RenderablePlanetProjection* t = static_cast<RenderablePlanetProjection*>(textureNode->renderable());
_texture = std::unique_ptr<ghoul::opengl::Texture>(&(t->baseTexture()));
float h = _texture->height();
float w = _texture->width();
float scale = h / w;
unsigned int h = _texture->height();
unsigned int w = _texture->width();
float scale = static_cast<float>(h) / static_cast<float>(w);
scaleTransform = glm::scale(glm::mat4(1.0), glm::vec3(1.f, scale, 1.f));
}
}

View File

@@ -82,10 +82,10 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
//int nr2 = 0;
for (int i = 0; i <= _segments; i++) {
for (int nSegment = 0; nSegment <= _segments; ++nSegment) {
// define an extra vertex around the y-axis due to texture mapping
for (int j = 0; j <= _segments; j++) {
const float fi = static_cast<float>(i);
const float fi = static_cast<float>(nSegment);
const float fj = static_cast<float>(j);
// inclination angle (north to south)

View File

@@ -155,17 +155,17 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
addProperty(_useLineFade);
if (dictionary.hasKeyAndValue<double>(KeyFade)) {
_lineFade = dictionary.value<double>(KeyFade);
_lineFade = static_cast<float>(dictionary.value<double>(KeyFade));
}
addProperty(_lineFade);
if (dictionary.hasKeyAndValue<double>(KeyLineWidth)) {
_lineWidth = dictionary.value<double>(KeyLineWidth);
_lineWidth = static_cast<float>(dictionary.value<double>(KeyLineWidth));
}
addProperty(_lineWidth);
if (dictionary.hasKeyAndValue<double>(KeyPointSize)) {
_pointSize = dictionary.value<double>(KeyPointSize);
_pointSize = static_cast<int>(dictionary.value<double>(KeyPointSize));
}
addProperty(_pointSize);
@@ -247,12 +247,12 @@ void RenderableTrail::render(const RenderData & data) {
}
bool renderLines =
_renderingModes == RenderingModeLines |
_renderingModes == RenderingModeLinesPoints;
(_renderingModes == RenderingModeLines) |
(_renderingModes == RenderingModeLinesPoints);
bool renderPoints =
_renderingModes == RenderingModePoints |
_renderingModes == RenderingModeLinesPoints;
(_renderingModes == RenderingModePoints) |
(_renderingModes == RenderingModeLinesPoints);
if (renderLines) {
glLineWidth(_lineWidth);

View File

@@ -132,7 +132,7 @@ documentation::Documentation RenderableTrailOrbit::Documentation() {
RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary)
: RenderableTrail(dictionary)
, _period("period", "Period in days", 0.0, 0.0, 1e9)
, _resolution("resolution", "Number of Samples along Orbit", 10000, 1, 1e6)
, _resolution("resolution", "Number of Samples along Orbit", 10000, 1, 1000000)
, _needsFullSweep(true)
, _indexBufferDirty(true)
{
@@ -148,7 +148,7 @@ RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary)
// Period is in days
using namespace std::chrono;
int factor = duration_cast<seconds>(hours(24)).count();
long long factor = duration_cast<seconds>(hours(24)).count();
_period = dictionary.value<double>(KeyPeriod) * factor;
_period.onChange([&] { _needsFullSweep = true; _indexBufferDirty = true; });
addProperty(_period);
@@ -349,7 +349,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
}
// See how many points we need to drop
int nNewPoints = floor(delta / secondsPerPoint);
int nNewPoints = static_cast<int>(floor(delta / secondsPerPoint));
// If we would need to generate more new points than there are total points in the
// array, it is faster to regenerate the entire array
@@ -384,7 +384,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
else {
// See how many new points needs to be generated. Delta is negative, so we need
// to invert the ratio
int nNewPoints = -(floor(delta / secondsPerPoint));
int nNewPoints = -(static_cast<int>(floor(delta / secondsPerPoint)));
// If we would need to generate more new points than there are total points in the
// array, it is faster to regenerate the entire array

View File

@@ -130,7 +130,7 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di
, _timeStampSubsamplingFactor(
"subSample",
"Time Stamp Subsampling Factor",
1, 1, 1e9
1, 1, 1000000000
)
, _renderFullTrail("renderFullTrail", "Render Full Trail", false)
, _needsFullSweep(true)
@@ -159,7 +159,9 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di
addProperty(_sampleInterval);
if (dictionary.hasKeyAndValue<double>(KeyTimeStampSubsample)) {
_timeStampSubsamplingFactor = dictionary.value<double>(KeyTimeStampSubsample);
_timeStampSubsamplingFactor = static_cast<int>(
dictionary.value<double>(KeyTimeStampSubsample)
);
}
_timeStampSubsamplingFactor.onChange([this] { _subsamplingIsDirty = true; });
addProperty(_timeStampSubsamplingFactor);
@@ -208,7 +210,7 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
double totalSampleInterval = _sampleInterval / _timeStampSubsamplingFactor;
// How many values do we need to compute given the distance between the start and
// end date and the desired sample interval
int nValues = (_end - _start) / totalSampleInterval;
int nValues = static_cast<int>((_end - _start) / totalSampleInterval);
// Make space for the vertices
_vertexArray.clear();
@@ -246,16 +248,16 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
// If the full trail should be rendered at all times, we can directly render the
// entire set
_primaryRenderInformation.first = 0;
_primaryRenderInformation.count = _vertexArray.size();
_primaryRenderInformation.count = static_cast<GLsizei>(_vertexArray.size());
}
else {
// If only trail so far should be rendered, we need to find the corresponding time
// in the array and only render it until then
_primaryRenderInformation.first = 0;
double t = (data.time - _start) / (_end - _start);
_primaryRenderInformation.count = std::min<GLsizei>(
ceil(_vertexArray.size() * t),
_vertexArray.size() - 1
_primaryRenderInformation.count = std::min(
static_cast<GLsizei>(ceil(_vertexArray.size() * t)),
static_cast<GLsizei>(_vertexArray.size() - 1)
);
}

View File

@@ -82,15 +82,20 @@ bool ScreenSpaceFramebuffer::deinitialize(){
return true;
}
void ScreenSpaceFramebuffer::render(){
void ScreenSpaceFramebuffer::render() {
glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution();
glm::vec4 size = _size.value();
float xratio = _originalViewportSize.x / (size.z-size.x);
float yratio = _originalViewportSize.y / (size.w-size.y);;
if(!_renderFunctions.empty()){
glViewport (-size.x*xratio, -size.y*yratio, _originalViewportSize.x*xratio, _originalViewportSize.y*yratio);
if (!_renderFunctions.empty()) {
glViewport(
static_cast<GLint>(-size.x * xratio),
static_cast<GLint>(-size.y * yratio),
static_cast<GLsizei>(_originalViewportSize.x * xratio),
static_cast<GLsizei>(_originalViewportSize.y * yratio)
);
GLint defaultFBO = _framebuffer->getActiveObject();
_framebuffer->activate();
@@ -103,7 +108,12 @@ void ScreenSpaceFramebuffer::render(){
_framebuffer->deactivate();
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
glViewport (0, 0, resolution.x, resolution.y);
glViewport(
0,
0,
static_cast<GLsizei>(resolution.x),
static_cast<GLsizei>(resolution.y)
);
glm::mat4 rotation = rotationMatrix();
glm::mat4 translation = translationMatrix();

View File

@@ -157,15 +157,18 @@ void ScreenSpaceImage::updateTexture() {
if (_futureImage.valid() && DownloadManager::futureReady(_futureImage)) {
DownloadManager::MemoryFile imageFile = _futureImage.get();
if (imageFile.corrupted)
if (imageFile.corrupted) {
return nullptr;
}
return (ghoul::io::TextureReader::ref().loadTexture(
reinterpret_cast<void*>(imageFile.buffer),
imageFile.size,
imageFile.format)
);
}
else {
return nullptr;
}
}

View File

@@ -59,7 +59,7 @@ StaticScale::StaticScale(const ghoul::Dictionary& dictionary)
{
documentation::testSpecificationAndThrow(Documentation(), dictionary, "StaticScale");
_scaleValue = dictionary.value<double>(KeyValue);
_scaleValue = static_cast<float>(dictionary.value<double>(KeyValue));
}
double StaticScale::scaleValue() const {

View File

@@ -224,7 +224,7 @@ RenderableMultiresVolume::RenderableMultiresVolume (const ghoul::Dictionary& dic
}
addProperty(_selectorName);
_selectorName.onChange([&] {
_selectorName.onChange([&]() {
Selector s;
std::string newSelectorName = _selectorName;
if (newSelectorName == "simple") {

View File

@@ -65,7 +65,9 @@ bool inRange(float x, float a, float b){
void main() {
vec2 uv = (vs_position.xy + vec2(1.0)) / vec2(2.0);
vec4 vertex = uvToModel(uv, _radius, _segments);
vec4 radius = vec4(1.1883, 1.1883, 1.1883, 6);
vec4 vertex = uvToModel(uv, radius, _segments);
// vec4 vertex = uvToModel(uv, _radius, _segments);
vec4 raw_pos = psc_to_meter(vertex, _scaling);
vec4 projected = ProjectorMatrix * ModelTransform * raw_pos;

View File

@@ -97,10 +97,14 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
glm::vec2 planetRadiusVec;
success = geometryDictionary.getValue(keyRadius, planetRadiusVec);
if (success)
_planetRadius = planetRadiusVec[0] * glm::pow(10, planetRadiusVec[1]);
else
if (success) {
_planetRadius = static_cast<float>(
planetRadiusVec[0] * glm::pow(10, planetRadiusVec[1])
);
}
else {
LWARNING("No Radius value expecified for " << name << " planet.");
}
}
dictionary.getValue(keyFrame, _frame);
@@ -432,7 +436,7 @@ void RenderablePlanet::render(const RenderData& data) {
float xp_test = shadowConf.caster.second * sc_length / (shadowConf.source.second + shadowConf.caster.second);
float rp_test = shadowConf.caster.second * (glm::length(planetCaster_proj) + xp_test) / xp_test;
float casterDistSun = glm::length(casterPos);
double casterDistSun = glm::length(casterPos);
float planetDistSun = glm::length(data.position.vec3());
ShadowRenderingStruct shadowData;

View File

@@ -105,7 +105,7 @@ RenderableRings::RenderableRings(const ghoul::Dictionary& dictionary)
"RenderableRings"
);
_size = dictionary.value<double>(KeySize);
_size = static_cast<float>(dictionary.value<double>(KeySize));
setBoundingSphere(PowerScaledScalar::CreatePSS(_size));
addProperty(_size);
_size.onChange([&]() { _planeIsDirty = true; });

View File

@@ -467,7 +467,7 @@ bool RenderableStars::readSpeckFile() {
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
std::string line = "";
while (true) {
std::ifstream::streampos position = file.tellg();
std::streampos position = file.tellg();
std::getline(file, line);
if (line[0] == '#' || line.empty()) {

View File

@@ -252,6 +252,9 @@ double KeplerTranslation::eccentricAnomaly(double meanAnomaly) const {
};
return solveIteration(solver, e, 0.0, 8);
}
else {
ghoul_assert(false, "Eccentricity must not be >= 1.0");
}
}
void KeplerTranslation::update(const UpdateData& data) {

View File

@@ -64,7 +64,7 @@ namespace {
auto y2000 = std::find(LeapYears.begin(), LeapYears.end(), Epoch);
// The distance between the two iterators gives us the number of leap years
int nLeapYears = std::abs(std::distance(y2000, lb));
int nLeapYears = static_cast<int>(std::abs(std::distance(y2000, lb)));
int nYears = std::abs(year - Epoch);
int nRegularYears = nYears - nLeapYears;
@@ -130,7 +130,7 @@ namespace {
auto y2000 = std::lower_bound(LeapSeconds.begin(), LeapSeconds.end(), Epoch);
// The distance between the two iterators gives us the number of leap years
int nLeapSeconds = std::abs(std::distance(y2000, it));
int nLeapSeconds = static_cast<int>(std::abs(std::distance(y2000, it)));
return nLeapSeconds;
};
@@ -182,16 +182,19 @@ namespace {
// 3
using namespace std::chrono;
int SecondsPerDay = seconds(hours(24)).count();
int SecondsPerDay = static_cast<int>(seconds(hours(24)).count());
double nSecondsSince2000 = (daysSince2000 + daysInYear) * SecondsPerDay;
// 4
// We need to remove additionbal leap seconds past 2000 and add them prior to
// 2000 to sync up the time zones
double nLeapSecondsOffset = -countLeapSeconds(year, std::floor(daysInYear));
double nLeapSecondsOffset = -countLeapSeconds(
year,
static_cast<int>(std::floor(daysInYear))
);
// 5
double nSecondsEpochOffset = seconds(hours(12)).count();
double nSecondsEpochOffset = static_cast<double>(seconds(hours(12)).count());
// Combine all of the values
double epoch = nSecondsSince2000 + nLeapSecondsOffset - nSecondsEpochOffset;
@@ -270,14 +273,14 @@ void TLETranslation::readTLEFile(const std::string& filename) {
// All of the Kepler element information
struct {
double inclination;
double semiMajorAxis;
double ascendingNode;
double eccentricity;
double argumentOfPeriapsis;
double meanAnomaly;
double meanMotion;
double epoch;
double inclination = 0.0;
double semiMajorAxis = 0.0;
double ascendingNode = 0.0;
double eccentricity = 0.0;
double argumentOfPeriapsis = 0.0;
double meanAnomaly = 0.0;
double meanMotion = 0.0;
double epoch = 0.0;
} keplerElements;
enum class State {

View File

@@ -78,6 +78,8 @@ std::string to_string(openspace::documentation::TestResult::Offense::Reason reas
return "Verification failed";
case openspace::documentation::TestResult::Offense::Reason::WrongType:
return "Wrong type";
default:
ghoul_assert(false, "Missing case label");
}
}
@@ -85,6 +87,8 @@ std::string to_string(openspace::documentation::TestResult::Warning::Reason reas
switch (reason) {
case openspace::documentation::TestResult::Warning::Reason::Deprecated:
return "Deprecated";
default:
ghoul_assert(false, "Missing case label");
}
}

View File

@@ -217,33 +217,33 @@ TestResult ReferencingVerifier::operator()(const ghoul::Dictionary& dictionary,
{
TestResult res = TableVerifier::operator()(dictionary, key);
if (res.success) {
std::vector<Documentation> documentations = DocEng.documentations();
std::vector<Documentation> docs = DocEng.documentations();
auto it = std::find_if(
documentations.begin(),
documentations.end(),
docs.begin(),
docs.end(),
[this](const Documentation& doc) { return doc.id == identifier; }
);
ghoul_assert(
it != documentations.end(),
it != docs.end(),
"Did not find referencing identifier '" + identifier + "'"
);
ghoul::Dictionary d = dictionary.value<ghoul::Dictionary>(key);
TestResult res = testSpecification(*it, d);
TestResult r = testSpecification(*it, d);
// Add the 'key' as a prefix to make the offender a fully qualified identifer
for (TestResult::Offense& s : res.offenses) {
for (TestResult::Offense& s : r.offenses) {
s.offender = key + "." + s.offender;
}
// Add the 'key' as a prefix to make the warning a fully qualified identifer
for (TestResult::Warning& w : res.warnings) {
for (TestResult::Warning& w : r.warnings) {
w.offender = key + "." + w.offender;
}
return res;
return r;
}
else {
return res;

View File

@@ -111,7 +111,9 @@ namespace {
// Compute estimated time remaining.
auto timeRemaining = estimatedTime - transferTime;
float s = std::chrono::duration_cast<std::chrono::seconds>(timeRemaining).count();
float s = static_cast<float>(
std::chrono::duration_cast<std::chrono::seconds>(timeRemaining).count()
);
i->future->secondsRemaining = s;
@@ -233,44 +235,46 @@ std::future<DownloadManager::MemoryFile> DownloadManager::fetchFile(
file.corrupted = false;
CURL* curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&file);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeMemoryCallback);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5L);
// Will fail when response status is 400 or above
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
CURLcode res = curl_easy_perform(curl);
if(res == CURLE_OK){
// ask for the content-type
char *ct;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
if(res == CURLE_OK){
std::string extension = std::string(ct);
std::stringstream ss(extension);
getline(ss, extension ,'/');
getline(ss, extension);
file.format = extension;
} else{
LWARNING("Could not get File extension from file downloaded from: " + url);
}
successCallback(file);
curl_easy_cleanup(curl);
return std::move(file);
} else {
std::string err = curl_easy_strerror(res);
errorCallback(err);
curl_easy_cleanup(curl);
// Throw an error and use try-catch around call to future.get()
//throw std::runtime_error( err );
if (!curl) {
throw ghoul::RuntimeError("Error initializing cURL");
}
// or set a boolean variable in MemoryFile to determine if it is valid/corrupted or not.
// Return MemoryFile even if it is not valid, and check if it is after future.get() call.
file.corrupted = true;
return std::move(file);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&file);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeMemoryCallback);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5L);
// Will fail when response status is 400 or above
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
CURLcode res = curl_easy_perform(curl);
if(res == CURLE_OK){
// ask for the content-type
char *ct;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
if(res == CURLE_OK){
std::string extension = std::string(ct);
std::stringstream ss(extension);
getline(ss, extension ,'/');
getline(ss, extension);
file.format = extension;
} else{
LWARNING("Could not get File extension from file downloaded from: " + url);
}
successCallback(file);
curl_easy_cleanup(curl);
return std::move(file);
} else {
std::string err = curl_easy_strerror(res);
errorCallback(err);
curl_easy_cleanup(curl);
// Throw an error and use try-catch around call to future.get()
//throw std::runtime_error( err );
// or set a boolean variable in MemoryFile to determine if it is valid/corrupted or not.
// Return MemoryFile even if it is not valid, and check if it is after future.get() call.
file.corrupted = true;
return std::move(file);
}
};

View File

@@ -276,7 +276,7 @@ void OpenSpaceEngine::create(int argc, char** argv,
}
throw;
}
catch (const ghoul::RuntimeError& e) {
catch (const ghoul::RuntimeError&) {
LFATAL("Loading of configuration file '" << configurationFilePath << "' failed");
throw;
}
@@ -475,9 +475,9 @@ void OpenSpaceEngine::initialize() {
writeDocumentation();
if (configurationManager().hasKey(ConfigurationManager::KeyShutdownCountdown)) {
_shutdown.waitTime = configurationManager().value<double>(
_shutdown.waitTime = static_cast<float>(configurationManager().value<double>(
ConfigurationManager::KeyShutdownCountdown
);
));
}
if (!commandlineArgumentPlaceholders.sceneName.empty()) {
@@ -874,7 +874,7 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
if (_shutdown.timer <= 0.f) {
_windowWrapper->terminate();
}
_shutdown.timer -= _windowWrapper->averageDeltaTime();
_shutdown.timer -= static_cast<float>(_windowWrapper->averageDeltaTime());
}
_renderEngine->updateSceneGraph();

View File

@@ -74,7 +74,7 @@ void SettingsEngine::initialize() {
std::vector<std::string> scenes = ghoul::filesystem::Directory(sceneDir).readFiles();
for (std::size_t i = 0; i < scenes.size(); ++i) {
std::size_t found = scenes[i].find_last_of("/\\");
_scenes.addOption(i, scenes[i].substr(found + 1));
_scenes.addOption(static_cast<int>(i), scenes[i].substr(found + 1));
}
// Set interaction to change ConfigurationManager and schedule the load

View File

@@ -224,8 +224,9 @@ bool SGCTWindowWrapper::isExternalControlConnected() const {
void SGCTWindowWrapper::sendMessageToExternalControl(const std::vector<char>& message) const {
sgct::Engine::instance()->sendMessageToExternalControl(
message.data(),
message.size());
message.data(),
static_cast<int>(message.size())
);
}
bool SGCTWindowWrapper::isSimpleRendering() const {

View File

@@ -77,8 +77,8 @@ InteractionHandler::InteractionHandler()
, _rotationalFriction("rotationalFriction", "Rotational Friction", true)
, _horizontalFriction("horizontalFriction", "Horizontal Friction", true)
, _verticalFriction("verticalFriction", "Vertical Friction", true)
, _sensitivity("sensitivity", "Sensitivity", 0.5, 0.001, 1)
, _rapidness("rapidness", "Rapidness", 1, 0.1, 60)
, _sensitivity("sensitivity", "Sensitivity", 0.5f, 0.001f, 1.f)
, _rapidness("rapidness", "Rapidness", 1.f, 0.1f, 60.f)
{
_origin.onChange([this]() {
SceneGraphNode* node = sceneGraphNode(_origin.value());

View File

@@ -198,9 +198,9 @@ int goToChunk(lua_State* L) {
if (nArguments != 3)
return luaL_error(L, "Expected %i arguments, got %i", 3, nArguments);
int x = lua_tonumber(L, 1);
int y = lua_tonumber(L, 2);
int level = lua_tonumber(L, 3);
int x = static_cast<int>(lua_tonumber(L, 1));
int y = static_cast<int>(lua_tonumber(L, 2));
int level = static_cast<int>(lua_tonumber(L, 3));
OsEng.interactionHandler().goToChunk(x, y, level);
@@ -214,8 +214,8 @@ int goToGeo(lua_State* L) {
if (nArguments != 2)
return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments);
double latitude = lua_tonumber(L, 1);
double longitude = lua_tonumber(L, 2);
double latitude = static_cast<int>(lua_tonumber(L, 1));
double longitude = static_cast<int>(lua_tonumber(L, 2));
OsEng.interactionHandler().goToGeo(latitude, longitude);
@@ -224,7 +224,6 @@ int goToGeo(lua_State* L) {
int restoreCameraStateFromFile(lua_State* L) {
using ghoul::lua::luaTypeToString;
const std::string _loggerCat = "lua.restoreCameraStateFromFile";
int nArguments = lua_gettop(L);
if (nArguments != 1)
@@ -232,8 +231,9 @@ int restoreCameraStateFromFile(lua_State* L) {
std::string cameraStateFilePath = luaL_checkstring(L, -1);
if (cameraStateFilePath.empty())
if (cameraStateFilePath.empty()) {
return luaL_error(L, "filepath string is empty");
}
OsEng.interactionHandler().restoreCameraStateFromFile(cameraStateFilePath);
return 0;
@@ -241,7 +241,6 @@ int restoreCameraStateFromFile(lua_State* L) {
int saveCameraStateToFile(lua_State* L) {
using ghoul::lua::luaTypeToString;
const std::string _loggerCat = "lua.setCameraPosition";
int nArguments = lua_gettop(L);
if (nArguments != 1)
@@ -249,10 +248,12 @@ int saveCameraStateToFile(lua_State* L) {
std::string cameraStateFilePath = luaL_checkstring(L, -1);
if (cameraStateFilePath.empty())
if (cameraStateFilePath.empty()) {
return luaL_error(L, "filepath string is empty");
}
OsEng.interactionHandler().saveCameraStateToFile(cameraStateFilePath);
return 0;
}
int resetCameraDirection(lua_State* L) {
@@ -260,10 +261,12 @@ int resetCameraDirection(lua_State* L) {
const std::string _loggerCat = "lua.resetCameraDirection";
int nArguments = lua_gettop(L);
if (nArguments != 0)
if (nArguments != 0) {
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
}
OsEng.interactionHandler().resetCameraDirection();
return 0;
}

View File

@@ -384,7 +384,7 @@ void LuaConsole::charCallback(unsigned int codepoint, KeyModifier modifier) {
return;
}
addToCommand(std::string(1, codepoint));
addToCommand(std::string(1, static_cast<const char>(codepoint)));
}
void LuaConsole::render() {

View File

@@ -25,31 +25,34 @@
namespace openspace {
namespace luascriptfunctions {
int loadMission(lua_State* L) {
using ghoul::lua::luaTypeToString;
int nArguments = lua_gettop(L);
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
using ghoul::lua::luaTypeToString;
int nArguments = lua_gettop(L);
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
std::string missionFileName = luaL_checkstring(L, -1);
if (missionFileName.empty()) {
return luaL_error(L, "filepath string is empty");
}
MissionManager::ref().loadMission(absPath(missionFileName));
std::string missionFileName = luaL_checkstring(L, -1);
if (missionFileName.empty()) {
return luaL_error(L, "filepath string is empty");
}
MissionManager::ref().loadMission(absPath(missionFileName));
return 0;
}
int setCurrentMission(lua_State* L) {
using ghoul::lua::luaTypeToString;
int nArguments = lua_gettop(L);
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
int setCurrentMission(lua_State* L) {
using ghoul::lua::luaTypeToString;
int nArguments = lua_gettop(L);
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
std::string missionName = luaL_checkstring(L, -1);
if (missionName.empty()) {
return luaL_error(L, "mission name string is empty");
}
MissionManager::ref().setCurrentMission(missionName);
std::string missionName = luaL_checkstring(L, -1);
if (missionName.empty()) {
return luaL_error(L, "mission name string is empty");
}
MissionManager::ref().setCurrentMission(missionName);
return 0;
}
} // namespace luascriptfunction
} // namespace openspace

View File

@@ -128,13 +128,13 @@ void NetworkEngine::publishIdentifierMappingMessage() {
std::vector<char> buffer(bufferSize);
size_t currentWritingPosition = 0;
uint16_t size = _identifiers.size();
uint16_t size = static_cast<uint16_t>(_identifiers.size());
std::memcpy(buffer.data(), &size, sizeof(uint16_t));
currentWritingPosition += sizeof(uint16_t);
for (const std::pair<std::string, MessageIdentifier>& i : _identifiers) {
std::memcpy(buffer.data() + currentWritingPosition, &(i.second), sizeof(MessageIdentifier));
currentWritingPosition += sizeof(MessageIdentifier);
uint8_t stringSize = i.first.size();
uint8_t stringSize = static_cast<uint8_t>(i.first.size());
std::memcpy(buffer.data() + currentWritingPosition, &stringSize, sizeof(uint8_t));
currentWritingPosition += sizeof(uint8_t);
std::memcpy(buffer.data() + currentWritingPosition, i.first.data(), stringSize);

View File

@@ -231,7 +231,7 @@ void ParallelConnection::clientConnect(){
return;
}
struct addrinfo *addresult = NULL, *ptr = NULL, hints;
struct addrinfo *addresult = NULL, hints;
memset(&hints, 0, sizeof(hints));
@@ -963,7 +963,7 @@ void ParallelConnection::setNConnections(size_t nConnections) {
}
}
size_t ParallelConnection::nConnections() {
int ParallelConnection::nConnections() {
return _nConnections;
}

View File

@@ -41,7 +41,7 @@ int setPort(lua_State* L) {
bool isNumber = (lua_isnumber(L, -1) != 0);
if (isNumber) {
int value = lua_tonumber(L, -1);
int value = static_cast<int>(lua_tonumber(L, -1));
std::string port = std::to_string(value);
if (OsEng.windowWrapper().isMaster()) {
OsEng.parallelConnection().setPort(port);
@@ -53,8 +53,6 @@ int setPort(lua_State* L) {
lua_typename(L, LUA_TNUMBER), luaL_typename(L, -1));
return luaL_error(L, "bad argument #%d (%s)", 1, msg);
}
return 0;
}
int setAddress(lua_State* L) {
@@ -78,8 +76,6 @@ int setAddress(lua_State* L) {
lua_typename(L, LUA_TSTRING), luaL_typename(L, -1));
return luaL_error(L, "bad argument #%d (%s)", 1, msg);
}
return 0;
}
int setPassword(lua_State* L) {
@@ -103,8 +99,6 @@ int setPassword(lua_State* L) {
lua_typename(L, LUA_TSTRING), luaL_typename(L, -1));
return luaL_error(L, "bad argument #%d (%s)", 1, msg);
}
return 0;
}
int setDisplayName(lua_State* L) {
@@ -128,8 +122,6 @@ int setDisplayName(lua_State* L) {
lua_typename(L, LUA_TSTRING), luaL_typename(L, -1));
return luaL_error(L, "bad argument #%d (%s)", 1, msg);
}
return 0;
}
int connect(lua_State* L) {
@@ -175,8 +167,6 @@ int requestHostship(lua_State* L) {
lua_typename(L, LUA_TSTRING), luaL_typename(L, -1));
return luaL_error(L, "bad argument #%d (%s)", 1, msg);
}
return 0;
}
int resignHostship(lua_State* L) {

View File

@@ -242,7 +242,7 @@ void PerformanceManager::storeScenePerformanceMeasurements(
_performanceMemory->acquireLock();
int nNodes = static_cast<int>(sceneNodes.size());
layout->nScaleGraphEntries = nNodes;
layout->nScaleGraphEntries = static_cast<int16_t>(nNodes);
for (int i = 0; i < nNodes; ++i) {
SceneGraphNode* node = sceneNodes[i];

View File

@@ -98,6 +98,7 @@ std::string OptionProperty::getDescriptionByValue(int value) {
return option.description;
}
}
return "";
}
std::string OptionProperty::generateAdditionalDescription() const {

View File

@@ -374,12 +374,12 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure
ghoul::opengl::ProgramObject* raycastProgram = nullptr;
if (cameraIsInside) {
if (raycastProgram = _insideRaycastPrograms[raycaster].get()) {
if (raycastProgram == _insideRaycastPrograms[raycaster].get()) {
raycastProgram->activate();
raycastProgram->setUniform("cameraPosInRaycaster", cameraPosition);
}
} else {
if (raycastProgram = _raycastPrograms[raycaster].get()) {
if (raycastProgram == _raycastPrograms[raycaster].get()) {
raycastProgram->activate();
}
}

View File

@@ -74,6 +74,8 @@ namespace {
return "ELLIPSOID";
case openspace::SpiceManager::FieldOfViewMethod::Point:
return "POINT";
default:
ghoul_assert(false, "Missing case label");
}
}
@@ -83,6 +85,8 @@ namespace {
return "UMBRAL";
case openspace::SpiceManager::TerminatorType::Penumbral:
return "PENUMBRAL";
default:
ghoul_assert(false, "Missing case label");
}
}
}
@@ -143,6 +147,8 @@ SpiceManager::AberrationCorrection::operator const char*() const {
return (direction == Direction::Reception) ? "CN" : "XCN";
case Type::ConvergedNewtonianStellar:
return (direction == Direction::Reception) ? "CN+S" : "XCN+S";
default:
ghoul_assert(false, "Missing case label");
}
}